Example #1
0
    protected void btnForward_Click(object sender, EventArgs e)
    {
        string strApproverType = clsPCASApproval.GetApproverType(clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()), Request.QueryString["pcascode"].ToString());

        if ((strApproverType == "F3"))
        {
        }
        else
        {
            try
            {
                using (clsPCASRequestCustodian objRequestCustodian = new clsPCASRequestCustodian())
                {
                    objRequestCustodian.PCascode = Request.QueryString["pcascode"].ToString();
                    objRequestCustodian.Delete();
                    objRequestCustodian.PCascode = Request.QueryString["pcascode"].ToString();
                    objRequestCustodian.Username = ddlAssignedCustodian.SelectedValue.ToString();
                    objRequestCustodian.Insert();
                }

                clsPCASApproval.UpdateFPC3Approver(Request.QueryString["pcascode"].ToString(), ddlFinalApprover.SelectedValue.ToString());
            }
            catch { }


            if (clsPCASApproval.TagApprovedOrNot(Request.QueryString["pcascode"].ToString(), clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()), "1") > 0)
            {
                try
                {
                    //clsPCASRequest.SendEmailNotification("FPCApproved", Request.QueryString["pcascode"].ToString(), Request.Cookies["Speedo"]["UserName"].ToString(), "");
                }
                catch { }
                //clsPCASRequest.SendEmailNotification("Approver", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()));
                //Response.Redirect("PettyCashRequestDetailsFPC.aspx?pcascode=");
                clsPCASRequest.SendEmailNotification("Approver", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()));
                Response.Redirect(Request.RawUrl);
            }
        }
    }
    protected void btnSaveAndApprove_Click(object sender, EventArgs e)
    {
        if (ValidateAmount() == false)
        {
        }
        else
        {
            string strApproverType = clsPCASApproval.GetApproverType(Request.Cookies["Speedo"]["UserName"].ToString(), Request.QueryString["pcascode"].ToString());


            using (clsPCASRequestAllocation objDELRequestAllocation = new clsPCASRequestAllocation())
            {
                objDELRequestAllocation.PCascode = Request.QueryString["pcascode"].ToString();
                objDELRequestAllocation.Delete();
            }

            DataTable tblCart1 = ViewState["Cart"] as DataTable;

            foreach (DataRow drw in tblCart1.Rows)
            {
                using (clsPCASRequestAllocation objRequestAllocation = new clsPCASRequestAllocation())
                {
                    objRequestAllocation.PCascode           = Request.QueryString["pcascode"].ToString();
                    objRequestAllocation.AccountExpenseCode = drw["aexpcode"].ToString();
                    objRequestAllocation.RCCode             = drw["rccode"].ToString();
                    objRequestAllocation.Schoolcode         = drw["schlcode"].ToString();
                    objRequestAllocation.Others             = drw["others"].ToString();
                    objRequestAllocation.Amount             = Convert.ToDouble(drw["amount"]);
                    objRequestAllocation.Insert();
                }
            }

            if (clsPCASApproval.TagApprovedOrNot(Request.QueryString["pcascode"].ToString(), Request.Cookies["Speedo"]["UserName"].ToString(), "1") > 0)
            {
                try
                {
                    clsPCASRequest.SendEmailNotification("FPCApproved", Request.QueryString["pcascode"].ToString(), Request.Cookies["Speedo"]["UserName"].ToString(), "");
                    if ((strApproverType == "F1") || (strApproverType == "F2") || (strApproverType == "F3"))
                    {
                        clsPCASRequest.UpdateFPCData(Request.QueryString["pcascode"].ToString(), Convert.ToDouble(txtApprovedRFA.Text), Convert.ToDouble(txtAmountAllocated.Text), Convert.ToDouble(txtNet.Text), Convert.ToDouble(txtRequestAmount.Text), Convert.ToDouble(txtRemainingBudget.Text));
                    }

                    if ((strApproverType == "E") || (strApproverType == "H") || (strApproverType == "D") || (strApproverType == "F3"))
                    {
                        if ((strApproverType == "F3"))
                        {
                            clsPCASRequest.Approve(Request.QueryString["pcascode"].ToString());
                            clsPCASRequest.UpdateAdjustment(Request.QueryString["pcascode"].ToString(), clsPCASRequestAllocation.GetAmount(Request.QueryString["pcascode"].ToString()) - clsPCASRequestDetails.GetAmount(Request.QueryString["pcascode"].ToString()));
                            clsPCASRequest.SendEmailNotification("RequestorFinalFPC", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), "");
                            clsPCASRequest.SendEmailNotification("CashierApprover", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), ddlCustodian.SelectedValue.ToString());

                            foreach (DataRow drw in clsPCASRequest.GetDSGMainFormApproverPerRC(Request.QueryString["pcascode"].ToString()).Rows)
                            {
                                string pTable;
                                pTable = "<TABLE border='1'>" +
                                         "<TR><TD class='GirdRows'>Account Expenses</TD><TD class='GirdRows'>Amount</TD></TR>";
                                foreach (DataRow drw1 in clsFinanceAccountExpenses.GetDSGMainFormExpensesAmount(Request.QueryString["pcascode"].ToString(), drw["rccode"].ToString()).Rows)
                                {
                                    pTable = pTable +
                                             "<TR><TD class='GirdRows'>" + drw1["aexpname"] + "</TD><TD class='GirdRows'>" + drw1["amount"] + "</TD></TR>";
                                }
                                pTable = pTable + "</TABLE>";
                                clsPCASRequest.SendEmailNotificationAdjustment("Adjustment4Heads", clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), drw["username"].ToString(), pTable);
                            }
                        }
                        else
                        {
                            // clsPCASRequest.UpdateAdjustment(Request.QueryString["pcascode"].ToString(), clsPCASRequestAllocation.GetAmount(Request.QueryString["pcascode"].ToString()) - clsPCASRequestDetails.GetAmount(Request.QueryString["pcascode"].ToString()));
                            clsPCASRequest.SendEmailNotification("Requestor", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()));
                        }
                    }
                    else
                    {
                        clsPCASApproval.UpdateFPC3Approver(Request.QueryString["pcascode"].ToString(), ddlFPCFinalApprover.SelectedValue.ToString());
                    }
                    using (clsPCASRequestCustodian objRequestCustodian = new clsPCASRequestCustodian())
                    {
                        objRequestCustodian.PCascode = Request.QueryString["pcascode"].ToString();
                        objRequestCustodian.Delete();
                        objRequestCustodian.PCascode = Request.QueryString["pcascode"].ToString();
                        objRequestCustodian.Username = ddlCustodian.SelectedValue.ToString();
                        objRequestCustodian.Insert();
                    }
                }
                catch { }

                try
                {
                    txtNet.Text = (Convert.ToDouble(txtApprovedRFA.Text) - Convert.ToDouble(txtAmountAllocated.Text)).ToString();
                }
                catch { }
                try
                {
                    //txtRemainingBudget.Text = (Convert.ToDouble(txtNet.Text) - Convert.ToDouble(txtRequestAmount.Text)).ToString();
                }
                catch { }

                clsPCASRequest.SendEmailNotification("Approver", Request.QueryString["pcascode"].ToString(), clsPCASRequest.GetCreatedBy(Request.QueryString["pcascode"].ToString()), clsPCASApproval.GetNextApproverUserName(Request.QueryString["pcascode"].ToString()));
                Response.Redirect("PettyCashRequestMenu.aspx");
            }
        }
    }