using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 货品管理
{
class YingYong
{
String[] name = new String[10];
int[] number = new int[10];
int j = 3;
public void ChuShi() {
this.name[0] = "杯子";
this.number[0] = 1;
this.name[1] = "花瓶";
this.number[1] = 1;
this.name[2] = "热水器";
this.number[2] = 1;
}
public void CaiDan(){
Console.WriteLine("========欢迎使用库存管理系统========");
Console.WriteLine("1:查看 2:添加 3:删除");
this.XuanZe();
}
public void XuanZe() {
Console.Write("请选择:");
int a = Convert.ToInt32(Console.ReadLine());
switch (a) {
case 1:
this.ChaKan();
break;
case 2:
this.TianJia();
break;
case 3:
this.ShanChu();
break;
default:
Console.WriteLine("输入错误");
this.CaiDan();
break;
}
}
private void ShanChu()
{
Console.Write("输入名称:");
String w = Convert.ToString(Console.ReadLine());
for (int i = 0; i < j; i++) {
if (w == this.name[i])
{
this.name[i+1] = this.name[i];
this.number[i+1] = this.number[i];
Console.WriteLine("删除成功");
Console.WriteLine("输入0返回");
int a = Convert.ToInt32(Console.ReadLine());
if (a == 0)
{
this.CaiDan();
}
else {
Console.WriteLine("输入错误");
this.CaiDan();
}
}
}
}
private void TianJia()
{
Console.WriteLine("添加");
Console.Write("输入名称:");
String b = Convert.ToString(Console.ReadLine());
Console.Write("输入数目:");
int c = Convert.ToInt32(Console.ReadLine());
for(int i = 0;i<j;i++){
if(b==this.name[i]){
Console.WriteLine("输入错误,按0返回");
Console.Write("");
int d = Convert.ToInt32(Console.ReadLine());
if (d == 0) {
this.CaiDan();
}
}
if (b!=this.name[i]) {
this.name[j] = b;
this.number[j] = c;
j++;
Console.WriteLine("添加成功");
Console.WriteLine("输入0返回");
int t = Convert.ToInt32(Console.ReadLine());
if(t==0){
this.CaiDan();
}
}
}
}
private void ChaKan()
{
this.ChuShi();
Console.WriteLine("查看");
Console.WriteLine("名称\t数目\t");
for (int i = 0; i < j; i++)
{
Console.WriteLine(name[i]+"\t"+number[i]+"\t");
}
Console.WriteLine("输入0返回");
int a = Convert.ToInt32(Console.ReadLine());
if(a==0){
this.CaiDan();
}
}
}
}