/// <summary> /// Function to fill Datagridview /// </summary> public void GridFill() { try { SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP(); DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text); dgvSalaryPackageDetails.DataSource = dtbl; decCountAdditon = 0; decCountDeduction = 0; decTotalAmount = 0; foreach (DataGridViewRow dgvRaw in dgvSalaryPackageDetails.Rows) { if (dgvRaw.Cells["dgvtxttype"].Value.ToString() == "Addition") { decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString()); decCountAdditon = decCountAdditon + decAmt; } else { decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString()); decCountDeduction = decCountDeduction + decAmt; } if (dgvRaw.Cells["txtAmount"].Value != null && dgvRaw.Cells["txtAmount"].Value.ToString() != "") { decimal decAmt = Convert.ToDecimal(dgvRaw.Cells["txtAmount"].Value.ToString()); decTotalAmount = decTotalAmount + decAmt; } } txttotalReduction.Text = Math.Round(decCountDeduction, PublicVariables._inNoOfDecimalPlaces).ToString(); txttotalAddition.Text = Math.Round(decCountAdditon, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decCountAdditon); txtTotal.Text = Math.Round(decTotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); //Convert.ToString(decTotalAmount); } catch (Exception ex) { MessageBox.Show("SPDR:1" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// On 'Print' button click to Print /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { if (dgvSalaryPackageDetails.RowCount > 0) { DataTable dtblOther = new DataTable(); ////frmReport //frmReport = new frmReport(); DataSet ds = new DataSet(); CompanySP spCompany = new CompanySP(); DataTable dtblCompany = spCompany.CompanyViewDataTable(1); SalaryPackageDetailsSP spSalaryPackageDetails = new SalaryPackageDetailsSP(); DataTable dtbl = spSalaryPackageDetails.SalaryPackageDetailsForSalaryPackageDetailsReport(cmbSalaryPackage.Text); ds.Tables.Add(dtblCompany); ds.Tables.Add(dtbl); ds.Tables.Add(dtblOther); DataColumn dc = new DataColumn("Addition", typeof(decimal)); dtblOther.Columns.Add(dc); dc = new DataColumn("Deduction", typeof(decimal)); dtblOther.Columns.Add(dc); DataRow dr = dtblOther.NewRow(); dr[0] = decCountAdditon; dr[1] = decCountDeduction; dtblOther.Rows.InsertAt(dr, 0); //frmReport.MdiParent = formMDI.MDIObj; // frmreport.SalaryPackageDetailsReport(ds); } else { Messages.InformationMessage("No data found"); } } catch (Exception ex) { MessageBox.Show("SPDR:7" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }