/// <summary> /// Add item execute /// </summary> private void AddItemExecute() { try { if (Item != null) { OrderDBEntities1 db = new OrderDBEntities1(); tblOrder order = new tblOrder(); string quantityItem = MainWindow.quantity; DateTime dateNow = DateTime.Now; order.TotalPrice = Item.ItemPrice * int.Parse(quantityItem); order.OrderStatus = "pending"; order.OrderCreated = dateNow; order.UserID = Service.currentUser.UserID; order.ItemID = Item.ItemID; Service.currentOrder = order; db.tblOrders.Add(order); db.SaveChanges(); MessageBox.Show("Order successfuly created. Your order is pending."); Login log = new Login(); main.Close(); log.Show(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// delete order /// </summary> /// <param name="orderID">order id</param> public void AddUser(tblUser user) { try { using (OrderDBEntities1 context = new OrderDBEntities1()) { context.tblUsers.Add(user); context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }
/// <summary> /// deny order /// </summary> /// <param name="orderID">order id</param> public void DenyOrder(int orderID) { try { using (OrderDBEntities1 context = new OrderDBEntities1()) { tblOrder orderToDeny = (from r in context.tblOrders where r.OrderID == orderID select r).First(); orderToDeny.OrderStatus = "denied"; context.SaveChanges(); } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); } }