/// <summary> /// On print button click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { frmReport crptReport = new frmReport(); DataSet ds = new DataSet(); List<DataTable> listObjFormat2 = new List<DataTable>(); DataTable dtblTotal = new DataTable(); //CompanySP spCompany = new CompanySP(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); List<DataTable> listObjCompany = new List<DataTable>(); listObjCompany = bllCompanyCreation.CompanyViewAll(); if (dgvVatreturn.Rows.Count > 0) { if (dtblFill.Rows.Count > 0) { DataTable dtblReportFill = new DataTable(); dtblReportFill.Columns.Add("SlNO"); dtblReportFill.Columns.Add("Invoice No"); dtblReportFill.Columns.Add("Date"); dtblReportFill.Columns.Add("Party Name"); dtblReportFill.Columns.Add("Mailing Name"); dtblReportFill.Columns.Add("Tin No"); dtblReportFill.Columns.Add("qt"); dtblReportFill.Columns.Add("Sales Amound"); dtblReportFill.Columns.Add("Tax Amount"); dtblReportFill.Columns.Add("Cess"); dtblReportFill.Columns.Add("Net Amount"); dtblReportFill.Columns.Add("billDiscount"); dtblReportFill.Columns.Add("grandtotal"); for (int i = 0; i < dgvVatreturn.Rows.Count; i++) { DataRow drow = dtblReportFill.NewRow(); if (dgvVatreturn.Rows[i].Cells["dgvtxtSlno"].Value != null) drow["SlNO"] = dgvVatreturn.Rows[i].Cells["dgvtxtSlno"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtInvoiceNo"].Value != null) drow["Invoice No"] = dgvVatreturn.Rows[i].Cells["dgvtxtInvoiceNo"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtDate"].Value != null) drow["Date"] = dgvVatreturn.Rows[i].Cells["dgvtxtDate"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtPartyName"].Value != null) drow["Party Name"] = dgvVatreturn.Rows[i].Cells["dgvtxtPartyName"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtMailingName"].Value.ToString() != string.Empty) drow["Mailing Name"] = dgvVatreturn.Rows[i].Cells["dgvtxtMailingName"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtTinNo"].Value != null) drow["Tin No"] = dgvVatreturn.Rows[i].Cells["dgvtxtTinNo"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtQty"].Value != null) drow["qt"] = dgvVatreturn.Rows[i].Cells["dgvtxtQty"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtSalesAmount"].Value != null) drow["Sales Amound"] = dgvVatreturn.Rows[i].Cells["dgvtxtSalesAmount"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtTaxAmount"].Value != null) drow["Tax Amount"] = dgvVatreturn.Rows[i].Cells["dgvtxtTaxAmount"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtCess"].Value != null) drow["Cess"] = dgvVatreturn.Rows[i].Cells["dgvtxtCess"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtNetAmount"].Value != null) drow["Net Amount"] = dgvVatreturn.Rows[i].Cells["dgvtxtNetAmount"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtbillDiscount"].Value != null) drow["billDiscount"] = dgvVatreturn.Rows[i].Cells["dgvtxtbillDiscount"].Value.ToString(); if (dgvVatreturn.Rows[i].Cells["dgvtxtGrandTotal"].Value != null) drow["grandtotal"] = dgvVatreturn.Rows[i].Cells["dgvtxtGrandTotal"].Value.ToString(); dtblReportFill.Rows.Add(drow); } ds.Tables.Add(dtblReportFill); ds.Tables.Add(listObjCompany[0]); crptReport.vatreturnReport(ds); } else { VoucherTypeBll BllVoucherType = new VoucherTypeBll(); listObjFormat2 = BllVoucherType.VatGridFill(DateTime.Parse(dtpFrmDate.Text), DateTime.Parse(dtpToDate.Text), cmbTypeofVoucher.Text, Convert.ToDecimal(cmbVouchertype.SelectedValue.ToString()), strformat, cmbTax.Text); if (dgvVatreturn.Rows.Count > 1) { dtblTotal.Columns.Add("taxableamt"); dtblTotal.Columns.Add("taxAmount"); DataRow dr1 = dtblTotal.NewRow(); dr1["taxableamt"] = dgvVatreturn.Rows[dgvVatreturn.Rows.Count - 2].Cells["dgvtxtTaxableAmount"].Value.ToString(); dr1["taxAmount"] = dgvVatreturn.Rows[dgvVatreturn.Rows.Count - 2].Cells["dgvtxttax"].Value.ToString(); dtblTotal.Rows.Add(dr1); ds.Tables.Add(listObjCompany[0]); ds.Tables.Add(listObjFormat2[0]); ds.Tables.Add(dtblTotal); crptReport.vatreturnReportFormat(ds); } } } else { MessageBox.Show("No data found", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("VRR:14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }