private void btnExportPDF_Click(object sender, EventArgs e) { try { int? driverId = ddl_Driver.SelectedValue.ToIntorNull(); DateTime?fromDate = dtpFromDate.Value.ToDate(); DateTime?tillDate = dtpTillDate.Value.ToDate(); string error = string.Empty; if (fromDate == null) { if (string.IsNullOrEmpty(error)) { error += Environment.NewLine; } error += "Required : From Date"; } if (tillDate == null) { if (string.IsNullOrEmpty(error)) { error += Environment.NewLine; } error += "Required : To Date"; } if (!string.IsNullOrEmpty(error)) { ENUtils.ShowMessage(error); return; } rptfrmDrvRentAccStatmentSummary frm = new rptfrmDrvRentAccStatmentSummary(); frm.DataSource = GetDataSource(driverId, fromDate, tillDate); frm.DatePeriod = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate); frm.GenerateReport(); frm.ExportReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
public override void Print() { try { int? driverId = ddl_Driver.SelectedValue.ToIntorNull(); DateTime?fromDate = dtpFromDate.Value.ToDate(); DateTime?tillDate = dtpTillDate.Value.ToDate(); string error = string.Empty; if (fromDate == null) { if (string.IsNullOrEmpty(error)) { error += Environment.NewLine; } error += "Required : From Date"; } if (tillDate == null) { if (string.IsNullOrEmpty(error)) { error += Environment.NewLine; } error += "Required : To Date"; } if (!string.IsNullOrEmpty(error)) { ENUtils.ShowMessage(error); return; } rptfrmDrvRentAccStatmentSummary frm = new rptfrmDrvRentAccStatmentSummary(); frm.DataSource = GetDataSource(driverId, fromDate, tillDate); frm.DatePeriod = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate); frm.GenerateReport(); DockWindow doc = UI.MainMenuForm.MainMenuFrm.GetDockByName("rptfrmDrvRentAccStatmentSummary1"); if (doc != null) { doc.Close(); } UI.MainMenuForm.MainMenuFrm.ShowForm(frm); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }