Пример #1
0
        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);
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public Order Get(String ID)
 {
     return(Get_Data.Get_Order(ID));
 }
Пример #5
0
 public Employee Get(int id)
 {
     return(Get_Data.Get_Employee(id));
 }
Пример #6
0
 public List <Contract> Get_All()
 {
     return(Get_Data.Get_Contracts().ToList());
 }
Пример #7
0
 public Employee Login(String UserName, String Password)
 {
     return(Get_Data.Login(UserName, Password));
 }
Пример #8
0
 public List <Order> GetPharmacyOrders()
 {
     return(Get_Data.Get_Orders().ToList());
 }
Пример #9
0
 public List <OrderInfo> GetOIs_ByProduct(String PID)
 {
     return(Get_Data.GetOIs_ByProduct(PID).ToList());
 }
Пример #10
0
 public Category Get(String Name)
 {
     return(Get_Data.Get_Categories().Where(item => item.Name.CompareTo(Name) == 0).FirstOrDefault());
 }
Пример #11
0
 public Category Get(int ID)
 {
     return(Get_Data.Get_Category(ID));
 }
Пример #12
0
 public List <Producer> Get_All()
 {
     return(Get_Data.Get_Producers().ToList());
 }
Пример #13
0
 public Producer Get(String Name)
 {
     return(Get_Data.Get_Producers().Where(item => item.Name.CompareTo(Name) == 0).FirstOrDefault());
 }
Пример #14
0
 public Producer Get(int id)
 {
     return(Get_Data.Get_Producer(id));
 }
Пример #15
0
 public List <Employee> Get_All()
 {
     return(Get_Data.Get_Employees().ToList());
 }
Пример #16
0
 public Employee GetByNIC(String nic)
 {
     return(Get_Data.GetEmployeeByNIC(nic));
 }
Пример #17
0
 public List <OrderInfo> GetOrders_Info(String OrderID)
 {
     return(Get_Data.GetOIs_ByOrder(OrderID).ToList());
 }
Пример #18
0
 public List <Category> Get_All()
 {
     return(Get_Data.Get_Categories().ToList());
 }
Пример #19
0
 public List <Order> Get_All()
 {
     return(Get_Data.Get_Orders().ToList());
 }
Пример #20
0
 public Pharmacy Get()
 {
     return(Get_Data.GetPharmacy());
 }
Пример #21
0
 public List <Order> GetCustumorsOrders()
 {
     return(Get_Data.Get_Orders().ToList());
 }
Пример #22
0
 public Department Get(int id)
 {
     return(Get_Data.Get_Department(id));
 }
Пример #23
0
        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);
            }
        }
Пример #24
0
 public List <Department> Get_All()
 {
     return(Get_Data.Get_Departments().ToList());
 }
Пример #25
0
 public Contract Get(int ID)
 {
     return(Get_Data.Get_Contract(ID));
 }
Пример #26
0
 public Department Get(string title)
 {
     return(Get_Data.Get_Departments().Where(item => item.Title.CompareTo(title) == 0).FirstOrDefault());
 }
Пример #27
0
 public Contract GetEmpContract(int empid)
 {
     return(Get_Data.Get_Contracts().Where(item => item.Employee_ID == empid).FirstOrDefault());
 }
Пример #28
0
 public Product Get(String ID)
 {
     return(Get_Data.Get_Product(ID));
 }