//Employee -- Approve Requisition Page -- //1.. Get Department Requistions which status is "Pending" public List <RequisitionBO> getDeptPendingRequisition(int departmentID) { List <RequisitionBO> lst = new List <RequisitionBO>(); var qry = (from r in context.Requisitions join ri in context.Requisition_Item on r.RequisitionID equals ri.RequisitionID join emp in context.Employees on r.EmployeeID equals emp.EmployeeID where (r.DepartmentID == departmentID && r.Status.Equals("Pending")) group new { r, ri, emp } by r.RequisitionID into g select new { g.FirstOrDefault().r.RequisitionID, totalCount = g.Count(), g.FirstOrDefault().emp.FirstName, g.FirstOrDefault().emp.LastName, g.FirstOrDefault().r.OrderDate }).ToList(); foreach (var q in qry) { RequisitionBO reqBO = new RequisitionBO(); reqBO.RequisitionID = q.RequisitionID; reqBO.TotalItem = q.totalCount; reqBO.FirstName = q.FirstName; reqBO.LastName = q.LastName; reqBO.OrderDate = q.OrderDate; reqBO.FullName = q.FirstName + " " + q.LastName; //For Full Name lst.Add(reqBO); } return(lst); //return context.Requisitions.Where(r => r.DepartmentID == 2).ToList<Requisition>(); }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { string i = Request.QueryString["rID"]; rbo = bl.getRequistionByID(int.Parse(i)); lblItemCode.Text = rbo.ReqID; DateTime dt = DateTime.Parse(rbo.OrderDate.ToString()); lblIssueDate.Text = dt.ToString("dd/MM/yyyy"); lblStatus.Text = rbo.Status; string reqNumberStr = lblItemCode.Text; int reqNum = Convert.ToInt32(reqNumberStr.Substring(1, reqNumberStr.Length - 1)); RequisitionDetailGV.DataSource = bl.getRequisitionDetailList(reqNum); RequisitionDetailGV.DataBind(); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
//Get the requisition object by Number public RequisitionBO getRequisitionIDByNumber(int rid) { var qry = context.Requisitions.Where(x => x.RequisitionID == rid).FirstOrDefault(); RequisitionBO rbo = new RequisitionBO(); rbo.ReqID = "R" + qry.RequisitionID; rbo.OrderDate = qry.OrderDate; rbo.Status = qry.Status; return(rbo); }
public RequisitionBO convertRequisitionBO(Requisition r) { rbo = new RequisitionBO(); rbo.RequisitionId = r.RequisitionID; rbo.EmpId = r.EmpID; rbo.CommentsByEmp = r.CommentsByEmp; rbo.Status = r.Status; rbo.EmpRequisitionDate = r.EmpRequisitionDate; rbo.ApprovalDate = r.ApprovalDate; rbo.CommentsByHead = r.CommentsByHead; return(rbo); }
public Requisition convertRequisitionBO(RequisitionBO rbo) { Requisition r = new Requisition(); r.RequisitionID = rbo.RequisitionId; r.EmpID = rbo.EmpId; r.CommentsByEmp = rbo.CommentsByEmp; r.Status = rbo.Status; r.EmpRequisitionDate = rbo.EmpRequisitionDate; r.ApprovalDate = rbo.ApprovalDate; r.CommentsByHead = rbo.CommentsByHead; return(r); }
//For Requistion Page public List <RequisitionBO> getRequistionList(int depID) { var qry = (from i in context.Employees join si in context.Requisitions on i.EmployeeID equals si.EmployeeID where i.DepartmentID == depID //loggined employee deparment id select new { si.RequisitionID, si.DepartmentID, si.EmployeeID, si.OrderDate, si.Status, i.FirstName, i.LastName }).ToList(); List <RequisitionBO> lst = new List <RequisitionBO>(); foreach (var q in qry) { RequisitionBO b = new RequisitionBO(); b.RequisitionID = q.RequisitionID; b.ReqID = "R" + q.RequisitionID; b.DepartmentID = q.DepartmentID; b.EmployeeID = q.EmployeeID; b.OrderDate = q.OrderDate; b.Status = q.Status; b.FullName = q.FirstName + " " + q.LastName; lst.Add(b); } return(lst); }
//Search By Date public List <RequisitionBO> searchRequisitionByDate(string fromDate, string toDate, int deptID) { DateTime dt1 = DateTime.Parse(fromDate); DateTime dt2 = DateTime.Parse(toDate); var qry = (from i in context.Employees join si in context.Requisitions on i.EmployeeID equals si.EmployeeID where i.DepartmentID == deptID && (si.OrderDate >= dt1 && si.OrderDate <= dt2) //added dept id by parameter pass select new { si.RequisitionID, si.DepartmentID, si.EmployeeID, si.OrderDate, si.Status, i.FirstName, i.LastName }).ToList(); List <RequisitionBO> lst = new List <RequisitionBO>(); foreach (var q in qry) { RequisitionBO b = new RequisitionBO(); b.ReqID = "R" + q.RequisitionID; b.DepartmentID = q.DepartmentID; b.EmployeeID = q.EmployeeID; b.OrderDate = q.OrderDate; b.Status = q.Status; b.FullName = q.FirstName + " " + q.LastName; lst.Add(b); } return(lst); }
protected void BtbSubmit_Click(object sender, EventArgs e) { dt = (DataTable)Session["AddRequisitionTable"]; if (dt.Rows.Count == 0) { LabelSubmit.Text = "Please add item first."; } else { LabelSubmit.Text = ""; RequisitionBO rbo = new RequisitionBO(); EmployeeBO ebo = (EmployeeBO)Session["employee"]; dt = (DataTable)Session["AddRequisitionTable"]; string requisitionId = crbl.createRequisitionId(); rbo.RequisitionId = requisitionId; rbo.EmpId = ebo.EmployeeId; rbo.CommentsByEmp = Request.Form["tbEmployeeComments"]; rbo.Status = "Pending"; rbo.EmpRequisitionDate = DateTime.Today; crbl.submitRequisition(rbo); string sub = "New Requisition"; string name = crbl.getHeadNameByDepId(ebo.Department.DeptId); string body = "Dear " + name + ", \n" + "\n" + "I have made a new requisition for those items below: " + "\n"; string bodyForOutOfStock = "Dear clerk, \n\n"; foreach (DataRow dr in dt.Rows) { RequisitionDetailsBO rdbo = new RequisitionDetailsBO(); rdbo.RequisitionId = requisitionId; rdbo.RequisitionDetailsId = crbl.createRequisitionDetailsId(); string itemNumber = crbl.getItemNumberByItemName(dr["updateItemName"].ToString()); rdbo.ItemNumber = itemNumber; int itemQuantity = Convert.ToInt32(dr["updateQuantity"].ToString()); rdbo.ItemQuantity = itemQuantity; if (checkReorderLevel(itemNumber, itemQuantity) == false) { bodyForOutOfStock += "The item: " + dr["updateItemName"].ToString() + " is reaching the reorder level, Please place orders.\n"; Label1.Text += bodyForOutOfStock + " " + itemNumber + " " + itemQuantity + " " + checkReorderLevel(itemNumber, itemQuantity).ToString(); } crbl.submitRequisitionDetails(rdbo); body += "Item Name: " + dr["updateItemName"].ToString() + ":\t Quantity: " + dr["updateQuantity"].ToString() + "\n"; } body += "\n\n" + "Regards," + "\n" + ebo.EmployeeName; SendEmail sendEmail = new SendEmail(); sendEmail.sendCPEmail(sub, body, crbl.getHeadEmailByDepId(ebo.Department.DeptId)); if (bodyForOutOfStock != "Dear clerk, \n\n") { string subject = "items out of stock"; foreach (string email in crbl.getAllClerksEmail()) { sendEmail.sendCPEmail(subject, bodyForOutOfStock, email); } } Response.Redirect("~/Department/RequisitionList.aspx"); } }
public void submitRequisition(RequisitionBO rbo) { crda.submitRequisition(convertRequisitionBO(rbo)); }