protected void btnApprove_Click(object sender, EventArgs e) { bool CheckTrue = false; try { for (int r = 0; r < gvRequest.Rows.Count; r++) //find checkbox checked or not { CheckBox chkResult = (CheckBox)gvRequest.Rows[r].Cells[0].FindControl("chkResult1"); if (chkResult.Checked == true) { CheckTrue = true; } } if (CheckTrue != true) { string script = "alert('At least one check box need to selected to delete process.');"; ClientScript.RegisterStartupScript(this.GetType(), "test", script, true); } else { DepartmentBLL deptbll = new DepartmentBLL(); //int empid = 1004;// to update empid int empid = Convert.ToInt32(Session["loginUser"]); Department depart = deptbll.getDeptCodebyEmpID(empid); //need to update session value of employee id DepartmentRequBLL deptreqBll = new DepartmentRequBLL(); DateTime processdate = DateTime.Now; int dep_reqid = deptreqBll.insertHeaderRecord(processdate, "current", depart.Department_Code); //create header record first if (dep_reqid > 0) { for (int r = 0; r < gvRequest.Rows.Count; r++) //find checkbox checked or not { CheckBox chkResult = (CheckBox)gvRequest.Rows[r].Cells[0].FindControl("chkResult1"); if (chkResult.Checked == true) { string emp_reqID = gvRequest.DataKeys[r].Values["Emp_ReqID"].ToString(); deptreqBll.insertDetailRecord(dep_reqid, Convert.ToInt32(emp_reqID), processdate);//insert detail records updateStatustoEmpReq(Convert.ToInt32(emp_reqID), "Approved");//update request status String body = "Your registration have been approved! \n" + txtRejectInfo.Text + "\n Thanks \nBest Regards,\n"; String subject = "Approved your Stationery Request "; String employeeid = gvRequest.DataKeys[r].Values["EmployeeID"].ToString(); SendNotification(Convert.ToInt32(employeeid), body, subject); } } } } gvRequest_DataBind(); } catch (Exception ex) { lblMessage.Text = ex.Message; } }
void SaveHeaderRecord() { DepartmentBLL deptbll = new DepartmentBLL(); //int empid = 1004;// to update empid int empid = Convert.ToInt32(Session["loginUser"]); Department depart = deptbll.getDeptCodebyEmpID(empid); //need to update session value of employee id int empreqid = emreqbll.insertHeaderRecord(empid, DateTime.Now, txtStatus.Text, depart.Department_Code); txtRequestID.Text = Convert.ToString(empreqid); txtDeptName.Text = depart.Department_Name; //need to bind the correct departname by empid }
void gvRequestHeader_DataBind() { DepartmentBLL deptbll = new DepartmentBLL(); int empid = Convert.ToInt32(Session["loginUser"]); // int empid = 1004; //to update empid EmployeeBLL empbll = new EmployeeBLL(); Employee empinfo = empbll.getEmployeebyempid(empid); //Department depart = deptbll.getDeptCodebyEmpID(empid); if (empinfo.EmployeeType.ToLower().Trim() == "head") { gvRequestHeader.DataSource = emreqbll.GetHeaderRecordsforHead(empinfo.DepartmentCode); //to show all requisition if loginuser is department head } else { gvRequestHeader.DataSource = emreqbll.GetHeaderRecords(empinfo.DepartmentCode, empid); //to show only individual records if loginuser is employee } gvRequestHeader.DataBind(); }
void gvRequest_DataBind() { DepartmentBLL deptbll = new DepartmentBLL(); //int empid = 1004; //to update empid int empid = Convert.ToInt32(Session["loginUser"]); Department depart = deptbll.getDeptCodebyEmpID(empid); gvRequest.DataSource = emreqbll.GetPendingRequest(depart.Department_Code); gvRequest.DataBind(); }