Example #1
0
    private void OpenRecord()
    {
        dtSalaryHead   = objPayrollMgr.SelectSalaryHead(0, "");
        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);
        dtTotalSalHead = objPayrollMgr.SelectTotalSalHeadWithSeq(0);

        grTotalSalary.DataSource = dtSalaryHead;
        grTotalSalary.DataBind();
        DataRow[] foundRows;
        DataRow[] foundGrRows;
        DataRow[] foundRptRows;
        string    strExpr      = "";
        string    strExprGross = "";

        for (int i = 0; i < grTotalSalary.Rows.Count; i++)
        {
            strExpr      = "SHEADID=" + grTotalSalary.DataKeys[i].Values[0].ToString().Trim();
            strExprGross = "SHEADID=" + grTotalSalary.DataKeys[i].Values[0].ToString().Trim();
            foundRows    = dtTotalSalHead.Select(strExpr);
            foundGrRows  = dtGrossSalHead.Select(strExprGross);

            HiddenField hfDT = (HiddenField)grTotalSalary.Rows[i].FindControl("hfDispType");


            if (foundRows.Length > 0)
            {
                CheckBox chBox = (CheckBox)grTotalSalary.Rows[i].FindControl("chkBox");
                chBox.Checked = true;

                TextBox txtSN = (TextBox)grTotalSalary.Rows[i].FindControl("txtSeqNo");
                txtSN.Text = foundRows[0]["SEQNO"].ToString().Trim();
            }
            if (foundGrRows.Length > 0)
            {
                hfDT.Value = "S";
                grTotalSalary.Rows[i].Cells[2].Text = "Salary";
            }
            else
            {
                if (grTotalSalary.DataKeys[i].Values[1].ToString().Trim() == "1")
                {
                    hfDT.Value = "B";
                    grTotalSalary.Rows[i].Cells[2].Text = "Benefit";
                }
                else if (grTotalSalary.DataKeys[i].Values[1].ToString().Trim() == "-1")
                {
                    hfDT.Value = "D";
                    grTotalSalary.Rows[i].Cells[2].Text = "Deduction";
                }
            }
            foundGrRows = null;
            foundRows   = null;
        }
    }
    private void OpenRecord()
    {
        dtSalaryHead = objPayrollMgr.SelectSalaryHead(0, "N");

        dtGrossSalHead = objPayrollMgr.SelectGrossSalHead(0);

        grGrossSalary.DataSource = dtSalaryHead;
        grGrossSalary.DataBind();
        DataRow[] foundRows;
        string    strExpr = "";

        for (int i = 0; i < grGrossSalary.Rows.Count; i++)
        {
            strExpr   = "SHEADID=" + grGrossSalary.DataKeys[i].Values[0].ToString().Trim();
            foundRows = dtGrossSalHead.Select(strExpr);
            if (foundRows.Length > 0)
            {
                CheckBox chBox = (CheckBox)grGrossSalary.Rows[i].FindControl("chkBox");
                chBox.Checked = true;
            }
        }
    }
    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;
        }
    }
Example #4
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();
        }
    }
    private void OpenRecord()
    {
        DataTable dtSalaryHead    = objPayrollMgr.SelectSalaryHead(0, "");
        DataTable dtGrossSalHead  = objPayrollMgr.SelectGrossSalHead(0);
        DataTable dtTotalSalHead  = objPayrollMgr.SelectTotalSalHeadWithSeq(0);
        DataTable dtReportSalHead = objPayRptMgr.SelectSalHeadWithSeqForReport(1);

        DataRow nRow = dtSalaryHead.NewRow();

        nRow["SHEADID"]    = "99999";
        nRow["HEADNAME"]   = "Gross Salary";
        nRow["HEADNATURE"] = "2";
        nRow["DEFALTAMNT"] = "0.00";
        dtSalaryHead.Rows.Add(nRow);
        dtSalaryHead.AcceptChanges();
        grSalItem.DataSource = dtSalaryHead;
        grSalItem.DataBind();
        DataRow[] foundRows;
        DataRow[] foundGrRows;
        DataRow[] foundRptRows;
        string    strExpr      = "";
        string    strExprGross = "";

        for (int i = 0; i < grSalItem.Rows.Count; i++)
        {
            strExpr      = "SHEADID=" + grSalItem.DataKeys[i].Values[0].ToString().Trim();
            strExprGross = "SHEADID=" + grSalItem.DataKeys[i].Values[0].ToString().Trim();
            foundRows    = dtTotalSalHead.Select(strExpr);
            foundGrRows  = dtGrossSalHead.Select(strExprGross);
            foundRptRows = dtReportSalHead.Select(strExpr);

            if (grSalItem.DataKeys[i].Values[0].ToString().Trim() == "99999")
            {
                if (foundRptRows.Length > 0)
                {
                    CheckBox chBox1 = (CheckBox)grSalItem.Rows[i].FindControl("chkBox");
                    chBox1.Checked = true;
                    TextBox txtSN1 = (TextBox)grSalItem.Rows[i].FindControl("txtSeqNo");
                    txtSN1.Text = foundRptRows[0]["SEQNO"].ToString().Trim();
                }
                continue;
            }

            HiddenField hfDT = (HiddenField)grSalItem.Rows[i].FindControl("hfDispType");
            if (foundRptRows.Length > 0)
            {
                CheckBox chBox = (CheckBox)grSalItem.Rows[i].FindControl("chkBox");
                chBox.Checked = true;
                TextBox txtSN = (TextBox)grSalItem.Rows[i].FindControl("txtSeqNo");
                txtSN.Text = foundRptRows[0]["SEQNO"].ToString().Trim();
            }

            if (foundRows.Length == 0)
            {
                if (foundGrRows.Length == 0)
                {
                    grSalItem.Rows[i].Visible = false;
                    foundGrRows = null;
                    foundRows   = null;
                    continue;
                }
            }
            if (foundGrRows.Length > 0)
            {
                hfDT.Value = "S";
                grSalItem.Rows[i].Cells[2].Text = "Salary";
            }
            else
            {
                if (grSalItem.DataKeys[i].Values[1].ToString().Trim() == "1")
                {
                    hfDT.Value = "B";
                    grSalItem.Rows[i].Cells[2].Text = "Benefit";
                }
                else if (grSalItem.DataKeys[i].Values[1].ToString().Trim() == "-1")
                {
                    hfDT.Value = "D";
                    grSalItem.Rows[i].Cells[2].Text = "Deduction";
                }
            }
            foundGrRows = null;
            foundRows   = null;
        }
    }
    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 = "";
        }
    }
