Example #1
0
        //private string _name;
        //private string _address;
        //private string _phone;
        //private DateTime _orderTime;
        //private string _addText;
        //private string _status;
        public TOrder CreateOrder(string name, string address, string phone, string text, long OrderTypeID)
        {
            TOrder order = new TOrder();

            order.Name      = name;
            order.Address   = address;
            order.Phone     = phone;
            order.AddText   = text;
            order.OrderTime = DateTime.Now;
            order.OrderType = OrderTypeID;
            if (order.Status <= 0)
            {
                order.Status = 1; //if not specified then set it unprocessed
            }
            order.Items = new ArrayList();


            using (ISession session = _sessions.OpenSession())
                using (ITransaction tx = session.BeginTransaction())
                {
                    session.Save(order);
                    tx.Commit();
                }


            return(order);
        }
Example #2
0
        public List <TOrder> GetOrdersAndAllItems(DateTime min, DateTime max, string Name)
        {
            List <TOrder> rslt  = new List <TOrder>();
            TOrder        order = null;

            using (ISession session = _sessions.OpenSession())
                using (ITransaction tx = session.BeginTransaction())
                {
                    IQuery q = session.CreateQuery(
                        "from TOrder as order " +
                        "where order.UserName = :userName " +
                        "and order.OrderTime>=:beginDate " +
                        "and order.OrderTime<=:endDate "

                        );
                    q.SetParameter("userName", Name);
                    q.SetParameter("beginDate", min);
                    q.SetParameter("endDate", max);

                    for (int i = 0; i < q.List().Count; i++)
                    {
                        order = (TOrder)q.List()[i];
                        int count = order.Items.Count;
                        rslt.Add(order);
                    }

                    tx.Commit();
                }

            return(rslt);
        }
Example #3
0
 public void UpdateOrder(TOrder order)
 {
     using (ISession session = _sessions.OpenSession())
         using (ITransaction tx = session.BeginTransaction())
         {
             session.Update(order);
             tx.Commit();
         }
 }
Example #4
0
        public TOrder GetOrderAndAllItems(long orderId)
        {
            TOrder order = null;

            using (ISession session = _sessions.OpenSession())
                using (ITransaction tx = session.BeginTransaction())
                {
                    order = session.Load <TOrder>(orderId);
                    IList list = order.Items;

                    int count = order.Items.Count;
                    tx.Commit();
                }

            return(order);
        }
Example #5
0
        public TOrderItem CreateOrderItem(TOrder order, long dishId, string dishName,
            decimal price, decimal amount, decimal subPrice, string text)
        {
            TOrderItem item = new TOrderItem();
            item.DishId = dishId;
            item.DishName = dishName;
            item.Price = price;
            item.Amount = amount;
            item.SubPrice = subPrice;
            item.Text = text;

            order.Items.Add(item);

            using (ISession session = _sessions.OpenSession())
            using (ITransaction tx = session.BeginTransaction())
            {
                session.Update(order);
                tx.Commit();
            }

            return item;
        }
Example #6
0
        //private string _name;
        //private string _address;
        //private string _phone;
        //private DateTime _orderTime;
        //private string _addText;
        //private string _status;
        public TOrder CreateOrder(string name,string address,string phone,string text,long OrderTypeID)
        {
            TOrder order = new TOrder();
            order.Name = name;
            order.Address = address;
            order.Phone = phone;
            order.AddText = text;
            order.OrderTime = DateTime.Now;
            order.OrderType = OrderTypeID;
            if (order.Status<=0)
                order.Status = 1; //if not specified then set it unprocessed
            order.Items = new ArrayList();

            using (ISession session = _sessions.OpenSession())
            using (ITransaction tx = session.BeginTransaction())
            {
                session.Save(order);
                tx.Commit();
            }

            return order;
        }
Example #7
0
        public TOrderItem CreateOrderItem(TOrder order, long dishId, string dishName,
                                          decimal price, decimal amount, decimal subPrice, string text)
        {
            TOrderItem item = new TOrderItem();

            item.DishId   = dishId;
            item.DishName = dishName;
            item.Price    = price;
            item.Amount   = amount;
            item.SubPrice = subPrice;
            item.Text     = text;

            order.Items.Add(item);

            using (ISession session = _sessions.OpenSession())
                using (ITransaction tx = session.BeginTransaction())
                {
                    session.Update(order);
                    tx.Commit();
                }

            return(item);
        }
Example #8
0
 public void UpdateOrder(TOrder order)
 {
     using (ISession session = _sessions.OpenSession())
     using (ITransaction tx = session.BeginTransaction())
     {
         session.Update(order);
         tx.Commit();
     }
 }