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 = "";
        }
    }