Esempio n. 1
0
        public static void printInvoice(string sDocumentNumber, bool bFirstPrint, bool sendToDepot,string sCurrentSalesman, PrintDialog pdPrintDetails)
        {
            //get printquantity

            decimal iFPQuantity = Convert.ToDecimal(ConfigurationSettings.AppSettings.Get("InvoiceFirstPrintCopies"));
            decimal iDPQuantity = Convert.ToDecimal(ConfigurationSettings.AppSettings.Get("InvoiceDuplicatePrintCopies"));
            //using (PsqlConnection oConn = new PsqlConnection(Connect.sConnStr))
            //{
            //    oConn.Open();
            //    string sSql = "SELECT InvoiceFirst, InvoiceDuplicate FROM SOLCS";
            //    PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader();
            //    while (rdReader.Read())
            //    {
            //       iFPQuantity = Convert.ToDecimal(rdReader["InvoiceFirst"].ToString());
            //       iDPQuantity = Convert.ToInt16(rdReader["InvoiceDuplicate"].ToString());
            //    }
            //}

            ReportClass reportDelivery = getInvoiceReport(sDocumentNumber,"","","","","","NormalPrint",sCurrentSalesman);
            if (reportDelivery != null)
            {
                try
                {
                    if (sendToDepot)
                    {
                        //Send file to workstation
                        if (!Directory.Exists(Application.StartupPath + "\\Temp"))
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\Temp");
                        }
                        string sFilename = sDocumentNumber + ".rpt";
                        if (File.Exists(Application.StartupPath + "\\Temp\\" + sFilename))
                        {
                            File.Delete(Application.StartupPath + "\\Temp\\" + sFilename);
                        }
                        //                            reportDelivery.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Application.StartupPath + "\\Temp\\" + sFilename);
                        reportDelivery.SaveAs(Application.StartupPath + "\\Temp\\" + sFilename, true);

                        sDepotFilename = Application.StartupPath + "\\Temp\\" + sFilename;
                        return;
                    }

                    if (Global.sInvoiceTemplate == "Kings Hire")
                    {
                        reportDelivery.PrintOptions.PrinterName = pdPrintDetails.PrinterSettings.PrinterName;
                        reportDelivery.PrintToPrinter(Convert.ToInt16(pdPrintDetails.PrinterSettings.Copies), false, 0, 0);
                    }
                    else
                    {

                        if (bFirstPrint)
                        {
                            reportDelivery.PrintOptions.PrinterName = Global.sDefaultDocPrinter;
                            reportDelivery.PrintToPrinter(Convert.ToInt16(iFPQuantity), false, 0, 0);
                        }
                        else if (!bFirstPrint)
                        {
                            reportDelivery.PrintOptions.PrinterName = Global.sDefaultDocPrinter;
                            reportDelivery.PrintToPrinter(Convert.ToInt16(iDPQuantity), false, 0, 0);

                        }
                    }
                }
                catch
                {
                    using (Solsage_Process_Management_System.Documents.PrintInvoice frmPrint = new Solsage_Process_Management_System.Documents.PrintInvoice())
                    {
                        frmPrint.crystalReportViewer1.ReportSource = reportDelivery;
                        frmPrint.printThisDocument();
                    }

                }
            }
        }