コード例 #1
0
        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();
                    }
                }
            }
        }
コード例 #2
0
        //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");
            }
        }