public void UpdateOrderItem(long itemId, long dishId, string dishName, decimal price, decimal amount, decimal subPrice, string text) { using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { TOrderItem item = (TOrderItem)session.Load(typeof(TOrderItem), itemId); item.DishId = dishId; item.DishName = dishName; item.Price = price; item.Amount = amount; item.SubPrice = subPrice; item.Text = text; tx.Commit(); } }
public void UpdateOrderItem(TOrderItem item, long dishId, string dishName, decimal price, decimal amount, decimal subPrice, string text) { item.DishId = dishId; item.DishName = dishName; item.Price = price; item.Amount = amount; item.SubPrice = subPrice; item.Text = text; using (ISession session = _sessions.OpenSession()) using (ITransaction tx = session.BeginTransaction()) { session.Update(item); tx.Commit(); } }
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 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; }
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); }
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 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; }