using Ease.CoreV35.Model; using Microsoft.Reporting.WinForms; using Payroll.BO; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Payroll.Report { public partial class fIncometaxCertificate : Form { #region Declaration and Constructor ObjectsTemplate _TaxParameters = null; int _nRow; public fIncometaxCertificate() { InitializeComponent(); } #endregion #region Events private void fIncometaxCertificate_Load(object sender, EventArgs e) { GetTaxParameter(); RefreshCbo(); lblTotalDeduction.Text = "0"; } private void dgvDeduction_CellValueChanged(object sender, DataGridViewCellEventArgs e) { double amount = 0; if (dgvDeduction.Rows.Count > 0) { foreach (DataGridViewRow item in dgvDeduction.Rows) { amount += Convert.ToDouble(item.Cells[1].Value); } } lblTotalDeduction.Text = amount.ToString(); } private void ctlEmployee_ItemChanged() { RefreshGrid(); } private void btnPreview_Click(object sender, EventArgs e) { if (ctlEmployee.SelectedEmployee != null) { fReportViewer form = new fReportViewer(); DataTable dt = new DataTable(); dt.Columns.Add("Description", typeof(string)); dt.Columns.Add("Amount", typeof(double)); DataRow dr = null; if (dgvDeduction.Rows.Count > 0) { foreach (DataGridViewRow item in dgvDeduction.Rows) { dr = dt.NewRow(); dr["Description"] = item.Cells[0].Value.ToString(); dr["Amount"] = Convert.ToDouble(item.Cells[1].Value); dt.Rows.Add(dr); } } DataSet dSet = new DataSet(); dt.TableName = "PayrollDataSet_IncometaxCertificate"; dSet.Tables.Add(dt); List parameters = new List(); parameters.Add(new ReportParameter("EmpName", ctlEmployee.SelectedEmployee.Employee.Name)); parameters.Add(new ReportParameter("FinancialYear", _TaxParameters[cboFesicalYear.SelectedIndex].FiscalYear)); parameters.Add(new ReportParameter("AssessmentYear", _TaxParameters[cboFesicalYear.SelectedIndex].AssessmentYear)); parameters.Add(new ReportParameter("Designation", ctlEmployee.SelectedEmployee.Employee.Designation.Name)); parameters.Add(new ReportParameter("AmountInWord", Ease.CoreV35.Utility.Global.NumericFunctions.TakaWords(Convert.ToDouble(lblTotalDeduction.Text)))); form.CommonReportView(null, dSet, "Payroll.Report.RDLC.IncometaxCertificate.rdlc", parameters); } else { MessageBox.Show("No Employee is selected", "Incometax Certificate", MessageBoxButtons.OK, MessageBoxIcon.Information); } } #endregion #region Private Functions private void GetTaxParameter() { _TaxParameters = TaxParameter.Get(false); } private void RefreshGrid() { dgvDeduction.Rows.Clear(); _nRow = 0; TaxParameter taxParameter = _TaxParameters[cboFesicalYear.SelectedIndex]; DateTime FiscalyearDatefrom = taxParameter.FiscalyearDatefrom; DateTime FiscalyearDateTo = taxParameter.FiscalyearDateTo; ObjectsTemplate osalaryMonthlys = SalaryMonthly.GetByDateRange(ctlEmployee.SelectedEmployee.EmployeeID, FiscalyearDatefrom, FiscalyearDateTo); double directorComputerRental = 0; foreach (SalaryMonthly item in osalaryMonthlys) { directorComputerRental += item.GetAmount(EnumSalaryGroup.Gross, EnumSalaryItemCode.Allowance, 7); } DataSet ds = IncomeTax.GetTaxCertificate(ctlEmployee.SelectedEmployee.EmployeeNo, _TaxParameters[cboFesicalYear.SelectedIndex].ID.Integer); if (ds != null) { foreach (DataRow dr in ds.Tables[0].Rows) { FillGrid(dr["Description"].ToString(), Convert.ToDouble(dr["Amount"].ToString()), directorComputerRental); } } } private void FillGrid(string sItemName, double nAmount, double directorComputerRental) { dgvDeduction.Rows.Add(1); dgvDeduction.Rows[_nRow].Cells[0].Value = sItemName; dgvDeduction.Rows[_nRow].Cells[1].Value = sItemName.Trim() == "Bonus & other allowance" ? GlobalFunctions.TakaFormat(GlobalFunctions.Round(nAmount + directorComputerRental)) : GlobalFunctions.TakaFormat(GlobalFunctions.Round(nAmount)); _nRow++; } private void RefreshCbo() { cboFesicalYear.Items.Clear(); foreach (TaxParameter oTaxParameter in _TaxParameters) { cboFesicalYear.Items.Add(oTaxParameter.FiscalYear); } if (cboFesicalYear.Items.Count > 0) cboFesicalYear.SelectedIndex = 0; } #endregion } }