public ActionResult GenerateDelOrder() { Dictionary <int, int> collist = new Dictionary <int, int>(); if (Session["collist"] != null) { collist = (Dictionary <int, int>)Session["collist"]; } else { Session["collist"] = new Dictionary <int, int>(); } List <ReqItem> lri = ReqItemData.GetAllReqItemApproved(); var itemIdset = new HashSet <int>(collist.Keys); var depIdset = new HashSet <int>(lri.Select(x => x.emp.department.Id).ToList()); List <ReqItem> slist = new List <ReqItem>(); List <ReqItem> xlist = new List <ReqItem>(); Dictionary <int, Dictionary <int, int> > list = new Dictionary <int, Dictionary <int, int> >(); foreach (int depId in depIdset) { slist = lri.Where(x => x.emp.department.Id == depId).ToList(); Dictionary <int, int> itemmap = new Dictionary <int, int>(); foreach (int itemId in itemIdset) { xlist = slist.Where(x => x.item.Id == itemId).ToList(); int quant = xlist.Select(x => x.Quant).Sum(); double price = StockCardData.GetLatestPriceByItem(ItemData.GetItemById(itemId)); if (quant != 0) { itemmap.Add(itemId, quant); } DepOrderData.CreateDepOrder(depId, itemId, quant, price); //Withdraw from stock Item item = ItemData.GetItemById(itemId); int balance = StockCardData.GetStockBalanceByItem(item); StockCardData.WithdrawFromStockRecord(item, DateTime.Today, DepartmentData.GetDepById(depId), quant, balance); int stockbalance = StockCardData.GetStockBalanceByItem(item); //if (stockbalance < item.ReorderLevel) Send Notification } list.Add(depId, itemmap); } ViewBag.Rlist = list; Session["plannedlist"] = list; return(View()); }
// GET: StoreClerk public ActionResult TobeCollectList() { ////////////////////////////////////////////////////////Dispatch features ///Retrieve all reqitems need to be deal with List <ReqItem> lri = ReqItemData.GetAllReqItemApproved(); List <ReqItem> slist = new List <ReqItem>(); List <ReqItem> xlist = new List <ReqItem>(); var itemIdset = new HashSet <int>(lri.Select(x => x.item.Id).ToList()); var depIdset = new HashSet <int>(lri.Select(x => x.emp.department.Id).ToList()); var empIdset = new HashSet <int>(lri.Select(x => x.emp.Id).ToList()); List <List <List <ReqItem> > > lll = new List <List <List <ReqItem> > >(); List <List <ReqItem> > ll = new List <List <ReqItem> >(); Dictionary <int, Dictionary <int, int> > list = new Dictionary <int, Dictionary <int, int> >(); foreach (int itemId in itemIdset) { slist = lri.Where(x => x.item.Id == itemId).ToList(); Dictionary <int, int> depmap = new Dictionary <int, int>(); foreach (int depId in depIdset) { xlist = slist.Where(x => x.emp.department.Id == depId && x.item.Id == itemId).ToList(); depmap.Add(depId, xlist.Select(x => x.Quant).Sum()); foreach (int empId in empIdset) {//ReqItemData.SetReqItemCollecting(empId, itemId); } } list.Add(itemId, depmap); } ViewBag.Rlist = list; return(View()); }