示例#1
0
        public bool UpdateCollectionPt(string codeDepartment, int idCollectionPt)
        {
            Department model = null;

            using (SSISContext db = new SSISContext())
            {
                model = db.Departments.OfType <Department>()
                        .Where(x => x.CodeDepartment == codeDepartment)
                        .FirstOrDefault();
                if (model == null)
                {
                    return(false);
                }
                CollectionPoint collectionPt = db.CollectionPoints.OfType <CollectionPoint>()
                                               .Where(x => x.IdCollectionPt == idCollectionPt)
                                               .FirstOrDefault();
                if (collectionPt == null)
                {
                    return(false);
                }
                model.IdCollectionPt = idCollectionPt;
                db.SaveChanges();
            }
            return(true);
        }
示例#2
0
        public bool UpdateCollectionPt(int idDisbursement, int idCollectionPt)
        {
            Disbursement model = null;

            using (SSISContext db = new SSISContext())
            {
                model = db.Disbursements.OfType <Disbursement>()
                        .Where(x => x.IdDisbursement == idDisbursement)
                        .FirstOrDefault();
                if (model == null)
                {
                    return(false);
                }
                CollectionPoint collectionPt = db.CollectionPoints
                                               .Include("CPClerks")
                                               .OfType <CollectionPoint>()
                                               .Where(x => x.IdCollectionPt == idCollectionPt)
                                               .FirstOrDefault();
                if (collectionPt == null)
                {
                    return(false);
                }
                model.IdCollectionPt = idCollectionPt;
                model.IdDisbursedBy  = collectionPt.CPClerks.FirstOrDefault().IdStoreClerk;
                db.SaveChanges();
            }
            return(true);
        }
示例#3
0
 public List <Delegation> FindAll()
 {
     using (SSISContext context = new SSISContext())
     {
         return(context.Delegations.OfType <Delegation>().ToList <Delegation>());
     }
 }
示例#4
0
        public List <Disbursement> GetReceivedDisbursements(string codeDepartment, string searchContext = "")
        {
            List <Disbursement> model = new List <Disbursement>();

            using (SSISContext db = new SSISContext())
            {
                if (string.IsNullOrEmpty(searchContext))
                {
                    model = db.Disbursements
                            .Include("DisbursementItems.Item")
                            .Include("Department")
                            .Include("CollectedBy")
                            .Include("DisbursedBy")
                            .Include("CollectionPoint")
                            .Include("Status")
                            .Where(x => x.IdStatus == 11 && x.CodeDepartment == codeDepartment)
                            .ToList();
                }
                else
                {
                    model = db.Disbursements
                            .Include("DisbursementItems.Item")
                            .Include("Department")
                            .Include("CollectedBy")
                            .Include("DisbursedBy")
                            .Include("CollectionPoint")
                            .Include("Status")
                            .Where(x => x.IdStatus == 11 && x.CodeDepartment == codeDepartment &&
                                   (x.Date.ToString().Contains(searchContext) || x.CollectionPoint.Location.ToString().Contains(searchContext) || x.DisbursedBy.Name.ToString().Contains(searchContext) || x.CollectedBy.Name.ToString().Contains(searchContext)))
                            .ToList();
                }
            }
            return(model);
        }
        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);
        }
示例#6
0
 public CollectionPoint Find(int id)
 {
     using (SSISContext context = new SSISContext())
     {
         return(context.CollectionPoints.OfType <CollectionPoint>().Where(x => x.IdCollectionPt == id).FirstOrDefault());
     }
 }
示例#7
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);
        }
示例#8
0
 public void Create(Delegation d)
 {
     using (SSISContext context = new SSISContext())
     {
         context.Delegations.Add(d);
         context.SaveChanges();
     }
 }
示例#9
0
 public void Delete(Delegation d)
 {
     using (SSISContext context = new SSISContext())
     {
         Delegation del = context.Delegations.OfType <Delegation>().Where(x => x.IdDelegation == d.IdDelegation).FirstOrDefault();
         context.Delegations.Remove(del);
         context.SaveChanges();
     }
 }
示例#10
0
 public void Update(Delegation d)
 {
     using (SSISContext context = new SSISContext())
     {
         Delegation del = context.Delegations.OfType <Delegation>().Where(x => x.IdDelegation == d.IdDelegation).FirstOrDefault();
         del.IdEmployee = d.IdEmployee;
         del.StartDate  = d.StartDate;
         del.EndDate    = d.EndDate;
         context.SaveChanges();
     }
 }
示例#11
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);
        }
