protected void GeneratePayrollReport()
    {
        string strGenerateValue   = "";
        int    inBenefitHeadCount = 0;
        int    inDeductCount      = 0;

        switch (ddlGeneratefor.SelectedValue.ToString())
        {
        case "O":
            strGenerateValue        = ddlBank.SelectedValue.ToString();
            lblGenerateFor.Text     = ddlBank.SelectedItem.Text.Trim();
            lblGenerateForTab2.Text = ddlBank.SelectedItem.Text.Trim();
            break;

        case "B":
            strGenerateValue        = ddlBank.SelectedValue.ToString();
            lblGenerateFor.Text     = ddlBank.SelectedItem.Text.Trim();
            lblGenerateForTab2.Text = ddlBank.SelectedItem.Text.Trim();
            break;
        }

        DataTable dtSalaryHead = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        DataTable dtHeadCount  = objPayRptMgr.GetHeadCount();

        DataRow[] founHCRows = dtHeadCount.Select("DISPLAYTYPE='B'");
        inBenefitHeadCount = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);
        founHCRows         = null;
        founHCRows         = dtHeadCount.Select("DISPLAYTYPE='D'");
        inDeductCount      = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);

        // Audited Data
        dtEmpPayroll = objPayAppMgr.GetAuditedDataForEndorcement(ddlGeneratefor.SelectedValue.ToString(), strGenerateValue,
                                                                 ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), ddlBank.SelectedValue.Trim());
        this.GenerateReport(grAuditList, dtSalaryHead, inBenefitHeadCount, lblGenerateFor, lblPayrollMonth);
        if (grAuditList.Rows.Count > 0)
        {
            lblPreparedBy.Text   = dtEmpPayroll.Rows[0]["PREPAREDBY"].ToString().Trim();
            lblPreparedDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) : "";

            lblReviewedBy.Text = dtEmpPayroll.Rows[0]["REVIEWEDBY"].ToString().Trim();
            lblReviewDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) : "";

            lblCheckedBy.Text = dtEmpPayroll.Rows[0]["CHECKEDBY"].ToString().Trim();
            //lblCheckDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) == false ? Common.DisplayDateTime(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) : "";
        }
        else
        {
            lblPreparedBy.Text   = "";
            lblPreparedDate.Text = "";
            lblReviewedBy.Text   = "";
            lblReviewDate.Text   = "";
            lblCheckedBy.Text    = "";
            //lblCheckDate.Text = "";
        }

        // Approved Data
        dtEmpPayroll.Rows.Clear();
        dtEmpPayroll.Dispose();
        dtEmpPayroll = objPayAppMgr.GetPayrollApprovedData(ddlGeneratefor.SelectedValue.ToString(), strGenerateValue,
                                                           ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), ddlBank.SelectedValue.Trim());
        this.GenerateReport(grApproveList, dtSalaryHead, inBenefitHeadCount, lblGenerateForTab2, lblPayrollMonthTab2);
        if (grApproveList.Rows.Count > 0)
        {
            lblPreparedByTab2.Text   = dtEmpPayroll.Rows[0]["PREPAREDBY"].ToString().Trim();
            lblPreparedDateTab2.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) : "";

            lblReviewedByTab2.Text = dtEmpPayroll.Rows[0]["REVIEWEDBY"].ToString().Trim();
            lblReviewDateTab2.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) : "";

            //lblCheckedByTab2.Text = dtEmpPayroll.Rows[0]["CHECKEDBY"].ToString().Trim();
            //lblCheckDateTab2.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) == false ? Common.DisplayDateTime(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) : "";
            lblApprovedByTab2.Text  = dtEmpPayroll.Rows[0]["APPROVEDBY"].ToString().Trim();
            lblApproveDateTab2.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) : "";

            lblDisburseByTab2.Text   = Common.CheckNullString(dtEmpPayroll.Rows[0]["DISBURSEBY"].ToString().Trim());
            lblDisburseDatetab2.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) : "";
        }
        else
        {
            lblPreparedByTab2.Text   = "";
            lblPreparedDateTab2.Text = "";
            lblReviewedByTab2.Text   = "";
            lblReviewDateTab2.Text   = "";
            //lblCheckedByTab2.Text = "";
            //lblCheckDateTab2.Text = "";
            lblApprovedByTab2.Text   = "";
            lblApproveDateTab2.Text  = "";
            lblDisburseByTab2.Text   = "";
            lblDisburseDatetab2.Text = "";
        }


        // Tab Container Height
        int inHeightRev = grAuditList.Rows.Count * 18 + 50;
        int inHeightAud = grApproveList.Rows.Count * 18 + 50;

        if (inHeightRev < 430)
        {
            inHeightRev = 430;
        }
        if (inHeightAud < 430)
        {
            inHeightAud = 430;
        }

        if (inHeightRev > inHeightAud)
        {
            TabContainer1.Height = Unit.Pixel(inHeightRev);
        }
        else
        {
            TabContainer1.Height = Unit.Pixel(inHeightAud);
        }
        if (grAuditList.Rows.Count > 0)
        {
            TabContainer1.ActiveTabIndex = 0;
        }
        else if (grApproveList.Rows.Count > 0)
        {
            TabContainer1.ActiveTabIndex = 1;
        }
        else
        {
            TabContainer1.ActiveTabIndex = 0;
        }
    }
Beispiel #2
0
    protected void GeneratePayrollReport()
    {
        string strEmpID         = "";
        string strGenerateValue = "";

        int     inBenefitHeadCount = 0;
        int     inDeductCount      = 0;
        decimal dclSalHeadAmt      = 0;

        switch (ddlGeneratefor.SelectedValue.ToString())
        {
        case "O":
            strGenerateValue    = ddlGenerateValue.SelectedValue.ToString();
            lblGenerateFor.Text = ddlGenerateValue.SelectedItem.Text.Trim();
            break;

        case "B":
            strGenerateValue    = ddlBank.SelectedValue.ToString();
            lblGenerateFor.Text = ddlBank.SelectedItem.Text.Trim();
            break;

        case "E":
            strGenerateValue = txtTextValue.Text.Trim();
            break;
        }
        lblIntervention.Text = "Intervention : " + ddlIntervention.SelectedItem.Text.Trim();
        dtSalaryHead         = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        dtHeadCount          = objPayRptMgr.GetHeadCount();
        DataRow[] founHCRows = dtHeadCount.Select("DISPLAYTYPE='B'");
        inBenefitHeadCount = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);
        founHCRows         = null;
        founHCRows         = dtHeadCount.Select("DISPLAYTYPE='D'");
        inDeductCount      = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);
        dtEmpPayroll   = objPayRptMgr.GetPayrollData(ddlIntervention.SelectedValue.Trim(), ddlGeneratefor.SelectedValue.ToString(), strGenerateValue, ddlMonth.SelectedValue.ToString(),
                                                     ddlYear.SelectedValue.ToString(), ddlBank.SelectedValue.Trim());

        this.InitializeSummaryTable(dtSalaryHead.Rows.Count + 8);

        int i = 5;
        int j = 1;

        foreach (DataRow dEmpRow in dtEmpPayroll.Rows)
        {
            dclEmpBenefits = 0;
            dclEmpDeduct   = 0;
            dclTotalSalary = 0;
            this.GetEmpBenefitsAmount(dtSalaryHead, dEmpRow["EMPID"].ToString().Trim(), dEmpRow["GROSSAMNT"].ToString());
            i = 5;
            if (strEmpID == dEmpRow["EMPID"].ToString().Trim())
            {
                continue;
            }
            DataRow nRow = dtPayrollSummary.NewRow();
            nRow[0] = dEmpRow["PAYID"].ToString().Trim();
            nRow[1] = dEmpRow["EMPID"].ToString().Trim();
            nRow[2] = dEmpRow["FULLNAME"].ToString().Trim();
            nRow[3] = dEmpRow["JobTitleName"].ToString().Trim();
            nRow[4] = dEmpRow["GradeName"].ToString().Trim();

            foreach (DataRow dSalRow in dtSalaryHead.Rows)
            {
                if (i - 5 == dtGrossSalHead.Rows.Count)
                {
                    nRow[i] = Common.RoundDecimal(dEmpRow["GROSSAMNT"].ToString(), 0);
                    i++;
                }
                //if ((i - 5) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                //{
                //    nRow[i] = dclEmpBenefits.ToString();
                //    i++;
                //}
                if ((i - 5) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                {
                    nRow[i] = dclTotalSalary.ToString();
                    i++;

                    dclSalHeadAmt = 0;
                    dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["EMPID"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                    if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                    {
                        if (dclSalHeadAmt > 0)
                        {
                            dclSalHeadAmt = dclSalHeadAmt * -1;
                        }
                    }

                    nRow[i] = dclSalHeadAmt.ToString();
                    i++;
                }
                else
                {
                    dclSalHeadAmt = 0;
                    dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["EMPID"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                    if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                    {
                        if (dclSalHeadAmt > 0)
                        {
                            dclSalHeadAmt = dclSalHeadAmt * -1;
                        }
                    }

                    nRow[i] = dclSalHeadAmt.ToString();
                    i++;
                }
            }

            nRow[i] = dclEmpDeduct.ToString();
            i++;

            nRow[i] = Common.RoundDecimal(dEmpRow["NETPAY"].ToString(), 0);
            i++;

            //nRow[i] = "0";
            //i++;

            //nRow[i] = dclEmpPF.ToString();

            dtPayrollSummary.Rows.Add(nRow);
            dtPayrollSummary.AcceptChanges();
            strEmpID = dEmpRow["EMPID"].ToString().Trim();
            j++;
        }

        grPayroll.DataSource = dtPayrollSummary;
        grPayroll.DataBind();
        if (dtPayrollSummary.Rows.Count > 0)
        {
            this.FormatGridView(grPayroll, dtSalaryHead, inBenefitHeadCount);
            this.GetSummaryTotal(grPayroll, ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), true);
            if (ddlGeneratefor.SelectedValue.Trim() == "E")
            {
                lblGenerateFor.Text = grPayroll.Rows[0].Cells[2].Text.Trim() + " [" + grPayroll.Rows[0].Cells[1].Text.Trim() + "] ";
            }
            //lblPayrollMonth.Text = "Salary for the month of " + Common.retMonthName(ddlMonth.SelectedValue.Trim()) + " " + ddlYear.SelectedItem.Text;


            strCurrMonthHeadCount = grPayroll.Rows.Count.ToString();
            lblCurrHeadCount.Text = "HR Count in " + Common.ReturnFullMonthName(ddlMonth.SelectedValue.Trim()) + " Payroll :  " + strCurrMonthHeadCount;

            this.InitializeMonthlySummaryTable(dtPayrollSummary.Columns.Count);
            this.FillMonthlySummary(grPayrollSummary);
            this.FormatGridView(grPayrollSummary, dtSalaryHead, inBenefitHeadCount);
            // this.FillMonthlySummary(grMovement);


            this.GetMonthlySummaryData(grPayrollSummary, grPayroll, 1, Common.ReturnFullMonthName(ddlMonth.SelectedValue.Trim()));


            this.InitializeResultTable(dtPayrollSummary.Columns.Count);
            this.FillSingeRowResult(grResult);
            this.FormatGridView(grResult, dtSalaryHead, inBenefitHeadCount);
        }
        else
        {
            lblCurrHeadCount.Text = "HR Count in " + Common.ReturnFullMonthName(ddlMonth.SelectedValue.Trim()) + " Payroll :  " + "0";

            this.InitializeMonthlySummaryTable(dtPayrollSummary.Columns.Count);
            this.FillMonthlySummary(grPayrollSummary);
            this.FormatGridView(grPayrollSummary, dtSalaryHead, inBenefitHeadCount);

            this.InitializeResultTable(dtPayrollSummary.Columns.Count);
            //this.FillMonthlySummary(grMovement);
            this.FillSingeRowResult(grResult);
            this.FormatGridView(grResult, dtSalaryHead, inBenefitHeadCount);
            grDetails.DataSource = null;
            grDetails.DataBind();
        }
    }
Beispiel #3
0
    protected void GeneratePayrollReport()
    {
        string  strEmpID           = "";
        string  strGenerateValue   = "";
        int     inBenefitHeadCount = 0;
        int     inDeductCount      = 0;
        decimal dclSalHeadAmt      = 0;

        switch (ddlGeneratefor.SelectedValue.ToString())
        {
        case "O":
            strGenerateValue    = ddlGenerateValue.SelectedValue.ToString();
            lblGenerateFor.Text = ddlGenerateValue.SelectedItem.Text.Trim();
            break;

        case "B":
            strGenerateValue    = ddlBank.SelectedValue.ToString();
            lblGenerateFor.Text = ddlBank.SelectedItem.Text.Trim();
            break;

        case "E":
            strGenerateValue = txtTextValue.Text.Trim();
            break;
        }

        DataTable dtSalaryHead = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        DataTable dtHeadCount  = objPayRptMgr.GetHeadCount();

        DataRow[] founHCRows = dtHeadCount.Select("DISPLAYTYPE='B'");
        inBenefitHeadCount = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);
        founHCRows         = null;
        founHCRows         = dtHeadCount.Select("DISPLAYTYPE='D'");
        inDeductCount      = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);
        dtEmpPayroll   = objPayRptMgr.GetPayrollDataSalaryTypeWise(ddlGeneratefor.SelectedValue.ToString(), strGenerateValue,
                                                                   ddlMonth.SelectedValue.ToString(), ddlYear.SelectedValue.ToString(), ddlBank.SelectedValue.Trim());

        this.InitializeSummaryTable(dtSalaryHead.Rows.Count + 11);

        int i = 5;
        int j = 1;

        foreach (DataRow dEmpRow in dtEmpPayroll.Rows)
        {
            dclEmpBenefits = 0;
            dclEmpDeduct   = 0;
            dclTotalSalary = 0;
            this.GetEmpBenefitsAmount(dtSalaryHead, dEmpRow["EMPID"].ToString().Trim(), dEmpRow["GROSSAMNT"].ToString());
            i = 5;
            if (strEmpID == dEmpRow["EMPID"].ToString().Trim())
            {
                continue;
            }

            DataRow nRow = dtPayrollSummary.NewRow();
            nRow[0] = Convert.ToString(j);
            nRow[1] = dEmpRow["EMPID"].ToString().Trim();
            nRow[2] = dEmpRow["FULLNAME"].ToString().Trim();
            nRow[3] = dEmpRow["JobTitleName"].ToString().Trim();
            nRow[4] = dEmpRow["GradeName"].ToString().Trim();

            foreach (DataRow dSalRow in dtSalaryHead.Rows)
            {
                if (i - 5 == dtGrossSalHead.Rows.Count)
                {
                    nRow[i] = Common.RoundDecimal(dEmpRow["GROSSAMNT"].ToString(), 0);
                    i++;
                }

                //if ((i - 5) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                //{
                //    nRow[i] = dclEmpBenefits.ToString();
                //    i++;
                //}

                if ((i - 5) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                {
                    nRow[i] = dclTotalSalary.ToString();
                    i++;

                    dclSalHeadAmt = 0;
                    dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["EMPID"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                    if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                    {
                        if (dclSalHeadAmt > 0)
                        {
                            dclSalHeadAmt = dclSalHeadAmt * -1;
                        }
                    }

                    nRow[i] = dclSalHeadAmt.ToString();
                    i++;
                }
                else
                {
                    dclSalHeadAmt = 0;
                    dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["EMPID"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                    if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                    {
                        if (dclSalHeadAmt > 0)
                        {
                            dclSalHeadAmt = dclSalHeadAmt * -1;
                        }
                    }

                    nRow[i] = dclSalHeadAmt.ToString();
                    i++;
                }
            }

            nRow[i] = dclEmpDeduct.ToString();
            i++;

            nRow[i] = Common.RoundDecimal(dEmpRow["NETPAY"].ToString(), 0);
            i++;

            nRow[i] = "0";
            i++;

            nRow[i] = dclEmpPF.ToString();

            dtPayrollSummary.Rows.Add(nRow);
            dtPayrollSummary.AcceptChanges();
            strEmpID = dEmpRow["EMPID"].ToString().Trim();
            j++;
        }

        grPayroll.DataSource = dtPayrollSummary;
        grPayroll.DataBind();

        if (dtPayrollSummary.Rows.Count > 0)
        {
            this.FormatGridView(dtSalaryHead, inBenefitHeadCount);
            this.GetSummaryTotal();
            if (ddlGeneratefor.SelectedValue.Trim() == "E")
            {
                lblGenerateFor.Text = grPayroll.Rows[0].Cells[2].Text.Trim() + " [" + grPayroll.Rows[0].Cells[1].Text.Trim() + "] ";
            }
            lblPayrollMonth.Text = "Salary for the month of " + ddlMonth.SelectedItem.Text + " " + ddlYear.SelectedItem.Text;

            lblPreparedBy.Text   = dtEmpPayroll.Rows[0]["PREPAREDBY"].ToString().Trim();
            lblPreparedDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) : "";

            lblReviewedBy.Text = dtEmpPayroll.Rows[0]["REVIEWEDBY"].ToString().Trim();
            lblReviewDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) : "";

            //lblCheckedBy.Text = dtEmpPayroll.Rows[0]["CHECKEDBY"].ToString().Trim();
            //lblCheckDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) == false ? Common.DisplayDateTime(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) : "";
            lblApprovedBy.Text  = dtEmpPayroll.Rows[0]["APPROVEDBY"].ToString().Trim();
            lblApproveDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) : "";

            lblDisburseBy.Text   = dtEmpPayroll.Rows[0]["DISBURSEBY"].ToString().Trim();
            lblDisburseDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) : "";
        }
        else
        {
            lblGenerateFor.Text  = "";
            lblPayrollMonth.Text = "";
            lblPreparedBy.Text   = "";
            lblPreparedDate.Text = "";
            lblReviewedBy.Text   = "";
            lblReviewDate.Text   = "";
            //lblCheckedBy.Text = "";
            //lblCheckDate.Text = "";
            lblApprovedBy.Text   = "";
            lblApproveDate.Text  = "";
            lblDisburseBy.Text   = "";
            lblDisburseDate.Text = "";
        }
    }
    protected void GeneratePayrollReport()
    {
        string  strVmonth          = "";
        int     inBenefitHeadCount = 0;
        int     inDeductCount      = 0;
        decimal dclSalHeadAmt      = 0;

        //lblGenerateFor.Text = ddlGenerateValue.SelectedItem.Text.Trim();
        DataTable dtSalaryHead = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        DataTable dtHeadCount  = objPayRptMgr.GetHeadCount();

        DataRow[] founHCRows = dtHeadCount.Select("DISPLAYTYPE='B'");
        inBenefitHeadCount = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);
        founHCRows         = null;
        founHCRows         = dtHeadCount.Select("DISPLAYTYPE='D'");
        inDeductCount      = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);
        dtEmpPayroll   = objPayRptMgr.GetEmpWiseSalaryDataForFiscalYear(ddlFiscalYear.SelectedValue.Trim(), ddlEmployee.SelectedValue.Trim());

        DataRow[] fEmpPayrollRow;
        this.InitializeSummaryTable(dtSalaryHead.Rows.Count + 8);

        int i = 2;
        int j = 1;

        //foreach (DataRow dEmpRow in dtEmpPayroll.Rows)
        for (int k = 1; k <= 12; k++)
        {
            dclEmpBenefits = 0;
            dclEmpDeduct   = 0;
            dclTotalSalary = 0;
            fEmpPayrollRow = null;
            switch (k)
            {
            case 1:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 7);
                break;

            case 2:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 8);
                break;

            case 3:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 9);
                break;

            case 4:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 10);
                break;

            case 5:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 11);
                break;

            case 6:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 12);
                break;

            case 7:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 1);
                break;

            case 8:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 2);
                break;

            case 9:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 3);
                break;

            case 10:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 4);
                break;

            case 11:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 5);
                break;

            case 12:
                fEmpPayrollRow = dtEmpPayroll.Select("VMONTH = " + 6);
                break;
            }
            if (fEmpPayrollRow.Length > 0)
            {
                foreach (DataRow dEmpRow in fEmpPayrollRow)
                {
                    this.GetEmpBenefitsAmount(dtSalaryHead, dEmpRow["VMONTH"].ToString().Trim(), dEmpRow["GROSSAMNT"].ToString());
                    i = 2;
                    if (strVmonth == dEmpRow["VMONTH"].ToString().Trim())
                    {
                        continue;
                    }
                    DataRow nRow = dtPayrollSummary.NewRow();
                    nRow[0] = Convert.ToString(j);
                    nRow[1] = Common.ReturnFullMonthName(dEmpRow["VMONTH"].ToString().Trim()) + "-" + dEmpRow["VYEAR"].ToString().Trim();

                    foreach (DataRow dSalRow in dtSalaryHead.Rows)
                    {
                        if (i - 2 == dtGrossSalHead.Rows.Count)
                        {
                            nRow[i] = Common.RoundDecimal(dEmpRow["GROSSAMNT"].ToString(), 0);
                            i++;
                        }
                        //if ((i - 2) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                        //{
                        //    nRow[i] = dclEmpBenefits.ToString();
                        //    i++;
                        //}
                        if ((i - 2) - dtGrossSalHead.Rows.Count == inBenefitHeadCount + 1)
                        {
                            nRow[i] = dclTotalSalary.ToString();
                            i++;

                            dclSalHeadAmt = 0;
                            dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["VMONTH"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                            if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                            {
                                if (dclSalHeadAmt > 0)
                                {
                                    dclSalHeadAmt = dclSalHeadAmt * -1;
                                }
                            }

                            nRow[i] = dclSalHeadAmt.ToString();
                            i++;
                        }
                        else
                        {
                            dclSalHeadAmt = 0;
                            dclSalHeadAmt = this.GetSalHeadAmt(dEmpRow["VMONTH"].ToString().Trim(), dSalRow["SHEADID"].ToString().Trim());
                            if (dSalRow["DISPLAYTYPE"].ToString().Trim() == "D")
                            {
                                if (dclSalHeadAmt > 0)
                                {
                                    dclSalHeadAmt = dclSalHeadAmt * -1;
                                }
                            }

                            nRow[i] = dclSalHeadAmt.ToString();
                            i++;
                        }
                    }

                    nRow[i] = dclEmpDeduct.ToString();
                    i++;

                    nRow[i] = Common.RoundDecimal(dEmpRow["NETPAY"].ToString(), 0);
                    i++;

                    nRow[i] = "0";
                    i++;

                    nRow[i] = dclEmpPF.ToString();

                    dtPayrollSummary.Rows.Add(nRow);
                    dtPayrollSummary.AcceptChanges();
                    strVmonth = dEmpRow["VMONTH"].ToString().Trim();
                    j++;
                }
            }
            //else
            //{
            //    DataRow nRow = dtPayrollSummary.NewRow();
            //    nRow[0] = Convert.ToString(j);
            //    nRow[1] = dEmpRow["EMPID"].ToString().Trim();
            //    nRow[2] = dEmpRow["FULLNAME"].ToString().Trim();
            //    nRow[3] = dEmpRow["ACCLINE"].ToString().Trim();
            //    dtPayrollSummary.Rows.Add(nRow);
            //    dtPayrollSummary.AcceptChanges();
            //}
        }

        grPayroll.DataSource = dtPayrollSummary;
        grPayroll.DataBind();
        if (dtPayrollSummary.Rows.Count > 0)
        {
            this.FormatGridView(dtSalaryHead, inBenefitHeadCount);
            this.GenerateMovement();
            //this.GetSummaryTotal();

            //if (ddlGeneratefor.SelectedValue.Trim() == "E")
            lblGenerateFor.Text  = "Payroll Movement For: " + ddlEmployee.SelectedItem.Text.Trim();
            lblPayrollMonth.Text = "Fiscal Year: " + ddlFiscalYear.SelectedItem.Text;
        }
        else
        {
            lblGenerateFor.Text  = "";
            lblPayrollMonth.Text = "";
        }
    }
    protected void GeneratePayrollReport()
    {
        string strGenerateValue   = "";
        int    inBenefitHeadCount = 0;
        int    inDeductCount      = 0;

        switch (ddlGeneratefor.SelectedValue.ToString())
        {
        case "B":
            strGenerateValue    = ddlBank.SelectedValue.ToString();
            lblGenerateFor.Text = ddlBank.SelectedItem.Text.Trim();
            break;
        }

        DataTable dtSalaryHead = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        DataTable dtHeadCount  = objPayRptMgr.GetHeadCount();

        DataRow[] founHCRows = dtHeadCount.Select("DISPLAYTYPE='B'");
        inBenefitHeadCount = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);
        founHCRows         = null;
        founHCRows         = dtHeadCount.Select("DISPLAYTYPE='D'");
        inDeductCount      = Convert.ToInt32(founHCRows[0]["HEADCOUNT"]);

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);

        // Approved Data
        dtEmpPayroll.Rows.Clear();
        dtEmpPayroll.Dispose();
        dtEmpPayroll = objPayAppMgr.GetPayrollApprovedDataForDisbursement(ddlIntervention.SelectedValue.Trim(), ddlOffice.SelectedValue.Trim(), ddlGeneratefor.SelectedValue.ToString(), strGenerateValue, ddlMonth.SelectedValue.ToString(),
                                                                          ddlYear.SelectedValue.ToString(), ddlBank.SelectedValue.Trim(), ddlEmpType.SelectedValue.ToString());
        this.GenerateReport(grApproveList, dtSalaryHead, inBenefitHeadCount, lblGenerateFor, lblPayrollMonth);
        if (grApproveList.Rows.Count > 0)
        {
            lblPreparedBy.Text   = dtEmpPayroll.Rows[0]["PREPAREDBY"].ToString().Trim();
            lblPreparedDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["PREPARINGDATE"].ToString().Trim()) : "";

            lblReviewedBy.Text = dtEmpPayroll.Rows[0]["REVIEWEDBY"].ToString().Trim();
            lblReviewDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["REVIEWDATE"].ToString().Trim()) : "";

            //lblCheckedBy.Text = dtEmpPayroll.Rows[0]["CHECKEDBY"].ToString().Trim();
            //lblCheckDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) == false ? Common.DisplayDateTime(dtEmpPayroll.Rows[0]["CHECKDATE"].ToString().Trim()) : "";
            lblApprovedBy.Text  = dtEmpPayroll.Rows[0]["APPROVEDBY"].ToString().Trim();
            lblApproveDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["APPROVINGDATE"].ToString().Trim()) : "";

            lblDisburseBy.Text   = dtEmpPayroll.Rows[0]["DISBURSEBY"].ToString().Trim();
            lblDisburseDate.Text = string.IsNullOrEmpty(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) == false?Common.DisplayDateTime(dtEmpPayroll.Rows[0]["DISBURSINGDATE"].ToString().Trim()) : "";

            if (string.IsNullOrEmpty(lblDisburseBy.Text) == false)
            {
                btnDisburse.Enabled = false;
            }
            else
            {
                btnDisburse.Enabled = true;
            }
        }
        else
        {
            lblPreparedBy.Text   = "";
            lblPreparedDate.Text = "";
            lblReviewedBy.Text   = "";
            lblReviewDate.Text   = "";
            //lblCheckedBy.Text = "";
            //lblCheckDate.Text = "";
            lblApprovedBy.Text   = "";
            lblApproveDate.Text  = "";
            lblDisburseBy.Text   = "";
            lblDisburseDate.Text = "";
        }
    }