Exemple #1
0
        //修改物品订购
        public void RemoveGoods()
        {
            string goodremove; int num;

            Console.WriteLine("请输入物品名,修改数量:");
            Console.Write("商品名:"); goodremove = Console.ReadLine();
            Console.Write("数量:"); int.TryParse((Console.ReadLine()), out num);

            string goodname; bool has = false;

            for (int i = Detail.GoodList.Count - 1; i >= 0; i--)
            {
                goodname = Detail.GoodList[i].Backname();
                if (goodname == goodremove)//物品名匹配
                {
                    string price = Detail.GoodList[i].Backprice();
                    OrderDetail.GoodOrder tempgood = new OrderDetail.GoodOrder(goodremove, price, num);
                    Detail.GoodList[i] = tempgood; has = true;
                }//修改物品
            }
            if (has == false)
            {
                Console.WriteLine("订单内没有该物品!");
            }
        }
Exemple #2
0
        //添加物品
        public void AddGoods()
        {
            string goods; string price; int num;
            Random rd = new Random();

            price = rd.Next(1, 100).ToString();
            Console.WriteLine("请输入物品名,数量:");
            Console.Write("物品名:"); goods = Console.ReadLine();
            Console.Write("数量:"); int.TryParse((Console.ReadLine()), out num);
            OrderDetail.GoodOrder tempgood = new OrderDetail.GoodOrder(goods, price, num);
            Detail.GoodList.Add(tempgood);
        }