/// <summary> /// Muestra el reporte en un mediante el visor de Crystal Reports o /// manda a imprimir el reporte directamente a la impresora configurada. /// </summary> /// <param name="report"> Documento .rpt </param> /// <param name="reportName"> Nombre del reporte. </param> /// <param name="isDialog"> Se mostrarĂ¡ en una ventana tipo Dialogo. </param> /// <param name="owner"> Ventana Principal que utiliza el visor. </param> /// <param name="isDirectPrint"> Bandera de impresion directa. </param> /// <history> /// [edgrodriguez] 16/Jul/2016 Created /// </history> public static void ShowReport(ReportDocument report, string reportName = "", bool isDialog = false, Window owner = null, EnumPrintDevice PrintDevice = EnumPrintDevice.pdScreen, bool IsInvitation = false, int numCopies = 1) { switch (PrintDevice) { case EnumPrintDevice.pdPrinter: var boPrintReportOptions = new PrintReportOptions(); boPrintReportOptions.PrinterName = (IsInvitation) ? ConfigRegistryHelper.GetConfiguredPrinter("PrintInvit") : boPrintReportOptions.PrinterName; if (IsInvitation && string.IsNullOrEmpty(boPrintReportOptions.PrinterName)) { UIHelper.ShowMessage($"The printer is not configured, please configure your printer."); return; } var boReportClientDocument = report.ReportClientDocument; var boPrintOutputController = boReportClientDocument.PrintOutputController; boPrintReportOptions.JobTitle = reportName; boPrintReportOptions.NumberOfCopies = numCopies; boPrintOutputController.PrintReport(boPrintReportOptions); break; case EnumPrintDevice.pdScreen: var crViewer = new frmViewer(report, reportName); crViewer.Owner = owner; if (isDialog) { crViewer.ShowDialog(); break; } crViewer.Show(); break; } }
/// <summary> /// Imprime el reporte RefundsLetter /// </summary> /// <history> /// [edgrodriguez] 15/Jul/2016 Created /// </history> private async void btnPrint_Click(object sender, RoutedEventArgs e) { var Refund = grdRefund.SelectedItem as DepositsRefund; if (Refund != null) { var RptRefundLetter = await BRDepositsRefund.GetRptRefundLetter(Refund.drID); if (RptRefundLetter.Any()) { var objRptRefundletter = RptRefundLetter[0].Cast <RptRefundLetter>().FirstOrDefault(); var reportText = await BRReportsTexts.GetReportTexts("RefundLetter", objRptRefundletter.gula); var header = reportText[0].reText .Replace("[SaleRoom]", objRptRefundletter.SaleRoom) .Replace("[RefundDate]", objRptRefundletter.RefundDate.ToString()) .Replace("[RefundID]", objRptRefundletter.RefundID.ToString()) .Replace("[RefundFolio]", objRptRefundletter.RefundFolio.ToString()) .Replace("[GuestID]", objRptRefundletter.GuestID.ToString()) .Replace("[OutInvt]", objRptRefundletter.OutInvt) .Replace("[GuestNames]", objRptRefundletter.GuestNames) .Replace("[TotalAmount]", objRptRefundletter.TotalAmount.ToString("#,##0.00")) .Replace("[PRName]", objRptRefundletter.PRName); var footer = reportText[1].reText; var crptRefundLetter = new Reports.rptRefundLetter(); crptRefundLetter.Database.Tables["depositRefund"].SetDataSource(ObjectHelper.ObjectToList(objRptRefundletter)); crptRefundLetter.Database.Tables["reportText"].SetDataSource(ObjectHelper.ObjectToList(new Classes.objReportText { Header = header, Footer = footer })); crptRefundLetter.Subreports["RptBookingDeposits.rpt"].SetDataSource(TableHelper.GetDataTableFromList(RptRefundLetter[1].Cast <RptRefundLetter_BookingDeposit>().ToList())); CrystalReportHelper.SetLanguage(crptRefundLetter, objRptRefundletter.gula); //(crptRefundLetter.ReportDefinition.ReportObjects["txtHeader"] as FieldObject).ObjectFormat. = header; //(crptRefundLetter.ReportDefinition.ReportObjects["txtFooter"] as FieldObject).Text = footer; var frmReportViewer = new frmViewer(crptRefundLetter); frmReportViewer.Show(); } } else { UIHelper.ShowMessage("Select a Refund from the list."); } }