예제 #1
0
        public static Order SelectOrder(OrderService os)
        {
            Console.WriteLine("请输入订单ID,-1放弃查询,留空则使用条件查询");
            int?id;

            do
            {
                id = ReadInt(-1, 2147483647, true);
                if (id.HasValue)
                {
                    if (id == -1)
                    {
                        return(null);
                    }
                    Order order = os.GetOrderByID(id.Value);
                    if (order == null)
                    {
                        Console.WriteLine("该订单不存在,请重新输入ID:");
                        continue;
                    }
                    else
                    {
                        return(order);
                    }
                }
            } while (id.HasValue);
            OrderQueryArgs args = new OrderQueryArgs();

            Console.WriteLine("请输入订单客户名,留空则不使用此条件");
            args.customerName = Console.ReadLine();
            Console.WriteLine("请输入包含的商品名,留空结束输入");
            string itemName;

            do
            {
                itemName = Console.ReadLine();
                if (itemName != "")
                {
                    args.itemNames.Add(itemName);
                }
            }while (itemName != "");
            Console.WriteLine("请输入最小金额,留空则不使用此条件");
            args.minPrice = ReadDecimal(true) ?? -1;
            Console.WriteLine("请输入最大金额,留空则不使用此条件");
            args.maxPrice = ReadDecimal(true) ?? -1;
            args.sortKey  = SelectSortKey();
            List <Order> orders = os.QueryOrder(args);

            if (orders.Count == 0)
            {
                Console.WriteLine("没有符合条件的订单");
                Console.WriteLine("按任意键继续...");
                Console.ReadKey(true);
                return(null);
            }
            for (int i = 0; i < orders.Count; i++)
            {
                Console.WriteLine($"{i + 1}. {orders[i].ToString()}");
            }
            Console.WriteLine("请输入所选择订单的编号");
            int index = ReadInt(1, orders.Count);

            return(orders[index - 1]);
        }
예제 #2
0
 private void QueryAll()
 {
     orderBindingSource.DataSource = OrderService.GetAllOrders();
     orderBindingSource.ResetBindings(false);
 }