public bool CreateRequisition(Requisition modelReq)
        {
            bool isSuccessful = false;

            LogicUniStoreModel dbContext;

            try
            {
                dbContext = new LogicUniStoreModel();
                dbContext.Database.Connection.Open();
                using (var txn = dbContext.Database.BeginTransaction())
                {
                    //Create Adjustment and Items
                    RequisitionDao dao = new RequisitionDao(dbContext);
                    dao.Create(modelReq);
                    RequisitionItemDao itemDao = new RequisitionItemDao(dbContext);
                    foreach (RequisitionItem item in modelReq.RequisitionItems)
                    {
                        itemDao.addRequisitionItem(item);
                    }
                    txn.Commit();
                    isSuccessful = true;
                }
                dbContext.Database.Connection.Close();
            }
            catch (Exception ex)
            {
                //   throw;
            }
            return(isSuccessful);
        }
        public AdjustmentVoucherManagerController()
        {
            LogicUniStoreModel db = new LogicUniStoreModel();

            adj  = new AdjustmentItemDao();
            adao = new AdjustmentDao(db);
            idao = new ItemDao();
            sdao = new StockCardDao();
        }
        public ProcessReqController()
        {
            LogicUniStoreModel db = new LogicUniStoreModel();

            RequisitionDao     = new RequisitionDao(db);
            StockCardDao       = new StockCardDao(db);
            RequisitionItemDao = new RequisitionItemDao(db);
            mainList           = new Dictionary <Requisition, double>();
            LockedItem         = new Dictionary <int, int>();
        }
        public List <Requisition> GetReqItemForProcess(List <Requisition> reqs)
        {
            LogicUniStoreModel db = new LogicUniStoreModel();

            if (reqs == null)
            {
                reqs = db.Requisitions.Where(r => r.Status == RequisitionStatus.Approved.ToString()).ToList();
            }
            int                pId, stockCount, approveQnty;
            double             progrssMeter;
            List <Requisition> reqList = new List <Requisition>();

            foreach (var req in reqs.ToList())
            {
                progrssMeter = 0.0;
                foreach (var item in req.RequisitionItems.ToList())
                {
                    pId         = item.SupplierItem.ItemID;
                    approveQnty = item.NeededQuantity.Value;
                    stockCount  = StockCardDao.GetProductCountInStock(pId);

                    if (!LockedItem.ContainsKey(pId))
                    {
                        if (approveQnty > stockCount)
                        {
                            approveQnty = (stockCount - approveQnty > 0)? stockCount - approveQnty : stockCount;
                        }
                        LockedItem.Add(pId, approveQnty);
                    }
                    else
                    {
                        stockCount = (stockCount - LockedItem[pId]);
                        if (approveQnty > stockCount)
                        {
                            approveQnty = (stockCount - approveQnty > 0)? stockCount - approveQnty : stockCount;
                        }
                        LockedItem[pId] += approveQnty;
                    }
                    item.ApprovedQuantity = approveQnty;

                    if (item.ApprovedQuantity == item.NeededQuantity)
                    {
                        progrssMeter += 1; // add 1 on scale of item.count()
                    }
                    else
                    {
                        progrssMeter += (double)item.ApprovedQuantity / (double)item.NeededQuantity; // add fraction on scale of item.count()
                    }
                }
                meter[req.ReqID] = (progrssMeter / req.RequisitionItems.Count) * 100;
                reqList.Add(req);
            }
            return(reqList);
        }
        public bool CreatePO(POBatch poBactch, PurchaseOrder Order)
        {
            bool result           = false;
            LogicUniStoreModel db = new LogicUniStoreModel();

            db.POBatches.Add(poBactch);
            db.SaveChanges();
            Order.POBatchID = poBactch.POBatchID;
            db.PurchaseOrders.Add(Order);
            result = db.SaveChanges() > 0 ? true : false;
            return(result);
        }
        public bool CreateSpotAdjustment(Adjustment adjustment)
        {
            bool isSuccessful = false;
            LogicUniStoreModel dbContext;

            try
            {
                StockAdjustment objAdjustment = new StockAdjustment()
                {
                    CreatedBy            = adjustment.CreatedBy,
                    CreatedDate          = DateTime.Now,
                    SockAdjustmentNumber = adjustment.Number,
                    Status = AdjustmentStatus.Created.ToString(),
                    Type   = StockCheckType.OnSpot.ToString()
                };
                objAdjustment.StockAdjustmentItems = new List <StockAdjustmentItem>();
                foreach (AdjustmentItem item in adjustment.Items)
                {
                    StockAdjustmentItem objAdjItem = new StockAdjustmentItem()
                    {
                        CountDate       = DateTime.Now,
                        CountPerson     = adjustment.CreatedBy.ToString(), //TODO: Change to Id
                        CountQuantity   = item.Quantity,
                        ItemID          = item.ItemId,
                        Remark          = item.Remarks,
                        Status          = AdjustmentStatus.Created.ToString(),
                        AdjustQuantity  = item.Quantity,
                        StockAdjustment = objAdjustment
                    };
                    objAdjustment.StockAdjustmentItems.Add(objAdjItem);
                }

                dbContext = new LogicUniStoreModel();
                dbContext.Database.Connection.Open();
                using (var txn = dbContext.Database.BeginTransaction())
                {
                    //Create Adjustment and Items
                    AdjustmentDao dao = new AdjustmentDao(dbContext);
                    dao.CreateAdjustment(objAdjustment);
                    //Update stock card
                    //dao.updateStockCard(objAdjustment.StockAdjustmentItems.ToList());
                    txn.Commit();
                    isSuccessful = true;
                }
                dbContext.Database.Connection.Close();
            }
            catch (Exception)
            {
                //   throw;
            }
            return(isSuccessful);
        }
