public ActionResult addnew(AdjustmentDetail form_detail_obj) { if (string.IsNullOrEmpty(form_detail_obj.ProductId)) { return(RedirectToAction("addcart")); } using (LogicEntities db = new LogicEntities()) { List <AdjustmentDetail> temp = db.AdjustmentDetail.ToList(); int form_details_num = (db.AdjustmentDetail.AsEnumerable().ToList().Count == 0) ? 1 : (db.AdjustmentDetail.AsEnumerable().Max(p => p.AdjustmentDetailId)) + 1; AdjustmentDetail old_rec_to_update = (from f in db.AdjustmentDetail where f.ProductId == form_detail_obj.ProductId && f.AdjustmentId == form_detail_obj.AdjustmentId select f).FirstOrDefault(); if (old_rec_to_update != null) { old_rec_to_update.Qty += form_detail_obj.Qty; } else { //Debug.WriteLine("____________" + form_details_num + "##" + form_detail_obj.AdjustmentId); db.AdjustmentDetail.Add(new AdjustmentDetail { AdjustmentDetailId = form_details_num, AdjustmentId = form_detail_obj.AdjustmentId, ProductId = form_detail_obj.ProductId, Qty = Convert.ToInt32(form_detail_obj.Qty), UnitPrice = form_detail_obj.UnitPrice, TotalPrice = form_detail_obj.TotalPrice, reason = form_detail_obj.reason }); } db.SaveChanges(); } return(RedirectToAction("addcart")); }
public ProxyResponse <InsertItemAdjustmentResult> InsertItemAdjustment(AdjustmentDetail detail) { OperationMethod = HttpMethod.Post; var uri = base.GetRequestUri(null); return(base.GetResponse <AdjustmentDetail, InsertItemAdjustmentResult>(uri, detail)); }
public static void SeedEntities(ADProjectDb context) { StockInfo stockInfo = new StockInfo(); stockInfo.ItemCatalogue = context.ItemCatalogue.FirstOrDefault(); AdjustmentStatus adjustmentStatus = new AdjustmentStatus(); adjustmentStatus.Description = "APPROVED"; AdjustmentDetail adjustmentDetail = new AdjustmentDetail(); adjustmentDetail.ItemCatalogue = context.ItemCatalogue.FirstOrDefault(); AdjustmentVoucher adjustmentVoucher = new AdjustmentVoucher(); adjustmentVoucher.AdjustmentStatus = adjustmentStatus; adjustmentVoucher.AdjustmentDetail = new List <AdjustmentDetail>() { adjustmentDetail }; context.StockInfo.Add(stockInfo); context.AdjustmentStatus.Add(adjustmentStatus); context.AdjustmentDetail.Add(adjustmentDetail); context.AdjustmentVoucher.Add(adjustmentVoucher); context.SaveChanges(); }
//add adjustment, single entry, to an voucher public ActionResult SubmitAdjustmentEntry(int adjusQty, string VoucherReason, string SelectedVoucher, int ItemId) { // create new voucher detail object AdjustmentDetail adjustmentDetail = new AdjustmentDetail() { ItemCatalogueId = ItemId, Reason = VoucherReason, Quantity = adjusQty }; //Update adjustmentVoucher with new dsetail int VoucherId = Int32.Parse(SelectedVoucher); using (var db = new ADProjectDb()) { //Check if entry existed bool IsExisted = inventoryService.CheckifAdjExist(db, ItemId, VoucherId); if (IsExisted == true) { inventoryService.UpdateAdjDetails(db, ItemId, VoucherId, adjusQty, VoucherReason); } else { inventoryService.AddtoAdjustmentVoucher(db, VoucherId, adjustmentDetail); } } // redirect back to inventory list return(RedirectToAction("showLowStock", "Inventory")); }
public ProxyResponse <UpdateItemAdjustmentResult> UpdateItemAdjustment(AdjustmentDetail detail, int id) { OperationMethod = HttpMethod.Put; var uri = base.GetRequestUri(id.ToString()); return(base.GetResponse <AdjustmentDetail, UpdateItemAdjustmentResult>(uri, detail)); }
public void AddtoAdjustmentVoucher(ADProjectDb db, int voucherId, AdjustmentDetail AD) { // Update cost of adjustmentDetail double price = (from IC in db.ItemCatalogue join SC in db.SupplierCatalogue on IC.ItemCatalogueId equals SC.ItemId where SC.SupplierRank == 1 where IC.ItemCatalogueId == AD.ItemCatalogueId select SC.ItemPrice).FirstOrDefault(); AD.Cost = AD.Quantity * price; //Add to AdjustmentDetail Database db.AdjustmentDetail.Add(AD); AdjustmentVoucher adjustmentVoucher = db.AdjustmentVoucher.Where(x => x.AdjustmentVoucherId == voucherId).FirstOrDefault(); if (adjustmentVoucher != null) { if (adjustmentVoucher.AdjustmentDetail == null) { adjustmentVoucher.AdjustmentDetail = new List <AdjustmentDetail>(); } adjustmentVoucher.AdjustmentDetail.Add(AD); } db.SaveChanges(); }
public string CreateAdjustmentVoucher(AdjustmentVoucherViewModel avvm) { //ItemInventoryLocation - 1 - StockQty, 2 - DisburseQty, 3 - AdjustQty (not used) decimal totalAdjAmt = 0M; //Initiate Adjustment entry Adjustment adjustment = new Adjustment(); adjustment.voucherId = avvm.voucherID; adjustment.clerk = new string(avvm.clerkIDName.Where(Char.IsDigit).ToArray()); adjustment.supervisor = new string(avvm.supervisorIDName.Where(Char.IsDigit).ToArray()); adjustment.date = avvm.voucherDate; adjustment.status = "Submitted"; foreach (AdjustmentVoucherViewModelDetail avvmd in avvm.itemList) { AdjustmentDetail adjustmentDetail = new AdjustmentDetail(); Inventory inventory = db.Inventories.Find(avvmd.itemID); //edit Adj detail adjustmentDetail.itemId = avvmd.itemID; adjustmentDetail.quantity = avvmd.itemQty; adjustmentDetail.voucherId = avvm.voucherID; if (avvmd.itemInventoryLocation == 1) { //Adj inventory inventory.storeQuantity = avvmd.itemQty < 0 ? inventory.storeQuantity - Math.Abs(avvmd.itemQty) : inventory.storeQuantity + avvmd.itemQty; inventory.adjQuantity -= avvmd.itemQty; avvmd.remark += (" Adjusted Item code : " + avvmd.itemID + " Qty : " + avvmd.itemQty + " from StoreQty"); } else if (avvmd.itemInventoryLocation == 2) { inventory.disburseQuantity += avvmd.itemQty < 0 ? inventory.disburseQuantity - Math.Abs(avvmd.itemQty) : inventory.disburseQuantity + avvmd.itemQty; inventory.adjQuantity -= avvmd.itemQty; avvmd.remark += (" Adjusted Item code : " + avvmd.itemID + " Qty : " + avvmd.itemQty + " from DisburseQty"); } string supplier = db.Catalogues.Find(avvmd.itemID).firstSupplier; decimal itemPrice = db.SupplierQuotations.Where(x => x.itemId == avvmd.itemID && x.supplierId == supplier).First().price; totalAdjAmt += (itemPrice * avvmd.itemQty); adjustmentDetail.remark = avvmd.remark; db.AdjustmentDetails.Add(adjustmentDetail); } avvm.needAuthority = totalAdjAmt > 250M ? true : false; avvm.status = "Submitted"; //Set need authority (Logic - if need manager approval, set manager id - else null) adjustment.needAuthority = avvm.needAuthority == true ? new string(avvm.managerIDName.Where(Char.IsDigit).ToArray()) : null; adjustment.adjustmentValue = totalAdjAmt; db.Adjustments.Add(adjustment); db.SaveChanges(); EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string receipient = avvm.needAuthority == true ? adjustment.needAuthority : adjustment.supervisor; string sender = adjustment.clerk; string linkref = "http://" + ConstantsConfig.linkrefURLPartial + "/Adjustment/AdjustmentDetail?adjustmentID=" + avvm.voucherID; emailBizLogic.SendEmail("submitAdj", receipient, sender, null, null, linkref); return(adjustment.voucherId); }
public DisbursementViewModel CreateDisbursementAdjustmentVoucher(DisbursementViewModel model, HttpSessionStateBase session) { Adjustment adjustment = new Adjustment(); DateTime date = DateTime.Now; adjustment.date = date.Date; string timestamp = date.ToString("yyyyMMddhhmmss"); adjustment.clerk = session["EmployeeID"].ToString(); adjustment.status = "Submitted"; adjustment.supervisor = session["HeadID"].ToString(); adjustment.voucherId = "ADJ" + adjustment.clerk + timestamp; string disburseID = model.disbursementID; decimal totalvalue = 0; Dictionary <string, string> storeEmpList = GetStoreEmployeeList(session["Username"].ToString(), session["Password"].ToString()); string managerIDName = storeEmpList["manager"]; foreach (DisbursementViewModelDetail dvmd in model.dvmdList) { if (dvmd.adjQty == 0 || dvmd.adjQty == null) { continue; } AdjustmentDetail adjDetail = new AdjustmentDetail(); adjDetail.itemId = dvmd.itemID; adjDetail.quantity = (int)dvmd.adjQty; adjDetail.remark = "Disbursement (" + disburseID + ") Adjustment"; adjDetail.voucherId = adjustment.voucherId; string supplier = db.Catalogues.Find(dvmd.itemID).firstSupplier; decimal itemPrice = db.SupplierQuotations.Where(x => x.itemId == dvmd.itemID && x.supplierId == supplier).First().price; totalvalue += (itemPrice * adjDetail.quantity); db.AdjustmentDetails.Add(adjDetail); } //Set need authority (Logic - if need manager approval, set manager id - else null) bool needAuthority = totalvalue > 250M ? true : false;; adjustment.needAuthority = needAuthority == true ? new string(managerIDName.Where(Char.IsDigit).ToArray()) : null; adjustment.adjustmentValue = totalvalue; db.Adjustments.Add(adjustment); Disbursement disbursement = db.Disbursements.Find(disburseID); disbursement.adjustmentID = adjustment.voucherId; db.SaveChanges(); model.status = "Adjustment Performed"; model.adjustmentID = adjustment.voucherId; EmailBusinessLogic emailBizLogic = new EmailBusinessLogic(); string receipient = needAuthority ? adjustment.needAuthority : adjustment.supervisor; string sender = adjustment.clerk; string linkref = "http://" + ConstantsConfig.linkrefURLPartial + "/Adjustment/AdjustmentDetail?adjustmentID=" + adjustment.voucherId; emailBizLogic.SendEmail("submitAdj", receipient, sender, null, null, linkref); return(model); }
public ActionResult AddDetail() //click 'Add new item button' to add new adjustment details { Adjustment currentAdjustment = (Adjustment)Session["adjustment"]; Session["adjustment"] = new Adjustment(); var adjustdetail = new AdjustmentDetail(); ViewBag.ItemNo = new SelectList(invSvc.GetAllInventory(), "ItemNo", "Description"); currentAdjustment.AdjustmentDetails.Add(adjustdetail); return(View(currentAdjustment)); }
public ActionResult Disbursements(List <RetrievalItem> items) { List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); bool valid = true; foreach (var i in items) { if (i.AllocatedQuantity > i.ActualQuantity) { AdjustmentDetail detail = new AdjustmentDetail() { Count = (i.StockQuantity - i.ActualQuantity), Item = new Item() { ItemId = i.ItemId } }; adjustmentDetails.Add(detail); } else if (i.AllocatedQuantity == i.ActualQuantity) { } else { valid = false; break; } } if (valid != false) { if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); ItemDao.UpdateStockForAdjustment(adjustmentDetails); } DisbursementDao.GenerateDisbursements(items); Task.Run(() => EmailUtility.SendEmailForItemsPickUp()); return(RedirectToAction("Retrieval", "Stationery")); } else { return(RedirectToAction("Retrieval", "Stationery")); } }
public List <DisbursementViewModel> GenerateDisbursementViewModels(string retrievalID, HttpSessionStateBase session) { List <DisbursementViewModel> disburseVMList = new List <DisbursementViewModel>(); List <Requisition> requisitions = db.Requisitions.Where(x => x.retrievalId == retrievalID).ToList(); Dictionary <string, string> empList = (Dictionary <string, string>)session["EmployeeList"]; foreach (Requisition req in requisitions) { DisbursementViewModel dvm = new DisbursementViewModel(); dvm.dvmdList = new List <DisbursementViewModelDetail>(); //Initialise dvm if not created if (!disburseVMList.Where(x => x.disbursementID == req.disbursementId).Any()) { dvm.disbursementID = req.disbursementId; dvm.requestorDeptID = req.departmentId; dvm.status = db.Disbursements.Where(x => x.disbursementId == req.disbursementId).First().status; dvm.repName = db.DeptCollectionDetails.Where(x => x.departmentId == req.departmentId).First().representative; dvm.collectionPoint = db.DeptCollectionDetails.Where(x => x.departmentId == req.departmentId).First().collectionPoint; dvm.collectionTime = db.CollectionPoints.Where(x => x.locationName == dvm.collectionPoint).First().collectTime; dvm.disburseDate = db.Disbursements.Where(x => x.disbursementId == req.disbursementId).First().disburseDate; dvm.adjustmentID = db.Disbursements.Where(x => x.disbursementId == req.disbursementId).First().adjustmentID; disburseVMList.Add(dvm); } else { dvm = disburseVMList.Find(x => x.disbursementID == req.disbursementId); } //pack reqdet into dvmd foreach (RequisitionDetail reqdet in req.RequisitionDetails) { DisbursementViewModelDetail dvmd = new DisbursementViewModelDetail(); dvmd.requestorID = req.employee; dvmd.requestorName = empList[req.employee].ToString(); dvmd.requisitionID = req.requisitionId; dvmd.itemID = reqdet.itemId; dvmd.itemDescription = db.Catalogues.Find(reqdet.itemId).description; dvmd.retrievalID = req.retrievalId; dvmd.requestQty = reqdet.requestQty; dvmd.retrieveQty = reqdet.retrieveQty; AdjustmentDetail adjustmentDetail = db.AdjustmentDetails.Where(w => w.voucherId == dvm.adjustmentID && w.itemId == dvmd.itemID).FirstOrDefault(); if (adjustmentDetail != null) { dvmd.adjQty = adjustmentDetail.quantity; } dvm.dvmdList.Add(dvmd); } } return(disburseVMList); }
protected void submitBtn_Click(object sender, EventArgs e) { Staff stf = (Staff)Session["LoginStaff"]; string voucherId = getvoucherId(); Adjustment adj = new Adjustment(); adj.Voucher_ID = "V0" + voucherId; //adj.Issue_Date = DateTime.Today; adj.Issue_Date = DateTime.Now; adj.Approved_Date = null; adj.IssuedByStaff_ID = stf.Staff_ID; adj.ApprovedByStaff_ID = null; adj.Status = "Pending"; adj.Remark = remarkTxt.Value; adjVoucher.setAdjustment(adj); List <AdjustmentDetail> adjList = new List <AdjustmentDetail>(); if (AdjVouGridview.Rows.Count > 0) { for (int i = 0; i < AdjVouGridview.Rows.Count; i++) { DropDownList itemCodeList = (DropDownList)AdjVouGridview.Rows[i].Cells[1].FindControl("DropDownListItemCode"); string itemCode = itemCodeList.SelectedItem.Text; TextBox quantity = (TextBox)AdjVouGridview.Rows[i].Cells[4].FindControl("qtyTxt"); int adjQty = Convert.ToInt32(quantity.Text); AdjustmentDetail adjDetail = new AdjustmentDetail(); adjDetail.Voucher_ID = adj.Voucher_ID; adjDetail.Item_ID = itemCode; adjDetail.Adj_Qty = adjQty; adjList.Add(adjDetail); //adjVoucher.setAdjustmentDetail(adjDetail); } adjList = adjList.GroupBy(x => new { x.Item_ID, x.Voucher_ID }) .Select(y => new AdjustmentDetail { Voucher_ID = y.Key.Voucher_ID, Item_ID = y.Key.Item_ID, Adj_Qty = y.Sum(t => t.Adj_Qty) }) .ToList(); foreach (AdjustmentDetail ad in adjList) { adjVoucher.setAdjustmentDetail(ad); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Adjustment has been Done!')</script>"); SetInitialRow(); submitBtn.Enabled = true; NewBtn.Enabled = true; remarkTxt.Value = string.Empty; }
public void createAdjustmentVoucherDetails(string adNum, string vID, string itemNum, string qty, string supp, string reason) { SA43Team2StoreDBEntities ctx = new SA43Team2StoreDBEntities(); AdjustmentDetail ad = new AdjustmentDetail(); ad.AdjustmentDetailsID = adNum; ad.VoucherID = vID; ad.ItemNumber = itemNum; ad.QuantityAdjustment = Convert.ToInt32(qty); ad.SupplierID = supp; ad.Reason = reason; ctx.AdjustmentDetails.Add(ad); ctx.SaveChanges(); }
public Boolean CheckifAdjExist(ADProjectDb db, int itemId, int voucherid) { AdjustmentDetail Ad = db.AdjustmentDetail.Where(x => x.AdjustmentVoucherId == voucherid) .Where(x => x.ItemCatalogueId == itemId) .FirstOrDefault(); if (Ad == null) { return(false); } else { return(true); } }
public ActionResult Create() //create new adjustment { Employee currentEmployee = (Employee)Session["User"]; var adjust = new Adjustment { AdjustmentDate = DateTime.Today, EmployeeId = currentEmployee.EmployeeId, Status = Convert.ToString("Pending Approval") }; var adjustdetail = new AdjustmentDetail(); ViewBag.ItemNo = new SelectList(invSvc.GetAllInventory(), "ItemNo", "Description"); adjust.AdjustmentDetails.Add(adjustdetail); return(View(adjust)); }
public void UpdateAdjDetails(ADProjectDb db, int itemId, int voucherid, int AdjQty, string VoucherReason) { AdjustmentDetail Ad = db.AdjustmentDetail.Where(x => x.AdjustmentVoucherId == voucherid) .Where(x => x.ItemCatalogueId == itemId) .FirstOrDefault(); Ad.Quantity = Ad.Quantity + AdjQty; double price = (from IC in db.ItemCatalogue join SC in db.SupplierCatalogue on IC.ItemCatalogueId equals SC.ItemId where SC.SupplierRank == 1 where IC.ItemCatalogueId == itemId select SC.ItemPrice).FirstOrDefault(); Ad.Cost = Ad.Quantity * price; Ad.Reason = VoucherReason; db.SaveChanges(); }
public ActionResult ReceiveItemsByDepartment(List <DisbursementDetail> details, int id) { Dictionary <int, DisbursementDetail> dDict = DisbursementDao.GetDisbursementDetailDictByDisbursementId(id); //generate adjustment if items are missing List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); foreach (var d in details) { DisbursementDetail disDetail = dDict[d.DisbursementDetailId]; if (disDetail.Quantity != d.Quantity && d.Quantity < disDetail.Quantity) { AdjustmentDetail adDetail = new AdjustmentDetail() { Item = new Item() { ItemId = d.Item.ItemId }, Count = disDetail.Quantity - d.Quantity }; adjustmentDetails.Add(adDetail); } } if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); } Disbursement dis = DisbursementDao.DeliverDisbursement(id, details); //need to update the request such as status, delivered Qty RequestDao.UpdateRequestById(dis.Request.RequestId); return(RedirectToAction("Deliveries")); }
protected void btnSubmit_Click(object sender, EventArgs e) { bool toMgr = false; Adjustment adj = new Adjustment(); List <AdjustmentDetail> adjDetails = new List <AdjustmentDetail>(); adj.VoucherId = lblVoucher.Text; adj.IssueDate = Convert.ToDateTime(DateTime.Now.ToShortDateString()); adj.Status = StatusType.Pending.ToString(); foreach (GridViewRow row in gvAdjustNew.Rows) { AdjustmentDetail detail = new AdjustmentDetail(); detail.VoucherId = lblVoucher.Text; detail.ItemId = row.Cells[0].Text; detail.Quantity_Adjusted = Double.Parse(row.Cells[1].Text); detail.Reason = row.Cells[4].Text; adjDetails.Add(detail); } controller.SaveDataToAdjustmentAndAdjustmentDetail(adj, adjDetails); foreach (GridViewRow row in gvAdjustNew.Rows) { String data = row.Cells[3].Text; double absData = Math.Abs(double.Parse(data)); if (absData > 250) { toMgr = true; } if (toMgr == true) { SentMailToManager(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Submit successfully');", true); ClearGridView(); } else { SendMailToSupervisor(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Submit successfully');", true); ClearGridView(); } } }
public ActionResult Adjustments(List <Item> items) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; List <AdjustmentDetail> details = new List <AdjustmentDetail>(); foreach (var i in items) { if (i.Quantity > 0) { AdjustmentDetail adjDetail = new AdjustmentDetail() { Item = new Item() { ItemId = i.ItemId }, Count = i.Quantity }; details.Add(adjDetail); } } if (details.Count > 0) { foreach (var d in details) { Debug.WriteLine("Item Id {0} Amount is {1} Requestor is {2}", d.Item.ItemId, d.Count, u.UserId); } Adjustment ad = AdjustmentDao.InsertAdjustment(details, u); AdjustmentDao.CalculateAdjustmentCost(ad); ItemDao.UpdateStockForAdjustment(details); } return(new HttpStatusCodeResult(200)); }
// [System.Web.Http.AcceptVerbs("PUT")] // [System.Web.Http.Route("api/inventory/put")] // [System.Web.Http.HttpPut] public IHttpActionResult PutAdjustmentVoucherUpdate(int adjusQty, string VoucherReason, int VoucherId, int ItemId) { // create new voucher detail object AdjustmentDetail adjustmentDetail = new AdjustmentDetail() { ItemCatalogueId = ItemId, Reason = VoucherReason, Quantity = adjusQty }; //Update adjustmentVoucher with new dsetail using (var db = new ADProjectDb()) { //Check if entry existed bool IsExisted = inventoryService.CheckifAdjExist(db, ItemId, VoucherId); if (IsExisted == true) { inventoryService.UpdateAdjDetails(db, ItemId, VoucherId, adjusQty, VoucherReason); } else { inventoryService.AddtoAdjustmentVoucher(db, VoucherId, adjustmentDetail); } } return(Ok()); }
public ActionResult CreateVoucher(string itemdes, string quantity, string reason, string cost, int?categoryId, bool?isSubmit) { var db = new ADProjectDb(); //-------Eugene's change List <SelectListItem> selectListCategory = db.Categories .Select(c => new SelectListItem { Text = c.CategoryDescription, Value = c.CategoryId.ToString() }).ToList(); ViewData["selectListCategory"] = selectListCategory; //------------ List <ItemCatalogue> items = (from Item in db.ItemCatalogue select Item).ToList(); //---Eugene's change if (categoryId != null) { items = items.Where(item => item.CategoryId == categoryId).ToList(); } ViewData["itemdes"] = itemdes; if (itemdes != null) { double unitPrice = adjustmentVoucherServices.getUnitPrice(db, itemdes); ViewData["unitPrice"] = unitPrice; } //---------- ViewData["items"] = items; List <AdjustmentDetail> details = new List <AdjustmentDetail>(); List <string> des = new List <string>(); Employee currentUser = Session["employee"] as Employee; int employeeId = currentUser.EmployeeId; AdjustmentVoucher NewVoucher = adjustmentVoucherServices.CreateAdjustmentVoucher(db, employeeId); ViewData["newvoucher"] = NewVoucher; if (Session["detail"] == null) { Session["detail"] = details; Session["des"] = des; } if (Session["detail"] != null && isSubmit == true) { if (itemdes != null && quantity != null && reason != null && cost != null) { ItemCatalogue item = db.ItemCatalogue.Where(ite => ite.ItemDes == itemdes).SingleOrDefault(); AdjustmentDetail detail = new AdjustmentDetail() { ItemCatalogueId = item.ItemCatalogueId, Quantity = Convert.ToInt32(quantity), AdjustmentVoucherId = NewVoucher.AdjustmentVoucherId, Reason = reason, Cost = Convert.ToDouble(cost) }; ((List <AdjustmentDetail>)Session["detail"]).Add(detail); ((List <string>)Session["des"]).Add(itemdes); Session["details"] = Session["detail"]; NewVoucher.AdjustmentDetail = (List <AdjustmentDetail>)Session["detail"]; Session["newvoucher"] = NewVoucher; return(RedirectToAction("ViewVoucherDetail", "AdjustmentVoucher")); } return(View()); } return(View()); }
public ActionResult ReceiveItemsByDepartment(List <DisbursementDetail> details, int id) { Dictionary <int, DisbursementDetail> dDict = DisbursementDao.GetDisbursementDetailDictByDisbursementId(id); //generate adjustment if items are missing List <AdjustmentDetail> adjustmentDetails = new List <AdjustmentDetail>(); //if detail drop to 0 , it should be removed List <DisbursementDetail> disDetails = new List <DisbursementDetail>(); foreach (var d in details) { DisbursementDetail disDetail = dDict[d.DisbursementDetailId]; if (disDetail.Quantity != d.Quantity && d.Quantity < disDetail.Quantity) { AdjustmentDetail adDetail = new AdjustmentDetail() { Item = new Item() { ItemId = d.Item.ItemId }, Count = disDetail.Quantity - d.Quantity }; if (d.Quantity == 0) { disDetails.Add(disDetail); } adjustmentDetails.Add(adDetail); } } if (adjustmentDetails.Count > 0) { int userId = Convert.ToInt32(RouteData.Values["userId"]); User u = new User() { UserId = userId }; Adjustment ad = AdjustmentDao.InsertAdjustment(adjustmentDetails, u); AdjustmentDao.CalculateAdjustmentCost(ad); } Disbursement dis = DisbursementDao.GetDisbursement(id); int requestId = dis.Request.RequestId; dis = DisbursementDao.DeliverDisbursement(id, details); //remove disbursement detail with quantity of zero if (disDetails.Count > 0) { DisbursementDao.RemoveDisbursementDetails(disDetails); //details have been removed, need to remove disbursement if disbursement got no details //removedDisbursement = DisbursementDao.RemoveDisbursementWithoutDetails(id); } dis = DisbursementDao.GetDeliveredDisbursement(id); if (dis != null) { //need to update the request such as status, delivered Qty RequestDao.UpdateRequestById(requestId); } else { //if disbursement is removed, change disbursement status of request back to not prepared RequestDao.UpdateRequestDisbursementStatus(requestId); } return(RedirectToAction("Deliveries")); }
public void setAdjustmentDetail(AdjustmentDetail adjDetail) { context.AdjustmentDetails.Add(adjDetail); context.SaveChanges(); }