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