コード例 #1
0
        public bool Change()
        {
            Console.WriteLine();
            Console.WriteLine("请输入订单号::");
            int orderNumber = int.Parse(Console.ReadLine());

            int index = orderService.IsInOrderList(orderNumber);

            if (index == -1)
            {
                throw new OrderException("不存在该订单", 7);
            }

            Console.WriteLine("请输入订单用户名:");
            Client client = new Client(Console.ReadLine());

            Order order = new Order(orderNumber, client, DateTime.Now);

            bool stop = false;

            while (!stop)
            {
                Console.WriteLine("请输入商品条目,A继续,B停止:");
                if (Console.ReadLine() == "A")
                {
                    Console.WriteLine("请输入商品名:");
                    string merName = Console.ReadLine();
                    Console.WriteLine("请输入商品价格:");
                    double      merPrice1   = double.Parse(Console.ReadLine());
                    Merchandise merchandise = new Merchandise(merName, merPrice1);

                    Console.WriteLine("请输入商品数量:");
                    int merNum1 = int.Parse(Console.ReadLine());
                    order.AddOrderItem(new OrderItem(merchandise, merNum1));
                }
                else
                {
                    stop = true;
                }
            }
            orderService.ChangeOrder(index, order);
            return(true);
        }
コード例 #2
0
        public List <Order> Add()   //执行添加操作
        {
            Console.WriteLine();
            Console.WriteLine("请输入订单号:");
            int orderNo = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入订单用户名:");
            Client client = new Client(Console.ReadLine());

            Order order = new Order(orderNo, client, DateTime.Now);

            bool stop = false;

            while (!stop)
            {
                Console.WriteLine("请输入商品条目,A继续,B停止:");
                if (Console.ReadLine() == "A")
                {
                    Console.WriteLine("请输入商品名:");
                    string merName = Console.ReadLine();
                    Console.WriteLine("请输入商品价格:");
                    double      merPrice    = double.Parse(Console.ReadLine());
                    Merchandise merchandise = new Merchandise(merName, merPrice);

                    Console.WriteLine("请输入商品数量:");
                    int merNum = int.Parse(Console.ReadLine());
                    order.AddOrderItem(new OrderItem(merchandise, merNum));
                }
                else
                {
                    stop = true;
                }
            }
            orderService.AddOrder(order);
            return(orderService.orderList);
        }
コード例 #3
0
ファイル: OrderItem.cs プロジェクト: Hallimede/MyRepository
 public OrderItem(Merchandise merchandise, int num)
 {
     this.merchandise = merchandise;
     this.num         = num;
 }