private void btnExportExcel_Click(object sender, EventArgs e) { try { DateTime?fromDate = (dtpFromDate.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); DateTime?tillDate = (dtpTillDate.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); 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; } int companyId = ddlCompany.SelectedValue.ToInt(); int driverId = ddlDriver.SelectedValue.ToInt(); int SubCompanyId = ddlSubCompany.SelectedValue.ToInt(); long FleetMasterId = ddlCompanyVehicle.SelectedValue.ToLong(); rptfrmIncome frm = new rptfrmIncome(); frm.ReportHeading = "Income Report for Date Range :" + string.Format("{0:dd/MM/yyyy HH:mm}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy HH:mm}", tillDate); frm.DataSource = GetDataSource(fromDate, tillDate, companyId, driverId, SubCompanyId, FleetMasterId); frm.GenerateReport(); frm.ExportReportToExcel(); } catch (Exception) { throw; } }
public override void Print() { DateTime?fromDate = (dtpFromDate.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); DateTime?tillDate = (dtpTillDate.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); 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; } int companyId = ddlCompany.SelectedValue.ToInt(); int driverId = ddlDriver.SelectedValue.ToInt(); int SubCompanyId = ddlSubCompany.SelectedValue.ToInt(); long FleetMasterId = ddlCompanyVehicle.SelectedValue.ToLong(); rptfrmIncome frm = new rptfrmIncome(); frm.ReportHeading = "Income Report for Date Range :" + string.Format("{0:dd/MM/yyyy HH:mm}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy HH:mm}", tillDate); frm.DataSource = GetDataSource(fromDate, tillDate, companyId, driverId, SubCompanyId, FleetMasterId); frm.GenerateReport(); DockWindow doc = UI.MainMenuForm.MainMenuFrm.GetDockByName("rptfrmIncome1"); if (doc != null) { doc.Close(); } UI.MainMenuForm.MainMenuFrm.ShowForm(frm); }