Beispiel #1
0
        public void reviseOrder()
        {
            Console.WriteLine("请输入要修改的订单的订单号:");
            string orderID = Console.ReadLine();

            try
            {
                Order m = checkOrderIDUnique(orderID);
                if (m == null)
                {
                    throw new OrderException("错误!不存在该订单号的订单");
                }
                Console.WriteLine("请输入新的订单号:");
                string s = Console.ReadLine();
                Order  i = checkOrderIDUnique(s);
                if (i != null)
                {
                    throw new OrderException("错误!已存在该订单号的订单");
                }
                m.OrderID = s;
                Console.WriteLine("请输入新的客户名:");
                m.Customer = Console.ReadLine();
                List <Orderdetails> orderdetailsList = new List <Orderdetails>();
                Console.WriteLine("请输入新的订单商品种类数目:");
                int a = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("请依次输入每一种商品名称,数量,价格。");
                for (int b = 1; b <= a; b++)
                {
                    Console.WriteLine("请输入第" + b + "种商品名称。");
                    string productname = Console.ReadLine();
                    Console.WriteLine("请输入第" + b + "种商品数量。");
                    int productnum = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("请输入第" + b + "种商品价格。");
                    int          productprice        = Convert.ToInt32(Console.ReadLine());
                    Orderdetails productorderdetails = new Orderdetails(productname, productnum, productprice);
                    orderdetailsList.Add(productorderdetails);
                }
                m.orderdetailsList = orderdetailsList;
            }
            catch (OrderException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #2
0
 public void addOrder()
 {
     try
     {
         Order neworder = new Order();
         List <Orderdetails> orderdetailsList = new List <Orderdetails>();
         Console.WriteLine("请输入订单号:");
         string neworderID = Console.ReadLine();
         Order  n          = checkOrderIDUnique(neworderID);
         if (n != null)
         {
             throw new OrderException("错误!订单号已存在,不可添加,若需要可以进行修改或者换一个订单号");
         }
         Console.WriteLine("请输入客户名称:");
         neworder.Customer = Console.ReadLine();
         Console.WriteLine("请输入该订单商品种类数目:");
         int m = Convert.ToInt32(Console.ReadLine());
         Console.WriteLine("请依次输入每一种商品名称,数量,价格。");
         for (int i = 1; i <= m; i++)
         {
             Console.WriteLine("请输入第" + i + "种商品名称。");
             string productname = Console.ReadLine();
             Console.WriteLine("请输入第" + i + "种商品数量。");
             int productnum = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine("请输入第" + i + "种商品价格。");
             int          productprice        = Convert.ToInt32(Console.ReadLine());
             Orderdetails productorderdetails = new Orderdetails(productname, productnum, productprice);
             orderdetailsList.Add(productorderdetails);
         }
         neworder.orderdetailsList = orderdetailsList;
         orderList.Add(neworder);
         Console.WriteLine("增加订单后订单打印如下:");
         PrintOrderList();
     }
     catch (OrderException e)
     {
         Console.WriteLine(e.Message);
     }
 }