как показать предварительный просмотр отчета Crystal с печатным документом в c# - PullRequest
0 голосов
/ 28 февраля 2020

Reports.rptsalesWithVat rpt = new Reports.rptsalesWithVat (); rpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4; rpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait; rpt.Database.Tables. [ "dtSales"] SetDataSource (dssalesbook.Tables [0]); rpt.Database.Tables. [ "dtSalesDetails"] SetDataSource (dssalesItems.Tables [0]); . Rpt.Database.Tables [ "dtPrint"] SetDataSource (dtPrint); rpt.SetParameterValue («Имя», Classes.GlobalData.CompanyName); ConvertNumbersToArabicAlphabet a = new ConvertNumbersToArabicAlphabet (txtNetTotal.Text); rpt.SetParameterValue ("AmountInArabi c", a.GetNumberAr ()); HeaderPage hp = new HeaderPage (); rpt.SetParameterValue ("BaseCurrency", Classes.GlobalData.BaseCurrency); rpt.SetParameterValue ("DecimalPortion", Classes.GlobalData.DecimalPortion); rpt.SetParameterValue ("PrintItemColumn", Classes.GlobalData.PrintItem); rpt.SetParameterValue ("Tin", GlobalData.CompanyTin); rpt.SetParameterValue ("Cst", GlobalData.CompanyCst);

                            if (dtCustomer.Rows.Count > 0)
                            {
                                if (dtCustomer.Rows[0][0].ToString() != "")
                                {
                                    rpt.SetParameterValue("CustomerTin", dtCustomer.Rows[0]["tin"].ToString());
                                    rpt.SetParameterValue("vendorId", dtCustomer.Rows[0]["vendorId"].ToString());
                                }
                                else
                                {
                                    rpt.SetParameterValue("CustomerTin", "");
                                    rpt.SetParameterValue("CustomerCst", "");
                                    rpt.SetParameterValue("vendorId", "");
                                }
                            }
                            else
                            {
                                rpt.SetParameterValue("CustomerTin", "");
                                rpt.SetParameterValue("CustomerCst", "");
                                rpt.SetParameterValue("vendorId", "");
                            }

                            rpt.SetParameterValue("currentBalance", balance);

                            //string type = "Cash Invoice      فاتورة بالنقد";
                            string type = "TAX INVOICE      فاتورة ضريبية";


                            rpt.SetParameterValue("Type", type);
                            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
                            PrintDialog printDialog = new PrintDialog();
                            printDialog.PrinterSettings = printerSettings;
                            printDialog.AllowPrintToFile = false;
                            printDialog.AllowSomePages = true;
                            printDialog.UseEXDialog = true;
                            DialogResult result = printDialog.ShowDialog();

                            if (result == DialogResult.Cancel)
                            {
                                return;
                            }

                            rpt.PrintOptions.PrinterName = printerSettings.PrinterName;



                            rpt.PrintToPrinter(printerSettings.Copies, false, 0, 0);
...