コード例 #1
0
        public JsonResult PostAdjustment(AdjList savdlist)
        {
            List <Info> aa = JsonConvert.DeserializeObject <List <Info> >(savdlist.Infos[0]);

            StockAdjustmentVoucher stockAdjustmentVoucher = new StockAdjustmentVoucher();

            stockAdjustmentVoucher.AdjustmentVoucherNumber = (db.StockAdjustmentVouchers.Count() + 1).ToString();
            stockAdjustmentVoucher.Status  = "Pending";
            stockAdjustmentVoucher.Date    = DateTime.Today;
            stockAdjustmentVoucher.Remarks = "Store clerk";
            int num = db.StockAdjustmentVoucherDetails.Count();

            db.StockAdjustmentVouchers.Add(stockAdjustmentVoucher);
            db.SaveChanges();

            for (int i = 0; i < aa.Count; i++)
            {
                int hh = num + 1 + i;
                StockAdjustmentVoucherDetail savd = new StockAdjustmentVoucherDetail
                {
                    AdjustmentDetailsNumber = hh,
                    AdjustmentVoucherNumber = stockAdjustmentVoucher.AdjustmentVoucherNumber,
                    ItemNumber       = aa[i].ItemNumber,
                    QuantityAdjusted = Convert.ToInt32(aa[i].QuantityAdjusted),
                    Reason           = aa[i].Reason
                };
                db.StockAdjustmentVoucherDetails.Add(savd);
                db.SaveChanges();
            }

            return(Json(new { status = "Submited Successfully" }));
        }
コード例 #2
0
        public ActionResult AdjustRetrieval([Bind(Include = "Id,DateCreated")] StockAdjustmentVoucher stockAdjustmentVoucher, FormCollection form, string sessionId)
        {
            //stockAdjustmentVoucher = (StockAdjustmentVoucher)TempData["s"];
            string VoucherId  = Request.Form["Id"];
            string DeptString = Request.Form["DeptString"];
            string RequisitionDetailsString = Request.Form["RequisitionDetailsString"];
            int    count = int.Parse(Request.Form["count"]);

            sessionId = Request["sessionId"];

            List <StockAdjustmentVoucherDetail> sList = db.StockAdjustmentVoucherDetails.Where(sd1 => sd1.StockAdjustmentVoucherId == VoucherId).ToList();

            for (int i = 0; i < count; i++)
            {
                string itemcode    = Request.Form["ItemCode[" + i + "]"];
                int    qtyadjusted = int.Parse(Request.Form["QuantityAdjusted[" + i + "]"]);
                string reason      = Request.Form["StockAdjustmentVoucherDetails[" + i + "].Reason"];

                if (sList.Any(a => a.ItemCode.Contains(itemcode)))
                {
                    StockAdjustmentVoucherDetail s0 = sList.Find(b => b.ItemCode == itemcode);
                    //s0.QuantityAdjusted = s0.QuantityAdjusted + qtyadjusted;
                    s0.Reason = "RETRIEVAL: " + reason;
                }
                else
                {
                    sList = AddVoucherDetailToVoucherDetailList(sList, itemcode, qtyadjusted, reason);
                }
            }
            AllocateAuthorizer(sList);

            ViewData["count"] = count;
            return(RedirectToAction("DisplayDisbursement", "Disbursements", new { RequisitionDetailsString = RequisitionDetailsString, DeptString = DeptString, sessionId = sessionId }));
        }
