public void bundleSelectedRequisition(List<Requisition> lstReqNo, string reqFrmNo, string empID, string deptID, List<Requisition> lstRej) { var q = from lr in lstReqNo join rd in ContextDB.Requisition_Detail on lr.Req_Form_No equals rd.Req_Form_No join s in ContextDB.Stationary_Catalogue on rd.Item_Code equals s.Item_Code group rd by new { rd.Item_Code, s.Description } into g select new Requisition_Detail { //Req_Form_No = g.Key.Req_Form_No, Item_Code = g.Key.Item_Code, Description = g.Key.Description, Qty = g.Sum(rd => rd.Qty) }; RequisitionEnt reqE = new RequisitionEnt(); Requisition req = new Requisition(); req.Req_Form_No = reqFrmNo; req.Emp_ID = empID; req.Approval_Status = 3; req.Approval_Date = DateTime.Now; req.Approval_By = null; req.Req_Status = false; req.Notification = false; req.Prior = false; reqE.createRequisition(req); foreach (var val in q) { Requisition_Detail rd = new Requisition_Detail(); rd.Req_Form_No = reqFrmNo; rd.Item_Code = val.Item_Code; rd.Description = val.Description; rd.Qty = val.Qty; RequisitionDetailEnt rdE = new RequisitionDetailEnt(); rdE.createReqDetail(rd); } foreach (var val in lstReqNo) { Requisition reqt = (Requisition)val; reqt.Approval_Status = 2; updateRequisition(reqt); } foreach (var val in lstRej) { Requisition reqt = (Requisition)val; reqt.Approval_Status = 0; updateRequisition(reqt); } }
public void createRequisition(Requisition req) { ContextDB.Requisitions.AddObject(req); ContextDB.SaveChanges(); dalUtl.Increament_GenID(1); }
//public IQueryable getPendingRequisition(string DeptID) //{ // var query = from r in ContextDB.Requisitions // join us in ContextDB.Users // on new { r.Emp_ID } equals new { us.Emp_ID } // where r.Approval_Status == 1 && us.Dept_ID == DeptID // select new // { // Form_No = r.Req_Form_No, // Emp_Name = us.Emp_Name, // Status = "Pending", // Req_Date = r.Request_Date // }; // return query; //} public bool updateRequisition(Requisition req) { try { Requisition r = getRequisition(req); r.Approval_Status = req.Approval_Status == null? r.Approval_Status: req.Approval_Status; r.Request_Date = req.Request_Date == null?r.Request_Date : req.Request_Date; r.Approval_Date = req.Approval_Date == null? r.Approval_Date : req.Approval_Date; r.Approval_By = req.Approval_By == null? r.Approval_By : req.Approval_By; r.Req_Status = !req.Req_Status.HasValue ? r.Req_Status : req.Req_Status; r.Rej_Comment = req.Rej_Comment == null ? r.Rej_Comment : req.Rej_Comment; r.Notification = req.Notification == null? r.Notification : req.Notification; r.Prior = !req.Prior.HasValue ? r.Prior : req.Prior; ContextDB.SaveChanges(); return true; } catch (Exception e) { return false; } }
public Requisition getRequisition(Requisition req) { var query = from r in ContextDB.Requisitions where r.Req_Form_No == req.Req_Form_No select r; return query.First(); }
public bool deleteRequisition(Requisition req) { try{ ContextDB.Requisitions.DeleteObject(req); ContextDB.SaveChanges(); return true; } catch(Exception e) { return false; } }
/// <summary> /// Deprecated Method for adding a new object to the Requisitions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRequisitions(Requisition requisition) { base.AddObject("Requisitions", requisition); }
/// <summary> /// Create a new Requisition object. /// </summary> /// <param name="req_Form_No">Initial value of the Req_Form_No property.</param> public static Requisition CreateRequisition(global::System.String req_Form_No) { Requisition requisition = new Requisition(); requisition.Req_Form_No = req_Form_No; return requisition; }