Example #7
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 = "";
        }
    }
    public string SaveAndApproveData(GridView gr, string strPSBID, string strEmdID, string strPayID, string strInsBy, string strInsDate)
    {
        DataTable dtGrossHead = objPayMstMgr.SelectGrossSalHead(0);

        SqlCommand[] command = new SqlCommand[gr.Rows.Count + 1];
        // Update Payslip Details Data
        int     i           = 0;
        decimal decNetPay   = 0;
        decimal dclGrossPay = 0;

        foreach (GridViewRow gRow in gr.Rows)
        {
            TextBox txtPAmt = (TextBox)gRow.Cells[2].FindControl("txtPayAmnt");
            decNetPay = decNetPay + Convert.ToDecimal(txtPAmt.Text.Trim());
            if (Common.FindInDataTable(dtGrossHead, "SHEADID", gr.DataKeys[gRow.DataItemIndex].Values[2].ToString().Trim(), "SHEADID") == gr.DataKeys[gRow.DataItemIndex].Values[2].ToString().Trim())
            {
                dclGrossPay = dclGrossPay + Common.RoundDecimal(txtPAmt.Text.Trim(), 2);
            }
            command[i] = this.UpdatePaySlipDetails(gr.DataKeys[gRow.DataItemIndex].Values[0].ToString(),
                                                   gr.DataKeys[gRow.DataItemIndex].Values[1].ToString(),
                                                   gr.DataKeys[gRow.DataItemIndex].Values[2].ToString(),
                                                   txtPAmt.Text,
                                                   strInsBy, strInsDate);
            i++;
        }
        // Update Payslip Master Data
        command[i]             = new SqlCommand("proc_Payroll_Update_PaySlipMst");
        command[i].CommandType = CommandType.StoredProcedure;

        SqlParameter p_PSBID = command[i].Parameters.Add("PSBID", SqlDbType.BigInt);

        p_PSBID.Direction = ParameterDirection.Input;
        p_PSBID.Value     = strPSBID;

        SqlParameter p_PAYID = command[i].Parameters.Add("PAYID", SqlDbType.BigInt);

        p_PAYID.Direction = ParameterDirection.Input;
        p_PAYID.Value     = strPayID;

        SqlParameter p_EMPID = command[i].Parameters.Add("EMPID", SqlDbType.Char);

        p_EMPID.Direction = ParameterDirection.Input;
        p_EMPID.Value     = strEmdID;

        SqlParameter p_NETPAY = command[i].Parameters.Add("NETPAY", SqlDbType.Decimal);

        p_NETPAY.Direction = ParameterDirection.Input;
        p_NETPAY.Value     = decNetPay;

        SqlParameter p_GROSSAMNT = command[i].Parameters.Add("GROSSAMNT", SqlDbType.Decimal);

        p_GROSSAMNT.Direction = ParameterDirection.Input;
        p_GROSSAMNT.Value     = dclGrossPay;

        SqlParameter p_PAYSLIPSTATUS = command[i].Parameters.Add("PAYSLIPSTATUS", SqlDbType.Char);

        p_PAYSLIPSTATUS.Direction = ParameterDirection.Input;
        p_PAYSLIPSTATUS.Value     = "P";

        SqlParameter p_INSERTEDBY = command[i].Parameters.Add("INSERTEDBY", SqlDbType.VarChar);

        p_INSERTEDBY.Direction = ParameterDirection.Input;
        p_INSERTEDBY.Value     = strInsBy;

        SqlParameter p_INSERTEDDATE = command[i].Parameters.Add("INSERTEDDATE", SqlDbType.DateTime);

        p_INSERTEDDATE.Direction = ParameterDirection.Input;
        p_INSERTEDDATE.Value     = strInsDate;

        objDC.MakeTransaction(command);
        return(decNetPay.ToString() + "," + dclGrossPay.ToString());
    }
    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 = "";
        }
    }