Exemplo n.º 1
0
        private void button21_Click(object sender, EventArgs e)
        {
            Empresa empresa = new Empresa();

            empresa.creaTabla();
        }
        public void procesoPaqueteXml(String fileJson, String fileXml)
        {
            empresa = empresa.getEmpresa();
            // inatancia txt_reader
            TxtReader lec = new TxtReader();

            Documento docLectura = new Documento();

            // Ejecuta metodo de txt_reader que llena y obtienen Clase Documento
            docLectura = lec.lectura(fileJson, true, " ");
            // instancia XML_admin
            xmlPaquete xml = new xmlPaquete();

            DateTime thisDay = DateTime.Now;
            String   fchName = String.Format("{0:yyyyMMddTHHmmss}", thisDay);


            String firsRut = String.Empty;

            if (docLectura != null)
            {
                GetTed ted = new GetTed();

                String TimbreElec = ted.getTed(fileXml);

                //si es Thermal
                if (empresa.PrnThermal == "True")
                {
                    for (int copies = 0; copies < 3; copies++)
                    {
                        Thermal thermal = new Thermal();
                        thermal.doc    = docLectura;
                        thermal.dd     = TimbreElec;
                        thermal.copias = copies;
                        if (docLectura.PrnTwoCopy == "True")
                        {
                            copies = 1;
                        }
                        docLectura.PrnTwoCopy = "False";
                        if (copies == 2)
                        {
                            if (docLectura.TipoDTE == 33 || docLectura.TipoDTE == 34)
                            {
                                thermal.tipoCopia = "CEDIBLE";
                            }
                            if (docLectura.TipoDTE == 52)
                            {
                                thermal.tipoCopia = "CEDIBLE CON SU FACTURA";
                            }

                            if (docLectura.TipoDTE == 61)
                            {
                                break;
                            }
                        }

                        //
                        PrintDocument pd = new PrintDocument();
                        pd.DefaultPageSettings.PaperSize = new PaperSize("", 284, 1800);
                        pd.PrintPage += new PrintPageEventHandler(thermal.OpenThermal);
                        pd.PrinterSettings.PrinterName = "prnPdf";
                        Console.WriteLine(pd.ToString());
                        pd.Print();
                    }
                }
                //si no es thermal else

                //Generar PDF
                Pdf docpdf = new Pdf();

                String fileNamePDF = @"" + Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Iat", "unidadIat", null).ToString() + ":/IatFiles/file/pdf/DTE_" + docLectura.RUTEmisor + "_" + docLectura.TipoDTE + "_" + docLectura.Folio + "_" + fchName + ".pdf";
                docpdf.OpenPdf(TimbreElec, docLectura, fileNamePDF, " ");

                docpdf.OpenPdf(TimbreElec, docLectura, fileNamePDF, " ");


                String fileNamePDFCed = @"" + Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\Iat", "unidadIat", null).ToString() + ":/IatFiles/file/pdf/DTE_" + docLectura.RUTEmisor + "_" + docLectura.TipoDTE + "_" + docLectura.Folio + "_" + fchName + "CEDIBLE.pdf";

                if (docLectura.TipoDTE == 33 || docLectura.TipoDTE == 34)
                {
                    docpdf.OpenPdf(TimbreElec, docLectura, fileNamePDFCed, "CEDIBLE");
                }

                if (docLectura.TipoDTE == 52)
                {
                    docpdf.OpenPdf(TimbreElec, docLectura, fileNamePDFCed, "CEDIBLE CON SU FACTURA");
                }

                //fin si no es thermal else
            }
        }
Exemplo n.º 3
0
 private void button21_Click(object sender, EventArgs e)
 {
     Empresa empresa = new Empresa();
     empresa.creaTabla();
 }
Exemplo n.º 4
0
        public String do_libroVentas(LibroVenta libro)
        {
            Documento doc     = new Documento();
            Empresa   empresa = new Empresa();

            empresa = empresa.getEmpresa();
            String folioNotificacion = "<FolioNotificacion>" + libro.FolioNotificacion + "</FolioNotificacion>\n";

            if (libro.NroResol != 0)
            {
                folioNotificacion = "";
            }
            String cabeceraLibro =
                "<LibroCompraVenta xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sii.cl/SiiDte LibroCV_v10.xsd\" version=\"1.0\" xmlns=\"http://www.sii.cl/SiiDte\">\n"
                + "<EnvioLibro ID=\"ID201204\">\n"
                + "<Caratula>\n"
                + "<RutEmisorLibro>" + libro.RutEmisorLibro + "</RutEmisorLibro>\n"
                + "<RutEnvia>" + libro.RutEnvia + "</RutEnvia>\n"
                + "<PeriodoTributario>" + libro.PeriodoTributario + "</PeriodoTributario>\n"
                + "<FchResol>" + libro.FchResol + "</FchResol>\n"
                + "<NroResol>" + libro.NroResol + "</NroResol>\n"
                + "<TipoOperacion>" + libro.TipoOperacion + "</TipoOperacion>\n"
                + "<TipoLibro>" + libro.TipoLibro + "</TipoLibro>\n"
                + "<TipoEnvio>" + libro.TipoEnvio + "</TipoEnvio>\n"
                + folioNotificacion
                + "</Caratula>\n";


            String resumen = "<ResumenPeriodo>\n";

            String TotalesP = String.Empty;

            foreach (var total in libro.TotalesPeriodo)
            {
                String b = String.Empty;
                String c = String.Empty;
                String d = String.Empty;
                String a = "<TotalesPeriodo>\n" +
                           "<TpoDoc>" + total.TpoDoc + "</TpoDoc>\n" +
                           "<TotDoc>" + total.TotDoc + "</TotDoc>\n" +
                           "<TotMntExe>" + total.TotMntExe + "</TotMntExe>\n" +
                           "<TotMntNeto>" + total.TotMntNeto + "</TotMntNeto>\n" +
                           "<TotMntIVA>" + total.TotMntIVA + "</TotMntIVA>\n";

                if (total.TotOtrosImp != null)
                {
                    foreach (var otrosimp in total.TotOtrosImp)
                    {
                        if (otrosimp.CodImp == 0)
                        {
                            c = "";
                        }
                        else
                        {
                            c = "<TotOtrosImp>\n" +
                                "<CodImp>" + otrosimp.CodImp + "</CodImp>\n" +
                                "<TotMntImp>" + otrosimp.TotMntImp + "</TotMntImp>\n" +
                                "</TotOtrosImp>\n";
                        }
                    }
                }
                // si montoivafueraplazo es nulo o cero no se agrega en el xml
                String totIVAFueraPlazo = String.Empty;
                if (total.TotIVAFueraPlazo == 0)
                {
                    totIVAFueraPlazo = "";
                }
                else
                {
                    totIVAFueraPlazo = "<TotIVAFueraPlazo>" + total.TotIVAFueraPlazo + "</TotIVAFueraPlazo>\n";
                }


                TotalesP += a + b + c + d +
                            totIVAFueraPlazo +
                            "<TotMntTotal>" + total.TotMntTotal + "</TotMntTotal>\n" +
                            "</TotalesPeriodo>\n";
            }

            String finResumen = "</ResumenPeriodo>\n";


            String detalle     = String.Empty;
            String detalles    = String.Empty;
            String detIvaNo    = String.Empty;
            String detOtrosImp = String.Empty;
            String mnttotal    = String.Empty;

            if (libro.Detalle == null)
            {
                detalle     = "";
                detOtrosImp = "";
            }
            else
            {
                foreach (var det in libro.Detalle)
                {
                    detalle = "<Detalle>\n" +
                              "<TpoDoc>" + det.TpoDoc + "</TpoDoc>\n" +
                              "<NroDoc>" + det.NroDoc + "</NroDoc>\n" +
                              "<TasaImp>" + det.TasaImp + "</TasaImp>\n" +
                              "<FchDoc>" + det.FchDoc + "</FchDoc>\n" +
                              "<RUTDoc>" + det.RUTDoc + "</RUTDoc>\n" +
                              "<RznSoc>" + det.RznSoc + "</RznSoc>\n" +
                              "<MntExe>" + det.MntExe + "</MntExe>\n" +
                              "<MntNeto>" + det.MntNeto + "</MntNeto>\n" +
                              "<MntIVA>" + det.MntIVA + "</MntIVA>\n";
                    if (det.OtrosImp != null)
                    {
                        foreach (var otros in det.OtrosImp)
                        {
                            detOtrosImp = "<OtrosImp>\n" +
                                          "<CodImp>" + otros.CodImp + "</CodImp>\n" +
                                          "<TasaImp>" + otros.TasaImp + "</TasaImp>\n" +
                                          "<MntImp>" + otros.MntImp + "</MntImp>\n" +
                                          "</OtrosImp>\n";
                        }
                    }

                    mnttotal = "<MntTotal>" + det.MntTotal + "</MntTotal>\n";
                    detalle += detIvaNo + detOtrosImp +
                               mnttotal +
                               "</Detalle>\n";
                    detalles += detalle;
                }
            }

            DateTime thisDay = DateTime.Now;
            String   fch     = String.Format("{0:yyyy-MM-ddTHH:mm:ss}", thisDay);

            String finLibro =
                "<TmstFirma>" + fch + "</TmstFirma>\n" +
                "</EnvioLibro>\n" +
                "</LibroCompraVenta>\n";

            String LibroCom = cabeceraLibro + resumen + TotalesP + finResumen + detalles + finLibro;

            X509Certificate2 cert = FuncionesComunes.obtenerCertificado(empresa.NomCertificado);

            String signLibro = firmarLibroVta(LibroCom, cert);

            return(signLibro);
        }