protected void btnApprove_Click(object sender, EventArgs e)
        {
            if (Session["ReqListID"] != null)
            {
                String id   = Convert.ToString(Session["ReqListID"]);
                string name = Session["EmployeeName"].ToString();

                string empNo    = Session["PendingEmployeeNumber"].ToString();
                string senderID = Session["EmployeeNumber"].ToString();

                Employee receiverInfo = EmployeeDAO.getEmployeeinfoByEmployeeNumber(empNo);
                Employee senderInfo   = EmployeeDAO.getEmployeeinfoByEmployeeNumber(senderID);

                string msgTitle = "Approved Request";

                string msgBody = receiverInfo.Name + "\n\n\n\n";
                msgBody += "These items are already approved.\n\n\n";
                for (int i = 0; i < grdApproveReq.Rows.Count; i++)
                {
                    string desc = grdApproveReq.Rows[i].Cells[1].Text;
                    string qty  = grdApproveReq.Rows[i].Cells[2].Text;
                    msgBody += desc + "      |      " + qty;
                    msgBody += "\n";
                }

                ApproveRequestController.submitApproval(id, "web");
                SendEmail(msgTitle, msgBody, senderInfo.Email, receiverInfo.Email);


                Label1.Text = "approved";
                Response.Redirect("../DepartmentHead/PendingRequests.aspx");
            }
        }
    public bool updateRequestReject(iRejectcomments rj)
    {
        ApproveRequestController ar = new ApproveRequestController();

        ar.updateRequestReject(Int32.Parse(rj.RequestID), rj.Comments);
        return(true);
    }
        protected void grdImpendingRequest_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                int    command   = Convert.ToInt32(e.CommandArgument);
                string reqlistid = grdImpendingRequest.Rows[command].Cells[0].Text;
                string name      = grdImpendingRequest.Rows[command].Cells[1].Text;

                Label lbl = (Label)grdImpendingRequest.Rows[command].Cells[6].FindControl("lblEmployeeNumber");

                Session["PendingEmployeeNumber"] = lbl.Text;
                Session["EmployeeName"]          = name;
                Session["ReqListID"]             = reqlistid;

                Response.Redirect("../DepartmentHead/ApproveRequest.aspx");
            }
            else
            if (e.CommandName == "UP")
            {
                int    command   = Convert.ToInt32(e.CommandArgument);
                string reqlistid = grdImpendingRequest.Rows[command].Cells[0].Text;

                ApproveRequestController.submitApproval(reqlistid, "web");
                grdImpendingRequest.DataSource = ApproveRequestController.populateAllPendingReq(empNo);
                grdImpendingRequest.DataBind();
            }
        }
    public bool updateRequestAccept(string requestID, string approveby)
    {
        int reid = Int32.Parse(requestID);
        ApproveRequestController ar = new ApproveRequestController();
        Request rq = new Request();

        rq.RequestID  = reid;
        rq.ApprovedBy = approveby;
        ar.updateRequestAccept(rq.RequestID, rq.ApprovedBy);
        return(true);
    }
    public iRequestDetail[] getReqDetail(string RequestID)
    {
        ApproveRequestController ar     = new ApproveRequestController();
        List <RequestDetail>     rdlist = new List <RequestDetail>();

        rdlist = ar.getRequestDetail(RequestID);
        List <iRequestDetail> irdlist = new List <iRequestDetail>();

        for (int i = 0; i < rdlist.Count; i++)
        {
            iRequestDetail ird = new iRequestDetail();
            ird = ChangeRequestEntitytoiRequestDetail(rdlist[i]);
            irdlist.Add(ird);
        }
        return(irdlist.ToArray());
    }
    public iRequest[] RequestList(string deptcode)
    {
        ApproveRequestController ar   = new ApproveRequestController();
        List <Request>           list = new List <Request>();

        list = ar.getPendingRequestList(deptcode);
        List <iRequest> ilist = new List <iRequest>();

        for (int i = 0; i < list.Count; i++)
        {
            iRequest ireq = new iRequest();
            ireq = ChangeRequestEntitytoiRequest(list[i]);
            ilist.Add(ireq);
        }

        return(ilist.ToArray <iRequest>());
    }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Web.UI.HtmlControls.HtmlGenericControl li = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("ImpendingRequests");
            li.Attributes.Add("class", "active");
            if (Session["Role"] != null)
            {
                if (Session["Role"].ToString() == "Employee")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "DelegateHead")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "StoreClerk")
                {
                    Response.Redirect("../StoreClerk/ViewRequesitionForm.aspx");
                }
                else if (Session["Role"].ToString() == "StoreSupervisor")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
                else if (Session["Role"].ToString() == "StoreManager")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
            Label lblWelcome = (Label)this.Master.FindControl("lblWelcome");

            lblWelcome.Text = Session["Name"].ToString();//from login username

            if (Session["ReqListID"] != null)
            {
                String id = Convert.ToString(Session["ReqListID"]);
                grdApproveReq.DataSource = ApproveRequestController.pupulateDetails(id);
                grdApproveReq.DataBind();
            }
        }
        protected void btnDeny_Click(object sender, EventArgs e)
        {
            if (Session["ReqListID"] != null)
            {
                String id      = Convert.ToString(Session["ReqListID"]);
                String comment = txtboxcomment.Text;

                string empNo    = Session["PendingEmployeeNumber"].ToString();
                string senderID = Session["EmployeeNumber"].ToString();

                Employee receiverInfo = EmployeeDAO.getEmployeeinfoByEmployeeNumber(empNo);
                Employee senderInfo   = EmployeeDAO.getEmployeeinfoByEmployeeNumber(senderID);

                string msgTitle = "Deny Request";

                string msgBody = receiverInfo.Name + "\n\n\n";
                msgBody += "These items are denied.\n";
                if (txtboxcomment.Text != "")
                {
                    msgBody += " Due to this," + txtboxcomment.Text + "\n\n";
                }
                for (int i = 0; i < grdApproveReq.Rows.Count; i++)
                {
                    string desc = grdApproveReq.Rows[i].Cells[1].Text;
                    string qty  = grdApproveReq.Rows[i].Cells[2].Text;
                    msgBody += desc + " |   " + qty;
                    msgBody += "\n";
                }

                ApproveRequestController.submitRejected(id, comment);
                SendEmail(msgTitle, msgBody, senderInfo.Email, receiverInfo.Email);

                Label1.Text = "denied";
                Response.Redirect("../DepartmentHead/PendingRequests.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string role = "";

            if (Session["Role"] != null)
            {
                role = Session["Role"].ToString();
            }
            if (role == "Head")
            {
                System.Web.UI.HtmlControls.HtmlGenericControl li = (System.Web.UI.HtmlControls.HtmlGenericControl) this.Page.Master.FindControl("ImpendingRequests");
                li.Attributes.Add("class", "active");
            }
            else if (role == "DelegateHead")
            {
                Label1.Visible           = false;
                ddlCollectorName.Visible = false;
                ddl1.Attributes.Remove("class");
                ddl2.Attributes.Remove("class");

                Label2.Visible             = false;
                ddlCollectionPoint.Visible = false;

                btnSave.Visible = false;
            }
            if (Session["Role"] != null)
            {
                if (Session["Role"].ToString() == "Employee")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "DelegateHead")
                {
                    Response.Redirect("../DepartmentEmployee/RequestStationery.aspx");
                }
                else if (Session["Role"].ToString() == "StoreClerk")
                {
                    Response.Redirect("../StoreClerk/ViewRequesitionForm.aspx");
                }
                else if (Session["Role"].ToString() == "StoreSupervisor")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
                else if (Session["Role"].ToString() == "StoreManager")
                {
                    Response.Redirect("../StoreSupervisor/PendingAdjustment.aspx");
                }
            }
            else
            {
                Response.Redirect("../Login.aspx");
            }
            empNo = Session["EmployeeNumber"].ToString();
            Label lblWelcome = (Label)this.Master.FindControl("lblWelcome");

            lblWelcome.Text = Session["Name"].ToString();//from login username

            if (!IsPostBack)
            {
                grdImpendingRequest.DataSource = ApproveRequestController.populateAllPendingReq(empNo);
                grdImpendingRequest.DataBind();


                ddlCollectorName.DataSource     = EditPickUpController.getAllEmployeesOfThisHead(empNo);
                ddlCollectorName.DataTextField  = "Name";
                ddlCollectorName.DataValueField = "EmployeeNumber";

                // ddlCollectorName.SelectedValue = EditPickUpController.GetRepresentativeName("C1");
                ddlCollectorName.DataBind();
                ddlCollectorName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select One", ""));

                txtboxrRepName.Text = EditPickUpController.GetRepresentativeName(empNo);
                txtboxcollecpt.Text = EditPickUpController.GetCollectionPoint(empNo);


                ddlCollectionPoint.DataSource     = EditPickUpController.getAllCollectionPoins();
                ddlCollectionPoint.DataTextField  = "Name";
                ddlCollectionPoint.DataValueField = "CollectionPointID";
                // ddlCollectorName.SelectedValue = EditPickUpController.GetCollectionPoint("C1");
                ddlCollectionPoint.DataBind();
                ddlCollectionPoint.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select One", ""));
            }
        }