Ejemplo n.º 1
0
        public ShippingModel PrintInvoice(ShippingModel shipping)
        {
            try
            {
                PrinterSettings setings = new PrinterSettings();
                setings.PrinterName = "KioskoPrinterBill";
                DevExpress.Pdf.PdfPrinterSettings sett = new DevExpress.Pdf.PdfPrinterSettings(setings);

                sett.ScaleMode       = DevExpress.Pdf.PdfPrintScaleMode.Fit;
                sett.PageOrientation = DevExpress.Pdf.PdfPrintPageOrientation.Portrait;
                sett.Settings.DefaultPageSettings.Margins.Left   = 0;
                sett.Settings.DefaultPageSettings.Margins.Right  = 0;
                sett.Settings.DefaultPageSettings.Margins.Bottom = 0;
                sett.Settings.DefaultPageSettings.Margins.Top    = 0;

                shipping.error.HasError = false;
                using (var pdfViewer = new DevExpress.XtraPdfViewer.PdfViewer())
                {
                    string path = @Properties.Settings.Default.INVOICE_PATH + shipping.guide.Code + ".pdf";
                    pdfViewer.LoadDocument(path);
                    SizeF        pg        = pdfViewer.GetPageSize(1);
                    PageSettings sets      = sett.Settings.DefaultPageSettings;
                    PaperSize    paperSize = new PaperSize("Print", (int)(800 / 2.94), (int)(3000 / 2.94));
                    paperSize.RawKind = (int)PaperKind.Custom;
                    sets.PaperSize    = paperSize;

                    pdfViewer.ShowPrintStatusDialog = false;
                    pdfViewer.Print(sett);
                    pdfViewer.CloseDocument();
                }
            }catch (SystemException E)
            {
                shipping.error.HasError = true;
                shipping.error.Message  = E.Message;

                return(shipping);
            }
            return(shipping);
        }
Ejemplo n.º 2
0
        public ShippingModel GenerateInvoice(ShippingModel shipping)
        {
            int Weight    = 0;
            int VolWeight = 0;

            foreach (var model in shipping.content.Measures)
            {
                Weight    += (int)Math.Round(model.Weight, 0);
                VolWeight += (int)Math.Round(model.VolumetricWeight, 0);

                model.VolumetricWeight = Math.Round(model.VolumetricWeight, 0);
                model.Weight           = Math.Round(model.Weight, 0);
            }

            int ValorFactura = Weight > VolWeight ? Weight : VolWeight;


            ///////////////////////////////////

            /*
             * Cuando es mensajería  No se imprimen rótulos Siempre debe llevar la bolsa
             * Cuando es contado en origen Se imprime Factura, para el usuario
             * Remesa (la remesa hay que indicarle al usuario que la meta en la bolsa)
             *
             * Cuando es contado en destino (flete contra entrega)
             * Se imprime 2 remesas , una para el usuario y la otra hay que indicarle que lo meta en la bolsa
             */

            PrinterSettings setings = new PrinterSettings();

            setings.PrinterName = "KioskoPrinterBill";

            DevExpress.Pdf.PdfPrinterSettings sett = new DevExpress.Pdf.PdfPrinterSettings(setings);

            sett.ScaleMode       = DevExpress.Pdf.PdfPrintScaleMode.Fit;
            sett.PageOrientation = DevExpress.Pdf.PdfPrintPageOrientation.Portrait;
            sett.Settings.DefaultPageSettings.Margins.Left   = 0;
            sett.Settings.DefaultPageSettings.Margins.Right  = 0;
            sett.Settings.DefaultPageSettings.Margins.Bottom = 0;
            sett.Settings.DefaultPageSettings.Margins.Top    = 0;


            XtraReport   xtrareport;
            FacturaModel fact;
            string       FormaDePago = "";

            if (shipping.payment.PaymentMethod == "COD")
            {
                FormaDePago = "CONTADO EN DESTINO";

                ///CONTADO EN ORIGEN;
            }
            else
            {
                FormaDePago = "CONTADO EN ORIGEN";
            }

            int unidaddenegocio = ReturnUnidadDeNegocio(shipping);

            if (unidaddenegocio == 1)
            {
                ////PAQUETERIA
                xtrareport = new RemesaTCC();


                fact = new FacturaModel
                {
                    NIT          = "860.016.640",
                    RazonSocial  = "TCC S.A.S",
                    Model        = shipping,
                    FormaDePago  = FormaDePago,
                    Fecha        = DateTime.Now.ToString("yyyy-MM-dd"),
                    ValorFactura = ValorFactura,
                    Weight       = Weight,
                    VolWeight    = VolWeight,
                    Res          = new ResolucionDian()
                    {
                        Resolucion = 18762014168428,
                    }
                };
                ///MENSAJERIA
            }
            else
            {
                xtrareport = new Factura();

                fact = new FacturaModel
                {
                    NIT          = "900.053.978-6",
                    RazonSocial  = "GLOBAL MENSAJERIA S.A.S",
                    Model        = shipping,
                    FormaDePago  = FormaDePago,
                    FactNumber   = shipping.payment.Invoice,
                    ValorFactura = ValorFactura,
                    Weight       = Weight,
                    VolWeight    = VolWeight,
                    Fecha        = DateTime.Now.ToString("yyyy-MM-dd"),
                    Res          = new ResolucionDian()
                    {
                        Resolucion = 18762012374330
                    }
                };
            }
            List <FacturaModel> ord = new List <FacturaModel>();

            ord.Add(fact);
            PdfExportOptions opts = new PdfExportOptions();

            unidaddenegocio = ReturnUnidadDeNegocio(shipping);
            if (unidaddenegocio == 1)
            {
                try
                {
                    ////PAQUETERIA CONTADO EN DESTINO Y ORIGEN, IMPRIME REMESA


                    ////PAQUETERIA NO IMPRIME FACTURA



                    /// SE DESCARGA LA GUIA:
                    ///
                    string path2 = @"C:\Kiosko\temp\guide\";

                    if (SavePDF(shipping.guide.Url, path2, shipping.guide.Code))
                    {
                        //imprimir guia;

                        using (var pdfViewer = new DevExpress.XtraPdfViewer.PdfViewer())
                        {
                            PrinterSettings settingGuide = new PrinterSettings();
                            settingGuide.PrinterName = "KioskoPrinterGuide";

                            DevExpress.Pdf.PdfPrinterSettings settguide = new DevExpress.Pdf.PdfPrinterSettings(settingGuide);

                            pdfViewer.LoadDocument(path2 + shipping.guide.Code + ".pdf");
                            PageSettings setsGG = settguide.Settings.DefaultPageSettings;

                            PaperSize paperSize = new PaperSize("Print", (int)(800 / 2.94), (int)(1500 / 2.94));
                            paperSize.RawKind = (int)PaperKind.Custom;

                            setsGG.PaperSize                = paperSize;
                            setsGG.Margins.Left             = 0;
                            setsGG.Margins.Right            = 0;
                            setsGG.Margins.Top              = 0;
                            setsGG.Margins.Bottom           = 0;
                            pdfViewer.ShowPrintStatusDialog = false;
                            pdfViewer.Print(settguide);
                            pdfViewer.CloseDocument();
                        }
                    }


                    shipping = this.PrintRemesa(ord, shipping, sett);
                }
                catch (Exception E)
                {
                    shipping.error.HasError = true;
                    shipping.error.Message  = "[SavePDF]" + E.Message;
                    return(shipping);
                }
            }
            else
            {
                ////MENSAJERIA CONTADO EN ORIGEN, IMPRIME FACTURA Y UNA REMESA


                ////MENSAJERIA CONTADO EN DESTINO, SE IMPRIMEN 2 REMESAS.


                if (fact.FormaDePago == "CONTADO EN DESTINO")
                {
                    shipping = this.PrintRemesa(ord, shipping, sett);
                    if (!shipping.error.HasError)
                    {
                        shipping = this.PrintRemesa(ord, shipping, sett);
                    }
                    else
                    {
                        return(shipping);
                    }
                }
                else
                {
                    shipping = this.PrintRemesa(ord, shipping, sett);

                    if (!shipping.error.HasError)
                    {
                        shipping = this.PrintFactura(ord, shipping, sett);
                    }
                    else
                    {
                        return(shipping);
                    }
                }
            }

            return(shipping);
        }