示例#12
0
        public Supplier GetSupplierById(string codeSupplier)
        {
            Supplier supplier = new Supplier();

            using (SSISContext db = new SSISContext())
            {
                supplier = db.Suppliers
                           .Where(s => s.CodeSupplier == codeSupplier)
                           .FirstOrDefault();
            }
            return(supplier);
        }
示例#13
0
        public List <SupplierItem> GetSuppliersById(int itemId)
        {
            List <SupplierItem> suppliers = new List <SupplierItem>();

            using (SSISContext db = new SSISContext())
            {
                suppliers = db.SupplierItems
                            .Include("Supplier")
                            .Include("Item")
                            .Where(s => s.IdItem == itemId)
                            .ToList();
            }
            return(suppliers);
        }
示例#14
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);
        }
示例#15
0
        public List <Disbursement> GetAllDisbursements()
        {
            List <Disbursement> models = new List <Disbursement>();

            using (SSISContext db = new SSISContext())
            {
                models = db.Disbursements
                         .Include("DisbursementItems.Item")
                         .Include("Department")
                         .Include("CollectedBy")
                         .Include("DisbursedBy")
                         .Include("CollectionPoint")
                         .Include("Status")
                         .ToList();
            }
            return(models);
        }
示例#16
0
        public List <Disbursement> GetDeptDisbursements(string codeDepartment)
        {
            List <Disbursement> models = new List <Disbursement>();

            using (SSISContext db = new SSISContext())
            {
                models = db.Disbursements
                         .Include("DisbursementItems.Item")
                         .Include("Department")
                         .Include("CollectedBy")
                         .Include("DisbursedBy")
                         .Include("CollectionPoint")
                         .Include("Status")
                         .Where(x => x.CodeDepartment == codeDepartment)
                         .ToList();
            }
            return(models);
        }
示例#17
0
        public Disbursement GetDisbursement(int id)
        {
            Disbursement model = new Disbursement();

            using (SSISContext db = new SSISContext())
            {
                model = db.Disbursements
                        .Include("DisbursementItems.Item")
                        .Include("Department")
                        .Include("CollectedBy")
                        .Include("DisbursedBy")
                        .Include("CollectionPoint")
                        .Include("Status")
                        .Where(x => x.IdDisbursement == id)
                        .FirstOrDefault();
            }
            return(model);
        }
示例#18
0
        public Disbursement GetScheduledDisbursement(string codeDepartment)
        {
            Disbursement model = new Disbursement();

            using (SSISContext db = new SSISContext())
            {
                model = db.Disbursements
                        .Include("DisbursementItems.Item")
                        .Include("Department")
                        .Include("CollectedBy")
                        .Include("DisbursedBy")
                        .Include("CollectionPoint")
                        .Include("Status")
                        .Where(x => x.IdStatus == 10 && x.CodeDepartment.Equals(codeDepartment))
                        .FirstOrDefault();
            }
            return(model);
        }
示例#19
0
 public bool AcknowledgeCollection(int idDisbursement, int IdCollectedBy)
 {
     using (SSISContext db = new SSISContext())
     {
         Disbursement disbursement = db.Disbursements.OfType <Disbursement>()
                                     .Where(x => x.IdDisbursement == idDisbursement)
                                     .FirstOrDefault();
         if (disbursement == null)
         {
             return(false);
         }
         List <DisbursementItem> disbursementItems = db.DisbursementItems.OfType <DisbursementItem>()
                                                     .Where(x => x.IdDisbursement == idDisbursement)
                                                     .ToList();
         disbursement.IdStatus      = 11;
         disbursement.IdCollectedBy = IdCollectedBy;
         foreach (DisbursementItem di in disbursementItems)
         {
             di.IdStatus = 11;
         }
         db.SaveChanges();
     }
     return(true);
 }
示例#20
0
 public DisbursementDAO()
 {
     this.context = new SSISContext();
 }
示例#21
0
 public RequisitionItemDAO()
 {
     this.context = new SSISContext();
 }
示例#22
0
 protected override void Seed(SSISContext context)
 {
     base.Seed(context);
 }
示例#23
0
 public StatusDAO()
 {
     this.context = new SSISContext();
 }
示例#24
0
 public CategoryDAO()
 {
     this.context = new SSISContext();
 }
示例#25
0
 public PurchaseOrderDAO()
 {
     this.context = new SSISContext();
 }
示例#26
0
 public DepartmentDAO()
 {
     context = new SSISContext();
 }
示例#27
0
 public ItemDAO()
 {
     this.context = new SSISContext();
 }
示例#28
0
 public StockRecordDAO()
 {
     this.context = new SSISContext();
 }
示例#29
0
 public SupplierItemDAO()
 {
     this.context = new SSISContext();
 }
示例#30
0
 public NotificationChannelDAO()
 {
     this.context = new SSISContext();
 }