public RedirectToRouteResult EditNewAdjReason(string data, int index) { using (SSISdbEntities e = new SSISdbEntities()) { List <StockAdjItemModel> list = (List <StockAdjItemModel>)Session["newAdjList"]; StockAdjItemModel item = list.ElementAt(index); item.Reason = data; Session["newAdjList"] = list; Session["StockAdjPage"] = "2"; return(RedirectToAction("Requisition", "Dept")); } }
public RedirectToRouteResult AddNewAdjItem(StockAdjItemModel item) { using (SSISdbEntities e = new SSISdbEntities()) { string itemCode = Request.Form["SelectItemDesc"].ToString(); int qtyOnHand = e.Items.Where(x => x.ItemCode == itemCode).Select(x => x.Quantity).FirstOrDefault(); if (item.AdjQty > qtyOnHand) { TempData["ErrorMsg"] = "Quantity cannot be larger than quantity on hand! Please check value entered."; } else { string itemDesc = e.Items.Where(x => x.ItemCode == itemCode).Select(x => x.Description).FirstOrDefault(); float avgUnitCost = e.Items.Where(x => x.ItemCode == itemCode).Select(x => x.AvgUnitCost).FirstOrDefault(); string reason = Request.Form["SelectAdjReason"].ToString(); List <StockAdjItemModel> list = new List <StockAdjItemModel>(); list = (List <StockAdjItemModel>)Session["newAdjList"]; StockAdjItemModel sad = new StockAdjItemModel(); sad.ItemCode = itemCode; sad.ItemDesc = itemDesc; sad.AdjQty = item.AdjQty; sad.Reason = reason; sad.AdjCost = (avgUnitCost * item.AdjQty); sad.AvgUnitCost = avgUnitCost; list.Add(sad); Session["newAdjList"] = list; //add to list meant for already added items List <String> tempList = (List <String>)Session["tempList"]; tempList.Add(itemCode); Session["tempList"] = tempList; } Session["StockAdjPage"] = "2"; return(RedirectToAction("Inventory", "Store")); } }
public RedirectToRouteResult EditNewAdjQty(string data, int index) { try { using (SSISdbEntities e = new SSISdbEntities()) { //edit sad item on qty text change //data is item desc, index is list index List <StockAdjItemModel> list = (List <StockAdjItemModel>)Session["newAdjList"]; StockAdjItemModel item = list.ElementAt(index); int qtyOnHand = e.Items.Where(x => x.ItemCode == item.ItemCode).Select(x => x.Quantity).FirstOrDefault(); if (item.AdjQty > qtyOnHand) { TempData["ErrorMsg"] = "Quantity cannot be larger than quantity on hand! Please check value entered."; } else { item.AdjQty = Int32.Parse(data); item.AdjCost = Int32.Parse(data) * item.AvgUnitCost; Session["newAdjList"] = list; } Session["StockAdjPage"] = "2"; } } catch (FormatException fe) { Debug.WriteLine(fe.Message); } catch (Exception e) { Debug.WriteLine(e.Message); } return(RedirectToAction("Requisition", "Dept")); }