//Get the adjustment lists public List <AdjustmentVoucherDetailBO> getAdjustmentDetailed(int adjustmentID) { var qry = (from ai in context.Adjustment_Item join i in context.Items on ai.ItemID equals i.ItemID join a in context.Adjustments on ai.AdjustmentID equals a.AdjustmentID where a.AdjustmentID == adjustmentID select new { i.ItemNumber, i.Description, ai.AdjustedQty, ai.Reason, ai.Condition, i.ItemID }).ToList(); List <AdjustmentVoucherDetailBO> lst = new List <AdjustmentVoucherDetailBO>(); foreach (var q in qry) { AdjustmentVoucherDetailBO b = new AdjustmentVoucherDetailBO(); b.ItemNumber = q.ItemNumber; b.ItemDescription = q.Description; b.QuantityAdjusted = Convert.ToString(q.AdjustedQty); b.Reason = q.Reason; lst.Add(b); } return(lst); }
protected void btnApprove_Click(object sender, EventArgs e) { try { string number = Request.QueryString["adjNumber"]; int adjNum = Convert.ToInt32(number.Substring(1, number.Length - 1)); if (bl.CheckPending(adjNum) == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You have already approved')", true); } else if (bl.CheckPending(adjNum) == 0) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('You have already rejected')", true); } else if (bl.CheckPending(adjNum) == 2) { int num = bl.ApprovedOrRejectedBL(1, adjNum); //1 mean approve //To Update the quantity in stock List <AdjustmentVoucherDetailBO> lst = new List <AdjustmentVoucherDetailBO>(); foreach (AdjustmentVoucherDetailBO b in bl.getAdjustmentDetail(adjNum)) { AdjustmentVoucherDetailBO obj = new AdjustmentVoucherDetailBO(); obj.ItemNumber = b.ItemNumber; obj.QuantityAdjusted = b.QuantityAdjusted; lst.Add(obj); } int i = bl.checkInStockAdjustment(lst); sendGmail("Approved", adjNum); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Approved Successful')", true); Response.Redirect("~/StoreClerk/AdjustmentVouchersList.aspx"); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }