public static void Run()
        {
            try
            {
                // ExStart:PdfToPostScript
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

                Aspose.Pdf.Facades.PdfViewer viewer = new Aspose.Pdf.Facades.PdfViewer();
                viewer.BindPdf(dataDir + "input.pdf");
                // Set PrinterSettings and PageSettings
                System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
                printerSetttings.Copies = 1;
                // Set PS printer, one can find this driver in the list of preinstalled printer drivers in Windows
                printerSetttings.PrinterName = "HP LaserJet 2300 Series PS";
                // Set output file name and PrintToFile attribute
                printerSetttings.PrintFileName = dataDir + "PdfToPostScript_out.ps";
                printerSetttings.PrintToFile = true;
                // Disable print page dialog
                viewer.PrintPageDialog = false;
                // Pass printer settings object to the method
                viewer.PrintDocumentWithSettings(printerSetttings);
                viewer.Close();
                // ExEnd:PdfToPostScript
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }       
 public PageSettings(System.Drawing.Printing.PrinterSettings printerSettings)
 {
     this.color = TriState.Default;
     this.landscape = TriState.Default;
     this.margins = new System.Drawing.Printing.Margins();
     this.printerSettings = printerSettings;
 }
Ejemplo n.º 3
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            Aspose.Pdf.Facades.PdfViewer pdfv = new Aspose.Pdf.Facades.PdfViewer();

            pdfv.PdfQueryPageSettings += PdfvOnPdfQueryPageSettings;

            System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
            System.Drawing.Printing.PrinterSettings prin = new System.Drawing.Printing.PrinterSettings();

            pdfv.BindPdf(dataDir + "NewInput.pdf");
            prin.PrinterName = "HP LaserJet M9050 MFP PCL6";
            prin.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

            Aspose.Pdf.Facades.PdfPageEditor pageEditor = new Aspose.Pdf.Facades.PdfPageEditor();
            pageEditor.BindPdf(dataDir+ "temp.pdf");

            pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            pgs.PaperSize = prin.DefaultPageSettings.PaperSize;

            pdfv.PrintDocumentWithSettings(pgs, prin);
            pdfv.Close();
        }
        public static void Run()
        {
            try
            {
                // ExStart:PrintPageRange
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

                Aspose.Pdf.Facades.PdfViewer pdfv = new Aspose.Pdf.Facades.PdfViewer();

                pdfv.PdfQueryPageSettings += PdfvOnPdfQueryPageSettings;

                System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
                System.Drawing.Printing.PrinterSettings prin = new System.Drawing.Printing.PrinterSettings();

                pdfv.BindPdf(dataDir + "Print-PageRange.pdf");
                prin.PrinterName = "HP LaserJet M9050 MFP PCL6";
                prin.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

                Aspose.Pdf.Facades.PdfPageEditor pageEditor = new Aspose.Pdf.Facades.PdfPageEditor();
                pageEditor.BindPdf(dataDir + "input.pdf");

                pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
                pgs.PaperSize = prin.DefaultPageSettings.PaperSize;

                pdfv.PrintDocumentWithSettings(pgs, prin);
                pdfv.Close();
                // ExEnd:PrintPageRange
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 5
0
		public PrintingService()
		{
			// we initialize the printer variables
			_printDocument = new System.Drawing.Printing.PrintDocument();
			// we set the print document default orientation to landscape
			_printDocument.DefaultPageSettings.Landscape = true;
			_printerSettings = new System.Drawing.Printing.PrinterSettings();
			UpdateBoundsAndMargins();
		}
Ejemplo n.º 6
0
        public PrintUtils(string printer)
        {
            settings = new System.Drawing.Printing.PrinterSettings();
            defaultPrinter = settings.PrinterName;

            if (string.IsNullOrEmpty(printer))
            {
                this.printer = string.Empty;
            }
            else if (printer == "*")
            {
                this.printer = defaultPrinter;
            }
            else
            {
                this.printer = printer;
            }
        }
Ejemplo n.º 7
0
		public static Lfx.Types.OperationResult ShowManualFeedDialog(string printerName, string documentName)
		{
                        Lui.Printing.ManualFeedDialog OFormFacturaCargaManual = new Lui.Printing.ManualFeedDialog();
			OFormFacturaCargaManual.DocumentName = documentName;

			// Muestro el nombre de la impresora
                        if (printerName != null && printerName.Length > 0) {
                                OFormFacturaCargaManual.PrinterName = printerName;
                        } else {
                                System.Drawing.Printing.PrinterSettings CurrentSettings = new System.Drawing.Printing.PrinterSettings();
                                OFormFacturaCargaManual.PrinterName = CurrentSettings.PrinterName;
                        }

			if (OFormFacturaCargaManual.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
				return new Lfx.Types.FailureOperationResult("Operación cancelada");
			else
				return new Lfx.Types.SuccessOperationResult();
		}
        public static void ShowPrintDialog()
        {
          
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

            // Create PdfViewer object
            PdfViewer viewer = new PdfViewer();

            // Open input PDF file
            viewer.BindPdf( dataDir + "input.pdf");

            // Set attributes for printing
            viewer.AutoResize = true;         // Print the file with adjusted size
            viewer.AutoRotate = true;         // Print the file with adjusted rotation
            viewer.PrintPageDialog = false;   // Do not produce the page number dialog when printing

            // Create objects for printer and page settings and PrintDocument
            System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
            System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
            System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

            // Set printer name
            ps.PrinterName = prtdoc.PrinterSettings.PrinterName;

            // Set PageSize (if required)
            pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

            // Set PageMargins (if required)
            pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
            // ExStart:PrintDialog
            System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                // Document printing code goes here
                // Print document using printer and page settings
                viewer.PrintDocumentWithSettings(pgs, ps);
            }
            // ExEnd:PrintDialog            

            // Close the PDF file after priting
            viewer.Close();
        }
        public static void Run()
        {
            // ExStart:PrintProgressDialog
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting(); 
            // Load the documents which store the shapes we want to render.
            Document doc = new Document(dataDir + "TestFile RenderShape.doc");
            // Obtain the settings of the default printer
            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

            // The standard print controller comes with no UI
            System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();

            // Print the document using the custom print controller
            AsposeWordsPrintDocument prntDoc = new AsposeWordsPrintDocument(doc);
            prntDoc.PrinterSettings = settings;
            prntDoc.PrintController = standardPrintController;
            prntDoc.Print();            
            // ExEnd:PrintProgressDialog
        }
Ejemplo n.º 10
0
        private void PrintSelect()
        {
            PrintDialog p = new PrintDialog();

            System.Drawing.Printing.PrinterSettings pSet = new System.Drawing.Printing.PrinterSettings();
            pSet.PrinterName = myPageSetup.PrintName;
            pSet.DefaultPageSettings.Landscape = myPageSetup.Landscape;
            p.PrinterSettings = pSet;
            p.UseEXDialog     = false;
            if (p.ShowDialog() == DialogResult.OK)
            {
                myPageSetup.PrintName   = pSet.PrinterName;
                myPageSetup.Landscape   = pSet.DefaultPageSettings.Landscape;
                myPageSetup.PaperSize   = pSet.DefaultPageSettings.PaperSize.RawKind;
                myPageSetup.PageWidth   = pSet.DefaultPageSettings.PaperSize.Width;
                myPageSetup.PageHeight  = pSet.DefaultPageSettings.PaperSize.Height;
                myPageSetup.ScaleWidth  = pSet.DefaultPageSettings.PrintableArea.Width;
                myPageSetup.ScaleHeight = pSet.DefaultPageSettings.PrintableArea.Height;
                myPageSetup.ColorPrint  = pSet.SupportsColor;
                RefreshPrintName(pSet.DefaultPageSettings.PaperSize);
            }
        }
Ejemplo n.º 11
0
            public void Print(bool useDefaultPrinter, string printerName)
            {

                //create PdfViewer object
                PdfViewer viewer = new PdfViewer();

                //open input PDF file
                viewer.OpenPdfFile(path);

                //set attributes for printing
                viewer.AutoResize = true;         //print the file with adjusted size
                viewer.AutoRotate = true;         //print the file with adjusted rotation
                viewer.PrintPageDialog = false;   //do not produce the page number dialog when printing

                //create objects for printer and page settings and PrintDocument
                System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
                System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
                System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

                //set printer name
                if (useDefaultPrinter)
                    ps.PrinterName = prtdoc.PrinterSettings.PrinterName;
                else
                    ps.PrinterName = printerName;


                //set PageSize (if required)
                pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

                //set PageMargins (if required)
                pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

                //print document using printer and page settings
                viewer.PrintDocumentWithSettings(pgs, ps);

                //close the PDF file after priting
                viewer.ClosePdfFile();

            }
        public static void Run()
        {
            // ExStart:PrintoXPSPrinter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

            // Create PdfViewer object
            PdfViewer viewer = new PdfViewer();

            // Open input PDF file
            viewer.BindPdf( dataDir + "input.pdf");

            // Set attributes for printing
            viewer.AutoResize = true;         // Print the file with adjusted size
            viewer.AutoRotate = true;         // Print the file with adjusted rotation
            viewer.PrintPageDialog = false;   // Do not produce the page number dialog when printing

            // Create objects for printer and page settings and PrintDocument
            System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
            System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();

            // Set XPS/PDF printer name
            ps.PrinterName = "Microsoft XPS Document Writer";
            // Or set the PDF printer
            // Ps.PrinterName = "Adobe PDF";

            // Set PageSize (if required)
            pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

            // Set PageMargins (if required)
            pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

            // Print document using printer and page settings
            viewer.PrintDocumentWithSettings(pgs, ps);

            // Close the PDF file after priting
            viewer.Close();
            // ExEnd:PrintoXPSPrinter
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 订单打印
 /// </summary>
 /// <param name="info"></param>
 private void PrintOrderInfo(OrderInfo info)
 {
     if (info == null)
     {
         return;
     }
     _report.Parameters.FindByName("PWONo").Value           = info.PWONo;
     _report.Parameters.FindByName("PlatNo").Value          = info.PlateNo;
     _report.Parameters.FindByName("T102Code").Value        = info.T102Code;
     _report.Parameters.FindByName("LotNumber").Value       = info.LotNumber;
     _report.Parameters.FindByName("MachineModeling").Value = info.MachineModelling;
     _report.Parameters.FindByName("Texture").Value         = info.Texture;
     _report.Parameters.FindByName("BatchNumber").Value     = info.BatchNumber;
     _report.Parameters.FindByName("Quantity").Value        = info.Qty.ToString();
     _report.Parameters.FindByName("BatchQty").Value        = info.BatchQty.ToString();
     _report.Parameters.FindByName("MONumber").Value        = info.MONumber;
     _report.Parameters.FindByName("MOLineNo").Value        = info.MOLineNo;
     System.Drawing.Printing.PrinterSettings prnSetting =
         new System.Drawing.Printing.PrinterSettings();
     if (_report.Prepare())
     {
         // 取消循环打印-李智颖 2018-3-2
         //bool rePrinter = false;
         //do
         //{
         if (_report.ShowPrintDialog(out prnSetting))
         {
             _report.PrintPrepared(prnSetting);
             //rePrinter = (
             //    ShowMessageBox.Show(
             //        "铸造产品标识卡已经打印完成,是否需要重新打印?",
             //        "系统信息",
             //        MessageBoxButtons.YesNo,
             //        MessageBoxIcon.Question,
             //        MessageBoxDefaultButton.Button2) == DialogResult.Yes);
         }
         //} while (rePrinter);
     }
 }
Ejemplo n.º 14
0
        public void DefaultPaperTray()
        {
            //ExStart
            //ExFor:PageSetup.FirstPageTray
            //ExFor:PageSetup.OtherPagesTray
            //ExSummary:Changes all sections in a document to use the default paper tray of the selected printer.
            Aspose.Words.Document doc = new Aspose.Words.Document();

            // Find the printer that will be used for printing this document. In this case it is the default printer.
            // You can define a specific printer using PrinterName.
            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

            // The paper tray value stored in documents is completely printer specific. This means
            // The code below resets all page tray values to use the current printers default tray.
            // You can enumerate PrinterSettings.PaperSources to find the other valid paper tray values of the selected printer.
            foreach (Aspose.Words.Section section in doc.Sections)
            {
                section.PageSetup.FirstPageTray  = settings.DefaultPageSettings.PaperSource.RawKind;
                section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
            }
            //ExEnd
        }
Ejemplo n.º 15
0
        public static void Run()
        {
            // ExStart:PrintProgressDialog
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_RenderingAndPrinting();
            // Load the documents which store the shapes we want to render.
            Document doc = new Document(dataDir + "TestFile RenderShape.doc");

            // Obtain the settings of the default printer
            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

            // The standard print controller comes with no UI
            System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();

            // Print the document using the custom print controller
            AsposeWordsPrintDocument prntDoc = new AsposeWordsPrintDocument(doc);

            prntDoc.PrinterSettings = settings;
            prntDoc.PrintController = standardPrintController;
            prntDoc.Print();
            // ExEnd:PrintProgressDialog
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 폼로드 이벤트
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void AEAAI03_Load(object sender, EventArgs e)
        {
            try
            {
                //기본프린터를 가져와 셋팅한다.
                String DefaultPrint = "";
                for (int i = 0; i < System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count; i++)
                {
                    String pkInstalledPrinters = System.Drawing.Printing.PrinterSettings.InstalledPrinters[i];

                    System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
                    settings.PrinterName = pkInstalledPrinters;

                    if (settings.IsDefaultPrinter)
                    {
                        DefaultPrint = pkInstalledPrinters;
                        break;
                    }
                }

                this.lblPrintName.Text = DefaultPrint;

                SetDataTable();
                this.progressBarControl1.Properties.Maximum = dt.Rows.Count;
                this.progressBarControl1.Properties.Minimum = 0;
                TotCount      = dt.Rows.Count;
                lblCount.Text = GetCount();
                Application.DoEvents();

                mprint.ErrorEvent  += new SpPrint.mPrint.ErrorEventHandler(mprint_ErrorEvent);
                mprint.SucessEvent += new SpPrint.mPrint.SucessEventHandler(mprint_SucessEvent);
            }
            catch (Exception ex)
            {
                Basic.ShowMessage(3, ex.Message);
                this.timer_Close.Enabled = true;
            }
        }
Ejemplo n.º 17
0
        public static void Run()
        {
            // ExStart:PrintToDefaultPrinter
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

            // Create PdfViewer object
            PdfViewer viewer = new PdfViewer();

            // Open input PDF file
            viewer.BindPdf(dataDir + "input.pdf");

            // Set attributes for printing
            viewer.AutoResize      = true;    // Print the file with adjusted size
            viewer.AutoRotate      = true;    // Print the file with adjusted rotation
            viewer.PrintPageDialog = false;   // Do not produce the page number dialog when printing

            // Create objects for printer and page settings and PrintDocument
            System.Drawing.Printing.PrinterSettings ps     = new System.Drawing.Printing.PrinterSettings();
            System.Drawing.Printing.PageSettings    pgs    = new System.Drawing.Printing.PageSettings();
            System.Drawing.Printing.PrintDocument   prtdoc = new System.Drawing.Printing.PrintDocument();

            // Set printer name
            ps.PrinterName = prtdoc.PrinterSettings.PrinterName;

            // Set PageSize (if required)
            pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);

            // Set PageMargins (if required)
            pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

            // Print document using printer and page settings
            viewer.PrintDocumentWithSettings(pgs, ps);

            // Close the PDF file after priting
            viewer.Close();
            // ExEnd:PrintToDefaultPrinter
        }
        private void reportViewer1_PrintingBegin(object sender, ReportPrintEventArgs e)
        {
            try
            {
                if (PrintBatch_CB.Checked == true)
                {
                    System.Drawing.Printing.PrinterSettings _PrinterSettings = new System.Drawing.Printing.PrinterSettings();
                    _PrinterSettings.PrinterName = Variables.PrinterName;
                    reportViewer1.PrintDialog(_PrinterSettings);

                    if (BillDataGridView.SelectedRows.Count > 0)
                    {
                        BillNumberSearch_txt.Text = BillDataGridView.SelectedRows[0].Cells["ID"].Value.ToString();
                        BillDataGridView.SelectedRows[0].Selected = false;
                        Variables.NotificationMessageTitle        = this.Name;
                        Variables.NotificationMessageText         = BillDataGridView.SelectedRows.Count.ToString();
                        Variables.NotificationStatus = true;
                    }
                }
            }
            catch (Exception ex)
            { }
        }
Ejemplo n.º 19
0
        protected void PrintReport(ReportClass rpt, string printerName, int nCopies)
        {
            if (rpt != null)
            {
                try
                {
                    System.Drawing.Printing.PrinterSettings printer_settings = new System.Drawing.Printing.PrinterSettings();
                    printer_settings.PrinterName = printerName;
                    printer_settings.Copies      = (short)nCopies;
                    System.Drawing.Printing.PageSettings page_settings = new System.Drawing.Printing.PageSettings(printer_settings);

                    CrystalDecisions.CrystalReports.Engine.ReportClass report = rpt;
                    report.PrintToPrinter(printer_settings, page_settings, false);
                }
                catch
                {
                    rpt.PrintToPrinter(nCopies, true, 0, 0);
                }
            }
            else
            {
                PgMng.ShowInfoException(Resources.Messages.NO_DATA_REPORTS);
            }
        }
 // ExEnd:GetCurrentUserCredentials
 public static void UsingImpersonation()
 {
     // ExStart:UsingImpersonation
     // The path to the documents directory.
     string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();
     PdfViewer viewer = new PdfViewer();
     viewer.BindPdf( dataDir + "input.pdf");
     viewer.PrintPageDialog = false;
     // Do not produce the page number dialog when printing
     using (new Impersonator("OwnerUserName", "SomeDomain", "OwnerUserNamePassword"))
     {
         System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
         ps.PrinterName = "Microsoft XPS Document Writer";
         viewer.PrintDocumentWithSettings(ps); // OwnerUserName is a value of Owner column in spooler app
         viewer.Close();
     }
     // ExEnd:UsingImpersonation
 }
        protected override void PrintSec()
        {
            // レコード定義を行う
            // DataTable table = new DataTable();
            ukkthbl = new UrikakekinTairyuuHyou_BL();
            string    header = string.Empty;
            DataTable dtPrint;

            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                msce = new M_StoreClose_Entity();
                msce = GetStoreClose_Data();

                DateTime now      = Convert.ToDateTime(txtDate.Text.ToString() + "/01 00:00:00");
                string[] strmonth = new string[12];
                for (int i = 11; i >= 0; i--)
                {
                    strmonth[i] = now.AddMonths(-i).ToString().Substring(0, 7);
                }


                dtPrint = ukkthbl.Select_DataToExport(msce);
                //header = "棚入れリスト";

                try
                {
                    if (dtPrint == null || dtPrint.Rows.Count <= 0)
                    {
                        bbl.ShowMessage("E128");
                        txtDate.Focus();
                    }
                    else
                    {
                        string customerCD = string.Empty;
                        for (int i = 0; i < dtPrint.Rows.Count; i++)
                        {
                            if (customerCD != dtPrint.Rows[i]["CustomerCD"].ToString())
                            {
                                customerCD = dtPrint.Rows[i]["CustomerCD"].ToString();
                            }

                            DataTable dtResult = dtPrint.Select("SaleA='売上' and CustomerCD='" + customerCD + "'").CopyToDataTable();
                            if (dtResult.Rows.Count == 1)
                            {
                                dtPrint.Rows[i]["Result"] = dtResult.Rows[0]["Result"].ToString();
                            }
                        }

                        //xsdファイルを保存します。

                        //①保存した.xsdはプロジェクトに追加しておきます。
                        DialogResult ret;
                        UrikakekinTairyuuHyou_Report Report = new UrikakekinTairyuuHyou_Report();

                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:

                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.No)
                            {
                                return;
                            }
                            //}

                            // 印字データをセット



                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtStore", cboStore.SelectedValue.ToString() + "  " + cboStore.Text);
                            Report.SetParameterValue("txtMonth11", strmonth[11].ToString());
                            Report.SetParameterValue("txtMonth10", strmonth[10].ToString());
                            Report.SetParameterValue("txtMonth9", strmonth[9].ToString());
                            Report.SetParameterValue("txtMonth8", strmonth[8].ToString());
                            Report.SetParameterValue("txtMonth7", strmonth[7].ToString());
                            Report.SetParameterValue("txtMonth6", strmonth[6].ToString());
                            Report.SetParameterValue("txtMonth5", strmonth[5].ToString());
                            Report.SetParameterValue("txtMonth4", strmonth[4].ToString());
                            Report.SetParameterValue("txtMonth3", strmonth[3].ToString());
                            Report.SetParameterValue("txtMonth2", strmonth[2].ToString());
                            Report.SetParameterValue("txtMonth1", strmonth[1].ToString());
                            Report.SetParameterValue("txtMonth0", strmonth[0].ToString());

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = new Viewer();
                                previewForm.CrystalReportViewer1.ShowPrintButton = true;
                                previewForm.CrystalReportViewer1.ReportSource    = Report;
                                previewForm.ShowDialog();
                            }
                            else         /// //Still Not Working because of Applymargin and Printer not Setting up  (PTK Will Solve)
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;     // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;   //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                Report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                                    Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;

                        case EPrintMode.PDF:
                            if (bbl.ShowMessage("Q204") != DialogResult.Yes)
                            {
                                return;
                            }
                            string filePath = "";
                            if (!ShowSaveFileDialog(InProgramNM, out filePath))
                            {
                                return;
                            }

                            // 印字データをセット
                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboStore.SelectedValue.ToString() + "  " + cboStore.Text);
                            Report.SetParameterValue("txtHeader", header);

                            bool result = OutputPDF(filePath, Report);

                            //PDF出力が完了しました。
                            bbl.ShowMessage("I202");

                            break;
                        }
                        //InsertLog(Get_L_Log_Entity(dtPrint));
                    }
                }
                finally
                {
                }
            }
        }
        /// <summary>
        /// Print Report on F12 Click
        /// </summary>
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            if (ErrorCheck())
            {
                sku_data = M_SKU_data();
                dms      = D_MonthlyStock_data();

                chk      = Check_ITemORMakerItem();
                dtReport = new DataTable();
                dtReport = zmibl.ZaikoMotochoulnsatsu_Report(sku_data, dms, chk);

                if (dtReport.Rows.Count > 0)
                {
                    CheckBeforeExport();
                    try
                    {
                        ZaikoMotochoulnsatsu_Report zm_report = new ZaikoMotochoulnsatsu_Report();
                        DialogResult DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            zm_report.SetDataSource(dtReport);
                            zm_report.Refresh();
                            zm_report.SetParameterValue("lblYearMonth", txtTargetPeriodF.Text + "  ~  " + txtTargetPeriodT.Text);
                            zm_report.SetParameterValue("lblSouko", cboSouko.SelectedValue.ToString() + " " + cboSouko.Text);
                            zm_report.SetParameterValue("lblToday", DateTime.Now.ToString("yyyy/MM/dd") + "  " + DateTime.Now.ToString("HH:mm"));
                            //zm_report.SetParameterValue("lblSKU", dtReport.Rows[0]["SKUCD"].ToString());
                            // zm_report.SetParameterValue("lblJANCD", dtReport.Rows[0]["JANCD"].ToString());
                            // zm_report.SetParameterValue("lblCSB", dtReport.Rows[0]["ColorName"].ToString() + " " + dtReport.Rows[0]["SizeName"].ToString() + " " + dtReport.Rows[0]["BrandName"].ToString());

                            vr.CrystalReportViewer1.ReportSource = zm_report;
                            //vr.ShowDialog();

                            try
                            {
                                //  crv = vr.CrystalReportViewer1;
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                //印刷処理プレビュー
                                vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = zm_report;

                                vr.ShowDialog();
                            }
                            else
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = zm_report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;        // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;      //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                zm_report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                                    zm_report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    zm_report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    zm_report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    zm_report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                    // Print the report. Set the startPageN and endPageN
                                    // parameters to 0 to print all pages.
                                    //Report.PrintToPrinter(1, false, 0, 0);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        //プログラム実行履歴
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        //画面はそのまま
                        txtTargetPeriodF.Focus();
                    }
                }
                else
                {
                    bbl.ShowMessage("E128");
                }
            }
        }
Ejemplo n.º 23
0
        private void Imprimir()
        {
            Lfx.Types.OperationResult Res;
            if (this.ReadOnly)
            {
                Res = new Lfx.Types.SuccessOperationResult();
            }
            else
            {
                if (this.Elemento.Existe == false)
                {
                    // Si es nuevo, lo guardo sin preguntar.
                    Res = this.Save();
                }
                else if (this.Changed)
                {
                    // Si es edición, y hay cambios, pregunto si quiere guardar
                    using (Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Hay modificaciones sin guardar (subrayadas en color rojo). Antes de imprimir el ducumento se guardarán las modificaciones. ¿Desea continuar?", "Imprimir")) {
                        Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                        this.ShowChanged       = true;
                        if (Pregunta.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            Res = this.Save();
                        }
                        else
                        {
                            Res = new Lfx.Types.CancelOperationResult();
                        }
                        this.ShowChanged = false;
                    }
                }
                else
                {
                    // Es edición y no hay cambios... continúo
                    Res = new Lfx.Types.SuccessOperationResult();
                }
            }

            if (Res.Success)
            {
                Res = this.ControlUnico.BeforePrint();
            }

            if (Res.Success)
            {
                Lbl.Impresion.Impresora Impresora = null;
                if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                {
                    using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
                        if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK)
                        {
                            Impresora = FormularioSeleccionarImpresora.SelectedPrinter;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                string NombreDocumento          = Elemento.ToString();
                Lbl.Impresion.CargasPapel Carga = Lbl.Impresion.CargasPapel.Automatica;
                if (Impresora != null && Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Manual)
                {
                    Carga = Lbl.Impresion.CargasPapel.Manual;
                }
                else if (this.Elemento is Lbl.Comprobantes.ComprobanteConArticulos)
                {
                    Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;

                    if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV].Tipo == Lbl.Comprobantes.TipoPv.Fiscal)
                    {
                        Carga = Lbl.Impresion.CargasPapel.Automatica;
                    }
                    else
                    {
                        // El tipo de comprobante puede forzar a una carga manual
                        Carga = Comprob.Tipo.CargaPapel;

                        // Intento averiguar el número de comprobante, en caso de que aun no esté numerado
                        if (Comprob.Numero == 0)
                        {
                            int ProximoNumero = Lbl.Comprobantes.Numerador.ProximoNumero(Comprob);
                            NombreDocumento = NombreDocumento.Replace("00000000", ProximoNumero.ToString("00000000"));
                        }
                    }
                }

                if (Carga == Lbl.Impresion.CargasPapel.Manual)
                {
                    using (Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog()) {
                        FormularioCargaManual.DocumentName = NombreDocumento;
                        // Muestro el nombre de la impresora
                        if (Impresora != null)
                        {
                            FormularioCargaManual.PrinterName = Impresora.Nombre;
                        }
                        else
                        {
                            System.Drawing.Printing.PrinterSettings ObjPrint = new System.Drawing.Printing.PrinterSettings();
                            FormularioCargaManual.PrinterName = ObjPrint.PrinterName;
                        }
                        if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                }

                if (Impresora != null && Impresora.EsVistaPrevia)
                {
                    Lazaro.Impresion.ImpresorElemento ImpresorVistaPrevia = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, null);
                    ImpresorVistaPrevia.PrintController = new System.Drawing.Printing.PreviewPrintController();
                    Lui.Printing.PrintPreviewForm VistaPrevia = new Lui.Printing.PrintPreviewForm();
                    VistaPrevia.MdiParent             = this.ParentForm.MdiParent;
                    VistaPrevia.PrintPreview.Document = ImpresorVistaPrevia;
                    VistaPrevia.Show();
                }
                else
                {
                    Lfx.Types.OperationProgress Progreso = new Lfx.Types.OperationProgress("Imprimiendo", "El documento se está enviando a la impresora.");
                    if (Impresora != null)
                    {
                        Progreso.Description = "El documento se está enviando a la impresora " + Impresora.ToString();
                    }
                    Progreso.Modal = false;
                    Progreso.Begin();

                    using (IDbTransaction Trans = this.Elemento.Connection.BeginTransaction()) {
                        Lazaro.Impresion.ImpresorElemento Impresor = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, Trans);
                        Impresor.Impresora = Impresora;
                        try {
                            Res = Impresor.Imprimir();
                        } catch (Exception ex) {
                            Res = new Lfx.Types.FailureOperationResult(ex.Message);
                        }
                        Progreso.End();
                        if (Res.Success == false)
                        {
                            if (Impresor.Transaction != null)
                            {
                                // Puede que la transacción ya haya sido finalizada por el impresor
                                Impresor.Transaction.Rollback();
                            }
                            Lui.Forms.MessageBox.Show(Res.Message, "Error");
                        }
                        else
                        {
                            if (Impresor.Transaction != null)
                            {
                                // Puede que la transacción ya haya sido finalizada por el impresor
                                Impresor.Transaction.Commit();
                            }
                            this.Elemento.Cargar();
                            this.FromRow(this.Elemento);
                            this.ControlUnico.AfterPrint();
                        }
                    }
                }
            }

            if (Res.Success == false && Res.Message != null)
            {
                Lui.Forms.MessageBox.Show(Res.Message, "Imprimir");
            }
        }
        private void reportViewer1_PrintingBegin(object sender, ReportPrintEventArgs e)
        {
            try
            {
                if (PrintBatch_CB.Checked == true)
                {
                    System.Drawing.Printing.PrinterSettings _PrinterSettings = new System.Drawing.Printing.PrinterSettings();
                    _PrinterSettings.PrinterName = Variables.PrinterName;
                    reportViewer1.PrintDialog(_PrinterSettings);

                    if (BillDataGridView.SelectedRows.Count > 0)
                    {
                        BillNumberSearch_txt.Text = BillDataGridView.SelectedRows[0].Cells["ID"].Value.ToString();
                        BillDataGridView.SelectedRows[0].Selected = false;
                        Variables.NotificationMessageTitle = this.Name;
                        Variables.NotificationMessageText = BillDataGridView.SelectedRows.Count.ToString();
                        Variables.NotificationStatus = true;
                    }
                }
            }
            catch (Exception ex)
            { }
        }
Ejemplo n.º 25
0
        private void StimulViewer_Load(object sender, EventArgs e)
        {
            //try
            //{
            if (_Traffic_bit == false && _Othercar_bit == false)
            {
                AcceptedTurnstiReport.Dictionary.Synchronize();
                AcceptedTurnstiReport.Dictionary.Databases.Clear();
                AcceptedTurnstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                AcceptedTurnstiReport.Compile();
                AcceptedTurnstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory   PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory      = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        AcceptedTurnstiReport["Messagetxt"]  = BillLst[0].Message_nvc;
                        AcceptedTurnstiReport["Message_bit"] = true;
                    }
                    else
                    {
                        AcceptedTurnstiReport["Message_bit"] = false;
                    }
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    AcceptedTurnstiReport["Price_nvc"] = " مبلغ دریافت شده هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                if (TrafficEntity.Price_dec != null)
                {
                    AcceptedTurnstiReport["PricewithOutTax_nvc"] = (TrafficEntity.Price_dec - TrafficEntity.PriceTax_dec).ToString();
                }

                if (!string.IsNullOrEmpty(TrafficEntity.AcceptedTurnComment_nvc))
                {
                    if (TrafficEntity.Area_bit)
                    {
                        AcceptedTurnstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;// +" حومه";
                    }
                    else
                    {
                        AcceptedTurnstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;
                    }
                }
                else
                {
                    //if (TrafficEntity.Area_bit)
                    //{
                    //    AcceptedTurnstiReport["Comment_nvc"] = "حومه";
                    //}
                }
                if (TrafficEntity.TurnPrinted_bit == true)
                {
                    AcceptedTurnstiReport["PrintedAgain_nvc"] = "المثنی";
                }
                else
                {
                    AcceptedTurnstiReport["PrintedAgain_nvc"] = "";
                }

                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlatecityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    Platecitykey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                Platecitykey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                HPS.BLL.PlateCityBLL.BLLPlateCity_T PlateCityEntity = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                PlateCityEntity = PlatecityFactory.GetBy(Platecitykey);

                if (PlateCityEntity != null)
                {
                    AcceptedTurnstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlateCityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    AcceptedTurnstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }

                if (TrafficEntity.LadeReturn_bit == true)
                {
                    AcceptedTurnstiReport["TurnNumber"] = "برگشت از بار";
                }
                else
                {
                    if (TrafficEntity.AcceptedTurnNumber_bint.HasValue)
                    {
                        AcceptedTurnstiReport["TurnNumber"] = "شماره نوبت : " + TrafficEntity.AcceptedTurnNumber_bint.ToString();
                    }
                    else
                    {
                        AcceptedTurnstiReport["TurnNumber"] = "شماره نوبت رزرو : " + TrafficEntity.TurnNumber_bint.ToString();
                    }
                }

                AcceptedTurnstiReport["TrafficNumber"] = " شماره قبض پارکینگ: " + TrafficEntity.TrafficNumber_bint.ToString();


                AcceptedTurnstiReport["InDate_vc"]    = TrafficEntity.Date_nvc;
                AcceptedTurnstiReport["InTime_vc"]    = TrafficEntity.Time_nvc;
                AcceptedTurnstiReport["Time_vc"]      = PortPlaceFactory.ServerTime;
                AcceptedTurnstiReport["Date_vc"]      = PortPlaceFactory.ServerJalaliDate;
                AcceptedTurnstiReport["username_nvc"] = HPS.Common.CurrentUser.user.UserName_nvc;


                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";

                AcceptedTurnstiReport["@TrafficID_bint"] = TrafficEntity.TrafficID_bint;
                AcceptedTurnstiReport["@Condition"]      = LaderTypecondition;
                AcceptedTurnstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    AcceptedTurnstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    AcceptedTurnstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }

            else if (_Traffic_bit == true && _Othercar_bit == false)
            {
                TrafficstiReport.Dictionary.Synchronize();
                TrafficstiReport.Dictionary.Databases.Clear();
                TrafficstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                TrafficstiReport.Compile();
                TrafficstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory   PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory      = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        TrafficstiReport["Messagetxt"]  = BillLst[0].Message_nvc;
                        TrafficstiReport["Message_bit"] = true;
                    }
                    else
                    {
                        TrafficstiReport["Message_bit"] = false;
                    }
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    TrafficstiReport["Price_nvc"] = " مبلغ دریافت شده هنگام ورود " + txt.Text + "  ريال می باشد";
                }

                if (!string.IsNullOrEmpty(TrafficEntity.AcceptedTurnComment_nvc))
                {
                    if (TrafficEntity.Area_bit)
                    {
                        TrafficstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;// +" حومه";
                    }
                    else
                    {
                        TrafficstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;
                    }
                }
                else
                {
                    //if (TrafficEntity.Area_bit)
                    //{
                    //    TrafficstiReport["Comment_nvc"] = "حومه";
                    //}
                }
                if (TrafficEntity.TurnPrinted_bit == true)
                {
                    TrafficstiReport["PrintedAgain_nvc"] = "المثنی";
                }
                else
                {
                    TrafficstiReport["PrintedAgain_nvc"] = "";
                }

                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlatecityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    Platecitykey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                Platecitykey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                HPS.BLL.PlateCityBLL.BLLPlateCity_T PlateCityEntity = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                PlateCityEntity = PlatecityFactory.GetBy(Platecitykey);

                if (PlateCityEntity != null)
                {
                    TrafficstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlateCityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    TrafficstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }


                if (TrafficEntity.ServiceID_int == 2)
                {
                    if (TrafficEntity.TurnAccepted_bit == true)
                    {
                        //نوبت تأیید شده داره
                        TrafficstiReport["TurnNumber"] = "شماره نوبت :   " + Convert.ToString(TrafficEntity.AcceptedTurnNumber_bint);
                        //AcceptedDate2TextBox.Text = TrafficEntityrpt.TurnDate_nvc;
                        //AcceptedTime2TextBox.Text = TrafficEntityrpt.TurnTime_nvc;
                        //TurnNumber2txt.Text = TrafficEntityrpt.AcceptedTurnNumber_bint.ToString();
                    }
                    else
                    {
                        //نوبت تأیید شده ندارد
                        TrafficstiReport["TurnNumber"] = "شماره نوبت رزرو :   " + Convert.ToString(TrafficEntity.TurnNumber_bint);
                    }
                }
                else
                {
                    // (عدم نمایش نوبت (مراجعه به غیر از نوبت
                    TrafficstiReport["TurnNumber"] = "";
                }

                TrafficstiReport["TrafficNumber"] = "شماره قبض پارکینگ : " + TrafficEntity.TrafficNumber_bint.ToString();

                HPS.BLL.SettingsBLL.BLLSetting_TFactory settingsFactory = new HPS.BLL.SettingsBLL.BLLSetting_TFactory();
                HPS.BLL.SettingsBLL.BLLSetting_T        SettingEntity   = new HPS.BLL.SettingsBLL.BLLSetting_T();
                HPS.BLL.SettingsBLL.BLLSetting_TKeys    SettingKey      = new HPS.BLL.SettingsBLL.BLLSetting_TKeys();
                SettingKey.SettingID_int = 1002;
                SettingEntity            = settingsFactory.GetBy(SettingKey);
                if (TrafficEntity.ServiceID_int == 2)
                {
                    TrafficstiReport["TAllowableHour"] = SettingEntity.Value_nvc; //TrafficEntityrpt.AllowableHour_int.ToString();
                }
                else
                {
                    TrafficstiReport["TAllowableHour"] = TrafficEntity.AllowableHour_int.ToString();
                }



                HPS.BLL.ServicesBLL.BLLServices_TFactory servicesFactory = new HPS.BLL.ServicesBLL.BLLServices_TFactory();
                HPS.BLL.ServicesBLL.BLLServices_TKeys    ServicesKey     = new HPS.BLL.ServicesBLL.BLLServices_TKeys();
                ServicesKey.ServicesID_int = TrafficEntity.ServiceID_int;
                HPS.BLL.ServicesBLL.BLLServices_T ServicesEntity = new HPS.BLL.ServicesBLL.BLLServices_T();
                ServicesEntity = servicesFactory.GetBy(ServicesKey);
                TrafficstiReport["system_nvc"] = " قبض مراجعه به : " + ServicesEntity.ServicesType_nvc;

                if (TrafficEntity.WithLade_bit == true)
                {
                    TrafficstiReport["WithLade_nvc"] = "وضعیت : " + "با بار" + "(" + TrafficEntity.Comment_nvc + ") ";
                }
                else
                {
                    TrafficstiReport["WithLade_nvc"] = "وضعیت : " + "بدون بار";
                }

                if (TrafficEntity.TurnHour_int != null)
                {
                    TrafficstiReport["TurnNumberAllert_nvc"] = " شماره نوبت شما رزرو می باشد لطفاً تا " + TrafficEntity.TurnHour_int.ToString() + " ساعت نسبت به تأیید آن اقدام نمایید";
                }


                TrafficstiReport["InDate_vc"]    = TrafficEntity.Date_nvc;
                TrafficstiReport["InTime_vc"]    = TrafficEntity.Time_nvc;
                TrafficstiReport["Time_vc"]      = PortPlaceFactory.ServerTime;
                TrafficstiReport["Date_vc"]      = PortPlaceFactory.ServerJalaliDate;
                TrafficstiReport["username_nvc"] = HPS.Common.CurrentUser.user.UserName_nvc;


                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";

                TrafficstiReport["@TrafficID_bint"] = TrafficEntity.TrafficID_bint;
                TrafficstiReport["@Condition"]      = LaderTypecondition;
                TrafficstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    TrafficstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    TrafficstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            //سواری وغیره
            else if (_Traffic_bit == false && _Othercar_bit == true)
            {
                //HPS.BLL.TrafficBLL.BLLTraffic_T TrafficEntityrpt = new HPS.BLL.TrafficBLL.BLLTraffic_T();
                OtherCarstiReport.Dictionary.Synchronize();
                OtherCarstiReport.Dictionary.Databases.Clear();
                OtherCarstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                OtherCarstiReport.Compile();
                OtherCarstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                OtherCarstiReport["DateTextBox"]      = TrafficEntity.Date_nvc;
                OtherCarstiReport["TimeTextBox"]      = TrafficEntity.Time_nvc;
                OtherCarstiReport["TrafficNumbertxt"] = TrafficEntity.TrafficNumber_bint.ToString();
                OtherCarstiReport["Servicestxt"]      = " مراجعه به : " + TrafficEntity.Services_nvc;
                OtherCarstiReport["CarTypetxt"]       = "نوع وسیله : " + TrafficEntity.System_nvc;
                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlateCityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_T        PlatecityEntity  = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    PlateCityKey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                PlateCityKey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                PlatecityEntity = PlateCityFactory.GetBy(PlateCityKey);
                OtherCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlatecityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                    OtherCarstiReport["Messagetxt"] = "";
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        OtherCarstiReport["Messagetxt"] = BillLst[0].Message_nvc;
                    }
                    else
                    {
                        OtherCarstiReport["Messagetxt"] = "";
                    }
                }

                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    OtherCarstiReport["Pricetxt"] = " مبلغ دریافتی هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                OtherCarstiReport["AllowableHourtxt"] = TrafficEntity.AllowableHour_int.ToString();
                OtherCarstiReport["ExtraHourtxt"]     = TrafficEntity.ExtraHour_int.ToString();
                txt.Text = TrafficEntity.Fee_dec.ToString();
                OtherCarstiReport["Feetxt"] = txt.Text;
                txt.Text = TrafficEntity.ExtraHourFee_dec.ToString();
                OtherCarstiReport["ExtraHourFeetxt"]      = txt.Text;
                OtherCarstiReport["UserNametxt"]          = TrafficEntity.UserName_nvc;
                OtherCarstiReport["TrafficNumberbarcode"] = TrafficEntity.TrafficNumber_bint.ToString();

                if (TrafficEntity.Printed_bit == true)
                {
                    OtherCarstiReport["txtPrintedAgain"] = "المثنی";
                }
                else
                {
                    OtherCarstiReport["txtPrintedAgain"] = "";
                }

                //DriverName_nvc
                OtherCarstiReport["DriverName_nvc"] = "نام راننده : " + TrafficEntity.FirstName_nvc + " " + TrafficEntity.LastName_nvc;
                OtherCarstiReport["Fee_dec"]        = TrafficEntity.Fee_dec.ToString();
                OtherCarstiReport["PriceTax_dec"]   = TrafficEntity.PriceTax_dec.ToString();
                OtherCarstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    OtherCarstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    OtherCarstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            //خارجی
            else if (_Traffic_bit == true && _Othercar_bit == true)
            {
                //HPS.BLL.TrafficBLL.BLLTraffic_T TrafficEntityrpt = new HPS.BLL.TrafficBLL.BLLTraffic_T();
                ForeignCarstiReport.Dictionary.Synchronize();
                ForeignCarstiReport.Dictionary.Databases.Clear();
                ForeignCarstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                ForeignCarstiReport.Compile();
                ForeignCarstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                ForeignCarstiReport["DateTextBox"]      = TrafficEntity.Date_nvc;
                ForeignCarstiReport["TimeTextBox"]      = TrafficEntity.Time_nvc;
                ForeignCarstiReport["TrafficNumbertxt"] = TrafficEntity.TrafficNumber_bint.ToString();
                ForeignCarstiReport["DriverNametxt"]    = " نام راننده : " + TrafficEntity.FirstName_nvc + " " + TrafficEntity.LastName_nvc;
                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";
                List <HPS.BLL.LaderTypeBLL.BLLLaderType_T> LaderTypeLst = laderTypeFactory.GetAllByCondition(LaderTypecondition);
                if (LaderTypeLst != null)
                {
                    ForeignCarstiReport["CarTypetxt"] = "نوع وسيله : " + TrafficEntity.System_nvc + "-  " + LaderTypeLst[0].LaderType_nvc;
                }
                if (!string.IsNullOrEmpty(TrafficEntity.SerialPlate_nvc))
                {
                    ForeignCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    ForeignCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc);
                }

                if (TrafficEntity.WithLade_bit == true)
                {
                    ForeignCarstiReport["WithLadetxt"] = "وضعیت : " + "با بار" + "(" + TrafficEntity.Comment_nvc + ") ";
                }
                else
                {
                    ForeignCarstiReport["WithLadetxt"] = "وضعیت : " + "بدون بار";
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    ForeignCarstiReport["Pricetxt"] = " مبلغ دریافتی هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                ForeignCarstiReport["AllowableHourtxt"] = TrafficEntity.AllowableHour_int.ToString();
                ForeignCarstiReport["ExtraHourtxt"]     = TrafficEntity.ExtraHour_int.ToString();
                txt.Text = TrafficEntity.Fee_dec.ToString();
                ForeignCarstiReport["Feetxt"] = txt.Text;
                txt.Text = TrafficEntity.ExtraHourFee_dec.ToString();
                ForeignCarstiReport["ExtraHourFeetxt"]      = txt.Text;
                ForeignCarstiReport["UserNametxt"]          = TrafficEntity.UserName_nvc;
                ForeignCarstiReport["TrafficNumberbarcode"] = TrafficEntity.TrafficNumber_bint.ToString();
                if (TrafficEntity.Printed_bit == true)
                {
                    ForeignCarstiReport["txtPrintedAgain"] = "المثنی";
                }
                else
                {
                    ForeignCarstiReport["txtPrintedAgain"] = "";
                }
                ForeignCarstiReport["Fee_dec"]      = TrafficEntity.Fee_dec.ToString();
                ForeignCarstiReport["PriceTax_dec"] = TrafficEntity.PriceTax_dec.ToString();
                ForeignCarstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    ForeignCarstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    ForeignCarstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            else if (_type == "dublicateTurns")
            {
                BLL.TrafficBLL.BLLTraffic_TFactory trafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory();
                DataTable duplicateTurnDataTable = new DataTable();
                trafficFactory.DuplicateTurnsReport(duplicateTurnDataTable);
                stiViewerControl1.Report = _sti;


                DuplicateTurnsReport.Dictionary.Synchronize();
                DuplicateTurnsReport.Dictionary.Databases.Clear();
                DuplicateTurnsReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                DuplicateTurnsReport.Compile();
                DuplicateTurnsReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                DuplicateTurnsReport["date_vc"]     = PortPlaceFactory.ServerJalaliDate + "   " + PortPlaceFactory.ServerTime;;
                DuplicateTurnsReport["userName_vc"] = HPS.Common.CurrentUser.user.UserName_nvc;
                DuplicateTurnsReport.Render();
                DuplicateTurnsReport.Show();
            }
            else if (_again == 1)
            {
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillCreditFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory();
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TKeys    LadBillKey           = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TKeys();
                LadBillKey.LadBillCreditID_int = _LadBIillCreditID;
                DataTable LadBillLadeAssignmentDataTable = new DataTable();
                LadBillCreditFactory.GetAllLadeAssignment(LadBillKey, ref LadBillLadeAssignmentDataTable);
                Stimulsoft.Report.StiReport LadBillReportstiReport = new Stimulsoft.Report.StiReport();
                LadBillReportstiReport.Load(Application.StartupPath + "\\LadBillCredit.mrt");
                LadBillReportstiReport.Dictionary.Synchronize();
                LadBillReportstiReport.Dictionary.Databases.Clear();
                LadBillReportstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                LadBillReportstiReport.Compile();
                LadBillReportstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                if (!string.IsNullOrEmpty(LadBillLadeAssignmentDataTable.Rows[0]["DriverCardNumber_nvc"].ToString()))
                {
                    LadBillReportstiReport["DriverCardNumber_vc"] = " کارت هوشمند راننده: " + LadBillLadeAssignmentDataTable.Rows[0]["DriverCardNumber_nvc"].ToString();
                }
                else
                {
                    LadBillReportstiReport["DriverCardNumber_vc"] = " کارت هوشمند راننده:فاقد كارت ";
                }
                if (!string.IsNullOrEmpty(LadBillLadeAssignmentDataTable.Rows[0]["CarCardNumber_nvc"].ToString()))
                {
                    LadBillReportstiReport["CarCardNumber_vc"] = " کارت هوشمند کامیون : " + LadBillLadeAssignmentDataTable.Rows[0]["CarCardNumber_nvc"].ToString();
                }
                else
                {
                    LadBillReportstiReport["CarCardNumber_vc"] = " کارت هوشمند کامیون :فاقد كارت ";
                }

                LadBillReportstiReport["MobileNumber_vc"]       = string.Format("موبایل راننده: {0}", LadBillLadeAssignmentDataTable.Rows[0]["DriverMobileNumber_nvc"].ToString());
                LadBillReportstiReport["Company_nvc"]           = LadBillLadeAssignmentDataTable.Rows[0]["CompanyID_intCompany_nvc"].ToString() + "(" + LadBillLadeAssignmentDataTable.Rows[0]["CompanyCode_nvc"].ToString() + ")" + "(" + LadBillLadeAssignmentDataTable.Rows[0]["Phone_nvc"].ToString() + ")";                                         //Cmp_nvc
                LadBillReportstiReport["LaderType_nvc"]         = LadBillLadeAssignmentDataTable.Rows[0]["LaderTypeID_intLaderType_nvc"].ToString();
                LadBillReportstiReport["Boxing_nvc"]            = LadBillLadeAssignmentDataTable.Rows[0]["BoxingID_intBoxingType_nvc"].ToString();                                                                                                                                                                                                       //LaderType
                LadBillReportstiReport["PlateNumber_nvc"]       = Hepsa.Core.Common.PersentationController.CorrectNumberPlate(LadBillLadeAssignmentDataTable.Rows[0]["NumberPlate_nvc"].ToString()) + " - " + LadBillLadeAssignmentDataTable.Rows[0]["PlateCity_nvc"].ToString() + LadBillLadeAssignmentDataTable.Rows[0]["SerialPlate_nvc"].ToString(); //Plaque
                LadBillReportstiReport["DriverName_nvc"]        = LadBillLadeAssignmentDataTable.Rows[0]["DriverName"].ToString();                                                                                                                                                                                                                       //Driver
                LadBillReportstiReport["LicenceNumber_bint"]    = (LadBillLadeAssignmentDataTable.Rows[0]["licenceNumber_int"] != DBNull.Value?Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["licenceNumber_int"]):0);                                                                                                                          //LicenceNumber
                LadBillReportstiReport["LicenceCity_nvc"]       = LadBillLadeAssignmentDataTable.Rows[0]["LicenceCityID_intCity_nvc"].ToString();                                                                                                                                                                                                        //LicenceCity
                LadBillReportstiReport["Good_nvc"]              = LadBillLadeAssignmentDataTable.Rows[0]["GoodID_intGood_nvc"].ToString();                                                                                                                                                                                                               //Good
                LadBillReportstiReport["Date_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadingDate_nvc"].ToString();                                                                                                                                                                                                                   //
                LadBillReportstiReport["Destination_nvc"]       = LadBillLadeAssignmentDataTable.Rows[0]["CityID_intCity_nvc"].ToString() + "-" + LadBillLadeAssignmentDataTable.Rows[0]["Address_nvc"].ToString();
                LadBillReportstiReport["PortajeFee_dec"]        = LadBillLadeAssignmentDataTable.Rows[0]["PortageFee_dec"].ToString();
                LadBillReportstiReport["AssignmentComment_nvc"] = LadBillLadeAssignmentDataTable.Rows[0]["AssignmentComment_nvc"].ToString();
                LadBillReportstiReport["Date_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadBillDate"].ToString();
                LadBillReportstiReport["Time_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadBillTime"].ToString();
                LadBillReportstiReport["TurnNumber_bint"]       = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["AcceptedTurnNumber_bint"]);
                LadBillReportstiReport["LadBillNumber_bint"]    = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["LadBillCreditID_int"]);
                LadBillReportstiReport["UserName_nvc"]          = LadBillLadeAssignmentDataTable.Rows[0]["LadBillUser"].ToString();
                LadBillReportstiReport["PortPlace_nvc"]         = LadBillLadeAssignmentDataTable.Rows[0]["PortPlaceID_intPortPlaces_nvc"].ToString();
                LadBillReportstiReport["MinWeight_nvc"]         = "از وزن: " + LadBillLadeAssignmentDataTable.Rows[0]["MinWeight_dec"];
                LadBillReportstiReport["MaxWeight_nvc"]         = "تا وزن: " + LadBillLadeAssignmentDataTable.Rows[0]["MaxWeight_dec"];
                LadBillReportstiReport["TrafficNumber_bint"]    = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["TrafficNumber_bint"]);
                LadBillReportstiReport["System_nvc"]            = LadBillLadeAssignmentDataTable.Rows[0]["System_nvc"].ToString();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillMessage_TFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillMessage_TList    = new List <HPS.BLL.BillMessageBLL.BLLBillMessage_T>();
                string Condition = string.Format("TrafficType_T.TrafficTypeID_int=9 AND [BillMessage_T].StartDate_nvc<='{0}' AND [BillMessage_T].[EndDate_nvc]>='{0}' ", BillMessage_TFactory.ServerJalaliDate);
                BillMessage_TList = BillMessage_TFactory.GetAllByCondition(Condition);
                if (BillMessage_TList != null && BillMessage_TList.Count > 0)
                {
                    LadBillReportstiReport["BillMessage_nvc"] = BillMessage_TList[0].Message_nvc;
                }
                if (_again != 1)
                {
                    if (LadBillLadeAssignmentDataTable.Rows[0]["LadeDate"].ToString().CompareTo(LadBillCreditFactory.ServerJalaliDate) < 0)
                    {
                        LadBillReportstiReport["Remained_bit"] = true;
                    }
                    else
                    {
                        LadBillReportstiReport["Remained_bit"] = false;
                    }
                }

                if (_again == 1)
                {
                    LadBillReportstiReport["Again_bit"]          = true;
                    LadBillReportstiReport["AgainPrintDate_vc"]  = LadBillCreditFactory.ServerJalaliDate;
                    LadBillReportstiReport["AgainPrintTime_vc"]  = LadBillCreditFactory.ServerTime;
                    LadBillReportstiReport["AgainPrintUser_vnc"] = HPS.Common.CurrentUser.user.UserName_nvc;
                }
                LadBillReportstiReport.Render();
                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    LadBillReportstiReport.PrinterSettings.Copies = 3;
                    LadBillReportstiReport.Print(true);
                }

                else
                {
                    LadBillReportstiReport.PrinterSettings.Copies = 3;
                    PrinterSetting.PrinterName = s.PrinterName;
                    LadBillReportstiReport.Print(false, PrinterSetting);
                }
            }
            else
            {
                stiViewerControl1.Report = _sti;
            }
            this.Close();
        }
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                dmpe = new D_MonthlyPurchase_Entity();
                dmpe = GetData();
                DataTable dt = szybl.RPC_SiiresakiZaikoYoteiHyou(dmpe);
                if (dt.Rows.Count > 0)
                {
                    // CheckBeforeExport();
                    try
                    {
                        SiiresakiZaikoYoteiHyou_Report szy_Report = new SiiresakiZaikoYoteiHyou_Report();
                        DialogResult DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            szy_Report.SetDataSource(dt);
                            szy_Report.Refresh();
                            szy_Report.SetParameterValue("lblDateFrom", txtTargetDateFrom.Text);
                            szy_Report.SetParameterValue("lblDateTo", txtTargetDateTo.Text);
                            szy_Report.SetParameterValue("lblStore", cboStore.SelectedValue.ToString() + "   " + cboStore.AccessibilityObject.Name);
                            szy_Report.SetParameterValue("lblToday", dt.Rows[0]["Today"].ToString());
                            try
                            {
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            if (DResult == DialogResult.Yes)
                            {
                                var vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = szy_Report;
                                vr.ShowDialog();
                            }
                            else
                            {
                                CrystalDecisions.Shared.PageMargins margin = szy_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;
                                margin.rightMargin  = DefaultMargin.Right;
                                szy_Report.PrintOptions.ApplyPageMargins(margin);
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
                                    szy_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    szy_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    szy_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    szy_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        txtTargetDateTo.Focus();
                    }
                }
                else
                {
                    szybl.ShowMessage("E128");
                    txtTargetDateTo.Focus();
                }
            }
        }
        public static void Run()
        {
            try
            {
                // ExStart:CheckPrintJobStatus
                // The path to the documents directory.
                string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

                // Instantiate PdfViewer object
                PdfViewer viewer = new PdfViewer();

                // Bind source PDF file
                viewer.BindPdf(dataDir + "input.pdf");
                viewer.AutoResize = true;

                // Hide printing dialog
                viewer.PrintPageDialog = false;

                // Create Printer Settings object
                System.Drawing.Printing.PrinterSettings ps = new System.Drawing.Printing.PrinterSettings();
                System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings();
                System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();

                // Specify the printer anme
                ps.PrinterName = "Microsoft XPS Document Writer";

                // Resultant Printout name
                ps.PrintFileName = "ResultantPrintout.xps";

                // Print the output to file
                ps.PrintToFile = true;
                ps.FromPage = 1;
                ps.ToPage = 2;
                ps.PrintRange = System.Drawing.Printing.PrintRange.SomePages;

                // Specify the page size of printout
                pgs.PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169);
                ps.DefaultPageSettings.PaperSize = pgs.PaperSize;
                pgs.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);

                // Print the document with settings specified above
                viewer.PrintDocumentWithSettings(pgs, ps);

                // Check the print status
                if (viewer.PrintStatus != null)
                {
                    // An exception was thrown
                    Exception ex = viewer.PrintStatus as Exception;
                    if (ex != null)
                    {
                        // Get exception message
                    }
                }
                else
                {
                    // No errors were found. Printing job has completed successfully
                    Console.WriteLine("printing completed without any issue..");
                }
                // ExEnd:CheckPrintJobStatus
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }
            if (ErrorCheck())
            {
                dpde = new D_Purchase_Details_Entity();
                dmse = new D_MonthlyStock_Entity();
                dpde = PurchaseDetailInfo();
                dmse = MonthlyStockInfo();
                if (chkRelatedPrinting.Checked == true)
                {
                    if (rdoITEM.Checked == true)
                    {
                        chk = 1;
                    }
                    else if (rdoProductCD.Checked == true)
                    {
                        chk = 2;
                    }
                }
                else
                {
                    chk = 3;
                }

                DataTable dt = zkhbl.RPC_ZaikoKanriHyou(dpde, dmse, chk);

                if (dt.Rows.Count > 0)
                {
                    // CheckBeforeExport();
                    try
                    {
                        ZaikoKanriHyou_Report zkh_Report = new ZaikoKanriHyou_Report();
                        DialogResult          DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            zkh_Report.SetDataSource(dt);
                            zkh_Report.Refresh();
                            zkh_Report.SetParameterValue("lblDate", txtTargetDate.Text);
                            zkh_Report.SetParameterValue("lblSouko", cboSouko.SelectedValue.ToString() + "   " + cboSouko.AccessibilityObject.Name);
                            zkh_Report.SetParameterValue("lblToday", dt.Rows[0]["Today"].ToString() + "  " + dt.Rows[0]["Now"].ToString());
                            try
                            {
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                var vr = new Viewer();
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = zkh_Report;
                                vr.ShowDialog();
                            }
                            else
                            {
                                CrystalDecisions.Shared.PageMargins margin = zkh_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;
                                margin.rightMargin  = DefaultMargin.Right;
                                zkh_Report.PrintOptions.ApplyPageMargins(margin);
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();
                                    zkh_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    zkh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    zkh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    zkh_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        txtTargetDate.Focus();
                    }
                }
                else
                {
                    zkhbl.ShowMessage("E128");
                    txtTargetDate.Focus();
                }
            }
        }
Ejemplo n.º 29
0
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            if (ErrorCheck())
            {
                // レコード定義を行う
                mde = GetMonthlyDebt_Data();
                if (chkBalancePrint.Checked == true)
                {
                    chk = 1;
                }
                else
                {
                    chk = 0;
                }
                dtExport = saimukanriBL.D_MonthlyDebt_CSV_Report(mde, chk);
                if (dtExport.Rows.Count > 0)
                {
                    CheckBeforeExport();
                    try
                    {
                        SaimuKanriKyou_Report smkh_Report = new SaimuKanriKyou_Report();
                        DialogResult          DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            smkh_Report.SetDataSource(dtExport);
                            smkh_Report.Refresh();
                            smkh_Report.SetParameterValue("lblYearMonth", txtTargetYear.Text);
                            smkh_Report.SetParameterValue("lblStore", dtExport.Rows[0]["StoreCD"].ToString() + "  " + dtExport.Rows[0]["StoreName"].ToString());
                            smkh_Report.SetParameterValue("lblToday", dtExport.Rows[0]["Today"].ToString() + "  " + dtExport.Rows[0]["Now"].ToString());
                            crv = vr.CrystalReportViewer1;
                            crv.ReportSource = smkh_Report;
                            vr.ShowDialog();

                            try
                            {
                                //  crv = vr.CrystalReportViewer1;
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message;
                            }
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                //印刷処理プレビュー
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = smkh_Report;

                                vr.ShowDialog();
                            }
                            else
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = smkh_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;          // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;        //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                smkh_Report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                                    smkh_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    smkh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    smkh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    smkh_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                    // Print the report. Set the startPageN and endPageN
                                    // parameters to 0 to print all pages.
                                    //Report.PrintToPrinter(1, false, 0, 0);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                        //プログラム実行履歴
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        //画面はそのまま
                        txtTargetYear.Focus();
                    }
                }
                else
                {
                    saimukanriBL.ShowMessage("E128");
                }
            }
        }
Ejemplo n.º 30
0
        internal static void OpenCashDrawer(byte[] controlCode)
        {
            var settings = new System.Drawing.Printing.PrinterSettings();

            RawPrinterHelper.SendStringToPrinter(settings.PrinterName, Encoding.ASCII.GetString(controlCode));
        }
Ejemplo n.º 31
0
        /// <summary>
        /// 纸张格式
        /// </summary>
        /// <param name="strPrinterName"></param>
        private void InitPaperTypeSource(string strPrinterName)
        {
            if (strPrinterName != "")
            {
                if (mSelectedPrinter == null)
                {
                    mSelectedPrinter = new System.Drawing.Printing.PrinterSettings();
                }
                mSelectedPrinter.PrinterName = strPrinterName;
                if (mSelectedPrinter.IsValid)
                {
                    if (dtPaperType == null)
                    {
                        dtPaperType = new DataTable();
                        dtPaperType.Columns.Add("PaperType", typeof(string));
                        dtPaperType.Columns.Add("PaperKind", typeof(int));
                        dtPaperType.Columns.Add("PaperSizeHeight", typeof(int));
                        dtPaperType.Columns.Add("PaperSizeWidth", typeof(int));
                    }
                    dtPaperType.Rows.Clear();
                    foreach (System.Drawing.Printing.PaperSize pageSize in mSelectedPrinter.PaperSizes)
                    {
                        DataRow drPaperType = dtPaperType.NewRow();
                        drPaperType["PaperType"]       = pageSize.PaperName;
                        drPaperType["PaperKind"]       = Convert.ToInt32(pageSize.Kind);
                        drPaperType["PaperSizeHeight"] = InchToMM(pageSize.Height);
                        drPaperType["PaperSizeWidth"]  = InchToMM(pageSize.Width);
                        dtPaperType.Rows.Add(drPaperType);
                    }

                    if (dtPaperSources == null)
                    {
                        dtPaperSources = new DataTable();
                        dtPaperSources.Columns.Add("PaperSourceName", typeof(string));
                        dtPaperSources.Columns.Add("PaperSourceKind", typeof(string));
                        dtPaperSources.Columns.Add("PaperSourceRawKind", typeof(int));
                    }
                    dtPaperSources.Rows.Clear();
                    DataRow drPaperSourcesNew = dtPaperSources.NewRow();
                    drPaperSourcesNew["PaperSourceName"]    = "自动选择";
                    drPaperSourcesNew["PaperSourceKind"]    = "FormSource";
                    drPaperSourcesNew["PaperSourceRawKind"] = 0;
                    dtPaperSources.Rows.Add(drPaperSourcesNew);
                    foreach (System.Drawing.Printing.PaperSource source in mSelectedPrinter.PaperSources)
                    {
                        if (source.Kind.ToString() == "FormSource")
                        {
                            continue;
                        }
                        DataRow drPaperSources = dtPaperSources.NewRow();
                        drPaperSources["PaperSourceName"]    = source.SourceName.ToString();
                        drPaperSources["PaperSourceKind"]    = source.Kind.ToString();
                        drPaperSources["PaperSourceRawKind"] = source.RawKind;
                        dtPaperSources.Rows.Add(drPaperSources);
                    }

                    txtPaperType.DisplayMember = txtPaperType.ValueMember = "PaperType";
                    txtPaperType.DataSource    = dtPaperType.DefaultView;
                }
                else
                {
                    LB.WinFunction.LBCommonHelper.ShowCommonMessage("所选打印机正处于脱机状态中");
                    return;
                }
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Set export file type or printer to Report Document object.
        /// </summary>
        private void ApplyReportOutput()
        {
            if (_printToPrinter)
            {
                var printerName = ReportArguments.PrinterName != null?ReportArguments.PrinterName.Trim() : "";

                if (printerName.Length > 0)
                {
                    _reportDoc.PrintOptions.PrinterName = printerName;
                }
                else
                {
                    System.Drawing.Printing.PrinterSettings prinSet = new System.Drawing.Printing.PrinterSettings();

                    if (prinSet.PrinterName.Trim().Length > 0)
                    {
                        _reportDoc.PrintOptions.PrinterName = prinSet.PrinterName;
                    }
                    else
                    {
                        throw new Exception("No printer name is specified");
                    }
                }
            }
            else
            {
                if (_outputFormat.ToUpper() == "RTF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.RichText;
                }
                else if (_outputFormat.ToUpper() == "TXT")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Text;
                }
                else if (_outputFormat.ToUpper() == "TAB")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.TabSeperatedText;
                }
                else if (_outputFormat.ToUpper() == "CSV")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.CharacterSeparatedValues;
                }
                else if (_outputFormat.ToUpper() == "PDF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                    var grpCnt = _reportDoc.DataDefinition.Groups.Count;
                    if (grpCnt > 0)
                    {
                        _reportDoc.ExportOptions.ExportFormatOptions = new PdfFormatOptions {
                            CreateBookmarksFromGroupTree = true
                        }
                    }
                    ;
                }
                else if (_outputFormat.ToUpper() == "RPT")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.CrystalReport;
                }
                else if (_outputFormat.ToUpper() == "DOC")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
                }
                else if (_outputFormat.ToUpper() == "XLS")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Excel;
                }
                else if (_outputFormat.ToUpper() == "XLSDATA")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.ExcelRecord;
                }
                else if (_outputFormat.ToUpper() == "ERTF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.EditableRTF;
                }
                else if (_outputFormat.ToUpper() == "XML")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Xml;
                }
                else if (_outputFormat.ToUpper() == "HTM")
                {
                    HTMLFormatOptions htmlFormatOptions = new HTMLFormatOptions();

                    if (_outputFilename.LastIndexOf("\\") > 0) //if absolute output path is specified
                    {
                        htmlFormatOptions.HTMLBaseFolderName = _outputFilename.Substring(0, _outputFilename.LastIndexOf("\\"));
                    }

                    htmlFormatOptions.HTMLFileName             = _outputFilename;
                    htmlFormatOptions.HTMLEnableSeparatedPages = false;
                    htmlFormatOptions.HTMLHasPageNavigator     = true;
                    htmlFormatOptions.FirstPageNumber          = 1;

                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.HTML40;
                    _reportDoc.ExportOptions.FormatOptions    = htmlFormatOptions;
                }
            }
        }
Ejemplo n.º 33
0
        public void F12()
        {
            if (ErrorCheck())
            {
                doe = new D_Order_Entity
                {
                    StoreCD            = cboStore.SelectedValue.ToString(),
                    DestinationSoukoCD = cboWareHouse.SelectedValue.ToString(),
                };
                DateTime firstday = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                firstday.AddDays(-1).ToString("dd/MM/yyyy");

                string Text = txtTargetDateTo.Text;
                if (!string.IsNullOrWhiteSpace(Text))
                {
                    string[] p       = Text.Split('/');
                    string   y       = p[0].ToString();
                    string   m       = p[1].ToString();
                    int      yy      = Convert.ToInt32(y);
                    int      mm      = Convert.ToInt32(m);
                    DateTime lastday = new DateTime(yy, mm,
                                                    DateTime.DaysInMonth(yy, mm));

                    dpe = new D_Purchase_Entity
                    {
                        PurchaseDateFrom = firstday.ToShortDateString(),
                        PurchaseDateTo   = lastday.ToShortDateString(),
                    };
                }
                else
                {
                    dpe = new D_Purchase_Entity
                    {
                        PurchaseDateFrom = firstday.ToShortDateString(),
                        PurchaseDateTo   = null,
                    };
                }


                DataTable dt = zkybl.D_Order_Select(doe, dpe);
                //if (dt == null)
                if (dt.Rows.Count == 0)
                {
                    //if (dt == null) return;
                    zkybl.ShowMessage("E128");
                    txtTargetDateTo.Focus();
                }
                else
                {
                    dt.Columns.Add("Total");
                    dt.Rows[0]["Total"] = dt.Rows[0]["Gaku"].ToString();
                    decimal t = Convert.ToDecimal(dt.Rows[1]["Gaku"]) + Convert.ToDecimal(dt.Rows[0]["Total"]);
                    dt.Rows[1]["Total"] = t.ToString();

                    for (int i = 2; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i]["Total"] = Convert.ToDecimal(dt.Rows[i]["Gaku"]) + Convert.ToDecimal(dt.Rows[i - 1]["Total"]);
                    }

                    try
                    {
                        ZaikoYoteiHyouReport Report = new ZaikoYoteiHyouReport();
                        DialogResult         ret;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            Report.SetDataSource(dt);
                            Report.Refresh();
                            Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));
                            Report.SetParameterValue("TargetDate", txtTargetDateFrom.Text + " ~ " + txtTargetDateTo.Text);
                            Report.SetParameterValue("txtSouko", cboWareHouse.SelectedValue.ToString() + "  " + cboWareHouse.Text);

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = new Viewer();
                                previewForm.CrystalReportViewer1.ShowPrintButton = true;
                                previewForm.CrystalReportViewer1.ReportSource    = Report;
                                previewForm.ShowDialog();
                            }
                            else
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;     // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;   //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                Report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                                    Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                    // Print the report. Set the startPageN and endPageN
                                    // parameters to 0 to print all pages.
                                    //Report.PrintToPrinter(1, false, 0, 0);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }
                    }
                    finally
                    {
                        txtTargetDateTo.Focus();
                    }
                }
            }
        }
Ejemplo n.º 34
0
 /// <summary>
 /// Handler for the printersComboBox selection changed event
 /// </summary>
 /// <param name="sender">not used</param>
 /// <param name="e">not used</param>
 void PrintersComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     // get printer PrintableArea and PaperSize
     string printer = printersComboBox.SelectedItem as string;
     if(printer != null && !printer.Equals(string.Empty))
     {
         System.Drawing.Printing.PrinterSettings settings
             = new System.Drawing.Printing.PrinterSettings();
         settings.PrinterName = printer;
         System.Drawing.RectangleF area = settings.DefaultPageSettings.PrintableArea;
         float paperHeight = settings.DefaultPageSettings.PaperSize.Height;
         float paperWidth = settings.DefaultPageSettings.PaperSize.Width;
         // convert margins to inches and mm
         LeftMarginInches = area.Left / 100F;
         LeftMarginMM = LeftMarginInches * 25.4F;
         LeftMarginBrush = LeftMarginInches > 0.25F ? Brushes.Red :
             Brushes.DarkGreen;
         TopMarginInches = area.Top / 100F;
         TopMarginMM = TopMarginInches * 25.4F;
         TopMarginBrush = TopMarginInches > 0.25F ? Brushes.Red :
             Brushes.DarkGreen;
         RightMarginInches = (paperWidth - area.Right) / 100F;
         RightMarginMM = RightMarginInches * 25.4F;
         RightMarginBrush = RightMarginInches > 0.25F ? Brushes.Red :
             Brushes.DarkGreen;
         BottomMarginInches = (paperHeight - area.Bottom) / 100F;
         BottomMarginMM = BottomMarginInches * 25.4F;
         BottomMarginBrush = BottomMarginInches > 0.25F ? Brushes.Red :
             Brushes.DarkGreen;
         // if any margin is greater than ¼ inch, warn user
         marginWarningText.Visibility = LeftMarginInches > 0.25 ||
             TopMarginInches > 0.25 || RightMarginInches > 0.25 ||
             BottomMarginInches > 0.25 ?
             Visibility.Visible : Visibility.Collapsed;
     }
 }
Ejemplo n.º 35
0
        static void Main(string[] args)
        {
            Console.WriteLine("PrintPDF Sample:");

            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
            if (String.IsNullOrEmpty(settings.PrinterName))
            {
                Console.WriteLine("A printer must be made available to use this sample.");
                return;
            }

            try
            {
                // Printing may fail for reasons that have nothing to do with APDFL.
                // PDF documents may contain material that cannot be printed, etc. Given
                // that, it's always best to expect the printing step to fail and take
                // appropriate measures. Such care becomes critical for server-based 24/7
                // systems. This try block is simply here as an example (the steps one
                // would normally take are more involved).

                // To use APDFL one must always begin by initializing the library. This action
                // is expensive (both time and resource wise) and should only be done when necessary.
                // In a threaded product, a separate library must be instantiated on each thread.
                // ReSharper disable once UnusedVariable
                using (Library lib = new Library())
                {
                    Console.WriteLine(@"Library initialized.");

                    String sInput = Library.ResourceDirectory + "Sample_Input/sample.pdf";

                    // HINT: you'll find the file (in the working directory) next to PrintPDF.exe
                    String outFileNamePrn = "PrintPDF_out.prn";

                    // HINT: you'll find the file (in the working directory) next to PrintPDF.exe
                    string outFileNamePs = "PrintPDF_out.ps";

                    if (args.Length > 0)
                    {
                        sInput = args[0];
                    }

                    Console.WriteLine("Input file: " + sInput + ". Writing to output " + outFileNamePrn + " and " +
                                      outFileNamePs);

                    // Open a PDF document ("using" will automatically .Close and .Dispose it)...
                    using (Document doc = new Document(sInput))
                    {
                        #region Print To File (via Printer Driver)

                        // Platform print to a file...
                        //
                        // Printed output from the following method is composed by the selected
                        // printer's driver; along with assistance from APDFL. The actual
                        // output format will vary (e.g., PCL, PostScript, XPS, etc.). PostScript
                        // files produced via a PostScript driver and this method are NOT suitable
                        // for Distillation, Normalization, etc. All output from the method below
                        // will be optimized specifically for the target printer and is only suitable
                        // for direct consumption by that printer (or a print spooler that will
                        // ultimately transfer it to the target printer).

                        using (PrintUserParams userParams = new PrintUserParams())
                        {
                            // NOTE: userParams are only valid for ONE print job...
                            userParams.NCopies = 1;
                            userParams.PrintParams.ExpandToFit = true;

#if WINDOWS
                            userParams.ShrinkToFit = true;

                            // This sets the file name that the printer driver knows about
                            // It's completely optional and only needs to be set if one wants
                            // a value that differs from the PDF file name (which is
                            // automatically provided by default). It is used for the
                            // %%Title comment in a PostScript file, etc.

                            //Isolate the filename from the path
                            int    index = sInput.LastIndexOf("/");
                            String nameOnly;

                            if (index != -1)
                            {
                                nameOnly = sInput.Substring(index + 1);
                            }
                            else
                            {
                                nameOnly = sInput;
                            }

                            userParams.InFileName = nameOnly;
#endif

                            // When print to file you MUST use 1+ page ranges...
                            // Page ranges allow complex collections of pages to be emitted.
                            // If you don't provide a page range, only the first page of the document will print.
                            //
                            // The code below creates 3 page ranges...
                            // As specified (below), PDFL will emit up to 8 pages (1-4, 2, 4, 1, 3).
                            int upToFourPages = ((doc.NumPages > 4) ? 3 : doc.NumPages - 1); // 0-based
                            if (upToFourPages == 0)
                            {
                                // the end page must always be >= 1
                                upToFourPages = 1;
                            }

                            IList <PageRange> pageRanges = new List <PageRange>();
                            pageRanges.Add(new PageRange(0, upToFourPages, PageSpec.AllPages)); // p1-4
                            if (doc.NumPages > 1)
                            {
                                // you can't ask for even or odd pages from a 1 page document
                                pageRanges.Add(new PageRange(0, upToFourPages, PageSpec.OddPagesOnly));  // p1,3
                                pageRanges.Add(new PageRange(0, upToFourPages, PageSpec.EvenPagesOnly)); // p2,4
                            }

                            PrintParams printParams = userParams.PrintParams;
                            printParams.PageRanges = pageRanges;

                            // Why .prn? Because we're printing via the printer driver (here)
                            // and cannot tell what type of output the driver will produce.
                            // PostScript drivers will produce PostScript output. PCL drivers
                            // will produce PCL or PCL_XL. Similarly, XPS drivers may produce
                            // XPS and PDF drivers may produce PDF (directly).
                            //
                            // PostScript produced via the PrintToFile method is NOT equivalent
                            // to PostScript produced via the ExportAsPostScript method.

                            Console.WriteLine("Printing to File: {0}", outFileNamePrn);
                            doc.PrintToFile(userParams, null /* for cancel see the PrintPDFGUI sample */,
                                            new SamplePrintProgressProc(), outFileNamePrn);
                        }

                        #endregion

                        #region Print To Printer (via Printer Driver)

                        // Now let's, print directly to a printer (without ui)...
                        //
                        // Printed output from the following method is composed by the selected
                        // printer's driver; along with assistance from APDFL. The actual
                        // output format will vary (e.g., PCL, PostScript, XPS, etc.). PostScript
                        // files produced via a PostScript driver and this method are NOT suitable
                        // for Distillation, Normalization, etc. All output from the method below
                        // will be optimized specifically for the target printer and is only suitable
                        // for direct consumption by that printer (or a print spooler that will
                        // ultimately transfer it to the target printer).

                        using (PrintUserParams userParams = new PrintUserParams())
                        {
                            // NOTE: userParams are only valid for ONE print job...
                            userParams.NCopies = 1;
                            userParams.PrintParams.ExpandToFit = true;

#if WINDOWS
                            userParams.ShrinkToFit = true;

                            // This sets the file name that the printer driver knows about
                            // It's completely optional and only needs to be set if one wants
                            // a value that differs from the PDF file name (which is
                            // automatically provided by default). It is used for the
                            // %%Title comment in a PostScript file, etc.

                            //Isolate the filename from the path
                            int    index = sInput.LastIndexOf("/");
                            String nameOnly;

                            if (index != -1)
                            {
                                nameOnly = sInput.Substring(index + 1);
                            }
                            else
                            {
                                nameOnly = sInput;
                            }

                            userParams.InFileName = nameOnly;

                            // When printing (directly) to a printer you cannot use page ranges...
                            // You need to use userParams.StartPage and EndPage (to request a single,
                            // linear sequence) instead. If you do not specify anything the entire
                            // document will print (i.e., all pages).
                            //
                            // As specified (below), PDFL will print up to 4 pages (1-4).
                            int upToFourPages = ((doc.NumPages > 4) ? 3 : doc.NumPages - 1);
                            userParams.StartPage = 0;             // 0-based
                            userParams.EndPage   = upToFourPages; // 0-based
#endif

                            // Use the default printer...
#if Windows || MacOS
                            userParams.UseDefaultPrinter(doc);
#endif

                            // ...or uncomment the code below (and comment out the code above) and
                            // assign the name of a (accessible) printer to userParams.DeviceName so
                            // as to explicitly target a printer.
                            //userParams.DeviceName = @"Change Me to a valid Printer Name";

#if WINDOWS
                            Console.WriteLine(String.Format("Printing (direct) to Printer: {0}", userParams.DeviceName));
#endif
                            doc.Print(userParams, null /* for cancel see the PrintPDFGUI sample */,
                                      new SamplePrintProgressProc());
                        }

                        #endregion

                        #region Export As PostScript (Device Independent, DSC Compliant)

                        // Export as (PDFL composed) PostScript...
                        //
                        // PostScript files produced via this *export* method are suitable
                        // for Distillation, Normalization, etc. If a PostScript Printer
                        // Description (PPD) is registered (not shown here) the output will
                        // be device specific. Otherwise, it will be device independent.
                        // Consult the PostScript Language Document Structuring Conventions
                        // for more information about the conformance / structure of the
                        // exported PostScript.
                        //
                        // https://partners.adobe.com/public/developer/en/ps/5001.DSC_Spec.pdf

                        using (PrintUserParams userParams = new PrintUserParams())
                        {
                            // NOTE: userParams are only valid for ONE print job...
                            userParams.NCopies = 1;

                            // When export as PostScript you MUST use 1+ page ranges...
                            // Page ranges allow complex collections of pages to be emitted.
                            //
                            // The code below exports the entire PDF document (to a PostScript file)...
                            IList <PageRange> pageRanges = new List <PageRange>();
                            pageRanges.Add(new PageRange(0, (((doc.NumPages > 1)) ? doc.NumPages - 1 : 1),
                                                         PageSpec.AllPages)); // all pages
                            PrintParams printParams = userParams.PrintParams;
                            printParams.PageRanges = pageRanges;

                            Console.WriteLine("Exporting as PostScript to File: {0}", outFileNamePs);
                            doc.ExportAsPostScript(userParams, null /* for cancel see the PrintPDFGUI sample */,
                                                   new SamplePrintProgressProc(), outFileNamePs);
                        }

                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"An exception occurred. Here is the related information:");
                Console.Write(ex.ToString());
            }
        }
Ejemplo n.º 36
0
                public override Lfx.Types.OperationResult BeforePrint()
                {
                        Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;
                        if (Comprob.Articulos.Count >= 1 && (Comprob.Articulos[0].Cantidad < 0 || Comprob.Articulos[0].Unitario < 0))
                                return new Lfx.Types.OperationResult(false, "El primer ítem de la factura no puede ser negativo. Utilice los ítem negativos en último lugar.");

                        Comprob.Cliente.Cargar();

                        if (Comprob.FormaDePago == null)
                                return new Lfx.Types.FailureOperationResult("Por favor seleccione la forma de pago.");

                        if (Comprob.Cliente == null)
                                return new Lfx.Types.FailureOperationResult("Por favor seleccione un cliente.");

                        if (Comprob.Tipo == null)
                                return new Lfx.Types.FailureOperationResult("Por favor seleccione el tipo de comprobante.");

                        if (Lbl.Sys.Config.Pais.Id == 1) {
                                // Verificaciones especiales para Argentina
                                if (Comprob.Tipo.EsFacturaNCoND && Comprob.Cliente.SituacionTributaria != null && Comprob.Tipo.Letra != Comprob.Cliente.LetraPredeterminada()) {
                                        Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog(@"La situación tributaria del cliente y el tipo de comprobante no se corresponden.
Un cliente " + Comprob.Cliente.SituacionTributaria.ToString() + @" debería llevar un comprobante tipo " + Comprob.Cliente.LetraPredeterminada() + @". No debería continuar con la impresión. 
¿Desea continuar de todos modos?", "Tipo de comprobante incorrecto");
                                        Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                                        if (Pregunta.ShowDialog() == DialogResult.Cancel)
                                                return new Lfx.Types.FailureOperationResult("Corrija la situación tributaria del cliente o el tipo de comprobante.");
                                }

                                if (Comprob.Tipo.Letra.ToUpperInvariant() == "A") {
                                        if (Comprob.Cliente.ClaveTributaria == null || Comprob.Cliente.ClaveTributaria.EsValido() == false)
                                                return new Lfx.Types.FailureOperationResult("El cliente no tiene una CUIT válida. Por favor edite el cliente y escriba una CUIT válida.");
                                } else if (Comprob.Tipo.Letra == "B") {
                                        //Si es factura B de más de $ 1000, debe llevar el Nº de DNI
                                        if (Comprob.Total >= 1000 && Comprob.Cliente.NumeroDocumento.Length < 5 &&
                                                (Comprob.Cliente.ClaveTributaria == null || Comprob.Cliente.ClaveTributaria.EsValido() == false))
                                                return new Lfx.Types.FailureOperationResult("Para Facturas B de $ 1.000 o más debe proporcionar el número de DNI/CUIT del cliente.");
                                        //Si es factura B de más de $ 1000, debe llevar domicilio
                                        if (Comprob.Total >= 1000 && Comprob.Cliente.Domicilio.Length < 1)
                                                return new Lfx.Types.FailureOperationResult("Para Facturas B de $ 1.000 o más debe proporcionar el domicilio del cliente.");
                                }
                        }

                        if (EntradaProductos.ShowStock && this.Tipo.MueveExistencias < 0 && Comprob.HayExistencias() == false) {
                                Lui.Forms.YesNoDialog OPregunta = new Lui.Forms.YesNoDialog("Las existencias actuales no son suficientes para cubrir la operación que intenta realizar.\n¿Desea continuar de todos modos?", "No hay existencias suficientes");
                                OPregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                                if (OPregunta.ShowDialog() == DialogResult.Cancel)
                                        return new Lfx.Types.FailureOperationResult("No se imprimir el comprobante por falta de existencias.");
                        }

                        if (Comprob.Cliente.Id != 999 && (Comprob.Tipo.EsFactura || Comprob.Tipo.EsNotaDebito)) {
                                decimal SaldoCtaCte = Comprob.Cliente.CuentaCorriente.ObtenerSaldo(false);

                                if (Comprob.FormaDePago != null && Comprob.FormaDePago.Tipo == Lbl.Pagos.TiposFormasDePago.CuentaCorriente) {
                                        decimal LimiteCredito = Comprob.Cliente.LimiteCredito;

                                        if (LimiteCredito == 0)
                                                LimiteCredito = Lfx.Types.Parsing.ParseCurrency(Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting<string>("Sistema.Cuentas.LimiteCreditoPredet", "0"));

                                        if (LimiteCredito != 0 && (Comprob.Total + SaldoCtaCte) > LimiteCredito)
                                                return new Lfx.Types.FailureOperationResult("El valor de la factura y/o el saldo en cuenta corriente supera el límite de crédito de este cliente.");
                                } else {
                                        if (SaldoCtaCte < 0) {
                                                using (SaldoEnCuentaCorriente FormularioError = new SaldoEnCuentaCorriente()) {
                                                        switch (FormularioError.ShowDialog()) {
                                                                case DialogResult.Yes:
                                                                        //Corregir el problema
                                                                        this.EntradaFormaPago.ValueInt = 3;
                                                                        this.Save();
                                                                        Comprob.FormaDePago.Tipo = Lbl.Pagos.TiposFormasDePago.CuentaCorriente;
                                                                        break;
                                                                case DialogResult.No:
                                                                        //Continuar. No corregir el problema.
                                                                        break;
                                                                default:
                                                                        //Cancelar y volver a la edición.
                                                                        return new Lfx.Types.OperationResult(false);
                                                        }
                                                }
                                        }
                                }
                        }

                        if (Comprob.PV < 1)
                                return new Lfx.Types.FailureOperationResult("Por favor escriba un punto de venta válido.");

                        if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.ContainsKey(Comprob.PV) == false) {
                                // No existe el PV... vacío la caché antes intentar de nuevo y dar un error
                                Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.Clear();
                                if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.ContainsKey(Comprob.PV) == false)
                                        return new Lfx.Types.FailureOperationResult("El punto de venta no existe. Si desea definir un nuevo punto de venta, utilice el menú Comprobantes -> Tablas -> Puntos de venta.");
                        }

                        Lbl.Comprobantes.PuntoDeVenta Pv = Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV];
                        if (Pv.Tipo == Lbl.Comprobantes.TipoPv.Normal) {
                                Lbl.Impresion.Impresora Impresora = Comprob.ObtenerImpresora();

                                if (Pv.CargaManual && (Impresora == null || Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Automatica)) {
                                        Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog();
                                        FormularioCargaManual.DocumentName = Comprob.Tipo.ToString() + " " + Comprob.PV.ToString("0000") + "-" + Lbl.Comprobantes.Numerador.ProximoNumero(Comprob).ToString("00000000");
                                        // Muestro el nombre de la impresora
                                        if (Impresora != null) {
                                                FormularioCargaManual.PrinterName = Impresora.Nombre;
                                        } else {
                                                System.Drawing.Printing.PrinterSettings objPrint = new System.Drawing.Printing.PrinterSettings();
                                                FormularioCargaManual.PrinterName = objPrint.PrinterName;
                                        }
                                        if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                                                return new Lfx.Types.CancelOperationResult();
                                }
                        }

                        if (Comprob.Tipo.MueveExistencias != 0) {
                                Lfx.Types.OperationResult Res = Comprob.VerificarSeries();
                                if (Res.Success == false)
                                        return Res;
                        }

                        return base.BeforePrint();
                }
Ejemplo n.º 37
0
        // Print out a document to a file which we will pass to ghostscript
        protected static void PrintToGhostscript(string printer, string outputFilename, PrintDocument printFunc)
        {
            String postscriptFilePath = "";
            String postscriptFile     = "";

            try
            {
                // Create a temporary location to output to
                postscriptFilePath = Path.GetTempFileName();
                File.Delete(postscriptFilePath);
                Directory.CreateDirectory(postscriptFilePath);
                postscriptFile = Path.Combine(postscriptFilePath, Guid.NewGuid() + ".ps");

                // Set up the printer
                PrintDialog printDialog = new PrintDialog
                {
                    AllowPrintToFile = true,
                    PrintToFile      = true
                };
                System.Drawing.Printing.PrinterSettings printerSettings = printDialog.PrinterSettings;
                printerSettings.PrintToFile   = true;
                printerSettings.PrinterName   = printer;
                printerSettings.PrintFileName = postscriptFile;

                // Call the appropriate printer function (changes based on the office application)
                printFunc(postscriptFile, printerSettings.PrinterName);
                ReleaseCOMObject(printerSettings);
                ReleaseCOMObject(printDialog);

                // Call ghostscript
                GhostscriptProcessor gsproc = new GhostscriptProcessor();
                List <string>        gsArgs = new List <string>
                {
                    "gs",
                    "-dBATCH",
                    "-dNOPAUSE",
                    "-dQUIET",
                    "-dSAFER",
                    "-dNOPROMPT",
                    "-sDEVICE=pdfwrite",
                    String.Format("-sOutputFile=\"{0}\"", string.Join(@"\\", outputFilename.Split(new string[] { @"\" }, StringSplitOptions.None))),
                    @"-f",
                    postscriptFile
                };
                gsproc.Process(gsArgs.ToArray());
            }
            finally {
                // Clean up the temporary files
                if (!String.IsNullOrWhiteSpace(postscriptFilePath) && Directory.Exists(postscriptFilePath))
                {
                    if (!String.IsNullOrWhiteSpace(postscriptFile) && File.Exists(postscriptFile))
                    {
                        // Make sure ghostscript is not holding onto the postscript file
                        for (var i = 0; i < 60; i++)
                        {
                            try
                            {
                                File.Delete(postscriptFile);
                                break;
                            }
                            catch (IOException)
                            {
                                Thread.Sleep(500);
                            }
                        }
                    }
                    Directory.Delete(postscriptFilePath);
                }
            }
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Routine to retrieve the name of the default printer.
 /// </summary>
 /// <returns>String value representing the name of the printer.</returns>
 public static string GetDefaultPrinterName()
 {
     System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();
     return(settings.PrinterName);
 }
        private void reportViewer1_ReportRefresh(object sender, CancelEventArgs e)
        {
            try
            {
                if (PrintBatch_CB.Checked == true)
                {
                    System.Drawing.Printing.PrinterSettings _PrinterSettings = new System.Drawing.Printing.PrinterSettings();
                    _PrinterSettings.PrinterName = Variables.PrinterName;
                    reportViewer1.PrintDialog(_PrinterSettings);

                    if (BillDataGridView.SelectedRows.Count > 0)
                    {
                        //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Dataset1", BillDataGridView.SelectedRows[0].Cells["ID"].Value.ToString()));
                        BillNumberSearch_txt.Text = BillDataGridView.SelectedRows[0].Cells["ID"].Value.ToString();
                        BillDataGridView.SelectedRows[0].Selected = false;

                        Variables.NotificationMessageTitle = this.Name;
                        Variables.NotificationMessageText = BillDataGridView.SelectedRows.Count.ToString();
                        Variables.NotificationStatus = true;

                        //reportViewer1.PrintDialog();
                    }
                }
            }
            catch (Exception ex)
            { }
            //           PrintwithDialog(reportViewer1);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Deserialize a Qsl Card saved as XML
        /// </summary>
        /// <param name="fileName">Name of XML file containing card description</param>
        /// <returns>Card object described by the XML file</returns>
        public static CardWF DeserializeCard(string fileName)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(CardWF));
            FileStream fs = new FileStream(fileName, FileMode.Open);
            XmlReader reader = XmlReader.Create(fs);

            CardWF card = (CardWF)serializer.Deserialize(reader);
            fs.Close();
            // set QslCard for each CardItem in card to this card
            card.BackgroundImage.QslCard = card;
            foreach(SecondaryWFImage si in card.SecondaryImages)
            {
                si.QslCard = card;
            }
            foreach(TextWFItem ti in card.TextItems)
            {
                ti.QslCard = card;
                System.Drawing.Text.InstalledFontCollection fontCol =
                    new System.Drawing.Text.InstalledFontCollection();
                // Must ensure that the font is installed. Otherwise card not displayed.
                string fontName = fontCol.Families[0].Name;
                foreach(System.Drawing.FontFamily family in fontCol.Families)
                {
                    if(family.Name == ti.TextFontFace)
                    {
                        fontName = ti.TextFontFace;
                        break;
                    }
                }
                ti.TextFontFace = fontName;
                foreach(TextPart part in ti.Text)
                {
                    part.RemoveExtraneousStaticTextMacros();
                }
            }
            if(card.QsosBox != null)
            {
                card.QsosBox.QslCard = card;
                foreach(TextPart part in card.QsosBox.ConfirmingText)
                {
                    part.RemoveExtraneousStaticTextMacros();
                }
            }
            // Must set default printer for card to system default printer if default
            // printer for card is not installed on computer. Otherwise, the card
            // will not display.
            System.Drawing.Printing.PrinterSettings settings = new
                System.Drawing.Printing.PrinterSettings();
            string printerName = settings.PrinterName;
            foreach(string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                if(printer.Equals(card.CardPrintProperties.PrinterName))
                {
                    printerName = card.CardPrintProperties.PrinterName;
                    break;
                }
            }
            card.CardPrintProperties.PrinterName = printerName;
            return card;
        }
        public void DefaultPaperTray()
        {
            //ExStart
            //ExFor:PageSetup.FirstPageTray
            //ExFor:PageSetup.OtherPagesTray
            //ExSummary:Changes all sections in a document to use the default paper tray of the selected printer.
            Document doc = new Document();

            // Find the printer that will be used for printing this document. In this case it is the default printer.
            // You can define a specific printer using PrinterName.
            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

            // The paper tray value stored in documents is completely printer specific. This means
            // The code below resets all page tray values to use the current printers default tray.
            // You can enumerate PrinterSettings.PaperSources to find the other valid paper tray values of the selected printer.
            foreach (Section section in doc.Sections)
            {
                section.PageSetup.FirstPageTray = settings.DefaultPageSettings.PaperSource.RawKind;
                section.PageSetup.OtherPagesTray = settings.DefaultPageSettings.PaperSource.RawKind;
            }
            //ExEnd
        }
Ejemplo n.º 42
0
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            if (ErrorCheck())
            {
                // レコード定義を行う
                dtResult = CheckData();

                //dmc_e = GetDataInfo();
                //dtResult = skh_bl.D_MonthlyClaims_Select(dmc_e);

                //if (dtResult == null)
                //{
                //    return;
                //}
                if (dtResult.Rows.Count > 0) // 2020-06-19 saw
                {
                    //exeRun
                    M_StoreCheck();
                    try
                    {
                        SaikenKanriHyou_Report skh_Report = new SaikenKanriHyou_Report();
                        DialogResult           DResult;
                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:
                            DResult = bbl.ShowMessage("Q201");
                            if (DResult == DialogResult.Cancel)
                            {
                                return;
                            }
                            // 印字データをセット
                            skh_Report.SetDataSource(dtResult);
                            skh_Report.Refresh();
                            skh_Report.SetParameterValue("YYYYMM", txtTargetdate.Text);
                            skh_Report.SetParameterValue("PrintDateTime", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));


                            crvr = vr.CrystalReportViewer1;
                            //out log before print
                            if (DResult == DialogResult.Yes)
                            {
                                //印刷処理プレビュー
                                vr.CrystalReportViewer1.ShowPrintButton = true;
                                vr.CrystalReportViewer1.ReportSource    = skh_Report;
                                vr.ShowDialog();
                            }
                            else
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = skh_Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;         // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;       //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                skh_Report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                                    skh_Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    skh_Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    skh_Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    skh_Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                    // Print the report. Set the startPageN and endPageN
                                    // parameters to 0 to print all pages.
                                    //Report.PrintToPrinter(1, false, 0, 0);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;
                        }

                        //プログラム実行履歴
                        InsertLog(Get_L_Log_Entity());
                    }
                    finally
                    {
                        //画面はそのまま
                        txtTargetdate.Focus();
                    }
                }
            }
        }
        protected override void PrintSec()
        {
            if (PrintMode != EPrintMode.DIRECT)
            {
                return;
            }

            //各項目のError Check
            if (ErrorCheck())
            {
                // レコード定義を行う
                // DataTable table = new DataTable();
                // レコード定義を行う
                dt = CheckData();
                if (dt == null)
                {
                    return;
                }
                try
                {
                    ShiraraiItiranHyou_Report Report = new ShiraraiItiranHyou_Report();
                    DialogResult DResult;
                    switch (PrintMode)
                    {
                    case EPrintMode.DIRECT:
                        DResult = bbl.ShowMessage("Q201");
                        if (DResult == DialogResult.Cancel)
                        {
                            return;
                        }
                        // 印字データをセット
                        Report.SetDataSource(dt);
                        Report.Refresh();
                        Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));
                        vr = previewForm.CrystalReportViewer1;
                        if (DResult == DialogResult.Yes)
                        {
                            //プレビュー
                            //var PreView = new Viewer();
                            previewForm.CrystalReportViewer1.ShowPrintButton = true;
                            previewForm.CrystalReportViewer1.ReportSource    = Report;
                            previewForm.ShowDialog();
                        }
                        else
                        {
                            //int marginLeft = 360;
                            CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                            margin.leftMargin   = DefaultMargin.Left;       // mmの指定をtwip単位に変換する
                            margin.topMargin    = DefaultMargin.Top;
                            margin.bottomMargin = DefaultMargin.Bottom;     //mmToTwip(marginLeft);
                            margin.rightMargin  = DefaultMargin.Right;
                            Report.PrintOptions.ApplyPageMargins(margin);   /// Error Now
                            // プリンタに印刷
                            System.Drawing.Printing.PageSettings ps;
                            try
                            {
                                System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                                Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                // Print the report. Set the startPageN and endPageN
                                // parameters to 0 to print all pages.
                                //Report.PrintToPrinter(1, false, 0, 0);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        break;
                    }

                    //プログラム実行履歴
                    InsertLog(Get_L_Log_Entity());
                }
                finally
                {
                    // 画面はそのまま
                    txtPurchaseDateFrom.Focus();
                }
            }
        }
Ejemplo n.º 44
0
        /// <summary>
        /// Print Report to specificed printer.
        /// </summary>
        /// <param name="rptViewer">The instance of Report Viewer Control.</param>
        /// <param name="printerName">The target printer name.</param>
        /// <param name="fromPage">-1 for print all</param>
        /// <param name="toPage">-1 for print all</param>
        /// <param name="noOfCopies">The Number of Copies.</param>
        /// <returns>Returns instance of RdlcPrintResult.</returns>
        public static RdlcPrintResult PrintTo(this ReportViewer rptViewer,
                                              string printerName,
                                              int fromPage     = -1, int toPage = -1,
                                              short noOfCopies = 1)
        {
            RdlcPrintResult result = new RdlcPrintResult();

            result.Success = false;

            if (string.IsNullOrWhiteSpace(printerName))
            {
                result.Message = "No printer selected.";

                RdlcMessageService.Instance.SendMessage(result.Message);

                return(result);
            }

            if (null == rptViewer.LocalReport ||
                null == rptViewer.LocalReport.DataSources ||
                rptViewer.LocalReport.DataSources.Count <= 0)
            {
                result.Message = "Report is not loaded or report has no data.";

                RdlcMessageService.Instance.SendMessage(result.Message);

                return(result);
            }

            LocalReportRenderer prt = null;

            try
            {
                LocalReport        lr       = rptViewer.LocalReport;
                ReportPageSettings settings = lr.GetDefaultPageSettings();

                if (null == settings)
                {
                    result.Message = "Cannot get page settings.";

                    RdlcMessageService.Instance.SendMessage(result.Message);

                    return(result);
                }

                #region Assign page setting

                LocalReportPageSettings pageSettings = new LocalReportPageSettings();

                if (!settings.IsLandscape)
                {
                    pageSettings.PageHeight = Convert.ToDouble(
                        (double)settings.PaperSize.Height / (double)100);
                    pageSettings.PageWidth = Convert.ToDouble(
                        (double)settings.PaperSize.Width / (double)100);
                }
                else
                {
                    pageSettings.PageHeight = Convert.ToDouble(
                        (double)settings.PaperSize.Width / (double)100);
                    pageSettings.PageWidth = Convert.ToDouble(
                        (double)settings.PaperSize.Height / (double)100);
                }
                pageSettings.MarginLeft = Convert.ToDouble(
                    (double)settings.Margins.Left / (double)100);
                pageSettings.MarginRight = Convert.ToDouble(
                    (double)settings.Margins.Right / (double)100);
                pageSettings.MarginTop = Convert.ToDouble(
                    (double)settings.Margins.Top / (double)100);
                pageSettings.MarginBottom = Convert.ToDouble(
                    (double)settings.Margins.Bottom / (double)100);

                //pageSettings.MarginLeft = 0;
                //pageSettings.MarginRight = 0;
                //pageSettings.MarginTop = 0;
                //pageSettings.MarginBottom = 0;

                pageSettings.Landscape = settings.IsLandscape;

                pageSettings.FromPage = fromPage;
                pageSettings.ToPage   = toPage;

#if WYSIWYG
                // Read Screen Resolution
                int dx, dy;
                System.Drawing.Graphics g = rptViewer.CreateGraphics();
                try
                {
                    dx = Convert.ToInt32(g.DpiX);
                    dy = Convert.ToInt32(g.DpiY);
                }
                finally
                {
                    g.Dispose();
                }
                pageSettings.DpiX = dx;
                pageSettings.DpiY = dy;

                // Create dialog and re read resolution.
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.PrinterSettings.PrinterName = printerName;
                System.Drawing.Printing.PrinterSettings ps = pd.PrinterSettings;

                pageSettings.PrintDpiX = ps.DefaultPageSettings.PrinterResolution.X;
                pageSettings.PrintDpiY = ps.DefaultPageSettings.PrinterResolution.Y;
#endif
                #endregion

                prt = new LocalReportRenderer();
                prt.Print(lr, printerName, pageSettings, noOfCopies);

                result.Success = true;
                result.Message = "Print Success.";
                RdlcMessageService.Instance.SendMessage(result.Message);
            }
            catch (Exception ex)
            {
                result.Message = ex.ToString();
            }
            finally
            {
                if (null != prt)
                {
                    prt.Dispose();
                }
                prt = null;
            }

            return(result);
        }
Ejemplo n.º 45
0
        /// <summary>
        /// <Remark>PDF出力F11</Remark>
        /// <Remark>印刷する処理F12</Remark>
        /// </summary>
        protected override void PrintSec()
        {
            // レコード定義を行う
            try
            {
                //DataTable table = CheckData(1);
                //if (table == null)
                //{
                //    return;
                //}
                DialogResult            ret;
                SiharaiYoteiHyou_Report Report = new SiharaiYoteiHyou_Report();

                switch (PrintMode)
                {
                case EPrintMode.DIRECT:
                    dtResult = CheckData(1);
                    if (dtResult == null)
                    {
                        return;
                    }

                    if (StartUpKBN == "1")
                    {
                        ret = DialogResult.No;
                    }
                    else
                    {
                        //Q202 印刷します。”はい”でプレビュー、”いいえ”で直接プリンターから印刷します。
                        ret = bbl.ShowMessage("Q201");
                        if (ret == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    Report.PrintOptions.PaperSize        = CrystalDecisions.Shared.PaperSize.PaperA4;
                    Report.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Portrait;

                    // 印字データをセット
                    Report.SetDataSource(dtResult);
                    Report.Refresh();
                    Report.SetParameterValue("StoreCD", comboStore.SelectedValue.ToString() + "  " + comboStore.Text);
                    Report.SetParameterValue("DateFrom", txtPaymentDueDateFrom.Text);
                    Report.SetParameterValue("DateTo", txtPaymentDueDateTo.Text);
                    Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));

                    if (ret == DialogResult.Yes)
                    {
                        //プレビュー
                        var previewForm = new Viewer();
                        previewForm.CrystalReportViewer1.ShowPrintButton = true;
                        previewForm.CrystalReportViewer1.ReportSource    = Report;
                        previewForm.ShowDialog();
                    }
                    else
                    {
                        //int marginLeft = 360;
                        CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                        margin.leftMargin   = DefaultMargin.Left;     // mmの指定をtwip単位に変換する
                        margin.topMargin    = DefaultMargin.Top;
                        margin.bottomMargin = DefaultMargin.Bottom;   //mmToTwip(marginLeft);
                        margin.rightMargin  = DefaultMargin.Right;
                        Report.PrintOptions.ApplyPageMargins(margin); /// Error Now
                        // プリンタに印刷
                        System.Drawing.Printing.PageSettings ps;
                        try
                        {
                            System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                            CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                            System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();



                            Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                            System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                            Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                            Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                            Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                            // Print the report. Set the startPageN and endPageN
                            // parameters to 0 to print all pages.
                            //Report.PrintToPrinter(1, false, 0, 0);
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    break;

                case EPrintMode.CSV:
                    dtCSV = CheckData(2);
                    if (dtCSV == null)
                    {
                        return;
                    }
                    try
                    {
                        DialogResult DResult;
                        DResult = bbl.ShowMessage("Q203");
                        if (DResult == DialogResult.Yes)
                        {
                            ////LoacalDirectory
                            string folderPath = "C:\\CSV\\";
                            if (!Directory.Exists(folderPath))
                            {
                                Directory.CreateDirectory(folderPath);
                            }
                            SaveFileDialog savedialog = new SaveFileDialog();
                            savedialog.Filter           = "CSV|*.csv";
                            savedialog.Title            = "Save";
                            savedialog.FileName         = "支払予定表";
                            savedialog.InitialDirectory = folderPath;
                            savedialog.RestoreDirectory = true;
                            if (savedialog.ShowDialog() == DialogResult.OK)
                            {
                                if (Path.GetExtension(savedialog.FileName).Contains("csv"))
                                {
                                    CsvWriter csvwriter = new CsvWriter();
                                    csvwriter.WriteCsv(dtCSV, savedialog.FileName, Encoding.GetEncoding(932));
                                }
                                Process.Start(Path.GetDirectoryName(savedialog.FileName));
                                shyhbl.ShowMessage("I203");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    break;

                case EPrintMode.PDF:

                    dtResult = CheckData(1);
                    if (dtResult == null)
                    {
                        return;
                    }

                    if (bbl.ShowMessage("Q204") != DialogResult.Yes)
                    {
                        return;
                    }
                    string filePath = "";
                    if (!ShowSaveFileDialog(InProgramNM, out filePath))
                    {
                        return;
                    }

                    // 印字データをセット
                    Report.SetDataSource(dtResult);
                    Report.Refresh();
                    Report.SetParameterValue("StoreCD", comboStore.SelectedValue.ToString() + "  " + comboStore.Text);
                    Report.SetParameterValue("DateFrom", txtPaymentDueDateFrom.Text);
                    Report.SetParameterValue("DateTo", txtPaymentDueDateTo.Text);
                    Report.SetParameterValue("PrintDate", System.DateTime.Now.ToString("yyyy/MM/dd") + " " + System.DateTime.Now.ToString("hh:mm"));

                    bool result = OutputPDF(filePath, Report);

                    //PDF出力が完了しました。
                    bbl.ShowMessage("I202");
                    break;
                }

                //プログラム実行履歴
                InsertLog(Get_L_Log_Entity());

                //ClearDetail();
            }
            finally
            {
            }
        }
Ejemplo n.º 46
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            try
            {

                System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                // The standard print controller comes with no UI
                System.Drawing.Printing.PrintController standardPrintController = new System.Drawing.Printing.StandardPrintController();

                // Print the report using the custom print controller
                Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

                //reportProcessor.PrintController = standardPrintController;

                //reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings);

                Hashtable deviceInfo = new Hashtable();
                deviceInfo.Add("ImmediatePrint", true);
                reportProcessor.RenderReport("PDF", ViewRptSumario.Report, deviceInfo);

                reportProcessor.PrintReport(ViewRptSumario.Report, printerSettings);

                //if (m_fDataAlta)
                //{
                //    //Atualiza Data Impressão
                //    m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now);
                //    m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"]));
                //    UtSessao.Sessao["Habilita"] = "N";
                //    ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!");
                //}
                //else
                //{
                //    ExibirMensagemPopUp("Data da Alta - não informada!!!");
                //}
            }
            catch (Exception ex)
            {
                ExibirMensagemPopUp(ex.Message);
            }

            if (UtSessao.Sessao["Habilita"].ToString() == "S")
            {
                if (m_fDataAlta)
                {
                    //Atualiza Data Impressão
                    m_oSumario.DATA_IMPRESSAO_SUMARIO = Convert.ToDateTime(DateTime.Now);
                    m_oSumario.SalvarSumario_Impressao(Convert.ToInt32(UtSessao.Sessao["Id058"]));
                    UtSessao.Sessao["Habilita"] = "N";
                    ExibirMensagemPopUp("Sumário de Alta foi Fechado com sucesso!!!");
                }
                else
                {
                    ExibirMensagemPopUp("Data da Alta - não informada!!!");
                }
            }
        }
        public void PaperTrayForDifferentPaperType()
        {
            //ExStart
            //ExFor:PageSetup.FirstPageTray
            //ExFor:PageSetup.OtherPagesTray
            //ExSummary:Shows how to set up printing using different printer trays for different paper sizes.
            Document doc = new Document();

            // Choose the default printer to be used for printing this document.
            System.Drawing.Printing.PrinterSettings settings = new System.Drawing.Printing.PrinterSettings();

            // This is the tray we will use for A4 paper size. This is the first tray in the paper sources collection.
            int printerTrayForA4 = settings.PaperSources[0].RawKind;
            // The is the tray we will use for Letter paper size. This is the second tray in the paper sources collection.
            int printerTrayForLetter = settings.PaperSources[1].RawKind;

            // Set the page tray used for each section based off the paper size used in the section.
            foreach (Section section in doc.Sections)
            {
                if(section.PageSetup.PaperSize == PaperSize.Letter)
                {
                    section.PageSetup.FirstPageTray = printerTrayForLetter;
                    section.PageSetup.OtherPagesTray = printerTrayForLetter;
                }
                else if(section.PageSetup.PaperSize == PaperSize.A4)
                {
                    section.PageSetup.FirstPageTray = printerTrayForA4;
                    section.PageSetup.OtherPagesTray = printerTrayForA4;
                }
            }
            //ExEnd
        }
Ejemplo n.º 48
0
        //public void F12()
        //{
        //    tnlbl = new TanaireList_BL();

        //    if (ErrorCheck(12))
        //    {
        //        if (tnlbl.ShowMessage(OperationMode == EOperationMode.DELETE ? "Q102" : "Q101") == DialogResult.Yes)
        //        {
        //            dse = GetDStockEntity();
        //            //if (string.IsNullOrWhiteSpace(ScSKUCD.Code))
        //            //    dtPrint = tnlbl.SelectDataForPrint(dse,"1");
        //            //else
        //            //    dtPrint = tnlbl.SelectDataForPrint(dse,"2");

        //            //PrintSec();
        //        }
        //        else
        //            PreviousCtrl.Focus();

        //    }

        //}


        protected override void PrintSec()
        {
            // レコード定義を行う
            // DataTable table = new DataTable();
            tnlbl = new TanaireList_BL();
            string    header  = string.Empty;
            DataTable dtPrint = new DataTable();

            if (ErrorCheck())
            {
                dse = GetDStockEntity();
                if (!string.IsNullOrWhiteSpace(ScSKUCD.Code))
                {
                    dtPrint = tnlbl.SelectDataForPrint(dse, "1");
                    header  = "棚入れリスト";
                }
                else
                {
                    dtPrint = tnlbl.SelectDataForPrint(dse, "2");
                    header  = "棚入れリスト(履歴)";
                }

                try
                {
                    if (dtPrint.Rows.Count <= 0 || dtPrint == null)
                    {
                        bbl.ShowMessage("E128");
                        txtStartDate.Focus();
                    }
                    else
                    {
                        //xsdファイルを保存します。

                        //①保存した.xsdはプロジェクトに追加しておきます。
                        DialogResult       ret;
                        TanaireList_Report Report = new TanaireList_Report();

                        switch (PrintMode)
                        {
                        case EPrintMode.DIRECT:

                            ret = bbl.ShowMessage("Q202");
                            if (ret == DialogResult.No)
                            {
                                return;
                            }
                            //}

                            // 印字データをセット

                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboSouko.SelectedValue.ToString() + "  " + cboSouko.Text);
                            Report.SetParameterValue("txtHeader", header);

                            if (ret == DialogResult.Yes)
                            {
                                var previewForm = new Viewer();
                                previewForm.CrystalReportViewer1.ShowPrintButton = true;
                                previewForm.CrystalReportViewer1.ReportSource    = Report;
                                previewForm.ShowDialog();
                            }
                            else             /// //Still Not Working because of Applymargin and Printer not Setting up  (PTK Will Solve)
                            {
                                //int marginLeft = 360;
                                CrystalDecisions.Shared.PageMargins margin = Report.PrintOptions.PageMargins;
                                margin.leftMargin   = DefaultMargin.Left;       // mmの指定をtwip単位に変換する
                                margin.topMargin    = DefaultMargin.Top;
                                margin.bottomMargin = DefaultMargin.Bottom;     //mmToTwip(marginLeft);
                                margin.rightMargin  = DefaultMargin.Right;
                                Report.PrintOptions.ApplyPageMargins(margin);   /// Error Now
                                // プリンタに印刷
                                System.Drawing.Printing.PageSettings ps;
                                try
                                {
                                    System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

                                    CrystalDecisions.Shared.PrintLayoutSettings PrintLayout = new CrystalDecisions.Shared.PrintLayoutSettings();

                                    System.Drawing.Printing.PrinterSettings printerSettings = new System.Drawing.Printing.PrinterSettings();

                                    Report.PrintOptions.PrinterName = "\\\\dataserver\\Canon LBP2900";
                                    System.Drawing.Printing.PageSettings pSettings = new System.Drawing.Printing.PageSettings(printerSettings);

                                    Report.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true;

                                    Report.PrintOptions.PrinterDuplex = PrinterDuplex.Simplex;

                                    Report.PrintToPrinter(printerSettings, pSettings, false, PrintLayout);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                            break;

                        case EPrintMode.PDF:
                            if (bbl.ShowMessage("Q204") != DialogResult.Yes)
                            {
                                return;
                            }
                            string filePath = "";
                            if (!ShowSaveFileDialog(InProgramNM, out filePath))
                            {
                                return;
                            }

                            // 印字データをセット
                            Report.SetDataSource(dtPrint);
                            Report.Refresh();
                            Report.SetParameterValue("txtSouko", cboSouko.SelectedValue.ToString() + "  " + cboSouko.Text);
                            Report.SetParameterValue("txtHeader", header);

                            bool result = OutputPDF(filePath, Report);

                            //PDF出力が完了しました。
                            bbl.ShowMessage("I202");

                            break;
                        }
                        InsertLog(Get_L_Log_Entity(dtPrint));
                    }
                    //else
                    //{
                    //    bbl.ShowMessage("E128");
                    //    txtStartDate.Focus();
                    //  }
                }
                finally
                {
                }
            }
        }
Ejemplo n.º 49
0
        /// <summary>
        /// Set export file type or printer to Report Document object.
        /// </summary>
        private void ApplyReportOutput()
        {
            if (_printToPrinter)
            {
                var printerName = ReportArguments.PrinterName != null?ReportArguments.PrinterName.Trim() : "";

                _logger.Write(string.Format("The default printer set in the Report is '{0}'", _reportDoc.PrintOptions.PrinterName));
                if (printerName.Length > 0 && printerName.ToUpper() != "DFLT")
                //Print to the Specified Printer
                {
                    _reportDoc.PrintOptions.NoPrinter   = false; //Changes the report option "No Printer: Optimized for Screen"
                    _reportDoc.PrintOptions.PrinterName = printerName;
                    _logger.Write(string.Format("The Specified PrinterName '{0}' is set by Parameter will be used", printerName));
                }
                else if (_reportDoc.PrintOptions.PrinterName.Length > 0 && printerName.ToUpper() == "DFLT")
                //Print to the reports default Printer
                {
                    _reportDoc.PrintOptions.NoPrinter = false; //Changes the report option "No Printer: Optimized for Screen"
                    _logger.Write(string.Format("The Specified PrinterName '{0}' is set in the report and DFLT flag will be used", _reportDoc.PrintOptions.PrinterName));
                }
                else
                //Print to the Windows default Printer
                {
                    System.Drawing.Printing.PrinterSettings prinSet = new System.Drawing.Printing.PrinterSettings();
                    _logger.Write(string.Format("Printer is not specified - The Windows Default Printer '{0}' will be used", prinSet.PrinterName));
                    if (prinSet.PrinterName.Trim().Length > 0)
                    {
                        _reportDoc.PrintOptions.NoPrinter   = false;   //Changes the report option "No Printer: Optimized for Screen"
                        _reportDoc.PrintOptions.PrinterName = prinSet.PrinterName;
                    }
                    else
                    {
                        throw new Exception("No printer name is specified");
                    }
                }
            }
            else
            {
                if (_outputFormat.ToUpper() == "RTF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.RichText;
                }
                else if (_outputFormat.ToUpper() == "TXT")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Text;
                }
                else if (_outputFormat.ToUpper() == "TAB")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.TabSeperatedText;
                }
                else if (_outputFormat.ToUpper() == "CSV")
                {
                    CharacterSeparatedValuesFormatOptions csvExpOpts = new CharacterSeparatedValuesFormatOptions();
                    csvExpOpts.ExportMode                     = CsvExportMode.Standard;
                    csvExpOpts.GroupSectionsOption            = CsvExportSectionsOption.Export;
                    csvExpOpts.ReportSectionsOption           = CsvExportSectionsOption.Export;
                    csvExpOpts.GroupSectionsOption            = CsvExportSectionsOption.ExportIsolated;
                    csvExpOpts.ReportSectionsOption           = CsvExportSectionsOption.ExportIsolated;
                    csvExpOpts.SeparatorText                  = ",";
                    csvExpOpts.Delimiter                      = "\"";
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.CharacterSeparatedValues;
                    _reportDoc.ExportOptions.FormatOptions    = csvExpOpts;
                }
                else if (_outputFormat.ToUpper() == "PDF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

                    var grpCnt = _reportDoc.DataDefinition.Groups.Count;

                    if (grpCnt > 0)
                    {
                        _reportDoc.ExportOptions.ExportFormatOptions = new PdfFormatOptions {
                            CreateBookmarksFromGroupTree = true
                        }
                    }
                    ;
                }
                else if (_outputFormat.ToUpper() == "RPT")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.CrystalReport;
                }
                else if (_outputFormat.ToUpper() == "DOC")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
                }
                else if (_outputFormat.ToUpper() == "XLS")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Excel;
                }
                else if (_outputFormat.ToUpper() == "XLSDATA")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.ExcelRecord;
                }
                else if (_outputFormat.ToUpper() == "XLSX")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.ExcelWorkbook;
                }
                else if (_outputFormat.ToUpper() == "ERTF")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.EditableRTF;
                }
                else if (_outputFormat.ToUpper() == "XML")
                {
                    _reportDoc.ExportOptions.ExportFormatType = ExportFormatType.Xml;
                }
                else if (_outputFormat.ToUpper() == "HTM" || _outputFormat.ToUpper() == "HTML")
                {
                    HTMLFormatOptions htmlFormatOptions = new HTMLFormatOptions();

                    if (_outputFilename.LastIndexOf("\\") > 0) //if absolute output path is specified
                    {
                        htmlFormatOptions.HTMLBaseFolderName = _outputFilename.Substring(0, _outputFilename.LastIndexOf("\\"));
                    }

                    htmlFormatOptions.HTMLFileName             = _outputFilename;
                    htmlFormatOptions.HTMLEnableSeparatedPages = false;
                    htmlFormatOptions.HTMLHasPageNavigator     = true;
                    htmlFormatOptions.FirstPageNumber          = 1;
                    _reportDoc.ExportOptions.ExportFormatType  = ExportFormatType.HTML40;
                    _reportDoc.ExportOptions.FormatOptions     = htmlFormatOptions;
                }
            }
        }
Ejemplo n.º 50
0
 public PrintUtils()
 {
     settings = new System.Drawing.Printing.PrinterSettings();
     defaultPrinter = settings.PrinterName;
     printer = defaultPrinter;
 }
Ejemplo n.º 51
0
        private async void buttonPrint_Click(object sender, EventArgs e)
        {
            //bool duplexSelectable = comboDuplex.Enabled;
            //bool colorSelectable = comboColor.Enabled;

            EnableControls(false);
            string statusText = labelStatus.Text;

            var chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var pwd    = new char[32];
            var random = new Random();

            for (int i = 0; i < pwd.Length; i++)
            {
                pwd[i] = chars[random.Next(chars.Length)];
            }
            string jobname = new string(pwd);

            try
            {
                string printer = null;

                if (comboPrinter.SelectedIndex >= 0)
                {
                    printer = comboPrinter.SelectedItem.ToString();
                }
                else
                {
                    throw new Exception("プリンタが選択されていません");
                }

                System.Drawing.Printing.PrinterSettings pset = new System.Drawing.Printing.PrinterSettings();
                pset.PrinterName = printer;
                if (!pset.IsValid)
                {
                    throw new Exception("選択されたプリンタは有効なプリンタではありません");
                }
                bool supported_paper = false;
                for (int i = 0; i < pset.PaperSizes.Count; i++)
                {
                    if (pset.PaperSizes[i].RawKind == comboPaper.SelectedIndex)
                    {
                        supported_paper = true;
                        break;
                    }
                }
                if (!supported_paper)
                {
                    throw new Exception("選択されたプリンタはこの用紙サイズを印刷できません\n\n" +
                                        "用紙サイズ: " + comboPaper.SelectedItem.ToString());
                }

                int color_count = this.ps.Pages.Color;
                int mono_count  = this.ps.Pages.Mono;
                if (comboColor.SelectedIndex == (int)PSFile.Color.MONO)
                {
                    mono_count += color_count;
                    color_count = 0;
                }
                WebAPI.PrintInfo info = await WebAPI.Payment(textUserName.Text, textPassword.Text, color_count, mono_count, this.ps.Pages.Blank, comboPaper.SelectedIndex, comboPrinter.SelectedItem.ToString(), INIFILE.GetValue("JOBINFO", "Document", "", this.ps.IniFileName));

                if (info == null)
                {
                    throw new Exception("認証サーバに接続できませんでした。(コード:" + WebAPI.StatusCode.ToString() + ")");
                }
                if (info.result != "OK")
                {
                    throw new Exception(info.message.Replace("\\n", "\r\n"));
                }
                labelAnalysis.Text = info.message.Replace("\\n", "\r\n");
                labelAnalysis.Refresh();

                // Task t = Task.Run(() => MessageBox.Show(labelAnalysis.Text));

                REG.PrinterName = printer;
                REG.JobName     = jobname;

                labelStatus.Text = "印刷中...";
                statusStrip1.Refresh();
                try
                {
                    this.ps.Print(printer, jobname,
                                  comboPaper.SelectedIndex < 0 ? 9 : comboPaper.SelectedIndex,
                                  comboColor.SelectedIndex < 0 ? PSFile.Color.AUTO : (PSFile.Color)comboColor.SelectedIndex,
                                  comboDuplex.SelectedIndex < 0 ? PSFile.Duplex.SIMPLEX : (PSFile.Duplex)comboDuplex.SelectedIndex,
                                  INIFILE.GetValue("DEVMODE", "Collate", 1, this.ps.IniFileName) == 1,
                                  INIFILE.GetValue("DEVMODE", "Copies", 1, this.ps.IniFileName));
#if DEBUG
#else
                    FILEUTIL.SafeDelete(this.ps.FileName);
                    FILEUTIL.SafeDelete(this.ps.IniFileName);
#endif
                    await Task.Delay(1500);

                    labelAnalysis.Text = "印刷が送信されました";
                    labelAnalysis.Refresh();
                    await Task.Delay(1500);

                    this.Close();
                }
                catch (Exception ex)
                {
                    labelStatus.Text = "印刷時エラー";
                    statusStrip1.Refresh();
                    throw new Exception("印刷処理ができませんでした\r\n\r\n理由:" + ex.Message + "\r\n詳細:" + ex.HResult.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Properties.Resources.Title, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                string printer = "";
                if (comboPrinter.SelectedIndex >= 0)
                {
                    printer = comboPrinter.SelectedItem.ToString();
                }
                try
                {
                    bool b = await WebAPI.Alert(textUserName.Text, this.ps.Pages.Color, this.ps.Pages.Mono, this.ps.Pages.Blank, comboPaper.SelectedIndex, printer, INIFILE.GetValue("JOBINFO", "Document", "", this.ps.IniFileName), ex.Message);
                }
                catch
                {
#if DEBUG
                    Console.WriteLine("double exception");
#endif
                }
            }
            finally
            {
                labelAnalysis.Text = "";
                labelAnalysis.Refresh();
                EnableControls(true);
                labelStatus.Text = statusText;
            }
        }
Ejemplo n.º 52
0
        public override Lfx.Types.OperationResult BeforePrint()
        {
            Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;
            if (Comprob.Articulos.Count >= 1 && (Comprob.Articulos[0].Cantidad < 0 || Comprob.Articulos[0].ImporteUnitario < 0))
            {
                return(new Lfx.Types.FailureOperationResult("El primer ítem de la factura no puede ser negativo. Utilice los ítem negativos en último lugar."));
            }

            Comprob.Cliente.Cargar();

            if (Comprob.FormaDePago == null)
            {
                return(new Lfx.Types.FailureOperationResult("Por favor seleccione la forma de pago."));
            }

            if (Comprob.Cliente == null)
            {
                return(new Lfx.Types.FailureOperationResult("Por favor seleccione un cliente."));
            }

            if (Comprob.Tipo == null)
            {
                return(new Lfx.Types.FailureOperationResult("Por favor seleccione el tipo de comprobante."));
            }

            if (Lbl.Sys.Config.Pais.Id == 1)
            {
                // Verificaciones especiales para Argentina
                if (Comprob.Tipo.EsFacturaNCoND && Comprob.Cliente.SituacionTributaria != null && Comprob.Tipo.Letra != Comprob.Cliente.LetraPredeterminada())
                {
                    Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog(@"La situación tributaria del cliente y el tipo de comprobante no se corresponden.
Un cliente " + Comprob.Cliente.SituacionTributaria.ToString() + @" debería llevar un comprobante tipo " + Comprob.Cliente.LetraPredeterminada() + @". No debería continuar con la impresión. 
¿Desea continuar de todos modos?", "Tipo de comprobante incorrecto");
                    Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                    if (Pregunta.ShowDialog() == DialogResult.Cancel)
                    {
                        return(new Lfx.Types.FailureOperationResult("Corrija la situación tributaria del cliente o el tipo de comprobante."));
                    }
                }

                if (Comprob.Tipo.Letra.ToUpperInvariant() == "A")
                {
                    if (Comprob.Cliente.ClaveTributaria == null || Comprob.Cliente.ClaveTributaria.EsValido() == false)
                    {
                        return(new Lfx.Types.FailureOperationResult("El cliente no tiene una CUIT válida. Por favor edite el cliente y escriba una CUIT válida."));
                    }
                }
                else if (Comprob.Tipo.Letra == "B")
                {
                    //Si es factura B de más de $ 1000, debe llevar el Nº de DNI
                    if (Comprob.Total >= 1000 && Comprob.Cliente.NumeroDocumento.Length < 5 &&
                        (Comprob.Cliente.ClaveTributaria == null || Comprob.Cliente.ClaveTributaria.EsValido() == false))
                    {
                        return(new Lfx.Types.FailureOperationResult("Para Facturas B de $ 1.000 o más debe proporcionar el número de DNI/CUIT del cliente."));
                    }
                    //Si es factura B de más de $ 1000, debe llevar domicilio
                    if (Comprob.Total >= 1000 && Comprob.Cliente.Domicilio.Length < 1)
                    {
                        return(new Lfx.Types.FailureOperationResult("Para Facturas B de $ 1.000 o más debe proporcionar el domicilio del cliente."));
                    }
                }
            }

            if (EntradaProductos.MostrarExistencias && this.Tipo.MueveExistencias < 0 && Comprob.HayExistencias() == false)
            {
                Lui.Forms.YesNoDialog OPregunta = new Lui.Forms.YesNoDialog("Las existencias actuales no son suficientes para cubrir la operación que intenta realizar.\n¿Desea continuar de todos modos?", "No hay existencias suficientes");
                OPregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                if (OPregunta.ShowDialog() == DialogResult.Cancel)
                {
                    return(new Lfx.Types.FailureOperationResult("No se imprimir el comprobante por falta de existencias."));
                }
            }

            if (Comprob.Cliente.Id != 999 && (Comprob.Tipo.EsFactura || Comprob.Tipo.EsNotaDebito))
            {
                decimal SaldoCtaCte = Comprob.Cliente.CuentaCorriente.ObtenerSaldo(false);

                if (Comprob.FormaDePago != null && Comprob.FormaDePago.Tipo == Lbl.Pagos.TiposFormasDePago.CuentaCorriente)
                {
                    decimal LimiteCredito = Comprob.Cliente.LimiteCredito;

                    if (LimiteCredito == 0)
                    {
                        LimiteCredito = Lfx.Types.Parsing.ParseCurrency(Lfx.Workspace.Master.CurrentConfig.ReadGlobalSetting <string>("Sistema.Cuentas.LimiteCreditoPredet", "0"));
                    }

                    if (LimiteCredito != 0 && (Comprob.Total + SaldoCtaCte) > LimiteCredito)
                    {
                        return(new Lfx.Types.FailureOperationResult("El valor de la factura y/o el saldo en cuenta corriente supera el límite de crédito de este cliente."));
                    }
                }
                else
                {
                    if (SaldoCtaCte < 0)
                    {
                        using (SaldoEnCuentaCorriente FormularioError = new SaldoEnCuentaCorriente()) {
                            switch (FormularioError.ShowDialog())
                            {
                            case DialogResult.Yes:
                                //Corregir el problema
                                this.EntradaFormaPago.ValueInt = 3;
                                this.Save();
                                Comprob.FormaDePago.Tipo = Lbl.Pagos.TiposFormasDePago.CuentaCorriente;
                                break;

                            case DialogResult.No:
                                //Continuar. No corregir el problema.
                                break;

                            default:
                                //Cancelar y volver a la edición.
                                return(new Lfx.Types.CancelOperationResult());
                            }
                        }
                    }
                }
            }

            if (Comprob.PV < 1)
            {
                return(new Lfx.Types.FailureOperationResult("Por favor escriba un punto de venta válido."));
            }

            if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.ContainsKey(Comprob.PV) == false)
            {
                // No existe el PV... vacío la caché antes intentar de nuevo y dar un error
                Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.Clear();
                if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero.ContainsKey(Comprob.PV) == false)
                {
                    return(new Lfx.Types.FailureOperationResult("El punto de venta no existe. Si desea definir un nuevo punto de venta, utilice el menú Comprobantes -> Tablas -> Puntos de venta."));
                }
            }

            Lbl.Comprobantes.PuntoDeVenta Pv = Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV];
            if (Pv.Tipo == Lbl.Comprobantes.TipoPv.Talonario)
            {
                Lbl.Impresion.Impresora Impresora = Comprob.ObtenerImpresora();

                if (Pv.CargaManual && (Impresora == null || Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Automatica))
                {
                    Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog();
                    FormularioCargaManual.DocumentName = Comprob.Tipo.ToString() + " " + Comprob.PV.ToString("0000") + "-" + Lbl.Comprobantes.Numerador.ProximoNumero(Comprob).ToString("00000000");
                    // Muestro el nombre de la impresora
                    if (Impresora != null)
                    {
                        FormularioCargaManual.PrinterName = Impresora.Nombre;
                    }
                    else
                    {
                        System.Drawing.Printing.PrinterSettings objPrint = new System.Drawing.Printing.PrinterSettings();
                        FormularioCargaManual.PrinterName = objPrint.PrinterName;
                    }
                    if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                    {
                        return(new Lfx.Types.CancelOperationResult());
                    }
                }
            }

            if (Comprob.Tipo.MueveExistencias != 0)
            {
                Lfx.Types.OperationResult Res = Comprob.VerificarSeries();
                if (Res.Success == false)
                {
                    return(Res);
                }
            }

            return(base.BeforePrint());
        }
Ejemplo n.º 53
0
                private void Imprimir()
                {
                        Lfx.Types.OperationResult Res;
                        if (this.ReadOnly) {
                                Res = new Lfx.Types.SuccessOperationResult();
                        } else {
                                if (this.Elemento.Existe == false) {
                                        // Si es nuevo, lo guardo sin preguntar.
                                        Res = this.Save();
                                } else if (this.Changed) {
                                        // Si es edición, y hay cambios, pregunto si quiere guardar
                                        using (Lui.Forms.YesNoDialog Pregunta = new Lui.Forms.YesNoDialog("Hay modificaciones sin guardar (subrayadas en color rojo). Antes de imprimir el ducumento se guardarán las modificaciones. ¿Desea continuar?", "Imprimir")) {
                                                Pregunta.DialogButtons = Lui.Forms.DialogButtons.YesNo;
                                                this.ShowChanged = true;
                                                if (Pregunta.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                                                        Res = this.Save();
                                                } else {
                                                        Res = new Lfx.Types.CancelOperationResult();
                                                }
                                                this.ShowChanged = false;
                                        }
                                } else {
                                        // Es edición y no hay cambios... continúo
                                        Res = new Lfx.Types.SuccessOperationResult();
                                }
                        }

                        if (Res.Success)
                                Res = this.ControlUnico.BeforePrint();

                        if (Res.Success) {
                                Lbl.Impresion.Impresora Impresora = null;
                                if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) == Keys.Shift) {
                                        using (Lui.Printing.PrinterSelectionDialog FormularioSeleccionarImpresora = new Lui.Printing.PrinterSelectionDialog()) {
                                                if (FormularioSeleccionarImpresora.ShowDialog() == DialogResult.OK) {
                                                        Impresora = FormularioSeleccionarImpresora.SelectedPrinter;
                                                } else {
                                                        return;
                                                }
                                        }
                                }

                                string NombreDocumento = Elemento.ToString();
                                Lbl.Impresion.CargasPapel Carga = Lbl.Impresion.CargasPapel.Automatica;
                                if (Impresora != null && Impresora.CargaPapel == Lbl.Impresion.CargasPapel.Manual) {
                                        Carga = Lbl.Impresion.CargasPapel.Manual;
                                } else if (this.Elemento is Lbl.Comprobantes.ComprobanteConArticulos) {
                                        Lbl.Comprobantes.ComprobanteConArticulos Comprob = this.Elemento as Lbl.Comprobantes.ComprobanteConArticulos;

                                        if (Lbl.Comprobantes.PuntoDeVenta.TodosPorNumero[Comprob.PV].Tipo == Lbl.Comprobantes.TipoPv.Fiscal) {
                                                Carga = Lbl.Impresion.CargasPapel.Automatica;
                                        } else {
                                                // El tipo de comprobante puede forzar a una carga manual
                                                Carga = Comprob.Tipo.CargaPapel;

                                                // Intento averiguar el número de comprobante, en caso de que aun no esté numerado
                                                if (Comprob.Numero == 0) {
                                                        int ProximoNumero = Lbl.Comprobantes.Numerador.ProximoNumero(Comprob);
                                                        NombreDocumento = NombreDocumento.Replace("00000000", ProximoNumero.ToString("00000000"));
                                                }
                                        }
                                }

                                if (Carga == Lbl.Impresion.CargasPapel.Manual) {
                                        using (Lui.Printing.ManualFeedDialog FormularioCargaManual = new Lui.Printing.ManualFeedDialog()) {
                                                FormularioCargaManual.DocumentName = NombreDocumento;
                                                // Muestro el nombre de la impresora
                                                if (Impresora != null) {
                                                        FormularioCargaManual.PrinterName = Impresora.Nombre;
                                                } else {
                                                        System.Drawing.Printing.PrinterSettings ObjPrint = new System.Drawing.Printing.PrinterSettings();
                                                        FormularioCargaManual.PrinterName = ObjPrint.PrinterName;
                                                }
                                                if (FormularioCargaManual.ShowDialog() == DialogResult.Cancel)
                                                        return;
                                        }
                                }

                                if (Impresora != null && Impresora.EsVistaPrevia) {
                                        Lazaro.Impresion.ImpresorElemento ImpresorVistaPrevia = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, null);
                                        ImpresorVistaPrevia.PrintController = new System.Drawing.Printing.PreviewPrintController();
                                        Lui.Printing.PrintPreviewForm VistaPrevia = new Lui.Printing.PrintPreviewForm();
                                        VistaPrevia.MdiParent = this.ParentForm.MdiParent;
                                        VistaPrevia.PrintPreview.Document = ImpresorVistaPrevia;
                                        VistaPrevia.Show();
                                } else {
                                        Lfx.Types.OperationProgress Progreso = new Lfx.Types.OperationProgress("Imprimiendo", "El documento se está enviando a la impresora.");
                                        if (Impresora != null)
                                                Progreso.Description = "El documento se está enviando a la impresora " + Impresora.ToString();
                                        Progreso.Modal = false;
                                        Progreso.Begin();

                                        using (IDbTransaction Trans = this.Elemento.Connection.BeginTransaction()) {
                                                Lazaro.Impresion.ImpresorElemento Impresor = Lazaro.Impresion.Instanciador.InstanciarImpresor(this.Elemento, Trans);
                                                Impresor.Impresora = Impresora;
                                                try {
                                                        Res = Impresor.Imprimir();
                                                } catch (Exception ex) {
                                                        Res = new Lfx.Types.FailureOperationResult(ex.Message);
                                                }
                                                Progreso.End();
                                                if (Res.Success == false) {
                                                        if (Impresor.Transaction != null)
                                                                // Puede que la transacción ya haya sido finalizada por el impresor
                                                                Impresor.Transaction.Rollback();
                                                        Lui.Forms.MessageBox.Show(Res.Message, "Error");
                                                } else {
                                                        if (Impresor.Transaction != null)
                                                                // Puede que la transacción ya haya sido finalizada por el impresor
                                                                Impresor.Transaction.Commit();
                                                        this.Elemento.Cargar();
                                                        this.FromRow(this.Elemento);
                                                        this.ControlUnico.AfterPrint();
                                                }
                                        }
                                }
                        } 
                        
                        if (Res.Success == false && Res.Message != null) {
                                Lui.Forms.MessageBox.Show(Res.Message, "Imprimir");
                        }
                }
        public static void HideDialgo()
        {
            // ExStart:HideDialgo
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Printing();

            // Create PdfViewer object and bind PDF file
            PdfViewer pdfViewer = new PdfViewer();
            pdfViewer.BindPdf( dataDir + "input.pdf");

            // Set PrinterSettings and PageSettings
            System.Drawing.Printing.PrinterSettings printerSetttings = new System.Drawing.Printing.PrinterSettings();
            printerSetttings.Copies = 1;
            printerSetttings.PrinterName = "Microsoft XPS Document Writer";

            // Set output file name and PrintToFile attribute
            printerSetttings.PrintFileName = dataDir + "print_out.xps";
            printerSetttings.PrintToFile = true;

            // Disable print page dialog
            pdfViewer.PrintPageDialog = false;

            // Pass printer settings object to the method
            pdfViewer.PrintDocumentWithSettings(printerSetttings);
            pdfViewer.Close();
            // ExEnd:HideDialgo
        }