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(); } }