private void btnExportPDF_Click(object sender, EventArgs e) { try { DateTime?dtFrom = dtpFromDate.Value.ToDateorNull(); DateTime?dtTill = dtpToDate.Value.ToDateorNull(); if (dtFrom != null && dtpFromTime.Value != null && dtpFromTime.Value.Value != null) { dtFrom = (dtFrom.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); } if (dtTill != null && dtptilltime.Value != null && dtptilltime.Value.Value != null) { dtTill = (dtTill.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); } string Error = string.Empty; if (dtFrom == null) { Error = "Required: From Date"; } if (dtTill == null) { if (string.IsNullOrEmpty(Error)) { Error = "Required: To Date"; } else { Error += Environment.NewLine + "Required: To Date"; } } if (!string.IsNullOrEmpty(Error)) { ENUtils.ShowMessage(Error); return; } rptfrmDriverEarning frm = new rptfrmDriverEarning(); frm.LoadReport(); frm.ExportReport(); //DockWindow doc = UI.MainMenuForm.MainMenuFrm.GetDockByName("rptfrmDriverEarning1"); //if (doc != null) //{ // doc.Close(); //} //UI.MainMenuForm.MainMenuFrm.ShowForm(frm); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void btnExportExcel_Click(object sender, EventArgs e) { try { DateTime?dtFrom = dtpFromDate.Value.ToDateorNull(); DateTime?dtTill = dtpToDate.Value.ToDateorNull(); if (dtFrom != null && dtpFromTime.Value != null && dtpFromTime.Value.Value != null) { dtFrom = (dtFrom.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); } if (dtTill != null && dtptilltime.Value != null && dtptilltime.Value.Value != null) { dtTill = (dtTill.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); } string Error = string.Empty; if (dtFrom == null) { Error = "Required: From Date"; } if (dtTill == null) { if (string.IsNullOrEmpty(Error)) { Error = "Required: To Date"; } else { Error += Environment.NewLine + "Required: To Date"; } } if (!string.IsNullOrEmpty(Error)) { ENUtils.ShowMessage(Error); return; } rptfrmDriverEarning frm = new rptfrmDriverEarning(); frm.LoadReport(); frm.ExportReportToExcel("Excel"); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }