Ejemplo n.º 1
0
        public override bool Equals(object obj)
        {
            OrderDetails o = obj as OrderDetails;

            return(o != null && o.P == P && o.Productquantity == Productquantity);
        }
Ejemplo n.º 2
0
 public static void ChangeOrderitme(Order o, OrderDetails od, OrderDetails odn)//调用增删来修改一个订单项
 {
     DeleteOrderitem(o, od);
     AddOrderitem(o, odn);
     o.aggregateamount();
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //-------------------客户----------------------
            Customer JackMa = new Customer("Jack Ma");
            Customer LeiJun = new Customer("Lei Jun");
            //-------------------客户----------------------

            //-------------------商品----------------------
            Product hdnoodle  = new Product("hd noodles", 5);
            Product dumpling  = new Product("dumpling", 8);
            Product baozi     = new Product("bao zi", 2);
            Product hamburger = new Product("hamburger", 10);
            Product xiaomi    = new Product("xiao mi", 3000);

            //-------------------商品----------------------

            //-------------------测试代码--------------------

            Console.WriteLine(baozi);//测试商品类ToString

            //----------------创立订单和订单项--------------
            Order        o1  = new Order(JackMa);
            Order        o2  = new Order(LeiJun);
            OrderDetails o_1 = new OrderDetails(baozi, 100);
            OrderDetails o_2 = new OrderDetails(hamburger, 50);
            OrderDetails o_3 = new OrderDetails(dumpling, 30);
            OrderDetails o_4 = new OrderDetails(hdnoodle, 100);
            OrderDetails o_5 = new OrderDetails(dumpling, 200);

            //----------------创立订单和订单项--------------

            //----------------增删改订单和订单项--------------
            OrderService.AddOrder(o1);
            OrderService.AddOrder(o1);
            OrderService.AddOrderitem(o1, o_1);
            OrderService.AddOrderitem(o1, o_2);
            OrderService.AddOrderitem(o1, o_2);
            Console.WriteLine(o1);
            OrderService.AddOrder(o2);
            OrderService.AddOrderitem(o2, o_4);
            OrderService.AddOrderitem(o2, o_5);
            OrderService.DeleteOrderitem(o1, o_2);
            OrderService.ChangeOrderitme(o1, o_1, o_3);
            OrderService.AddOrderitem(o2, o_1);
            //----------------增删改订单和订单项--------------

            //----------------对全部订单排序输出--------------
            OrderService.Disp_order();
            Console.WriteLine("Sort by Id lambda");
            OrderService.blanket_order.Sort((p1, p2) => p1.Id - p2.Id);
            foreach (var item in OrderService.blanket_order)
            {
                Console.WriteLine(item);
            }
            //----------------对全部订单排序输出--------------

            Console.WriteLine($"Is o1 equals to o2?: {o1.Equals(o2)}");//测试equal();

            //---------------按指定信息查找订单---------------
            Console.WriteLine("以下输出id为2的订单:\n");
            OrderService.GetOrderbyid(2);
            Console.WriteLine("以下输出含有dumplings的订单:\n");
            OrderService.GetOrder(dumpling);
            Console.WriteLine("以下输出含有xiaomi的订单:\n");
            OrderService.GetOrder(xiaomi);
            Console.WriteLine("以下输出leijun的订单:\n");
            OrderService.GetOrder("Lei Jun");
            Console.WriteLine("以下输出金额2300的订单:\n");
            OrderService.GetOrder(2300);
            //---------------按指定信息查找订单---------------

            OrderService.export();
            OrderService.import();
        }