public long saveOrder1()
        {
            ISessionFactory _sessions;
            Configuration cfg = new Configuration().Configure();
            _sessions = cfg.BuildSessionFactory();

            TOrderData ob = new TOrderData();
            ob.Configure();

            TOrder od = ob.CreateOrder("test", "order.Address", "order.Phone", "order.AddText",1);
            //od.Id = order.Id;
            //od.Name = order.Name;
            //od.OrderTime = order.OrderTime;
            //od.Phone = order.Phone;
            //od.Address = order.Address;
            //od.AddText = order.AddText;

                for (int i = 0; i < 8; i++)
                {
                    TOrderItem oditem = new TOrderItem();
                    oditem.Order = od;
                    oditem.Price = 9.99M;
                    oditem.Amount = 2;
                    oditem.SubPrice = 19.99M;
                    oditem.Text = "testb" + od.Id;
                    oditem.DishId = 1;
                    oditem.DishName = "testb" + i;
                    od.Items.Add(oditem);

                }
                ob.UpdateOrder(od);

                return od.Id;
        }
        public void saveOrder()
        {
            ISessionFactory _sessions;
            Configuration cfg = new Configuration().Configure();
            _sessions = cfg.BuildSessionFactory();

            TOrderData ob = new TOrderData();
            ob.Configure();

            TOrder od = ob.CreateOrder("test","order.Address", "order.Phone", "order.AddText",1);
            //od.Id = order.Id;
            //od.Name = order.Name;
            //od.OrderTime = order.OrderTime;
            //od.Phone = order.Phone;
            //od.Address = order.Address;
            //od.AddText = order.AddText;

            using (ISession session = _sessions.OpenSession())
            using (ITransaction tx = session.BeginTransaction())
            {

                od = session.Load<TOrder>(od.Id);

                for (int i = 0; i < 8; i++)
                {
                    TOrderItem oditem = new TOrderItem();
                    oditem.Order = od;
                    oditem.Price = 9.99M;
                    oditem.Amount = 2;
                    oditem.SubPrice = 19.99M;
                    oditem.Text = "test" + od.Id;
                    oditem.DishId = 1;
                    oditem.DishName = "test" + i;
                    //oditem.Id = -1;

                    od.Items.Add(oditem);

                }
                session.Flush();
                tx.Commit();
            }
        }
        public void TestMethod1()
        {
            List<DishItem> list = PersistData.DishItemObj.GetAllDishItem();

            Assert.AreNotEqual(list.Count, 0);

            Console.WriteLine("first dish" + list[0].Name);

            DataTable dt = RestaurantApp.RestaurantBiz.getDishItems();

            Console.WriteLine(dt.Rows.Count);

            TOrderData orderData = new TOrderData();

            orderData.Configure();

            long id = saveOrder1();

            TOrder order= orderData.GetOrderAndAllItems(id);

            Assert.AreNotEqual(order.Items.Count,0);

            Console.WriteLine(order.OrderTime);

            List<TOrderStatus> list1 =  orderData.GetAllOrderStatus();
            Console.WriteLine("List<TOrderStatus> count is " + list1.Count);

            List<TOrderType> list2 = orderData.GetAllOrderTypes();
            Console.WriteLine("List<TOrderType> count is " + list2.Count);
            /*
            orderData.ExportTables();

            try
            {
                StreamReader rd = File.OpenText(@"c:\orderTables.txt");
                while (!rd.EndOfStream)
                {
                   Console.WriteLine( rd.ReadLine());
                }

            }catch(Exception ex)
            {
                Assert.Fail("open file failed");
            }*/
        }
Example #4
0
        public static long saveOrder(TOrderBiz order)
        {
            TOrderData ob = new TOrderData();
            ob.Configure();

            TOrder od = ob.CreateOrder(order.Name, order.Address, order.Phone, order.AddText, order.OrderTypeID);

            od.UserName = order.UserName;

            foreach (TOrderItemBiz item in order.Items)
            {
                TOrderItem oditem = new TOrderItem();
                oditem.Order = od;
                oditem.Price = item.Price;
                oditem.Amount = item.Amount;
                oditem.SubPrice = item.SubPrice;
                oditem.Text = item.Text;
                oditem.DishId = item.DishId;
                oditem.DishName = item.DishName;

                od.Items.Add(oditem);
            }
            ob.UpdateOrder(od);
            return od.Id;
        }
Example #5
0
        public static List<TOrder> getOrdersAndItems(DateTime min, DateTime max, string user)
        {
            TOrderData ob = new TOrderData();
            ob.Configure();

            List<TOrder> list = ob.GetOrdersAndAllItems(min,max,user);

            return list;
        }
Example #6
0
        public static void getOrderAndItems(long orderId, DataTable dtOrder)
        {
            TOrderData ob = new TOrderData();
            ob.Configure();

            TOrder order = ob.GetOrderAndAllItems(orderId);

            dtOrder.Rows.Clear();
            if (order != null)
            {
                for (int i = 0; i < order.Items.Count; i++)
                {

                    TOrderItem item = (TOrderItem)order.Items[i];
                    dtOrder.Rows.Add();
                    dtOrder.Rows[i][0] = item.DishId;
                    dtOrder.Rows[i][1] = item.DishName;
                    dtOrder.Rows[i][2] = Convert.ToInt32(item.Amount);
                    dtOrder.Rows[i][3] = item.SubPrice.ToString();
                    dtOrder.Rows[i][4] = item.Price.ToString();

                }

            }
        }