public void GenerateReport() { try { string website = AppVars.objSubCompany.WebsiteUrl.ToStr(); reportViewer1.LocalReport.EnableExternalImages = true; Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[10]; decimal SurchargeAmount = 0.00m; string cardNumber = string.Empty; if (this.DataSource.Count > 0 && (this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.BANK_ACCOUNT || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD_PAID) && this.DataSource[0].AuthCode.ToStr().Trim().Length > 0) { Booking_Payment objPayment = General.GetObject <Booking_Payment>(c => c.BookingId == this.DataSource.FirstOrDefault().Id).DefaultIfEmpty(); if (objPayment != null) { SurchargeAmount = objPayment.SurchargeAmount.ToDecimal(); if (objPayment.CardNumber.ToStr().Length >= 16) { cardNumber = "**************" + objPayment.CardNumber.Substring(14).ToStr(); } } this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns.rptJobDetails4_acc.rdlc"; //this.reportViewer1.LocalReport.ReportPath = "Taxi_AppMain.ReportDesigns.rptJobDetails4_acc.rdlc"; } if (this.DataSource.Count(c => c.CompanyId != null) > 0) { this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns.rptJobDetails4_acc.rdlc"; // this.reportViewer1.LocalReport.ReportPath = "Taxi_AppMain.ReportDesigns.rptJobDetails4_acc.rdlc"; } List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyLogo", path); string header = " " + AppVars.objSubCompany.Address.ToStr() + ",\n" + " Telephone No:" + AppVars.objSubCompany.TelephoneNo; // header += ", Fax:" + AppVars.objSubCompany.Fax.ToStr(); header += "\n Email:" + AppVars.objSubCompany.EmailAddress.ToStr() + ", Website:" + AppVars.objSubCompany.WebsiteUrl; // DateTime ? dtPrintDate=DateTime.Now.ToDate(); string PrintDate = "Print date : " + string.Format("{0:dd-MMMM-yy HH:MM}", DateTime.Now.ToDateTime()); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Header", header); param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr()); param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyPhone", AppVars.objSubCompany.TelephoneNo.ToStr()); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_PrintDate", PrintDate); param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CreditCardExtraCharges", SurchargeAmount.ToStr()); //AppVars.objPolicyConfiguration.CreditCardExtraCharges.ToStr()); //Report_Parameter_CreditCardExtraCharges param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CardNumber", cardNumber); param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VatNumber", AppVars.objSubCompany.CompanyVatNumber.ToStr()); decimal fullTotal = Math.Round(SurchargeAmount + this.DataSource.FirstOrDefault().DefaultIfEmpty().TotalCharges.ToDecimal(), 2); param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", fullTotal.ToStr()); reportViewer1.LocalReport.SetParameters(param); this.Vu_BookingDetailBindingSource.DataSource = this.DataSource; this.reportViewer1.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local; this.reportViewer1.ZoomPercent = 100; this.reportViewer1.SetDisplayMode(DisplayMode.Normal); this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); //if (retrycnt == 0) //{ // retrycnt = 1; // GenerateReport(); //} //else General.AddLog(ex.Message + ",Target : " + ex.TargetSite + ",Source : " + ex.Source + ",Stack Trace :" + ex.StackTrace, Environment.MachineName.ToStr()); } }
public void GenerateReport() { try { if (this.DataSource.Count > 0 && this.DataSource[0].AuthCode.ToStr().Trim().Length > 0) { chkPaymentSummary.Visible = true; } reportViewer1.LocalReport.EnableExternalImages = true; Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[6]; objSubCompany = AppVars.objSubCompany; if (this.DataSource.Count > 0 && this.DataSource[0].SubCompanyId != null) { objSubCompany = General.GetObject <Gen_SubCompany>(c => c.Id == this.DataSource[0].SubCompanyId); if (objSubCompany == null) { objSubCompany = AppVars.objSubCompany; } } List <ClsLogo> objLogo = new List <ClsLogo>(); objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null }); ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo); this.reportViewer1.LocalReport.DataSources.Add(imageDataSource); string path = @"File:"; param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyLogo", path); string header = " " + objSubCompany.Address.ToStr() + ",\n" + " Telephone No:" + objSubCompany.TelephoneNo; header += ". Fax:" + objSubCompany.Fax.ToStr(); header += "\nEmergency Contact No:" + objSubCompany.EmergencyNo.ToStr() + ". " + objSubCompany.WebsiteUrl; header += "\n Email:" + objSubCompany.EmailAddress.ToStr(); param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Header", header); decimal SurchargeAmount = 0.00m; string cardNumber = string.Empty; if (chkPaymentSummary.Checked && this.DataSource.Count > 0 && (this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.BANK_ACCOUNT || this.DataSource[0].PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD_PAID) && this.DataSource[0].AuthCode.ToStr().Trim().Length > 0) { Booking_Payment objPayment = General.GetObject <Booking_Payment>(c => c.BookingId == this.DataSource.FirstOrDefault().Id).DefaultIfEmpty(); if (objPayment != null) { SurchargeAmount = objPayment.SurchargeAmount.ToDecimal(); if (objPayment.CardNumber.ToStr().Length >= 16) { cardNumber = "**************" + objPayment.CardNumber.Substring(14).ToStr(); } } } string criteria = ddlCriteria.Text; if (this.DataSource.Count > 0) { if (this.DataSource[0].CompanyId.ToInt() == 0 && criteria == "Customer") { criteria = "Driver"; } } param[2] = new Microsoft.Reporting.WinForms.ReportParameter("CreditCardExtraCharges", SurchargeAmount.ToStr()); //AppVars.objPolicyConfiguration.CreditCardExtraCharges.ToStr()); //Report_Parameter_CreditCardExtraCharges param[3] = new Microsoft.Reporting.WinForms.ReportParameter("CardNumber", cardNumber); param[4] = new Microsoft.Reporting.WinForms.ReportParameter("ReportFor", criteria); param[5] = new Microsoft.Reporting.WinForms.ReportParameter("PaymentSummary", chkPaymentSummary.Checked?"1":"0"); reportViewer1.LocalReport.SetParameters(param); //ReportDataSource data = new ReportDataSource("vuBookingDetailBindingSource", this.DataSource); //this.reportViewer1.LocalReport.DataSources.Add(data); this.vuBookingDetailBindingSource.DataSource = this.DataSource; this.reportViewer1.ZoomPercent = 100; //if (Debugger.IsAttached) //{ // this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); //} ////else // this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout); this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent; this.reportViewer1.RefreshReport(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }