protected void Page_Load(object sender, EventArgs e) { //Session["HODID"] = 104; Session["departmentid"] = "ARTS"; Session["employeeid"] = 78; departmentCode = (string)Session["departmentid"]; hodID = (int)Session["HODID"]; employeeID = (int)Session["employeeid"]; if (!IsPostBack) { //populate employee list excluding the HOD dgvAssignRep.DataSource = BusinessLogic_Sam.EmployeeList(departmentCode, hodID); dgvAssignRep.DataBind(); //check current rep name repName = BusinessLogic_Sam.checkCurrentRep(departmentCode); for (int rowIndex = 0; rowIndex < dgvAssignRep.Rows.Count; rowIndex++) { if (dgvAssignRep.Rows[rowIndex].Cells[0].Text == repName) { Button buttonAssign = (Button)dgvAssignRep.Rows[rowIndex].FindControl("btnAssign"); buttonAssign.Text = "Current"; buttonAssign.BackColor = System.Drawing.Color.Red; dgvAssignRep.Rows[rowIndex].BackColor = System.Drawing.Color.LightBlue; lblRepName.Text = repName; Session["CurrentRep"] = repName; lblRepSubtitle1.Text = " is the current Department Representative."; } } } }
protected void dgvAssignRep_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Assign") { //assign representative GridViewRow selectedRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); int selectedIndex = selectedRow.RowIndex; Button buttonAssign = (Button)dgvAssignRep.Rows[selectedIndex].FindControl("btnAssign"); string buttonAssignText = buttonAssign.Text; string newRepName = dgvAssignRep.Rows[selectedIndex].Cells[0].Text; if (buttonAssignText == "Assign") { try { string oldRepName = (string)Session["CurrentRep"]; lblRepName.Text = newRepName; lblRepSubtitle1.Text = " is the current Department Representative."; BusinessLogic_Sam.assignNewRepresentative(oldRepName, newRepName, departmentCode); Session["CurrentRep"] = newRepName; Response.Redirect("AssignRepresentative.aspx"); } catch (Exception exp) { Response.Write(exp.ToString()); } } else { lblRepName.Text = newRepName; lblRepSubtitle1.Text = " is the current Department Representative. "; lblRepSubtitle2.Text = "Please reselect new employee for assignment."; } } }
protected void btnApprove_Click(object sender, EventArgs e) { string requisitionid = (string)Session["requisitiondetail"]; string itemCode; int itemReqQty; //List<Catalogue> reqListItems = new List<Catalogue>(); Dictionary <string, int> reqListItems = new Dictionary <string, int>(); for (int i = 0; i < dgvRequisitionDetail.Rows.Count; i++) { itemCode = dgvRequisitionDetail.Rows[i].Cells[3].Text; itemReqQty = Convert.ToInt32(dgvRequisitionDetail.Rows[i].Cells[1].Text); reqListItems.Add(itemCode, itemReqQty); } try { reqid = Convert.ToInt32(requisitionid); int approverID = (int)Session["ApproverID"]; remarks = txtBoxRemarks.Text; BusinessLogic_Sam.approveRequisition(reqid, remarks, approverID.ToString()); BusinessLogic_Sam.updateItemStockLevel(reqListItems); Response.Redirect("DepartmentRequisition.aspx"); } catch (Exception exp) { Response.Write(exp.ToString()); } }
protected void dgvDelegateApproval_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { //Getting the row index of selected row & detect the delegate button's text. GridViewRow selectedRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); int selectedIndex = selectedRow.RowIndex; Button buttonDelegate = (Button)dgvDelegateApproval.Rows[selectedIndex].FindControl("btnDelegate"); string buttonDelegateText = buttonDelegate.Text; //HOD taking back the authority if (buttonDelegateText == "Undelegate") { int approverID = (int)Session["HODID"]; approvalStartDate = new DateTime(2018, 1, 1); approvalEndDate = new DateTime(2099, 1, 1); try { //Change: need to rename businesslogic path here BusinessLogic_Sam.delegateApprover(approverID, approvalStartDate, approvalEndDate, departmentCode); Response.Redirect("DelegateApproval.aspx"); } catch (Exception exp) { Response.Write(exp.ToString()); } //finally //{ //} } //if there are outstanding requisitions, delegation is not allowed and redirect to another page. else if (buttonDelegateText == "Delegate") { //get the selectedApprover ID and calculate his/her pending requisitions string selectedApproverName = selectedRow.Cells[0].Text; //Change: need to rename businesslogic path here int pendingReqQty = BusinessLogic_Sam.checkPendingRequisitionQuantity(selectedApproverName); if (pendingReqQty == 0) { lblApprover.Text = selectedApproverName; txtStartDate.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); txtEndDate.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); mPop1.Show(); } else { lblFailApprover.Text = selectedRow.Cells[0].Text; mPop2.Show(); } } } }
protected void btnReject_Click(object sender, EventArgs e) { string requisitionid = (string)Session["requisitiondetail"]; try { reqid = Convert.ToInt32(requisitionid); remarks = txtBoxRemarks.Text; BusinessLogic_Sam.rejectRequisition(reqid, remarks); Response.Redirect("DepartmentRequisition.aspx"); } catch (Exception exp) { Response.Write(exp.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { //Session["departmentid"] = "ARTS"; ////this employee is the approver //Session["employeeid"] = 104; //Session["ApproverID"] = 104; departmentCode = (string)Session["departmentcode"]; employeeID = (int)Session["employeeid"]; approverID = (int)Session["ApproverID"]; if (!IsPostBack) { btnReqHst.ForeColor = System.Drawing.Color.Green; dgvDepReqHst.DataSource = BusinessLogic_Sam.getDepartmentRequisitionList(departmentCode); dgvDepReqHst.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { //Session["departmentid"] = "ARTS"; ////this employee is the approver //Session["employeeid"] = 104; //Session["ApproverID"] = 104; departmentCode = (string)Session["departmentcode"]; employeeID = (int)Session["employeeid"]; approverID = (int)Session["ApproverID"]; //on page load, the Pending Requisition button is selected(green) and the dgv load requisitions with status pending if (!IsPostBack) { btnPendingReq.ForeColor = System.Drawing.Color.Green; dgvDepReq.DataSource = BusinessLogic_Sam.getDepartmentPendingRequisition(departmentCode); dgvDepReq.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { //Need to check the identity of the logged in user before we can load the employee list. //Need to get the HODID based on logged in employeeID //For now, we will always load the ARTS employee list. //Need to filter the HOD ID from the employee list from display[get from session state]. //Change: Need to get employeeid, HODID, departmentid from Session state. //Session["HODID"] = 104; Session["departmentid"] = "ARTS"; Session["employeeid"] = 78; departmentCode = (string)Session["departmentid"]; hodID = (int)Session["HODID"]; employeeID = (int)Session["employeeid"]; if (!IsPostBack) { //Change: need to rename businesslogic path here //only shows a particular employee list, excluding HOD name on the list to prevent unnecessary click. dgvDelegateApproval.DataSource = BusinessLogic_Sam.EmployeeList(departmentCode, hodID); dgvDelegateApproval.DataBind(); //Check who is the current approver (if any) and change the button text to "Undelegate" & color to red, current approver row is highlighted approverName = BusinessLogic_Sam.checkCurrentApprover(departmentCode); if (approverName != null) { for (int rowIndex = 0; rowIndex < dgvDelegateApproval.Rows.Count; rowIndex++) { if (dgvDelegateApproval.Rows[rowIndex].Cells[0].Text == approverName) { Button buttonDelegate = (Button)dgvDelegateApproval.Rows[rowIndex].FindControl("btnDelegate"); buttonDelegate.Text = "Undelegate"; buttonDelegate.BackColor = System.Drawing.Color.Red; dgvDelegateApproval.Rows[rowIndex].BackColor = System.Drawing.Color.LightBlue; } } } } }
//Confirm to update new Approver protected void btnConfirm_Click(object sender, EventArgs e) { string approverName = lblApprover.Text; //Change: need to rename businesslogic path here int approverID = BusinessLogic_Sam.getApproverIDfromName(approverName); string startdate = txtStartDate.Text; DateTime approvalStartDate = Convert.ToDateTime(startdate); string enddate = txtEndDate.Text; DateTime approvalEndDate = Convert.ToDateTime(enddate); try { //Change: need to rename businesslogic path here BusinessLogic_Sam.delegateApprover(approverID, approvalStartDate, approvalEndDate, departmentCode); } catch (Exception exp) { Response.Write(exp.ToString()); } finally { Response.Redirect("DelegateApproval.aspx"); } }