// GET: Inventories/Create public ActionResult Create() { List <SelectListItem> listItem = new List <SelectListItem> { new SelectListItem { Text = "Dozen", Value = "Dozen" }, new SelectListItem { Text = "Box", Value = "Box" }, new SelectListItem { Text = "Each", Value = "Each" }, new SelectListItem { Text = "Set", Value = "Set" }, new SelectListItem { Text = "Packet", Value = "Packet" } }; ViewBag.unitMeasure = new SelectList(listItem, "Value", "Text"); ViewBag.category = AdjustmentVoucherDAO.GetCategorySelectList(); ViewBag.supplierId1 = AdjustmentVoucherDAO.GetSupplierSelectList(); ViewBag.supplierId2 = AdjustmentVoucherDAO.GetSupplierSelectList(); ViewBag.supplierId3 = AdjustmentVoucherDAO.GetSupplierSelectList(); return(View()); }
public ActionResult Create(AdjustmentVoucherViewModel adjustmentVoucherViewModel) { if (ModelState.IsValidField("quantity") && adjustmentVoucherViewModel.quantity != 0 && adjustmentVoucherViewModel.remark != null) { if (Int32.TryParse(adjustmentVoucherViewModel.remark, out int result)) { MyReasonCode myCode = (MyReasonCode)result; // set the reasonable quantity if (myCode == MyReasonCode.InstoreDamaged || myCode == MyReasonCode.InstoreMissing) { adjustmentVoucherViewModel.quantity = -Math.Abs(adjustmentVoucherViewModel.quantity); } else if (myCode == MyReasonCode.FreeOfCharge) { adjustmentVoucherViewModel.quantity = Math.Abs(adjustmentVoucherViewModel.quantity); } // create the voucher AdjustmentVoucherDAO.CreateAdjustmentVoucher(adjustmentVoucherViewModel.itemNo, adjustmentVoucherViewModel.quantity, DateTime.Now.Date, myCode); return(RedirectToAction("ViewTotal")); } } return(RedirectToAction("Create")); }
public ActionResult VoucherItems(int id) { AdjustmentVoucherDAO adjustmentVoucherDAO = new AdjustmentVoucherDAO(); ViewData["VoucherItems"] = adjustmentVoucherDAO.GetVoucherItems(id); return(View()); }
public ActionResult AdjustmentVouchers() { AdjustmentVoucherDAO adjustmentVoucherDAO = new AdjustmentVoucherDAO(); ViewData["AdjustmentVouchers"] = adjustmentVoucherDAO.GetByStatusForManager("Pending"); return(View()); }
public MResponse GetAdjVoucherItems(int voucherId) { List <MAdjustmentItem> itemList = new AdjustmentVoucherDAO().GetAdjVoucherItems(voucherId); return(new MResponseList <MAdjustmentItem>() { ResList = itemList }); }
public MResponse GetAdjVoucherList(int clerkId) { List <AdjustmentVoucherVM> voucherList = new AdjustmentVoucherDAO().GetAdjVoucherByClerk(clerkId); return(new MResponseList <AdjustmentVoucherVM>() { ResList = voucherList }); }
public MResponse CreateAdjVoucher(int clerkId, List <MAdjustmentItem> items) { AdjustmentVoucherDAO dao = new AdjustmentVoucherDAO(); return(new MResponse() { Success = dao.CreateAdjVoucher(clerkId, items) }); }
// GET: AdjustmentVouchers/ViewDetail public ActionResult ViewDetail(string itemNo, int?year, int?month) { if (year == null || month == null) { return(View(new List <AdjustmentVoucherViewModel>())); } List <AdjustmentVoucherViewModel> list = AdjustmentVoucherDAO.FindDetailAdjustmentVoucher(itemNo, (int)year, (int)month); return(View(list)); }
public ActionResult DeleteConfirmed(string id) { InventoryViewModel inventoryViewModel = InventoryDAO.GetInventoryByItemNo(id); bool result = AdjustmentVoucherDAO.DeleteInventories(inventoryViewModel); if (!result) { return(View("~/Views/Shared/Error.cshtml")); } return(RedirectToAction("Index")); }
public ActionResult RejectAdjustmentVoucher(int id) { AdjustmentVoucherDAO adjustmentVoucherDAO = new AdjustmentVoucherDAO(); bool result = adjustmentVoucherDAO.ReviewAdjustmentVoucher(id, "Rejected", adjustmentVoucherDAO.GetVoucherItems(id)); if (result) { SetFlash(Enums.FlashMessageType.Success, "Successfully Rejected!"); return(RedirectToAction("AdjustmentVouchers")); } SetFlash(Enums.FlashMessageType.Error, "Something went wrong! Please try again later!"); return(RedirectToAction("AdjustmentVouchers")); }
// GET: Inventories public ActionResult Index(string category, string searchString) { ViewBag.category = AdjustmentVoucherDAO.GetCategorySelectList(); List <InventoryViewModel> inventories = AdjustmentVoucherDAO.GetInventoryViewModels(); if (!String.IsNullOrEmpty(searchString)) { inventories = inventories.Where(s => s.description.ToUpper().Contains(searchString.ToUpper())).ToList(); } if (!string.IsNullOrEmpty(category)) { inventories = inventories.Where(x => x.category == category).ToList(); } return(View(inventories.ToList())); }
public JsonResult AddAdjustmentVoucher(List <ItemAdjVoucher> itemData) { if (itemData == null) { return(Json("Your item list is empty!", JsonRequestBehavior.AllowGet)); } AdjustmentVoucherDAO adjustmentVoucherDAO = new AdjustmentVoucherDAO(); if (adjustmentVoucherDAO.Add(Convert.ToInt32(Session["userid"].ToString()), itemData)) { return(Json("Successfully Added", JsonRequestBehavior.AllowGet)); } else { return(Json("Something went wrong! Please try again later.", JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(InventoryViewModel inventoryViewModel) { if (!ModelState.IsValid) { List <SelectListItem> listItem = new List <SelectListItem> { new SelectListItem { Text = "Dozen", Value = "Dozen" }, new SelectListItem { Text = "Box", Value = "Box" }, new SelectListItem { Text = "Each", Value = "Each" }, new SelectListItem { Text = "Set", Value = "Set" }, new SelectListItem { Text = "Packet", Value = "Packet" } }; ViewBag.unitMeasure = new SelectList(listItem, "Value", "Text"); ViewBag.category = AdjustmentVoucherDAO.GetCategorySelectList(); ViewBag.supplierId1 = AdjustmentVoucherDAO.GetSupplierSelectList(); ViewBag.supplierId2 = AdjustmentVoucherDAO.GetSupplierSelectList(); ViewBag.supplierId3 = AdjustmentVoucherDAO.GetSupplierSelectList(); return(View(inventoryViewModel)); } bool result = AdjustmentVoucherDAO.CreateInventories(inventoryViewModel); if (!result) { return(View("~/Views/Shared/Error.cshtml")); } return(RedirectToAction("Index")); }
public ActionResult Edit(InventoryViewModel inventoryViewModel) { if (!ModelState.IsValidField(nameof(InventoryViewModel.itemNo)) || !ModelState.IsValidField(nameof(InventoryViewModel.category)) || !ModelState.IsValidField(nameof(InventoryViewModel.description)) || !ModelState.IsValidField(nameof(InventoryViewModel.unitMeasure)) || !ModelState.IsValidField(nameof(InventoryViewModel.reorderQuantity)) || !ModelState.IsValidField(nameof(InventoryViewModel.reorderLevel)) || !ModelState.IsValidField(nameof(InventoryViewModel.stdPrice)) || !ModelState.IsValidField(nameof(InventoryViewModel.balance)) ) { // drop down list List <String> listItem = new List <string>(); listItem.Add("Dozen"); listItem.Add("Box"); listItem.Add("Each"); listItem.Add("Set"); listItem.Add("Packet"); ViewBag.unitMeasure = new SelectList(listItem, inventoryViewModel.unitMeasure); // drop down list var categories = InventoryDAO.getAllCategoryId(); ViewBag.category = new SelectList(categories, inventoryViewModel.category); return(View(inventoryViewModel)); } // biz logic here... bool bRes = AdjustmentVoucherDAO.EditInventories(inventoryViewModel); if (bRes) { return(RedirectToAction("Index")); } else { return(View("~/Views/Shared/Error.cshtml")); } }
// GET: AdjustmentVouchers/ExportAdjustmentVoucher public ActionResult ExportAdjustmentVoucher(int month, int year) { DateTime date = new DateTime(year, month, 1); var adjustmentVoucher = AdjustmentVoucherDAO.GetAdjustmentVouchersByDate(date); var inventoriesList = AdjustmentVoucherDAO.GetListOfInventories(date); ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~"), "CrystalReport3.rpt")); rd.Database.Tables[0].SetDataSource(adjustmentVoucher); rd.Database.Tables[1].SetDataSource(inventoriesList); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application1/pdf", String.Format("AdjustmentVoucher({0}-{1}).pdf", month, year))); }
public int addAdjVoucher(WCFCart_Json cartList, string staffID) { AdjustmentVoucherDAO adjDAO = new AdjustmentVoucherDAO(); List <AdjustmentVoucherItemcart> adjItemCart = new List <AdjustmentVoucherItemcart>(); List <WCFAdjustmentVoucherCartItem> adjVItemList = cartList.CartList; foreach (WCFAdjustmentVoucherCartItem wcfCI in adjVItemList) { AdjustmentVoucherItemcart cartItem = new AdjustmentVoucherItemcart(); cartItem.ItemID = wcfCI.ItemID; cartItem.Qty = wcfCI.Qty; cartItem.Record = wcfCI.Record; adjItemCart.Add(cartItem); } try { adjDAO.addAdjustmentVoucher(staffID, adjItemCart); }catch (Exception e) { return(0); } return(1); }
public List <AdjustmentVoucherViewModel> FindGeneralAdjustmentVoucher(int year, int month) { var list = AdjustmentVoucherDAO.FindGeneralAdjustmentVoucher(year, month); return(list); }
public JsonResult FilterAdjustmentVouchers(string id) //Since we are using default route the parameter name must be id instead of status unless we wanna modify routes { AdjustmentVoucherDAO adjustment = new AdjustmentVoucherDAO(); return(Json(adjustment.GetByStatusForManager(id), JsonRequestBehavior.AllowGet)); }
public bool CreateAdjustmentVoucher([FromBody] AdjustmentVoucherViewModel model) { bool bRes = AdjustmentVoucherDAO.CreateAdjustmentVoucher(model.itemNo, model.quantity, DateTime.Now.Date, MyReasonCode.Else, model.remark); return(bRes); }
protected void Submit_Click(object sender, EventArgs e) { string name = this.staffID; SA45_Team09_LogicUEntities m = new DBEntities().getDBInstance(); List <AdjustmentVoucherItemcart> lac = new List <AdjustmentVoucherItemcart>(); lac = (List <AdjustmentVoucherItemcart>)Session["adjvcart"]; if (lac.Count > 0) { int num = 0; int judge = 0; foreach (Control i in cartRepeater.Items) //get Quantity { LinkButton deletebtn = i.FindControl("cart_deleteButton") as LinkButton; //get itemID TextBox cartqty = i.FindControl("cart_qtyTextBox") as TextBox; //get quantity TextBox cartrecord = i.FindControl("cart_recordTextBox") as TextBox; //get record lac[num].ItemID = deletebtn.CommandArgument.ToString(); if (cartqty.Text.Trim() == "") { judge = 1; break; } try { lac[num].Qty = Int32.Parse(cartqty.Text.ToString()); } catch { judge = 1; break; } if ((lac[num].Qty % 1 != 0) || (lac[num].Qty == 0)) { judge = 1; break; } if ((lac[num].Qty < 0) && (Math.Abs(lac[num].Qty) > itemDAO.getItemByitemID(lac[num].ItemID).First().qtyOnHand)) { judge = 2; break; } lac[num].Record = cartrecord.Text; num++; } if (judge == 0) { AdjustmentVoucherDAO adjvdao = new AdjustmentVoucherDAO(); adjvdao.addAdjustmentVoucher(name, lac); lac = new List <AdjustmentVoucherItemcart>();//clear the cart session Session["adjvcart"] = lac; //send email and notification to rep SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string clerkName = Session["loginName"].ToString(); StoreStaff supervisor = context.StoreStaffs.Where(x => x.role == "supervisor").ToList().First(); string supervisorID = supervisor.storeStaffID; string supervisorName = supervisor.storeStaffName; string confirmDate = DateTime.Now.ToShortDateString(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addStoreNotification(supervisorID, clerkName + " has send an adjustment voucher!" + confirmDate, DateTime.Now); Email email = new Email(); email.sendAdjustmentEmailToSupervisor(clerkName, supervisorName); HttpContext.Current.Response.Redirect("SC_ViewAdjustmentVoucher.aspx"); } else { if (judge == 1) { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be integer!');</script>"); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be lower than qty on hand!');</script>"); } } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage2", "alert('Nothing in cart')", true); return; } }
// GET: AdjustmentVouchers/ViewTotal public ActionResult ViewTotal(string month, string year) { DateTime year0 = DateTime.Today; DateTime year1 = DateTime.Today.AddYears(-1); DateTime year2 = DateTime.Today.AddYears(-2); List <SelectListItem> listItem1 = new List <SelectListItem> { new SelectListItem { Text = "WHOLE YEAR", Value = "WHOLE YEAR" }, new SelectListItem { Text = year0.Year.ToString(), Value = year0.Year.ToString() }, new SelectListItem { Text = year1.Year.ToString(), Value = year1.Year.ToString() }, new SelectListItem { Text = year2.Year.ToString(), Value = year2.Year.ToString() } }; List <SelectListItem> listItem2 = new List <SelectListItem> { new SelectListItem { Text = "WHOLE MONTH", Value = "WHOLE MONTH" }, new SelectListItem { Text = "January", Value = "1" }, new SelectListItem { Text = "February", Value = "2" }, new SelectListItem { Text = "March", Value = "3" }, new SelectListItem { Text = "April", Value = "4" }, new SelectListItem { Text = "May", Value = "5" }, new SelectListItem { Text = "June", Value = "6" }, new SelectListItem { Text = "July", Value = "7" }, new SelectListItem { Text = "August", Value = "8" }, new SelectListItem { Text = "September", Value = "9" }, new SelectListItem { Text = "October", Value = "10" }, new SelectListItem { Text = "November", Value = "11" }, new SelectListItem { Text = "December", Value = "12" } }; ViewBag.year = new SelectList(listItem1, "Value", "Text"); ViewBag.month = new SelectList(listItem2, "Value", "Text"); // convert the data here... int Year = -1, Month = -1; if (Int32.TryParse(year, out int tempYear)) { Year = tempYear; } if (Int32.TryParse(month, out int tempMonth)) { Month = tempMonth; } // whether show the result if (Year != -1 && Month != -1) { ViewBag.showReport = true; ViewBag.tempYear = Year; ViewBag.tempMonth = Month; } else { ViewBag.showReport = null; } List <AdjustmentVoucherViewModel> myList = AdjustmentVoucherDAO.FindGeneralAdjustmentVoucher(Year, Month); if (myList.Count == 0) { ViewBag.showReport = null; } return(View(myList)); }