public int updateDisburse(string deptid, string empid1) { int empid = Convert.ToInt32(empid1); var ddptg = (from odr in ad.Requests where odr.RequestStatus == "Alloted" && odr.RequestByDepartmentID == deptid select odr).ToList(); foreach (var qin in ddptg) { var outstand = (from ot in ad.RequestDetails where ot.RequestID == qin.RequestID && ot.RequestedQty != ot.ReceivedQty select ot).ToList(); if (outstand.Count > 0) { Request reqout = new Request { RequestStatus = "NEW", RequestByDepartmentID = qin.RequestByDepartmentID, RequestByEmployeeID = empid }; ad.Requests.Add(reqout); try { ad.SaveChanges(); } catch (Exception tye) { Console.WriteLine(tye); } var genReqNo = (from grn1 in ad.Requests where grn1.RequestStatus == "NEW" && grn1.RequestByEmployeeID == empid && grn1.RequestByDepartmentID == qin.RequestByDepartmentID select grn1).ToList(); int reqnoutstand = genReqNo[0].RequestID; EmpNewRequest outstandnewreq = new EmpNewRequest(); foreach (var outstandvar in outstand) { int qtyoutstand = (int)(outstandvar.RequestedQty - outstandvar.ReceivedQty); outstandnewreq.AddItem(reqnoutstand, outstandvar.RequestedItem, qtyoutstand); } outstandnewreq.AddOutStandingReqNo(reqnoutstand); } var all12 = from a12 in ad.Requests where a12.RequestID == qin.RequestID select a12; Request req = all12.First(); req.RequestStatus = "Disbursed"; req.ReceivedDate = System.DateTime.Now.Date; try { ad.SaveChanges(); } catch (Exception tye) { Console.WriteLine(tye); return(0); } } return(1); }
protected void Button1_Click(object sender, EventArgs e) { if (Page.IsValid) { int qty = Convert.ToInt32(TextBox1.Text); if (qty > 0) { GetRequestNumber(); Label2.Visible = Label3.Visible = true; GridView1.Visible = true; int req = Convert.ToInt32(Label3.Text); string itm = DropDownList2.SelectedItem.Value.ToString(); enr.AddItem(req, itm, qty); GridViewReqNew(req); Button1.Enabled = false; Button2.Enabled = true; DropDownList2.Enabled = false; Button2.Visible = true; } } }