Пример #1
0
        public PurchaseOrderDetail CreateOrAddAmount(Item i, PurchaseOrder po)
        {
            SSISContext context = new SSISContext();

            //item and po into pod

            PurchaseOrderDetail pod = context.PurchaseOrderDetails.OfType <PurchaseOrderDetail>().
                                      Where(x => x.Item.IdItem == i.IdItem && x.PurchaseOrder.IdPurchaseOrder == po.IdPurchaseOrder).FirstOrDefault();

            if (pod == null)
            {
                pod = new PurchaseOrderDetail
                {
                    IdItem          = i.IdItem,
                    IdPurchaseOrder = po.IdPurchaseOrder,
                    OrderUnit       = i.ReorderUnit,
                    DeliveredUnit   = 0,
                };
                context.PurchaseOrderDetails.Add(pod);
                context.SaveChanges();
            }
            else
            {
                pod.OrderUnit += i.ReorderUnit;
                context.SaveChanges();
            }
            context.Dispose();
            return(pod);
        }
Пример #2
0
        public PurchaseOrder FindIncompletePOWithSupplier(string codeSupplier)
        {
            SSISContext   context = new SSISContext();
            PurchaseOrder po      = context.PurchaseOrders.OfType <PurchaseOrder>().Where(x => x.Status.Label.Equals("Incomplete") && x.IdSupplier.Equals(codeSupplier)).Include(b => b.Supplier).Include(b => b.StoreClerk).FirstOrDefault();

            context.Dispose();
            return(po);
        }
Пример #3
0
        public List <Item> FindLowStockItems()
        {
            SSISContext context = new SSISContext();
            List <Item> items   = context.Items.OfType <Item>().
                                  Where(x => x.AvailableUnit <= x.ReorderLevel).
                                  Include(i => i.PurchaseOrderDetails).
                                  Include(i => i.PurchaseOrderDetails.Select(x => x.PurchaseOrder)).
                                  ToList <Item>();

            context.Dispose();
            return(items);
        }
Пример #4
0
        public PurchaseOrder Create(string codeSupplier, int idStoreClerk)
        {
            SSISContext   context       = new SSISContext();
            PurchaseOrder purchaseOrder = new PurchaseOrder {
                StoreClerk   = context.Employees.OfType <Employee>().Where(x => x.IdEmployee == idStoreClerk).FirstOrDefault(),
                Supplier     = context.Suppliers.OfType <Supplier>().Where(x => x.CodeSupplier.Equals(codeSupplier)).FirstOrDefault(),
                Status       = context.Status.OfType <Status>().Where(x => x.Label.Equals("Incomplete")).FirstOrDefault(),
                ApprovedDate = DateTime.Parse("01/01/1900"),
                DeliverDate  = DateTime.Parse("01/01/1900"),
                OrderDate    = DateTime.Parse("01/01/1900")
            };

            context.PurchaseOrders.Add(purchaseOrder);
            context.SaveChanges();
            context.Dispose();
            return(purchaseOrder);
        }