public void Delete(String ID, Boolean ChangeQuantity) { Order org = Get(ID); if (org == null) { throw new Exception($"Order ({ID}) is Not Exist"); } var ordersinfo = Get_Data.GetOIs_ByOrder(ID).ToList(); foreach (var item in ordersinfo) { if (ChangeQuantity) { var product = Get_Data.Get_Product(item.Product_ID); if (product != null) { product.Quantity -= item.Quantity; if (product.Quantity < 0) { product.Quantity = 0; } new MProducts().Update(product); } } Management.Remove(item); } Management.Remove(org); }
public void Remove(Pharmacy pharmacy) { Pharmacy org = Get_Data.GetPharmacy(); if (org == null) { throw new Exception($"There is No Pharmacy is Added Yet"); } Management.Remove(pharmacy); }
public void Add(Order order, List <OrderInfo> OrderInfo) { do { order.ID = GetNewID(); } while (Get(order.ID) != null); Management.Add(order); foreach (var item in OrderInfo) { Management.Add(new OrderInfo() { Order_ID = order.ID, Product_ID = item.Product_ID, Price = item.Price, Quantity = item.Quantity }); Product product = Get_Data.Get_Product(item.Product_ID); product.Quantity += item.Quantity; new MProducts().Update(product); } }
public Order Get(String ID) { return(Get_Data.Get_Order(ID)); }
public Employee Get(int id) { return(Get_Data.Get_Employee(id)); }
public List <Contract> Get_All() { return(Get_Data.Get_Contracts().ToList()); }
public Employee Login(String UserName, String Password) { return(Get_Data.Login(UserName, Password)); }
public List <Order> GetPharmacyOrders() { return(Get_Data.Get_Orders().ToList()); }
public List <OrderInfo> GetOIs_ByProduct(String PID) { return(Get_Data.GetOIs_ByProduct(PID).ToList()); }
public Category Get(String Name) { return(Get_Data.Get_Categories().Where(item => item.Name.CompareTo(Name) == 0).FirstOrDefault()); }
public Category Get(int ID) { return(Get_Data.Get_Category(ID)); }
public List <Producer> Get_All() { return(Get_Data.Get_Producers().ToList()); }
public Producer Get(String Name) { return(Get_Data.Get_Producers().Where(item => item.Name.CompareTo(Name) == 0).FirstOrDefault()); }
public Producer Get(int id) { return(Get_Data.Get_Producer(id)); }
public List <Employee> Get_All() { return(Get_Data.Get_Employees().ToList()); }
public Employee GetByNIC(String nic) { return(Get_Data.GetEmployeeByNIC(nic)); }
public List <OrderInfo> GetOrders_Info(String OrderID) { return(Get_Data.GetOIs_ByOrder(OrderID).ToList()); }
public List <Category> Get_All() { return(Get_Data.Get_Categories().ToList()); }
public List <Order> Get_All() { return(Get_Data.Get_Orders().ToList()); }
public Pharmacy Get() { return(Get_Data.GetPharmacy()); }
public List <Order> GetCustumorsOrders() { return(Get_Data.Get_Orders().ToList()); }
public Department Get(int id) { return(Get_Data.Get_Department(id)); }
public void Update(Order order, List <OrderInfo> OrderInfo) { Order org = Get(order.ID); if (org == null) { throw new Exception($"Order ({order.ID}) is Not Exist"); } var orgOIs = Get_Data.GetOIs_ByOrder(order.ID); var uc = new MCategories().GetUNCategory().ID; var up = new MProducers().GetUNProducer().ID; foreach (var item in orgOIs) { var ori = Get_Data.GetOrderInfo(item.Order_ID, item.Product_ID); var pi = OrderInfo.Where(i => i.Product_ID == item.Product_ID).FirstOrDefault(); var product = Get_Data.Get_Product(item.Product_ID); if (pi != null) { pi.ID = ori.ID; pi.Order_ID = order.ID; if (pi.Quantity != item.Quantity) { if (pi.Quantity > item.Quantity) { product.Quantity += (pi.Quantity - item.Quantity); } else if (pi.Quantity < item.Quantity) { product.Quantity -= (item.Quantity - pi.Quantity); } if (product.Quantity < 0) { product.Quantity = 0; } Management.Detach(ori); Management.Update(pi); } } else { product.Quantity -= item.Quantity; Management.Remove(item); } new MProducts().Update(product); } foreach (var item in OrderInfo.Where(i => String.IsNullOrEmpty(i.Order_ID)).ToList()) { Management.Add(new OrderInfo() { Order_ID = order.ID, Product_ID = item.Product_ID, Price = item.Price, Quantity = item.Quantity }); Product product = Get_Data.Get_Product(item.Product_ID); product.Quantity += item.Quantity; new MProducts().Update(product); } }
public List <Department> Get_All() { return(Get_Data.Get_Departments().ToList()); }
public Contract Get(int ID) { return(Get_Data.Get_Contract(ID)); }
public Department Get(string title) { return(Get_Data.Get_Departments().Where(item => item.Title.CompareTo(title) == 0).FirstOrDefault()); }
public Contract GetEmpContract(int empid) { return(Get_Data.Get_Contracts().Where(item => item.Employee_ID == empid).FirstOrDefault()); }
public Product Get(String ID) { return(Get_Data.Get_Product(ID)); }