public ActionResult DeleteConfirmed(string id, 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(); StationeryRetrievalForm stationeryRetrievalForm = db.StationeryRetrievalForms.Find(id); db.StationeryRetrievalForms.Remove(stationeryRetrievalForm); db.SaveChanges(); if (storeclerk != null) { return(RedirectToAction("Index", "StationeryRetrievalForms", new { sessionId = sessionId })); } else if (storeManager != null) { return(RedirectToAction("Index", "StationeryRetrievalForms", new { sessionId = sessionId })); } else if (storeSupervisor != null) { return(RedirectToAction("Index", "StationeryRetrievalForms", new { sessionId = sessionId })); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult Index(string sessionId, string tag) { StoreSupervisor storeSupervisor = db.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault(); if (storeSupervisor != null && sessionId != 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["num"] = num; ViewData["numDisbuserment"] = numDisbuserment; ViewData["numOutSt"] = numOutS; ViewData["numRetriF"] = numRetrive; ViewData["numPO"] = numPO; ViewData["numStockAj"] = numStock; ViewData["sumTotal"] = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString(); ViewData["sessionId"] = storeSupervisor.SessionId; ViewData["username"] = storeSupervisor.UserName; ViewData["tag"] = tag; return(View()); } else { return(RedirectToAction("LoginStoreSupervisor", "Login")); } }
public ActionResult StoreSupervisorLogin([Bind(Include = "UserName,Password")] StoreSupervisor storeSupervisor) { if (storeSupervisor.UserName != null && storeSupervisor.Password != null) { StoreSupervisor storeSupervisor1 = db1.StoreSupervisors.Where(p => p.UserName == storeSupervisor.UserName).FirstOrDefault(); string hashedPassword = CalculateMD5Hash(storeSupervisor.Password); if (ModelState.IsValid) { if (storeSupervisor1.Password == hashedPassword) { string sessionId = Guid.NewGuid().ToString(); storeSupervisor1.Password = hashedPassword; storeSupervisor1.SessionId = sessionId; db1.Entry(storeSupervisor1).State = EntityState.Modified; db1.SaveChanges(); return(RedirectToAction("Index", "StoreSupervisors", new { storeSupervisor1.SessionId, tag = "storeSupervisor" })); } else { return(RedirectToAction("LoginStoreSupervisor", "Login")); } } else { return(RedirectToAction("LoginStoreSupervisor", "Login")); } } return(RedirectToAction("LoginStoreSupervisor", "Login")); }
public ActionResult Logout(string sessionId) { StoreClerk storeclerk = db1.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreManager storeManager = db1.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreSupervisor storeSupervisor = db1.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault(); string newsessionId = Guid.NewGuid().ToString(); if (storeclerk != null && sessionId != null) { storeclerk.SessionId = newsessionId; db1.Entry(storeclerk).State = EntityState.Modified; db1.SaveChanges(); return(RedirectToAction("Login")); } else if (storeManager != null && sessionId != null) { storeManager.SessionId = newsessionId; db1.Entry(storeManager).State = EntityState.Modified; db1.SaveChanges(); return(RedirectToAction("LoginStoreManager", "Login")); } else { storeSupervisor.SessionId = newsessionId; db1.Entry(storeSupervisor).State = EntityState.Modified; db1.SaveChanges(); return(RedirectToAction("LoginStoreSupervisor", "Login")); } }
public ActionResult Edit([Bind(Include = "AdjustmentVoucherNumber,Status,Remarks,Date")] StockAdjustmentVoucher stockAdjustmentVoucher, 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(); if (storeclerk != null && ModelState.IsValid) { db.Entry(stockAdjustmentVoucher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else if (storeManager != null && ModelState.IsValid) { db.Entry(stockAdjustmentVoucher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else if (storeSupervisor != null && ModelState.IsValid) { db.Entry(stockAdjustmentVoucher).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else { return(RedirectToAction("Login", "Login")); } }
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 })); }
// GET: StationeryCatalogs/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(); ViewBag.SupplierCode1 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName"); ViewBag.SupplierCode2 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName"); ViewBag.SupplierCode3 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName"); 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()); } 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()); } 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()); } else { return(RedirectToAction("Login", "Login")); } }
// GET: RequisitionForms public ActionResult Index(string sessionId) { StoreClerk storeclerk = db2.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreManager storeManager = db2.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreSupervisor storeSupervisor = db2.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault(); if (storeclerk != null && sessionId != null) { ViewData["sessionId"] = storeclerk.SessionId; ViewData["username"] = storeclerk.UserName; ViewData["tag"] = "storeclerk"; int num = db2.RequisitionForms.Where(x => x.Status == "Approved").Count(); int numDisbuserment = db2.DisbursementLists.Where(x => x.Status == "Pending").Count(); int numOutS = db2.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count(); int numRetrive = db2.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count(); int numPO = db2.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count(); int numStock = db2.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count(); ViewData["sumTotal"] = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString(); List <RequisitionForm> rev = db1.RequisitionForms.Where(x => x.Status != "Rejected").Where(y => y.Status != "Pending").ToList(); return(View(rev)); } else if (storeManager != null && sessionId != null) { ViewData["sessionId"] = storeManager.SessionId; ViewData["username"] = storeManager.UserName; ViewData["tag"] = "storeManager"; int num = db2.RequisitionForms.Where(x => x.Status == "Approved").Count(); int numDisbuserment = db2.DisbursementLists.Where(x => x.Status == "Pending").Count(); int numOutS = db2.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count(); int numRetrive = db2.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count(); int numPO = db2.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count(); int numStock = db2.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count(); ViewData["sumTotal"] = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString(); List <RequisitionForm> rev = db1.RequisitionForms.ToList(); return(View(rev)); } else if (storeSupervisor != null && sessionId != null) { ViewData["sessionId"] = storeSupervisor.SessionId; ViewData["username"] = storeSupervisor.UserName; ViewData["tag"] = "storeSupervisor"; int num = db2.RequisitionForms.Where(x => x.Status == "Approved").Count(); int numDisbuserment = db2.DisbursementLists.Where(x => x.Status == "Pending").Count(); int numOutS = db2.OutstandingLists.Where(x => x.Status == "Awaiting Goods").Count(); int numRetrive = db2.StationeryRetrievalForms.Where(x => x.Status == "Pending").Count(); int numPO = db2.PurchaseOrders.Where(x => x.Status == "Not Submitted").Count(); int numStock = db2.StockAdjustmentVouchers.Where(x => x.Status == "Pending").Count(); ViewData["sumTotal"] = (num + numDisbuserment + numOutS + numRetrive + numPO + numStock).ToString(); List <RequisitionForm> rev = db1.RequisitionForms.ToList(); return(View(rev)); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult Create([Bind(Include = "ItemNumber,Category,Description,ReorderLevel,ReorderQuantity,UnitOfMeasure,BinNumber,Price,SupplierCode1,SupplierCode2,SupplierCode3,Balance")] StationeryCatalog stationeryCatalog, 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(); ViewBag.SupplierCode1 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName", stationeryCatalog.SupplierCode1); ViewBag.SupplierCode2 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName", stationeryCatalog.SupplierCode2); ViewBag.SupplierCode3 = new SelectList(db.SupplierLists, "SupplierCode", "SupplierName", stationeryCatalog.SupplierCode3); if (storeclerk != null) { if (ModelState.IsValid) { db.StationeryCatalogs.Add(stationeryCatalog); db.SaveChanges(); } return(RedirectToAction("Index", "StationeryCatalogs", new { sessionId = sessionId })); } else if (storeManager != null) { if (ModelState.IsValid) { db.StationeryCatalogs.Add(stationeryCatalog); db.SaveChanges(); } return(RedirectToAction("Index", "StationeryCatalogs", new { sessionId = sessionId })); } else if (storeSupervisor != null) { if (ModelState.IsValid) { db.StationeryCatalogs.Add(stationeryCatalog); db.SaveChanges(); } return(RedirectToAction("Index", "StationeryCatalogs", new { sessionId = sessionId })); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult DeleteConfirmed(string id, 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 = db.StockAdjustmentVouchers.Find(id); List <StockAdjustmentVoucherDetail> savd = db.StockAdjustmentVoucherDetails.ToList(); var toDelete = (from stockAdjustmentVoucherDetail in savd where stockAdjustmentVoucher.AdjustmentVoucherNumber == id select stockAdjustmentVoucherDetail).ToList(); foreach (StockAdjustmentVoucherDetail stockAdjustmentVoucherDetail in toDelete) { db.StockAdjustmentVoucherDetails.Remove(stockAdjustmentVoucherDetail); } db.StockAdjustmentVouchers.Remove(stockAdjustmentVoucher); db.SaveChanges(); if (storeclerk != null) { return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else if (storeManager != null) { return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else if (storeSupervisor != null) { return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } else { return(RedirectToAction("Login", "Login")); } }
// GET: StationeryCatalogReport public ActionResult Index(String searchString, 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(); 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"; } 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"; } 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"; } var item = from i in db.StationeryCatalogs select i; if (!String.IsNullOrEmpty(searchString)) { item = item.Where(i => i.Category.Contains(searchString)); return(View(item)); } else { return(View(item)); } //return View(db.StationeryCatalogs.ToList()); }
public ActionResult TrendSubmit(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(); string itemselected = Request["Items"].ToString(); string monthselected = Request["Months"].ToString(); var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:5000/itemmonth/"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = new JavaScriptSerializer().Serialize(new { item = itemselected, month = monthselected }); streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); String result = null; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { result = streamReader.ReadToEnd(); } //ViewBag.res = result; var JSONObj = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(result); String month1 = JSONObj["month1"]; String month2 = JSONObj["month2"]; String predict = JSONObj["predicted"]; int mon1 = Int32.Parse(month1); int mon2 = Int32.Parse(month2); int pred = Int32.Parse(predict); String mont1var = null; String mont2var = null; switch (Int32.Parse(Request["Months"])) { case 3: mont1var = "Jan"; mont2var = "Feb"; break; case 4: mont1var = "Feb"; mont2var = "March"; break; case 5: mont1var = "March"; mont2var = "April"; break; case 6: mont1var = "April"; mont2var = "May"; break; case 7: mont1var = "May"; mont2var = "June"; break; case 8: mont1var = "June"; mont2var = "July"; break; case 9: mont1var = "July"; mont2var = "August"; break; case 10: mont1var = "August"; mont2var = "September"; break; case 11: mont1var = "September"; mont2var = "October"; break; case 12: mont1var = "October"; mont2var = "November"; break; } decimal mont1 = mon1; decimal mont2 = mon2; decimal prd1 = pred; new Chart(width: 800, height: 200).AddSeries( chartType: "column", xValue: new[] { mont1var, mont2var, "predicted" }, yValues: new[] { mont1, mont2, prd1 }).Write("png"); 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"; ViewBag.res = Request["Months"]; return(View()); } 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"; ViewBag.res = Request["Months"]; return(View()); } 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"; ViewBag.res = Request["Months"]; return(View()); } else { return(RedirectToAction("Login", "Login")); } }
// GET: StationeryRetrievalForms/Delete/5 public ActionResult Delete(string id, string sessionId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StationeryRetrievalForm stationeryRetrievalForm = db.StationeryRetrievalForms.Find(id); if (stationeryRetrievalForm == null) { return(HttpNotFound()); } 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(); 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; return(View(stationeryRetrievalForm)); } 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; return(View(stationeryRetrievalForm)); } 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; return(View(stationeryRetrievalForm)); } else { return(RedirectToAction("Login", "Login")); } }
// GET: ReorderReport public ActionResult Index(string sortOrder, string searchString, 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(); 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"; } 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"; } 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"; } var item = from i in db.StationeryCatalogs join i1 in db.PurchaseOrderDetails on i.ItemNumber equals i1.ItemNumber join i2 in db.PurchaseOrders on i1.PONumber equals i2.PONumber where i.ItemNumber == i1.ItemNumber select new ReorderViewModel { ItemNumber = i.ItemNumber, Category = i.Category, Description = i.Description, Balance = (int)i.Balance, ReorderLevel = (int)i.ReorderLevel, ReorderQuantity = (int)i.ReorderQuantity, PONumber = i1.PONumber, SupplyByDate = (DateTime)i2.SupplyByDate }; if (!String.IsNullOrEmpty(searchString)) { item = item.Where(i => i.Category.Contains(searchString)); return(View(item)); } else { return(View(item)); } //Sample working code //var item = from i in db.StationeryCatalogs // select i; //if (!String.IsNullOrEmpty(searchString)) //{ // item = item.Where(i => i.Category.Contains(searchString)); // return View(item.ToList()); //} //else // return View(db.StationeryCatalogs.ToList()); }
// GET: StationeryRetrievalForms/Edit/5 public ActionResult Edit(string id, string sessionId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StationeryRetrievalForm stationeryRetrievalForm = db.StationeryRetrievalForms.Find(id); if (stationeryRetrievalForm == null) { return(HttpNotFound()); } 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(); List <StationeryRetrievalFormDetail> srfd = db.StationeryRetrievalFormDetails.ToList(); List <StationeryCatalog> sc = db.StationeryCatalogs.ToList(); var retrievalFormDetailsSelected = (from stationeryRetrievalFormDetail in srfd join stationeryCatalog in sc on stationeryRetrievalFormDetail.ItemNumber equals stationeryCatalog.ItemNumber into table1 from stationeryCatalog in table1 where stationeryRetrievalFormDetail.FormNumber == id select new RForm { stationeryRetrievalFormDetail = stationeryRetrievalFormDetail, Description = stationeryCatalog.Description, BinNumber = stationeryCatalog.BinNumber }).OrderBy(x => x.Description).ToList(); 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(retrievalFormDetailsSelected)); } 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(retrievalFormDetailsSelected)); } 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(retrievalFormDetailsSelected)); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult Edit(List <RForm> commitedRetrievalForm, 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(); if (ModelState.IsValid) { List <string> departmentList = new List <string>(); int outstandingListCount = db.OutstandingLists.Count(); //update retrieval form status to "Submitted" StationeryRetrievalForm existingStationeryRetrievalForm = db.StationeryRetrievalForms.Find(commitedRetrievalForm[0].stationeryRetrievalFormDetail.FormNumber); existingStationeryRetrievalForm.Status = "Submitted"; foreach (RForm commitedFormDetail in commitedRetrievalForm) { //Update actual values into retrieval form details StationeryRetrievalFormDetail existingStationeryRetrievalFormDetail = db.StationeryRetrievalFormDetails.Find(commitedFormDetail.stationeryRetrievalFormDetail.FormDetailsNumber); existingStationeryRetrievalFormDetail.Actual = commitedFormDetail.stationeryRetrievalFormDetail.Actual; //update stationery catalog StationeryCatalog existingCatalog = db.StationeryCatalogs.Find(commitedFormDetail.stationeryRetrievalFormDetail.ItemNumber); existingCatalog.Balance -= commitedFormDetail.stationeryRetrievalFormDetail.Actual; //add the department code to our department list created above, to generate disbursement list by department below if (!departmentList.Contains(commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode)) { departmentList.Add(commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode); } //If insufficient inventory, generate a outstanding list object for each retrieval form detail if (commitedFormDetail.stationeryRetrievalFormDetail.Needed > commitedFormDetail.stationeryRetrievalFormDetail.Actual) { outstandingListCount++; OutstandingList outstandingItem = new OutstandingList { OutstandingListNumber = outstandingListCount.ToString(), RetrievalFormDetailsNumber = commitedFormDetail.stationeryRetrievalFormDetail.FormDetailsNumber, Status = "Outstanding" }; db.OutstandingLists.Add(outstandingItem); } db.SaveChanges(); } //create a single disbursement list for each department foreach (string deptCode in departmentList) { DisbursementList dl = new DisbursementList { ListNumber = (db.DisbursementLists.Count() + 1).ToString(), DepartmentCode = deptCode, Date = DateTime.Today, Status = "Pending" }; db.DisbursementLists.Add(dl); db.SaveChanges(); DepartmentList dept = db.DepartmentLists.Where(x => x.DepartmentCode == deptCode).FirstOrDefault(); string Eid = dept.RepresentativeId; Employee repo = db.Employees.Find(Eid); string emailAddress = repo.EmailAddress; string pointId = dept.CollectionPoint; CollectionPoint point = db.CollectionPoints.Find(pointId); string subject = "Your items are ready for collection"; string message = "<p>Dear " + repo.UserName + "." + "</p><br/><p>Your items are ready for collection</p><br/><p>Collection point and time: " + point.CollectionPointName + "---" + point.CollectionTime + "</p><br/><p>Stationery Management Team</p>"; util.SendEmail(emailAddress, subject, message); int disbursementListDetailsCount = db.DisbursementListDetails.Count(); foreach (RForm commitedFormDetail in commitedRetrievalForm) { if (commitedFormDetail.stationeryRetrievalFormDetail.DepartmentCode.Equals(deptCode)) { disbursementListDetailsCount++; DisbursementListDetail dld = new DisbursementListDetail { ListDetailsNumber = disbursementListDetailsCount.ToString(), ListNumber = dl.ListNumber, ItemNumber = commitedFormDetail.stationeryRetrievalFormDetail.ItemNumber, Quantity = commitedFormDetail.stationeryRetrievalFormDetail.Actual }; db.DisbursementListDetails.Add(dld); db.SaveChanges(); } } } return(RedirectToAction("Index", "StationeryRetrievalForms", new { sessionId = sessionId })); } 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; return(View(commitedRetrievalForm)); } 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; return(View(commitedRetrievalForm)); } 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; return(View(commitedRetrievalForm)); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult Details(string id, string sessionId, string errorMeg) { 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(); List <DisbursementList> disbursementLists = db.DisbursementLists.ToList(); List <DisbursementListDetail> disbursementListDetails = db.DisbursementListDetails.ToList(); List <StationeryCatalog> stationeryCatalogs = db.StationeryCatalogs.ToList(); var disbursementDetailRecord = (from d in disbursementListDetails join l in disbursementLists on d.ListNumber equals l.ListNumber into table1 from l in table1.ToList() join s in stationeryCatalogs on d.ItemNumber equals s.ItemNumber into table2 from s in table2.ToList() select new ViewModelDDetails { disbursementList = l, disbursementListDetail = d, stationeryCatalog = s, }).Where(x => x.disbursementList.ListNumber == id).ToList(); if (disbursementDetailRecord.Count() == 0) { return(RedirectToAction("Index", "DisbursementLists", new { @sessionId = sessionId })); } DisbursementList disbursementList = db.DisbursementLists.Where(d => d.ListNumber == id).Single(); DepartmentList departmentList = db.DepartmentLists.Where(d => d.DepartmentCode == disbursementList.DepartmentCode).Single(); CollectionPoint collectionPoint = db.CollectionPoints.Where(c => c.CollectionPointCode == departmentList.CollectionPoint).Single(); Employee employee = db.Employees.Where(e => e.Id == departmentList.RepresentativeId).Single(); 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["collection"] = collectionPoint.CollectionPointName; ViewData["disbursementList"] = disbursementList.Date; ViewData["deparment"] = departmentList.DepartmentName; ViewData["employeeF"] = employee.FirstName; ViewData["employeeL"] = employee.LastName; ViewData["sessionId"] = storeclerk.SessionId; ViewData["username"] = storeclerk.UserName; ViewData["tag"] = "storeclerk"; ViewData["errorMeg"] = errorMeg; return(View(disbursementDetailRecord)); } 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["collection"] = collectionPoint.CollectionPointName; ViewData["disbursementList"] = disbursementList.Date; ViewData["deparment"] = departmentList.DepartmentName; ViewData["employeeF"] = employee.FirstName; ViewData["employeeL"] = employee.LastName; ViewData["sessionId"] = storeManager.SessionId; ViewData["username"] = storeManager.UserName; ViewData["tag"] = "storeManager"; ViewData["errorMeg"] = errorMeg; return(View(disbursementDetailRecord)); } 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["collection"] = collectionPoint.CollectionPointName; ViewData["disbursementList"] = disbursementList.Date; ViewData["deparment"] = departmentList.DepartmentName; ViewData["employeeF"] = employee.FirstName; ViewData["employeeL"] = employee.LastName; ViewData["sessionId"] = storeSupervisor.SessionId; ViewData["username"] = storeSupervisor.UserName; ViewData["tag"] = "storeSupervisor"; ViewData["errorMeg"] = errorMeg; return(View(disbursementDetailRecord)); } else { return(RedirectToAction("Login", "Login")); } }
// GET: StationeryRetrievalForms public ActionResult Index(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(); //GenerateRetrievalForm(); List <StationeryRetrievalForm> stationeryRetrievalForms = db.StationeryRetrievalForms.ToList(); var srfList = (from srf in stationeryRetrievalForms orderby srf.Date descending where srf.Status != "Merged" select srf).ToList(); 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(srfList)); } 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(db.StationeryRetrievalForms.ToList())); } 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(db.StationeryRetrievalForms.ToList())); } else { return(RedirectToAction("Login", "Login")); } }
// GET: StationeryCatalogs/Details/5 public ActionResult Details(string id, string sessionId) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } 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(); List <StockAdjustmentVoucher> stockAdjustmentVouchers = db.StockAdjustmentVouchers.ToList(); List <StockAdjustmentVoucherDetail> stockAdjustmentVoucherDetails = db.StockAdjustmentVoucherDetails.ToList(); var adjustJoinResult = (from savd in stockAdjustmentVoucherDetails join sav in stockAdjustmentVouchers on savd.AdjustmentVoucherNumber equals sav.AdjustmentVoucherNumber into table1 from sav in table1.ToList() select new RetrievalHistory { date = sav.Date, name = ("Stock Adjustment" + " " + sav.AdjustmentVoucherNumber), quantity = (int)savd.QuantityAdjusted, stockAdjustmentVoucherDetail = savd }).Where(x => x.stockAdjustmentVoucherDetail.ItemNumber == id && x.stockAdjustmentVoucherDetail.StockAdjustmentVoucher.Status == "Approved"); List <StationeryRetrievalFormDetail> stationeryRetrievalFormDetails = db.StationeryRetrievalFormDetails.ToList(); List <StationeryRetrievalForm> stationeryRetrievalForms = db.StationeryRetrievalForms.ToList(); List <DepartmentList> departmentLists = db.DepartmentLists.ToList(); var retrievalJoinResult = (from srf in stationeryRetrievalForms join srfd in stationeryRetrievalFormDetails on srf.FormNumber equals srfd.FormNumber into table1 from srfd in table1.ToList() join d in departmentLists on srfd.DepartmentCode equals d.DepartmentCode into table2 from d in table2.ToList() select new RetrievalHistory { date = srf.Date, name = d.DepartmentName, quantity = (int)srfd.Actual * -1, stationeryRetrievalFormDetail = srfd }).Where(x => x.stationeryRetrievalFormDetail.ItemNumber == id); List <PurchaseOrder> purchaseOrders = db.PurchaseOrders.ToList(); List <PurchaseOrderDetail> purchaseOrderDetails = db.PurchaseOrderDetails.ToList(); List <SupplierList> suppliers = db.SupplierLists.ToList(); var purchaseJoinResult = (from pod in purchaseOrderDetails join p in purchaseOrders on pod.PONumber equals p.PONumber into table1 from p in table1.ToList() join s in suppliers on p.SupplierCode equals s.SupplierCode into table2 from s in table2.ToList() select new RetrievalHistory { // result selector date = p.ReceivedDate, name = s.SupplierName, quantity = (int)pod.Quantity, purchaseOrderDetail = pod }).Where(x => x.purchaseOrderDetail.ItemNumber == id); var unionRetrievalPurchase = retrievalJoinResult.Concat(purchaseJoinResult); var unionRetrievalPurchaseAdjust = unionRetrievalPurchase.Concat(adjustJoinResult); var sortedResult = from u in unionRetrievalPurchaseAdjust orderby u.date select u; ViewBag.history = sortedResult; StationeryCatalog stationeryCatalog = db.StationeryCatalogs.Find(id); if (stationeryCatalog == null && sessionId != null) { return(HttpNotFound()); } //lxl-126-149 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(stationeryCatalog)); } 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(stationeryCatalog)); } 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(stationeryCatalog)); } else { return(RedirectToAction("Login", "Login")); } }
// 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")); } }
// GET: OutstandingLists public ActionResult Index(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(); List <OutstandingList> outstandingLists = db.OutstandingLists.ToList(); List <StationeryCatalog> catalogs = db.StationeryCatalogs.ToList(); List <StationeryRetrievalFormDetail> retrievalFormDetails = db.StationeryRetrievalFormDetails.ToList(); List <PurchaseOrder> purchaseOrders = db.PurchaseOrders.ToList(); var outstandingListRecord = (from o in outstandingLists join srfd in retrievalFormDetails on o.RetrievalFormDetailsNumber equals srfd.FormDetailsNumber into table1 from srfd in table1 join sc in catalogs on srfd.ItemNumber equals sc.ItemNumber into table2 from sc in table2 select new ViewModelOutstanding { ItemCode = srfd.ItemNumber, Description = sc.Description, ShortageQuantity = (int)(srfd.Needed - srfd.Actual), InventoryBalance = sc.Balance == null? 0:(int)sc.Balance, //to test Status = o.Status }).ToList(); 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(outstandingListRecord)); } 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(outstandingListRecord)); } 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(outstandingListRecord)); } else { return(RedirectToAction("Login", "Login")); } }
// GET: DisbursementLists public ActionResult Index(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(); List <DisbursementList> disbursementLists = db.DisbursementLists.ToList(); List <DepartmentList> departmentLists = db.DepartmentLists.ToList(); List <CollectionPoint> collectionPoints = db.CollectionPoints.ToList(); var disbursementRecord = from p in departmentLists join d in disbursementLists on p.DepartmentCode equals d.DepartmentCode into table1 from d in table1.ToList() join c in collectionPoints on p.CollectionPoint equals c.CollectionPointCode into table2 from c in table2.ToList() orderby d.Status descending select new ViewModelD { collectionPoint = c, disbursementList = d, departmentList = p }; 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(disbursementRecord)); } 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(disbursementRecord)); } 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(disbursementRecord)); } else { return(RedirectToAction("Login", "Login")); } }
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")); } }
// GET: RequisitionFormDetails/Details/5 public ActionResult Details(string id, string sessionId) { if (sessionId == null || id == null) { return(RedirectToAction("Login", "Login")); } StoreClerk storeclerk = db2.StoreClerks.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreManager storeManager = db2.StoreManagers.Where(p => p.SessionId == sessionId).FirstOrDefault(); StoreSupervisor storeSupervisor = db2.StoreSupervisors.Where(p => p.SessionId == sessionId).FirstOrDefault(); RequisitionForm request = db1.RequisitionForms.Where(p => p.FormNumber == id).FirstOrDefault(); List <RequisitionFormDetail> detail = db.RequisitionFormDetails.Where(x => x.FormNumber == id).ToList(); string eId = request.EmployeeId; Employee emp = db.Employees.Where(y => y.Id == eId).FirstOrDefault(); string emailAddress = emp.EmailAddress; string subject = "Your requisition has been received"; string message = "<p>Dear " + emp.UserName + "." + "</p><br/><p>Your requisition has been received and will be pending</p><br/><p>Stationery Management Team</p>"; if (storeclerk != null) { if (request.Status == "Approved" && request.Status != "Completed") { util.SendEmail(emailAddress, subject, message); request.DateReceived = DateTime.Now; request.ReceivedBy = storeclerk.Id; request.Status = "Read"; } db1.Entry(request).State = EntityState.Modified; db1.SaveChanges(); 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(detail)); } 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(detail)); } 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(detail)); } else { return(RedirectToAction("Login", "Login")); } }
public ActionResult Details(StockAdjustmentVoucher sav, string Command, 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(); if (ModelState.IsValid) { if (Command == "Reject") { sav.Status = "Rejected"; } else if (Command == "Approve") { sav.Status = "Approved"; } StockAdjustmentVoucher stockAdjustmentVoucher = db.StockAdjustmentVouchers.Find(sav.AdjustmentVoucherNumber); stockAdjustmentVoucher.Status = sav.Status; db.SaveChanges(); return(RedirectToAction("Index", "StockAdjustmentVouchers", new { sessionId = sessionId })); } 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(sav)); } 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(sav)); } 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(sav)); } else { return(RedirectToAction("Login", "Login")); } }