コード例 #3
0
        public ActionResult Create(List <StockAdjustmentVoucherDetail> savdlist, string sessionId)
        {
            if (sessionId == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            StoreClerk      storeclerk      = db.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreManager    storeManager    = db.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreSupervisor storeSupervisor = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault();

            StockAdjustmentVoucher stockAdjustmentVoucher = new StockAdjustmentVoucher();

            stockAdjustmentVoucher.AdjustmentVoucherNumber = (db.StockAdjustmentVouchers.Count() + 1).ToString();
            stockAdjustmentVoucher.Status  = "Pending";
            stockAdjustmentVoucher.Date    = DateTime.Today;
            stockAdjustmentVoucher.Remarks = "Store clerk";

            db.StockAdjustmentVouchers.Add(stockAdjustmentVoucher);
            db.SaveChanges();

            for (int i = 0; i < savdlist.Count; i++)
            {
                StockAdjustmentVoucherDetail savd = new StockAdjustmentVoucherDetail
                {
                    AdjustmentDetailsNumber = savdlist[i].AdjustmentDetailsNumber,
                    AdjustmentVoucherNumber = stockAdjustmentVoucher.AdjustmentVoucherNumber,
                    ItemNumber       = savdlist[i].ItemNumber,
                    QuantityAdjusted = savdlist[i].QuantityAdjusted,
                    Reason           = savdlist[i].Reason
                };
                db.StockAdjustmentVoucherDetails.Add(savd);
                db.SaveChanges();
            }
            return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId }));
        }
        public ActionResult Create([Bind(Include = "StockAdjustmentVoucherId,ItemCode,Reason,QuantityAdjusted,Status,ApproverRemarks,Balance,Approver")] StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail, string sessionId)
        {
            if (sessionId == null)
            {
                sessionId = Request["sessionId"];
            }
            if (Sessions.IsValidSession(sessionId))
            {
                ViewData["sessionId"] = sessionId;
                if (ModelState.IsValid)
                {
                    db.StockAdjustmentVoucherDetails.Add(stockAdjustmentVoucherDetail);
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { sessionId = sessionId }));
                }

                ViewBag.ItemCode = new SelectList(db.Products, "ItemCode", "Category", stockAdjustmentVoucherDetail.ItemCode);
                ViewBag.StockAdjustmentVoucherId = new SelectList(db.StockAdjustmentVouchers, "Id", "Id", stockAdjustmentVoucherDetail.StockAdjustmentVoucherId);
                return(View(stockAdjustmentVoucherDetail));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
        public ActionResult DeleteConfirmed(string id)
        {
            StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail = db.StockAdjustmentVoucherDetails.Find(id);

            db.StockAdjustmentVoucherDetails.Remove(stockAdjustmentVoucherDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "Id,DateCreated")] StockAdjustmentVoucher stockAdjustmentVoucher, FormCollection form, string sessionId)
        {
            if (Sessions.IsValidSession(sessionId))
            {
                ViewData["sessionId"] = sessionId;

                if (ModelState.IsValid)
                {
                    //A:
                    //5 is just the buffer given in the Get
                    int rows = db.Products.Count() + 5;

                    List <StockAdjustmentVoucherDetail> s0List = new List <StockAdjustmentVoucherDetail>();

                    for (int i = 0; i < rows; i++)
                    {
                        if (form["StockAdjustmentVoucherDetails[" + i + "].ItemCode"] != "")
                        {
                            string itemcode = form["StockAdjustmentVoucherDetails[" + i + "].ItemCode"];
                            //B:
                            if (s0List.Any(s => s.ItemCode.Contains(itemcode)))
                            {
                                StockAdjustmentVoucherDetail s0 = s0List.Find(s => s.ItemCode == itemcode);
                                s0.QuantityAdjusted = s0.QuantityAdjusted + double.Parse(form["StockAdjustmentVoucherDetails[" + i + "].QuantityAdjusted"]);
                            }
                            else
                            {
                                StockAdjustmentVoucherDetail s0 = new StockAdjustmentVoucherDetail();
                                s0.ItemCode         = itemcode;
                                s0.QuantityAdjusted = double.Parse(form["StockAdjustmentVoucherDetails[" + i + "].QuantityAdjusted"]);
                                s0.Reason           = form["StockAdjustmentVoucherDetails[" + i + "].Reason"];
                                s0.Status           = "Pending";
                                s0.Product          = db.Products.Find(s0.ItemCode);
                                s0List.Add(s0);
                            }
                        }
                    }

                    //C:
                    stockAdjustmentVoucher.StockAdjustmentVoucherDetails = s0List;
                    db.StockAdjustmentVouchers.Add(stockAdjustmentVoucher);
                    db.SaveChanges();
                    //D:
                    AllocateAuthorizer(stockAdjustmentVoucher);
                    return(RedirectToAction("Index", new { sessionId = sessionId }));
                }

                return(View(stockAdjustmentVoucher));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
 public ActionResult Edit([Bind(Include = "StockAdjustmentVoucherId,ItemCode,Reason,QuantityAdjusted,Status,ApproverRemarks,Balance,Approver")] StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockAdjustmentVoucherDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ItemCode = new SelectList(db.Products, "ItemCode", "Category", stockAdjustmentVoucherDetail.ItemCode);
     ViewBag.StockAdjustmentVoucherId = new SelectList(db.StockAdjustmentVouchers, "Id", "Id", stockAdjustmentVoucherDetail.StockAdjustmentVoucherId);
     return(View(stockAdjustmentVoucherDetail));
 }
コード例 #8
0
        public List <StockAdjustmentVoucherDetail> AddVoucherDetailToVoucherDetailList(List <StockAdjustmentVoucherDetail> sList, string itemcode, int quantityadjusted)
        {
            StockAdjustmentVoucherDetail s0 = new StockAdjustmentVoucherDetail();

            s0.Product          = db.Products.FirstOrDefault(p => p.ItemCode == itemcode);
            s0.ItemCode         = itemcode;
            s0.QuantityAdjusted = quantityadjusted;
            s0.Status           = "Pending";
            s0.Balance          = s0.Product.Balance + s0.QuantityAdjusted;
            sList.Add(s0);
            return(sList);
        }
        // GET: StockAdjustmentVoucherDetails/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail = db.StockAdjustmentVoucherDetails.Find(id);

            if (stockAdjustmentVoucherDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(stockAdjustmentVoucherDetail));
        }
        // GET: StockAdjustmentVoucherDetails/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail = db.StockAdjustmentVoucherDetails.Find(id);

            if (stockAdjustmentVoucherDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ItemCode = new SelectList(db.Products, "ItemCode", "Category", stockAdjustmentVoucherDetail.ItemCode);
            ViewBag.StockAdjustmentVoucherId = new SelectList(db.StockAdjustmentVouchers, "Id", "Id", stockAdjustmentVoucherDetail.StockAdjustmentVoucherId);
            return(View(stockAdjustmentVoucherDetail));
        }
コード例 #11
0
        public ActionResult AdjustDisbursement([Bind(Include = "Id,DateCreated")] StockAdjustmentVoucher stockAdjustmentVoucher, FormCollection form, string sessionId)
        {
            if (sessionId == null)
            {
                sessionId = Request["sessionId"];
            }
            int count = int.Parse(Request.Form["count"]);
            List <StockAdjustmentVoucherDetail> sList = new List <StockAdjustmentVoucherDetail>();

            for (int i = 0; i < count; i++)
            {
                string itemcode    = Request.Form["ItemCode[" + i + "]"];
                int    qtyadjusted = int.Parse(Request.Form["QuantityAdjusted[" + i + "]"]);
                string reason      = Request.Form["StockAdjustmentVoucherDetails[" + i + "].Reason"];

                if (sList.Any(a => a.ItemCode.Contains(itemcode)))
                {
                    StockAdjustmentVoucherDetail s0 = sList.Find(b => b.ItemCode == itemcode);
                    s0.QuantityAdjusted = s0.QuantityAdjusted + qtyadjusted;
                }
                else
                {
                    StockAdjustmentVoucherDetail s0 = new StockAdjustmentVoucherDetail();
                    s0.ItemCode         = itemcode;
                    s0.QuantityAdjusted = qtyadjusted;
                    s0.Reason           = "DISBURSEMENT: " + reason;
                    s0.Status           = "Pending";
                    s0.Product          = db.Products.FirstOrDefault(o => o.Description == itemcode);
                    sList.Add(s0);
                }
            }

            //C:
            stockAdjustmentVoucher.StockAdjustmentVoucherDetails = sList;
            db.StockAdjustmentVouchers.Add(stockAdjustmentVoucher);
            db.SaveChanges();
            //D:
            StockAdjustmentVoucher s = new StockAdjustmentVoucher();

            AllocateAuthorizer(stockAdjustmentVoucher);

            ViewData["count"] = count;
            return(RedirectToAction("Index", new { sessionId = sessionId }));
        }
コード例 #12
0
 public List <StockAdjustmentVoucherDetail> AddVoucherDetailToVoucherDetailList(List <StockAdjustmentVoucherDetail> sList, string itemcode, int quantityadjusted, string reason)
 {
     if (sList.Any(s => s.ItemCode.Contains(itemcode)))
     {
         StockAdjustmentVoucherDetail sd = sList.FirstOrDefault(s1 => s1.ItemCode == itemcode);
         sd.Reason = reason;
     }
     else
     {
         StockAdjustmentVoucherDetail s0 = new StockAdjustmentVoucherDetail();
         s0.Product          = db.Products.FirstOrDefault(p => p.ItemCode == itemcode);
         s0.ItemCode         = itemcode;
         s0.QuantityAdjusted = quantityadjusted;
         s0.Status           = "Pending";
         s0.Balance          = s0.Product.Balance + quantityadjusted;
         s0.Reason           = reason;
         sList.Add(s0);
     }
     return(sList);
 }
コード例 #13
0
ファイル: Service.svc.cs プロジェクト: cheesiang89/Team10AD
 /////////Voucher
 public string CreateVoucher(WCFVoucherDetail[] input)
 {
     try
     {
         List <StockAdjustmentVoucherDetail> detailList = new List <StockAdjustmentVoucherDetail>();
         foreach (WCFVoucherDetail WCFdetail in input)
         {
             StockAdjustmentVoucherDetail detail = new StockAdjustmentVoucherDetail();
             detail.ItemCode         = WCFdetail.ItemCode;
             detail.QuantityAdjusted = Convert.ToInt32(WCFdetail.QuantityAdjusted);
             detail.Reason           = WCFdetail.Reason;
             detailList.Add(detail);
         }
         Data.InsertVoucher(detailList, input[0].StoreStaffID);
         return("OK");
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
コード例 #14
0
        public static int GenerateAdjustmentVoucherDetails(List <RetrievalDetail> suggested, List <RetrievalDetail> userinput, int clerkid)
        {
            using (Team10ADModel context = new Team10ADModel())
            {
                //To be returned for redirecting to the correct adjustment detail
                int adjustmentVoucherId = 0;
                //Counter to check whether there is any item that need adjustment
                int needAdjustment = 0;

                //StockAdjustmentVoucher adjNew = new StockAdjustmentVoucher();
                List <StockAdjustmentVoucherDetail> adjDetailList = new List <StockAdjustmentVoucherDetail>();

                foreach (RetrievalDetail sDetail in suggested)
                {
                    foreach (RetrievalDetail uDetail in userinput)
                    {
                        if (sDetail.ItemCode == uDetail.ItemCode)
                        {
                            //Check that there is a change in suggested quantity and that the balance is below the requested quantity
                            //This is to give clerk the flexibility to still reduce the quantity and not trigger an adjustment
                            if (sDetail.RetrievedQuantity < sDetail.RequestedQuantity && sDetail.RetrievedQuantity != uDetail.RetrievedQuantity)
                            {
                                needAdjustment++;
                                if (needAdjustment == 1)
                                {
                                    StockAdjustmentVoucher adj = new StockAdjustmentVoucher();
                                    adj.StoreStaffID = clerkid;
                                    adj.DateIssue    = DateTime.Now;
                                    adj.Status       = "Pending";
                                    context.StockAdjustmentVouchers.Add(adj);
                                    context.SaveChanges();

                                    //adjNew = context.StockAdjustmentVouchers.OrderByDescending(x => x.VoucherID).First();
                                    //adjustmentVoucherId = adjNew.VoucherID;

                                    adjustmentVoucherId = adj.VoucherID;
                                }

                                StockAdjustmentVoucherDetail adjDetail = new StockAdjustmentVoucherDetail();
                                adjDetail.VoucherID        = adjustmentVoucherId;
                                adjDetail.ItemCode         = uDetail.ItemCode;
                                adjDetail.QuantityAdjusted = -(uDetail.Catalogue.BalanceQuantity - uDetail.RetrievedQuantity);

                                Catalogue item = context.Catalogues.Where(x => x.ItemCode == adjDetail.ItemCode).First();
                                item.BalanceQuantity -= (uDetail.Catalogue.BalanceQuantity - uDetail.RetrievedQuantity);

                                adjDetail.QuantityAfter = item.BalanceQuantity;
                                adjDetailList.Add(adjDetail);
                                context.SaveChanges();
                            }
                        }
                    }
                }

                if (needAdjustment > 0)
                {
                    foreach (StockAdjustmentVoucherDetail detail in adjDetailList)
                    {
                        context.StockAdjustmentVoucherDetails.Add(detail);
                        context.SaveChanges();
                    }
                }

                StoreStaff supervisor = context.StoreStaffs.Where(x => x.Title == "Supervisor").First();
                StoreStaff manager    = context.StoreStaffs.Where(x => x.Title == "Manager").First();
                if (adjustmentVoucherId > 0 && AdjustmentVoucherCost(adjustmentVoucherId) <= 250)
                {
                    LogicUtility.Instance.SendAdjustmentEmail(adjustmentVoucherId, supervisor.StoreStaffID);
                }
                else if (adjustmentVoucherId > 0 && AdjustmentVoucherCost(adjustmentVoucherId) > 250)
                {
                    LogicUtility.Instance.SendAdjustmentEmail(adjustmentVoucherId, manager.StoreStaffID);
                }

                return(adjustmentVoucherId);
            }
        }
コード例 #15
0
        public ActionResult DisplayDisbursement(FormCollection form, string sessionId)
        {
            sessionId = Request["sessionId"];

            if (Sessions.IsValidSession(sessionId))
            {
                ViewData["sessionId"] = sessionId;
                string RequisitionDetailsString = Request.Form["RequisitionDetailsString"];
                //create another submit button for the search department string
                if (Request.Form["SearchDept"] != null)
                {
                    string deptname = Request.Form["SearchDeptName"];

                    return(RedirectToAction("DisplayDisbursement", new { RequisitionDetailsString = "All", DeptString = deptname, sessionId = sessionId }));
                }
                if (Request.Form["SearchCP"] != null)
                {
                    string            CPId      = Request.Form["SearchCPId"];
                    List <Department> dListByCp = db.Departments.Where(d => d.CollectionLocationId == CPId).ToList();
                    string            deptname  = "";
                    foreach (Department d in dListByCp)
                    {
                        deptname = deptname + "," + d.DeptName;
                    }
                    return(RedirectToAction("DisplayDisbursement", new { RequisitionDetailsString = RequisitionDetailsString, DeptString = deptname, sessionId = sessionId }));
                }
                int                    count = int.Parse(Request.Form["count"]);
                string                 dept  = Request.Form["DeptString"];
                List <Department>      dList = splitDString(dept);
                StockAdjustmentVoucher s     = PrepareVoucher();

                List <StockAdjustmentVoucherDetail> sList = new List <StockAdjustmentVoucherDetail>();
                foreach (Department d in dList)
                {
                    Disbursement disbursement = new Disbursement();
                    disbursement = PrepareAndIncludeAllDisbursement(disbursement, d);
                    List <DisbursementDetail> ddList = new List <DisbursementDetail>();


                    for (int i = 0; i < count; i++)
                    {
                        string   itemcode  = Request.Form["Disbursement[" + i + "].itemcode"];
                        Products p         = db.Products.FirstOrDefault(o => o.ItemCode == itemcode);
                        int      quantity  = int.Parse(Request.Form["Disbursement[" + i + "].quantity"]);
                        int      collected = int.Parse(Request.Form["Disbursement[" + i + "].collected"]);

                        if (quantity != collected)
                        {
                            //if any of the voucher in sList itemcode == itemcode
                            if (sList.Any(sdv => sdv.ItemCode == itemcode))
                            {
                                StockAdjustmentVoucherDetail sd1 = sList.FirstOrDefault(sdv1 => sdv1.ItemCode == itemcode);
                                //sd1.QuantityAdjusted = sd1.QuantityAdjusted;
                            }
                            else
                            {
                                sList = AddVoucherDetailToVoucherDetailList(sList, itemcode, quantity - collected);
                            }
                        }
                        ddList = AddDisbursementDetailToDDList(ddList, itemcode, quantity, collected);
                    }
                    if (ddList.Count() != 0)
                    {
                        disbursement.Status = RequisitionDetailsString;
                        disbursement.DisbursementDetails = ddList;
                        db.Disbursements.Add(disbursement);
                        db.SaveChanges();
                    }
                    s.StockAdjustmentVoucherDetails = sList;
                }

                if (sList.Count() != 0)
                {
                    ViewData["s"]         = s;
                    ViewData["count"]     = sList.Count();
                    ViewData["sessionId"] = sessionId;
                    return(View("AdjustDisbursement", s));
                }
                else
                {
                    return(RedirectToAction("Index", "Disbursements", new { sessionId = sessionId }));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
コード例 #16
0
        // GET: StockAdjustmentVouchers/Create
        public ActionResult Create(string sessionId)
        {
            if (sessionId == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            StoreClerk      storeclerk      = db.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreManager    storeManager    = db.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreSupervisor storeSupervisor = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault();

            StockAdjustmentVoucher stockAdjustmentVoucher = new StockAdjustmentVoucher();

            stockAdjustmentVoucher.AdjustmentVoucherNumber = (db.StockAdjustmentVouchers.Count() + 1).ToString();
            stockAdjustmentVoucher.Status  = "Pending";
            stockAdjustmentVoucher.Date    = DateTime.Today;
            stockAdjustmentVoucher.Remarks = "Store clerk";

            ViewBag.voucher = stockAdjustmentVoucher;

            StockAdjustmentVoucherDetail savd = new StockAdjustmentVoucherDetail();

            savd.AdjustmentVoucherNumber = stockAdjustmentVoucher.AdjustmentVoucherNumber;
            savd.AdjustmentDetailsNumber = (db.StockAdjustmentVoucherDetails.Count() + 1);

            List <StockAdjustmentVoucherDetail> savdList = new List <StockAdjustmentVoucherDetail>();

            savdList.Add(savd);

            if (storeclerk != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeclerk.SessionId;
                ViewData["username"]  = storeclerk.UserName;
                ViewData["tag"]       = "storeclerk";
                return(View(savdList));
            }
            else if (storeManager != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeManager.SessionId;
                ViewData["username"]  = storeManager.UserName;
                ViewData["tag"]       = "storeManager";
                return(View(savdList));
            }
            else if (storeSupervisor != null)
            {
                int num             = db.RequisitionForms.Where(x => x.Status == "Approved").Count();
                int numDisbuserment = db.DisbursementLists.Where(x => x.Status == "Pending").Count();
                int numOutS         = db.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count();
                int numRetrive      = db.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count();
                int numPO           = db.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count();
                int numStock        = db.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count();
                ViewData["sumTotal"]  = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString();
                ViewData["sessionId"] = storeSupervisor.SessionId;
                ViewData["username"]  = storeSupervisor.UserName;
                ViewData["tag"]       = "storeSupervisor";
                return(View(savdList));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
コード例 #17
0
        public ActionResult Update(List <ViewModelDDetails> Details, string sessionId)
        {
            if (sessionId == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            StoreClerk       storeclerk       = db.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreManager     storeManager     = db.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault();
            StoreSupervisor  storeSupervisor  = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault();
            DisbursementList disbursementList = db.DisbursementLists.Find(Details[0].disbursementList.ListNumber);
            int  newNumer     = db.StockAdjustmentVouchers.Count();
            int  length       = Details.Count() + newNumer + 1;
            int  newNumer2    = db.StockAdjustmentVoucherDetails.Count() + 1;
            bool flag         = false;
            int  countnotshow = 0;
            int  recivedX;

            foreach (ViewModelDDetails item in Details)
            {
                DisbursementListDetail existing = db.DisbursementListDetails.Find(item.disbursementListDetail.ListDetailsNumber);
                if (item.disbursementListDetail.QuantityReceived < 0 || item.disbursementListDetail.QuantityReceived > existing.Quantity)
                {
                    string errorMeg = "Error: " + "QuantityReceived cannot be LESS THAN 0 or GREATER THAN Quantity";
                    return(RedirectToAction("Details", "DisbursementListDetails", new { @sessionId = sessionId, @id = Details[0].disbursementList.ListNumber, @errorMeg = errorMeg }));
                }
            }

            foreach (ViewModelDDetails item in Details)
            {
                DisbursementListDetail existing = db.DisbursementListDetails.Find(item.disbursementListDetail.ListDetailsNumber);
                existing.QuantityReceived = item.disbursementListDetail.QuantityReceived;
                existing.Remarks          = item.disbursementListDetail.Remarks;
                recivedX = Convert.ToInt32(existing.Quantity) - Convert.ToInt32(item.disbursementListDetail.QuantityReceived);
                if (recivedX > 0)
                {
                    flag = true;
                }
                if (Convert.ToInt32(item.disbursementListDetail.QuantityReceived) == 0)
                {
                    countnotshow++;
                }
                db.Entry(existing).State = EntityState.Modified;
                db.SaveChanges();
            }

            if (flag)
            {
                StockAdjustmentVoucher stockAdjustment = new StockAdjustmentVoucher();
                stockAdjustment.AdjustmentVoucherNumber = Convert.ToString(newNumer + 1);
                stockAdjustment.Status  = "Pending";
                stockAdjustment.Date    = DateTime.Now;
                stockAdjustment.Remarks = "System Generate";
                adb.StockAdjustmentVouchers.Add(stockAdjustment);
                adb.SaveChanges();
            }


            foreach (ViewModelDDetails item in Details)
            {
                DisbursementListDetail existing = db.DisbursementListDetails.Find(item.disbursementListDetail.ListDetailsNumber);
                existing.QuantityReceived = item.disbursementListDetail.QuantityReceived;
                existing.Remarks          = item.disbursementListDetail.Remarks;
                recivedX = Convert.ToInt32(existing.Quantity) - Convert.ToInt32(item.disbursementListDetail.QuantityReceived);
                if (recivedX > 0)
                {
                    StockAdjustmentVoucherDetail adjustmentVoucherDetail = new StockAdjustmentVoucherDetail();
                    adjustmentVoucherDetail.AdjustmentVoucherNumber = (newNumer + 1).ToString();
                    adjustmentVoucherDetail.AdjustmentDetailsNumber = newNumer2;
                    newNumer2++;
                    adjustmentVoucherDetail.QuantityAdjusted = recivedX;
                    adjustmentVoucherDetail.ItemNumber       = existing.ItemNumber;
                    // remarks from where?
                    adjustmentVoucherDetail.Reason = existing.Remarks;
                    db.StockAdjustmentVoucherDetails.Add(adjustmentVoucherDetail);
                    db.SaveChanges();
                }
            }

            if (countnotshow == Details.Count())
            {
                disbursementList.Status          = "Cancelled";
                db.Entry(disbursementList).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                disbursementList.Status          = "Collected";
                db.Entry(disbursementList).State = EntityState.Modified;
                db.SaveChanges();
            }

            if (storeclerk != null)
            {
                return(RedirectToAction("Index", "Home", new { @sessionId = sessionId, @tag = "storeclerk" }));
            }
            else if (storeManager != null)
            {
                return(RedirectToAction("Index", "StoreManagers", new { @sessionId = sessionId, @tag = "storeManager" }));
            }
            else if (storeSupervisor != null)
            {
                return(RedirectToAction("Index", "StoreSupervisors", new { @sessionId = sessionId, @tag = "storeSupervisor" }));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
コード例 #18
0
        public JsonResult PostDetails(Detail Details)
        {
            List <Infos>     bb = JsonConvert.DeserializeObject <List <Infos> >(Details.Infos1[0]);
            DisbursementList disbursementList = db.DisbursementLists.Find(bb[0].ListId);
            int  newNumer     = db.StockAdjustmentVouchers.Count();
            int  length       = bb.Count() + newNumer + 1;
            int  newNumer2    = db.StockAdjustmentVoucherDetails.Count() + 1;
            bool flag         = false;
            int  countnotshow = 0;
            int  recivedX;

            foreach (Infos item in bb)
            {
                DisbursementListDetail existing = db.DisbursementListDetails.Find(item.DetailId);
                existing.QuantityReceived = Convert.ToInt32(item.Actual);
                existing.Remarks          = item.Remark;
                recivedX = Convert.ToInt32(existing.Quantity) - Convert.ToInt32(item.Actual);
                if (recivedX > 0)
                {
                    flag = true;
                }
                if (Convert.ToInt32(item.Actual) == 0)
                {
                    countnotshow++;
                }
                db.Entry(existing).State = EntityState.Modified;
                db.SaveChanges();
            }

            if (flag)
            {
                StockAdjustmentVoucher stockAdjustment = new StockAdjustmentVoucher();
                stockAdjustment.AdjustmentVoucherNumber = Convert.ToString(newNumer + 1);
                stockAdjustment.Status  = "Pending";
                stockAdjustment.Date    = DateTime.Now;
                stockAdjustment.Remarks = "System Genarate";
                adb.StockAdjustmentVouchers.Add(stockAdjustment);
                adb.SaveChanges();
            }


            foreach (Infos item in bb)
            {
                DisbursementListDetail existing = db.DisbursementListDetails.Find(item.DetailId);
                existing.QuantityReceived = Convert.ToInt32(item.Actual);
                existing.Remarks          = item.Remark;
                recivedX = Convert.ToInt32(existing.Quantity) - Convert.ToInt32(item.Actual);
                if (recivedX > 0)
                {
                    StockAdjustmentVoucherDetail adjustmentVoucherDetail = new StockAdjustmentVoucherDetail();
                    adjustmentVoucherDetail.AdjustmentVoucherNumber = (newNumer + 1).ToString();
                    adjustmentVoucherDetail.AdjustmentDetailsNumber = newNumer2;
                    newNumer2++;
                    adjustmentVoucherDetail.QuantityAdjusted = recivedX;
                    adjustmentVoucherDetail.ItemNumber       = existing.ItemNumber;
                    // remarks from where?
                    adjustmentVoucherDetail.Reason = existing.Remarks;
                    db.StockAdjustmentVoucherDetails.Add(adjustmentVoucherDetail);
                    db.SaveChanges();
                }
            }

            if (countnotshow == bb.Count())
            {
                disbursementList.Status          = "Cancelled";
                db.Entry(disbursementList).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                disbursementList.Status          = "Collected";
                db.Entry(disbursementList).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new { status = "Submitted Successfully" }));
        }