Пример #7
0
        public bool ProcessDisbursement(int disbId, string key, int receivedBy, List <Tuple <int, int> > itemQtys)
        {
            bool result = true;
            LogicUniStoreModel dbContext = new LogicUniStoreModel();

            dbContext.Database.Connection.Open();
            using (var txn = dbContext.Database.BeginTransaction())
            {
                DisbursementDao disbDao = new DisbursementDao(dbContext);

                if (disbDao.ValidateDisbKey(disbId, key))
                {
                    disbDao.AcceptDisbursement(disbId, receivedBy);
                    disbDao.UpdateDisbusedQuantity(disbId, itemQtys);
                }
                else
                {
                    result = false;
                }
                txn.Commit();
            }
            dbContext.Database.Connection.Close();
            return(result);
        }
Пример #8
0
 public StockCardDao()
 {
     db = new LogicUniStoreModel();
 }
Пример #9
0
 public UserDao(LogicUniStoreModel context)
 {
     db = context;
 }
Пример #10
0
 public UserDao()
 {
     db = new LogicUniStoreModel();
 }
Пример #11
0
        public ClerkMainController()
        {
            LogicUniStoreModel db = new LogicUniStoreModel();

            RequisitionItemDao = new RequisitionItemDao(db);
        }
Пример #12
0
 public ItemDao()
 {
     db = new LogicUniStoreModel();
 }
Пример #13
0
 public DisbursementDao(LogicUniStoreModel dbContext)
 {
     db = dbContext;
 }
        public string GetToEmailIds(Roles role, int receiverDeptId)
        {
            var emails = new LogicUniStoreModel().LUUsers.Where(user => user.Role.RoleCode == role.ToString() && user.DepartmentID == receiverDeptId).Select(val => val.Email);

            return(String.Join(",", emails));
        }
 public RequisitionItemDao()
 {
     db = new LogicUniStoreModel();
 }
 public NotificationDao()
 {
     db = new LogicUniStoreModel();
 }
        public AdjustmentController()
        {
            LogicUniStoreModel db = new LogicUniStoreModel();

            dao = new AdjustmentDao(db);
        }
 public AdjustmentDao(LogicUniStoreModel dbContext)
 {
     db = dbContext;
 }
 public NotificationDao(LogicUniStoreModel db)
 {
     this.db = db;
 }
Пример #20
0
 public RequisitionDao(LogicUniStoreModel dbContext)
 {
     db = dbContext;
 }
Пример #21
0
 public StockCardDao(LogicUniStoreModel context)
 {
     db = context;
 }
 public RequisitionItemDao(LogicUniStoreModel context)
 {
     db = context;
 }
Пример #23
0
 public DisbursementDao()
 {
     db = new LogicUniStoreModel();
 }