コード例 #1
0
    public static List <ActividadEconomicaModel> LeerArchivoACTECO()
    {
        string RutaFileActeco = ParseExtensions.Get_AppData_Path("ACTECOLIST.txt");

        List <ActividadEconomicaModel> lstReturnActectos = new List <ActividadEconomicaModel>();
        var lines = File.ReadLines(RutaFileActeco); //File.ReadLines(@"C:\FE\wkhtmltopdf\bin\ACTECOLIST.txt");

        foreach (var line in lines)
        {
            string[] datosActeco    = Regex.Split(line, @"\//");
            string   codInterino    = datosActeco[0].Trim();
            string   nombreInterino = datosActeco[1].Trim();

            ACTECO_AfectoIVA EsAfectoIVA;
            string           AfectoIVAstr = datosActeco[2].Trim();
            if (AfectoIVAstr == "SI")
            {
                EsAfectoIVA = ACTECO_AfectoIVA.SI;
            }
            else if (AfectoIVAstr == "NO")
            {
                EsAfectoIVA = ACTECO_AfectoIVA.NO;
            }
            else
            {
                EsAfectoIVA = ACTECO_AfectoIVA.ND;
            }

            ACTECO_CategoriaTributaria CategoriaTrib;
            string CategoriaTributariaSTR = datosActeco[3].Trim();
            if (CategoriaTributariaSTR == "1")
            {
                CategoriaTrib = ACTECO_CategoriaTributaria.C1;
            }
            else if (CategoriaTributariaSTR == "2")
            {
                CategoriaTrib = ACTECO_CategoriaTributaria.C2;
            }
            else
            {
                CategoriaTrib = ACTECO_CategoriaTributaria.ND;
            }

            bool   bl_disponibleInternet = true;
            string strDisponibleInternet = datosActeco[4].Trim();
            if (strDisponibleInternet == "SI")
            {
                bl_disponibleInternet = true;
            }
            else
            {
                bl_disponibleInternet = false;
            }

            ActividadEconomicaModel objActividad = new ActividadEconomicaModel(codInterino, nombreInterino, EsAfectoIVA, CategoriaTrib, bl_disponibleInternet);
            lstReturnActectos.Add(objActividad);
        }

        return(lstReturnActectos);
    }
        public FileResult PlantillaExcelConciliacionManual()
        {
            string                 UserID     = User.Identity.GetUserId();
            FacturaPoliContext     db         = ParseExtensions.GetDatabaseContext(UserID);
            ClientesContablesModel objCliente = PerfilamientoModule.GetClienteContableSeleccionado(Session, UserID, db);

            string FileVirtualPath = ParseExtensions.Get_AppData_Path("PlantillaConciliacionBancaria.xlsx");

            return(File(FileVirtualPath, "application/force- download", Path.GetFileName(FileVirtualPath)));
        }
コード例 #3
0
    public static string GetMensajeRecuperarContraseña(string callbackUrl)
    {
        string RutaTemplateMailPasswordRecovery = ParseExtensions.Get_AppData_Path("MailBody.html");

        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        doc.Load(RutaTemplateMailPasswordRecovery);
        var node = doc.GetElementbyId("mainMessage");

        node.InnerHtml = "Por favor reestablezca su contraseña haciendo click en el siguiente <a href=\"" + callbackUrl + "\">link</a>";

        return(doc.DocumentNode.OuterHtml);
    }
コード例 #4
0
    public static byte[] ExportExcelLibroCentralizacionAuxiliaresVentaCompra(ClientesContablesModel objCliente, bool InformarMembrete, TipoCentralizacion tipoLibroCentralizacion, string tituloDocumento, FacturaPoliContext db, string FechaInicio = "", string FechaFin = "", int Anio = 0, int Mes = 0)
    {
        byte[] ExcelByteArray        = null;
        string pathFileArchivosLibro = ParseExtensions.Get_AppData_Path("LibroTemplate.xlsx");


        using (XLWorkbook excelFile = new XLWorkbook(pathFileArchivosLibro))
        {
            var workSheet = excelFile.Worksheet(1);

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = objCliente.RUTEmpresa;
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A6").Value = objCliente.Direccion;
                workSheet.Cell("A7").Value = objCliente.Ciudad;
                workSheet.Cell("A8").Value = objCliente.Representante;
                workSheet.Cell("A9").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
                workSheet.Cell("A8").Value = string.Empty;
                workSheet.Cell("A9").Value = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(tituloDocumento) == false)
            {
                workSheet.Cell("A12").Value = tituloDocumento;
            }
            else
            {
                workSheet.Cell("A12").Value = string.Empty;
            }

            List <AuxiliaresDetalleModel> lstAuxiliares = RescatarLibroCentralizacion(objCliente, tipoLibroCentralizacion, db, FechaInicio, FechaFin, Anio, Mes);

            int NumeroFilaExcel        = 15;
            int NumeroCorrelativoDummy = 1;


            foreach (AuxiliaresDetalleModel tableRow in lstAuxiliares)
            {
                List <string> valuesForExcel = new List <string>();
                //FECHA
                valuesForExcel.Add(ParseExtensions.ToDD_MM_AAAA(tableRow.Fecha));
                //NUMERO CORRELATIVO
                valuesForExcel.Add(NumeroCorrelativoDummy.ToString());
                //TIPO DE DOCUMENTO
                valuesForExcel.Add(ParseExtensions.EnumGetDisplayAttrib(tableRow.TipoDocumento));
                //FOLIO
                valuesForExcel.Add(tableRow.Folio.ToString());
                //RUT PRESTADOR
                valuesForExcel.Add(tableRow.Individuo.PrestadorRut);
                //NOMBRE PRESTADOR
                valuesForExcel.Add(tableRow.Individuo.PrestadorNombre);

                //EXENTO
                valuesForExcel.Add(tableRow.MontoExentoLinea.ToString());
                //MONTO
                valuesForExcel.Add(tableRow.MontoNetoLinea.ToString());
                //IVA
                valuesForExcel.Add(tableRow.MontoIVALinea.ToString());
                //TOTAL
                valuesForExcel.Add(tableRow.MontoTotalLinea.ToString());

                string[] theRow = valuesForExcel.ToArray();
                for (int i = 0; i < theRow.Length; i++)
                {
                    workSheet.Cell(NumeroFilaExcel, i + 1).Value = theRow[i];
                }
                workSheet.Range("A" + NumeroFilaExcel + ":J" + NumeroFilaExcel).Rows().Style.Border.OutsideBorder = XLBorderStyleValues.Medium;
                //workSheet.Range("A" + NumeroFilaExcel + "J" + NumeroFilaExcel).Rows().Style.Border.InsideBorder.Get = XLBorderStyleValues.Double;

                NumeroFilaExcel++;
                NumeroCorrelativoDummy++;
            }

            //OBTIENE TOTALES POR TIPO DE DOCUMENTO
            List <string[]> lstTotalValues = new List <string[]>();
            var             objX           = lstAuxiliares.Select(x => x.TipoDocumento).Distinct();
            foreach (TipoDte tipo_dte in objX)
            {
                lstTotalValues.Add(new string[] {
                    "Total",
                    lstAuxiliares.Where(r => r.TipoDocumento == tipo_dte).Count() + " " + ParseExtensions.EnumGetDisplayAttrib(tipo_dte),
                    ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoExentoLinea)),
                    ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoNetoLinea)),
                    ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoIVALinea)),
                    ParseExtensions.NumeroConPuntosDeMiles((lstAuxiliares.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoTotalLinea)))
                    //+ lstTotalValues.Where(r => r.TipoFactura == tipo_dte).Sum(r => r.ObjTotals.ImpuestoAdicionalMonto)))
                    //MANEJAR A FUTURO IMPUESTO ADICIONAL TOTAL DE LOS OTROS TIPOS?
                });
            }

            lstTotalValues.Add(new string[] {
                "Total",
                lstAuxiliares.Count() + " " + "Comprobantes",
                ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Sum(r => r.MontoExentoLinea)),
                ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Sum(r => r.MontoExentoLinea)),
                ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Sum(r => r.MontoExentoLinea)),
                ParseExtensions.NumeroConPuntosDeMiles(lstAuxiliares.Sum(r => r.MontoExentoLinea))
            });

            /*
             * lstTotalValues.Add(new string[] {
             *      "Total",
             *      lstVentasDelMes.Count() +" " + "Comprobantes",
             *      ParseExtensions.NumeroConPuntosDeMiles(rQuery.Where(CheckNonCredito).Sum(r => r.ObjTotals.MontoExento) - rQuery.Where(CheckCredito).Sum(r => r.ObjTotals.MontoExento)),
             *      ParseExtensions.NumeroConPuntosDeMiles(rQuery.Where(CheckNonCredito).Sum(r => r.ObjTotals.MontoNetoMonto) - rQuery.Where(CheckCredito).Sum(r => r.ObjTotals.MontoNetoMonto)),
             *      ParseExtensions.NumeroConPuntosDeMiles(rQuery.Where(CheckNonCredito).Sum(r => r.ObjTotals.IVAMonto) - rQuery.Where(CheckCredito).Sum(r => r.ObjTotals.IVAMonto)),
             *      ParseExtensions.NumeroConPuntosDeMiles((rQuery.Where(CheckNonCredito).Sum(r => r.ObjTotals.TotalMonto) + rQuery.Sum(r => r.ObjTotals.ImpuestoAdicionalMonto))
             *                                           - (rQuery.Where(CheckCredito).Sum(r => r.ObjTotals.TotalMonto) + rQuery.Where(CheckCredito).Sum(r => r.ObjTotals.ImpuestoAdicionalMonto)))
             * });*/

            if (lstTotalValues.Count > 0)
            {
                //var rangeWithArrays = workSheet.Cell(NumeroFilaExcel, 1).InsertData(lstTotalValues);
                //rangeWithArrays.LastRow().Style.Border.BottomBorder = XLBorderStyleValues.Thick;
                int lastRowLocation = NumeroFilaExcel + 1;
                workSheet.Cell(lastRowLocation, 5).InsertData(lstTotalValues);
            }
            else
            {
                workSheet.Cell(16, 5).InsertData(lstTotalValues);
            }


            workSheet.Columns().AdjustToContents();

            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);
        }
        if (ExcelByteArray == null)
        {
            return(null);
        }
        else
        {
            return(ExcelByteArray);
        }
    }
コード例 #5
0
    public static byte[] ExportExcelLibroVentaCompraNormal(List <string[]> cachedLibroCompra, ClientesContablesModel objCliente, bool InformarMembrete, TipoCentralizacion tipoLibroCentralizacion, string tituloDocumento, string FechaInicio = "", string FechaFin = "", int Anio = 0, int Mes = 0, bool TieneFiltros = false)
    {
        byte[] ExcelByteArray = null;


        string pathFileArchivosLibro = ParseExtensions.Get_AppData_Path("LibroTemplate.xlsx");

        if (tipoLibroCentralizacion == TipoCentralizacion.Compra)
        {
            pathFileArchivosLibro = ParseExtensions.Get_AppData_Path("LibroTemplate.xlsx");
        }
        else if (tipoLibroCentralizacion == TipoCentralizacion.Venta)
        {
            pathFileArchivosLibro = ParseExtensions.Get_AppData_Path("LibroTemplate2.xlsx");
        }



        using (XLWorkbook excelFile = new XLWorkbook(pathFileArchivosLibro))
        {
            var workSheet = excelFile.Worksheet(1);

            FacturaPoliContext db = new FacturaPoliContext();

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = "Rut: " + ParseExtensions.FormatoRutMembrete(objCliente.RUTEmpresa);
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A6").Value = objCliente.Direccion;
                workSheet.Cell("A7").Value = objCliente.Ciudad;
                workSheet.Cell("A8").Value = ParseExtensions.FormatoRutMembrete(objCliente.RUTRepresentante) + objCliente.Representante;
                // workSheet.Cell("A9").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
                workSheet.Cell("A8").Value = string.Empty;
                workSheet.Cell("A9").Value = string.Empty;
            }

            if (TieneFiltros)
            {
                workSheet.Cell("C4").Value = tituloDocumento;
            }
            else if (!TieneFiltros)
            {
                workSheet.Cell("C4").Value = "TODOS LOS AÑOS";
            }

            if (tipoLibroCentralizacion == TipoCentralizacion.Compra)
            {
                //H a M
                workSheet.Columns("A", "M").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
                workSheet.Columns("H:M").Style.NumberFormat.Format     = "#,##0 ;-#,##0";
            }
            else if (tipoLibroCentralizacion == TipoCentralizacion.Venta)
            {
                workSheet.Columns("A", "K").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;
                workSheet.Columns("H:K").Style.NumberFormat.Format     = "#,##0 ;-#,##0";
            }

            bool     ConversionFechaInicioExitosa = false;
            DateTime dtFechaInicio             = new DateTime();
            bool     ConversionFechaFinExitosa = false;
            DateTime dtFechaFin = new DateTime();

            ConversionFechaInicioExitosa = DateTime.TryParse(FechaInicio, out dtFechaInicio);
            ConversionFechaFinExitosa    = DateTime.TryParse(FechaFin, out dtFechaFin);

            workSheet.Columns("B", "C").Style.DateFormat.Format = "dd-MM-yyyy";

            int NumeroFilaExcel        = 15;
            int NumeroCorrelativoDummy = 1;
            //int IgnoraUltimo = cachedLibroCompra.Count() - 2;

            foreach (String[] tableRow in  cachedLibroCompra)
            {
                List <string> valuesForExcel = new List <string>();

                //Correlativo
                valuesForExcel.Add(tableRow[0]);
                //Fecha documento
                valuesForExcel.Add(tableRow[1]);
                //Fecha contabilización
                valuesForExcel.Add(tableRow[2]);
                //Comprobante
                valuesForExcel.Add(tableRow[3]);
                //Folio
                valuesForExcel.Add(tableRow[4]);
                //Nombre
                valuesForExcel.Add(tableRow[5]);
                //Rut
                valuesForExcel.Add(tableRow[6]);
                //Exento
                valuesForExcel.Add(tableRow[7]);
                //Monto Afecto
                valuesForExcel.Add(tableRow[8]);
                //IVA Recuperable (IVA a secas)
                valuesForExcel.Add(tableRow[9]);
                if (tipoLibroCentralizacion == TipoCentralizacion.Compra)
                {
                    //IVA no recuperable
                    valuesForExcel.Add(tableRow[10]);
                    //IVA uso común
                    valuesForExcel.Add(tableRow[11]);
                }
                //TOTAL
                valuesForExcel.Add(tableRow[12]);

                string[] theRow = valuesForExcel.ToArray();
                for (int i = 0; i < theRow.Length; i++)
                {
                    if (theRow[i] != "-" && !string.IsNullOrWhiteSpace(theRow[i]))
                    {
                        if (i == 1 || i == 2)
                        {
                            DateTime Fecha = ParseExtensions.CreaFechaLiteral(theRow[i]);
                            workSheet.Cell(NumeroFilaExcel, i + 1).Value = Fecha;
                        }
                        else
                        {
                            workSheet.Cell(NumeroFilaExcel, i + 1).Value = theRow[i]; //.Value = theRow[i];
                        }
                    }
                }
                if (tipoLibroCentralizacion == TipoCentralizacion.Compra)
                {
                    workSheet.Range("A" + NumeroFilaExcel + ":M" + NumeroFilaExcel).Rows().Style.Border.OutsideBorder = XLBorderStyleValues.Thin; // Se establece el rango que cubrirá el borde del excel
                                                                                                                                                  //workSheet.Range("A" + NumeroFilaExcel + "J" + NumeroFilaExcel).Rows().Style.Border.InsideBorder.Get = XLBorderStyleValues.Double;
                }
                else if (tipoLibroCentralizacion == TipoCentralizacion.Venta)
                {
                    workSheet.Range("A" + NumeroFilaExcel + ":K" + NumeroFilaExcel).Rows().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                }
                NumeroFilaExcel++;
                NumeroCorrelativoDummy++;
            }

            /*   foreach (LibrosContablesModel tableRow in bagDetalleLibros)
             * {
             *     List<string> valuesForExcel = new List<string>();
             *     //FECHA
             *     valuesForExcel.Add(ParseExtensions.ToDD_MM_AAAA(tableRow.FechaDoc));
             *     //NUMERO CORRELATIVO
             *     valuesForExcel.Add(NumeroCorrelativoDummy.ToString());
             *     //TIPO DE DOCUMENTO
             *     valuesForExcel.Add(ParseExtensions.EnumGetDisplayAttrib(tableRow.TipoDocumento));
             *     //FOLIO
             *     valuesForExcel.Add(tableRow.Folio.ToString());
             *     //RUT PRESTADOR
             *     valuesForExcel.Add(tableRow.individuo.RUT);
             *     //NOMBRE PRESTADOR
             *     valuesForExcel.Add(tableRow.individuo.RazonSocial);
             *
             *     //EXENTO
             *     valuesForExcel.Add(tableRow.MontoExento.ToString());
             *     //MONTO
             *     valuesForExcel.Add(tableRow.MontoNeto.ToString());
             *     //IVA
             *     valuesForExcel.Add(tableRow.MontoIva.ToString());
             *     //TOTAL
             *     valuesForExcel.Add(tableRow.MontoTotal.ToString());
             *
             *     string[] theRow = valuesForExcel.ToArray();
             *     for (int i = 0; i < theRow.Length; i++)
             *     {
             *         workSheet.Cell(NumeroFilaExcel, i + 1).SetValue<string>(theRow[i]); //.Value = theRow[i];
             *     }
             *     workSheet.Range("A" + NumeroFilaExcel + ":J" + NumeroFilaExcel).Rows().Style.Border.OutsideBorder = XLBorderStyleValues.Medium;
             *     //workSheet.Range("A" + NumeroFilaExcel + "J" + NumeroFilaExcel).Rows().Style.Border.InsideBorder.Get = XLBorderStyleValues.Double;
             *
             *     NumeroFilaExcel++;
             *     NumeroCorrelativoDummy++;
             * }*/

            //OBTIENE TOTALES POR TIPO DE DOCUMENTO

            List <string[]> lstTotalValues = new List <string[]>();
            var             objX           = cachedLibroCompra.Select(x => x[3]).Distinct();
            if (tipoLibroCentralizacion == TipoCentralizacion.Compra)
            {
                foreach (string tipo_dte in objX)
                {
                    lstTotalValues.Add(new string[] {
                        "Total",
                        cachedLibroCompra.Where(r => r[3] == tipo_dte).Count() + " " + tipo_dte,
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[7]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[8]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[9]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[10]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[11]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[12])))
                    });
                }

                lstTotalValues.Add(new string[] {
                    "Total",
                    cachedLibroCompra.Count() + " " + "Comprobantes",
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[7]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[7])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[8]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[8])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[9]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[9])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[10]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[10])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[11]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[11])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[12]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[12]))))
                });
            }
            else if (tipoLibroCentralizacion == TipoCentralizacion.Venta)
            {
                foreach (string tipo_dte in objX)
                {
                    lstTotalValues.Add(new string[] {
                        "Total",
                        cachedLibroCompra.Where(r => r[3] == tipo_dte).Count() + " " + tipo_dte,
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[7]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[8]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[9]))),
                        ParseExtensions.NumeroConPuntosDeMiles(cachedLibroCompra.Where(r => r[3] == tipo_dte).Sum(x => int.Parse(x[12])))
                    });
                }

                lstTotalValues.Add(new string[] {
                    "Total",
                    cachedLibroCompra.Count() + " " + "Comprobantes",
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[7]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[7])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[8]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[8])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[9]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[9])))),
                    ParseExtensions.NumeroConPuntosDeMiles((cachedLibroCompra.Where(w => bool.Parse(w[13]) == false).Sum(r => int.Parse(r[12]))) - (cachedLibroCompra.Where(w => bool.Parse(w[13]) == true).Sum(r => int.Parse(r[12]))))
                });
            }



            /*}
             *
             *
             *          List<string[]> lstTotalValues = new List<string[]>();
             *          var objX = bagDetalleLibros.Select(x => x.TipoDocumento).Distinct();
             *          foreach (TipoDte tipo_dte in objX)
             *          {
             *              lstTotalValues.Add(new string[] {
             *                  "Total",
             *                  bagDetalleLibros.Where(r => r.TipoDocumento == tipo_dte).Count() +" " + ParseExtensions.EnumGetDisplayAttrib(tipo_dte),
             *                  ParseExtensions.NumeroConPuntosDeMiles(bagDetalleLibros.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoExento)),
             *                  ParseExtensions.NumeroConPuntosDeMiles(bagDetalleLibros.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoNeto)),
             *                  ParseExtensions.NumeroConPuntosDeMiles(bagDetalleLibros.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoIva)),
             *                  ParseExtensions.NumeroConPuntosDeMiles((bagDetalleLibros.Where(r => r.TipoDocumento == tipo_dte).Sum(r => r.MontoTotal)))
             *              });
             *          }
             *
             *          lstTotalValues.Add(new string[] {
             *                  "Total",
             *                  bagDetalleLibros.Count() +" " + "Comprobantes",
             *                  ParseExtensions.NumeroConPuntosDeMiles( (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == false).Sum(r => r.MontoExento)) - (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == true).Sum(r => r.MontoExento)) ),
             *                  ParseExtensions.NumeroConPuntosDeMiles( (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == false).Sum(r => r.MontoNeto)) - (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == true).Sum(r => r.MontoNeto)) ),
             *                  ParseExtensions.NumeroConPuntosDeMiles( (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == false).Sum(r => r.MontoIva)) - (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == true).Sum(r => r.MontoIva)) ),
             *                  ParseExtensions.NumeroConPuntosDeMiles( (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == false).Sum(r => r.MontoTotal)) - (bagDetalleLibros.Where(w => w.TipoDocumento.EsUnaNotaCredito() == true).Sum(r => r.MontoTotal)) )
             *          });*/

            if (lstTotalValues.Count > 0)
            {
                int lastRowLocation = NumeroFilaExcel + 1;
                workSheet.Cell(lastRowLocation, 6).InsertData(lstTotalValues);
            }
            else
            {
                workSheet.Cell(16, 6).InsertData(lstTotalValues);
            }
            workSheet.Columns().AdjustToContents();
            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);
        }
        if (ExcelByteArray == null)
        {
            return(null);
        }
        else
        {
            return(ExcelByteArray);
        }
    }
コード例 #6
0
    public static byte[] GetExcelCuentasCorrientes(List <ObjetoCtasCtesPorConciliar> lstCtaCorriente, decimal SaldoAperturaGeneral, ClientesContablesModel objCliente, bool InformarMembrete)
    {
        string RutaPlanillaLibroMayor = ParseExtensions.Get_AppData_Path("ESTADOCTASCORRIENTES.xlsx");

        byte[] ExcelByteArray = null;
        using (XLWorkbook excelFile = new XLWorkbook(RutaPlanillaLibroMayor))
        {
            var workSheet = excelFile.Worksheet(1);

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = objCliente.RUTEmpresa;
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A4").Value = objCliente.Direccion;
                workSheet.Cell("A5").Value = objCliente.Ciudad;
                workSheet.Cell("A6").Value = objCliente.Representante;
                workSheet.Cell("A7").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A4").Value = string.Empty;
                workSheet.Cell("A5").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
            }

            int     numeroFilaExcel   = 12;
            int     Correlativo       = 0;
            decimal TotalGeneralDebe  = 0;
            decimal TotalGeneralHaber = 0;
            decimal TotalGeneralSaldo = 0;


            workSheet.Columns("D").Style.DateFormat.Format     = "dd-MM-yyyy";
            workSheet.Column("A").Style.NumberFormat.Format    = "#,##0 ;-#,##0";
            workSheet.Columns("I:K").Style.NumberFormat.Format = "#,##0 ;-#,##0";

            workSheet.Cell(numeroFilaExcel, "A").Value           = "Saldo Apertura: " + ParseExtensions.NumeroConPuntosDeMiles(SaldoAperturaGeneral);
            workSheet.Cell(numeroFilaExcel, "A").Style.Font.Bold = true;
            numeroFilaExcel++;

            foreach (var CapaCuentaContable in lstCtaCorriente)
            {
                foreach (var CapaAuxiliar in CapaCuentaContable.Contenido)
                {
                    workSheet.Cell(numeroFilaExcel, "A").Value           = ParseExtensions.ObtenerCodigoYNombreCtaContable(CapaAuxiliar.CodInterno, objCliente);
                    workSheet.Cell(numeroFilaExcel, "A").Style.Font.Bold = true;
                    numeroFilaExcel++;

                    workSheet.Cell(numeroFilaExcel, "A").Value           = CapaAuxiliar.Rut;
                    workSheet.Cell(numeroFilaExcel, "A").Style.Font.Bold = true;
                    numeroFilaExcel++;

                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                    workSheet.Cell(numeroFilaExcel, "A").Value = " ";
                    workSheet.Cell(numeroFilaExcel, "B").Value = "RUT";
                    workSheet.Cell(numeroFilaExcel, "C").Value = "NOMBRE";
                    workSheet.Cell(numeroFilaExcel, "D").Value = "FECHA";
                    workSheet.Cell(numeroFilaExcel, "E").Value = "Folio";
                    workSheet.Cell(numeroFilaExcel, "F").Value = "COMPROBANTE";
                    workSheet.Cell(numeroFilaExcel, "G").Value = "DOCUMENTO";
                    workSheet.Cell(numeroFilaExcel, "H").Value = "VENCIMIENTO";
                    workSheet.Cell(numeroFilaExcel, "I").Value = "DEBE";
                    workSheet.Cell(numeroFilaExcel, "J").Value = "HABER";
                    workSheet.Cell(numeroFilaExcel, "K").Value = "SALDO";
                    numeroFilaExcel++;

                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                    workSheet.Cell(numeroFilaExcel, "A").Value           = "Saldo Apertura: " + ParseExtensions.NumeroConPuntosDeMiles(CapaAuxiliar.SaldoRut);
                    workSheet.Cell(numeroFilaExcel, "A").Style.Font.Bold = true;
                    numeroFilaExcel++;

                    foreach (var CapaDetalle in CapaAuxiliar.Contenido)
                    {
                        workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                            ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                        workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                            ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                        Correlativo++;
                        workSheet.Cell(numeroFilaExcel, "A").Value = Correlativo;
                        workSheet.Cell(numeroFilaExcel, "B").Value = CapaDetalle.RutPrestador;
                        workSheet.Cell(numeroFilaExcel, "C").Value = CapaDetalle.NombrePrestador;
                        workSheet.Cell(numeroFilaExcel, "D").Value = CapaDetalle.Fecha;
                        workSheet.Cell(numeroFilaExcel, "E").Value = CapaDetalle.Folio;
                        if (!string.IsNullOrWhiteSpace(CapaDetalle.Comprobante2))
                        {
                            workSheet.Cell(numeroFilaExcel, "F").Value = CapaDetalle.Comprobante2;
                        }
                        else
                        {
                            workSheet.Cell(numeroFilaExcel, "F").Value = CapaDetalle.Comprobante;
                        }

                        if (CapaDetalle.Documento == 0)
                        {
                            workSheet.Cell(numeroFilaExcel, "G").Value = "Honorarios";
                        }
                        else
                        {
                            workSheet.Cell(numeroFilaExcel, "G").Value = ParseExtensions.EnumGetDisplayAttrib(CapaDetalle.Documento);
                        }
                        workSheet.Cell(numeroFilaExcel, "H").Value = "";
                        workSheet.Cell(numeroFilaExcel, "I").Value = CapaDetalle.Debe;
                        workSheet.Cell(numeroFilaExcel, "J").Value = CapaDetalle.Haber;

                        numeroFilaExcel++;
                    }

                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                    workSheet.Range("A" + numeroFilaExcel + ":K" + numeroFilaExcel).Rows
                        ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                    workSheet.Cell(numeroFilaExcel, "I").Value           = CapaAuxiliar.TotalDebe;
                    workSheet.Cell(numeroFilaExcel, "I").Style.Font.Bold = true;
                    workSheet.Cell(numeroFilaExcel, "J").Value           = CapaAuxiliar.TotalHaber;
                    workSheet.Cell(numeroFilaExcel, "J").Style.Font.Bold = true;
                    workSheet.Cell(numeroFilaExcel, "K").Value           = CapaAuxiliar.SaldoRut;
                    workSheet.Cell(numeroFilaExcel, "K").Style.Font.Bold = true;
                    numeroFilaExcel++;
                    numeroFilaExcel++;
                }


                workSheet.Cell(numeroFilaExcel, "G").Value           = "Saldo Apertura: " + ParseExtensions.NumeroConPuntosDeMiles(CapaCuentaContable.TotalSaldoAcumulado);
                workSheet.Cell(numeroFilaExcel, "G").Style.Font.Bold = true;
                numeroFilaExcel++;
                workSheet.Cell(numeroFilaExcel, "G").Value           = "TOTAL CUENTA CONTABLE: ";
                workSheet.Cell(numeroFilaExcel, "G").Style.Font.Bold = true;
                workSheet.Cell(numeroFilaExcel, "H").Value           = ParseExtensions.ObtenerCodigoYNombreCtaContable(CapaCuentaContable.CodigoInterno, objCliente);
                workSheet.Cell(numeroFilaExcel, "H").Style.Font.Bold = true;

                workSheet.Cell(numeroFilaExcel, "I").Value           = CapaCuentaContable.TotalDebe;
                workSheet.Cell(numeroFilaExcel, "I").Style.Font.Bold = true;
                TotalGeneralDebe += CapaCuentaContable.TotalDebe;
                workSheet.Cell(numeroFilaExcel, "J").Value           = CapaCuentaContable.TotalHaber;
                workSheet.Cell(numeroFilaExcel, "J").Style.Font.Bold = true;
                TotalGeneralHaber += CapaCuentaContable.TotalHaber;
                workSheet.Cell(numeroFilaExcel, "K").Value           = CapaCuentaContable.TotalSaldo;
                workSheet.Cell(numeroFilaExcel, "K").Style.Font.Bold = true;

                numeroFilaExcel++;
                numeroFilaExcel++;
            }

            workSheet.Cell(numeroFilaExcel, "H").Value           = "TOTAL FINAL: ";
            workSheet.Cell(numeroFilaExcel, "H").Style.Font.Bold = true;
            workSheet.Cell(numeroFilaExcel, "I").Value           = TotalGeneralDebe;
            workSheet.Cell(numeroFilaExcel, "I").Style.Font.Bold = true;
            workSheet.Cell(numeroFilaExcel, "J").Value           = TotalGeneralHaber;
            workSheet.Cell(numeroFilaExcel, "J").Style.Font.Bold = true;
            TotalGeneralSaldo = TotalGeneralHaber - TotalGeneralDebe;
            workSheet.Cell(numeroFilaExcel, "K").Value           = TotalGeneralSaldo;
            workSheet.Cell(numeroFilaExcel, "K").Style.Font.Bold = true;

            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);

            if (ExcelByteArray == null)
            {
                return(null);
            }
            else
            {
                return(ExcelByteArray);
            }
        }
    }
コード例 #7
0
    public static byte[] GetExcelCtaCorriente(List <EstadoCuentasCorrientesViewModel> lstCtaCorriente, ClientesContablesModel objCliente, bool InformarMembrete)
    {
        var UnicosEnLaLista = ParseExtensions.ObtieneLstAuxNombre(lstCtaCorriente);

        string RutaPlanillaLibroMayor = ParseExtensions.Get_AppData_Path("ESTADOCTASCORRIENTES.xlsx");

        byte[] ExcelByteArray = null;
        using (XLWorkbook excelFile = new XLWorkbook(RutaPlanillaLibroMayor))
        {
            var workSheet = excelFile.Worksheet(1);

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = objCliente.RUTEmpresa;
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A4").Value = objCliente.Direccion;
                workSheet.Cell("A5").Value = objCliente.Ciudad;
                workSheet.Cell("A6").Value = objCliente.Representante;
                workSheet.Cell("A7").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A4").Value = string.Empty;
                workSheet.Cell("A5").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
            }
            workSheet.Columns("C", "F").Style.DateFormat.Format = "dd-MM-yyyy";
            workSheet.Columns("G:I").Style.NumberFormat.Format  = "#,##0 ;-#,##0";

            decimal TotalHaber = 0;
            decimal TotalDebe  = 0;
            decimal TotalSaldo = 0;

            int NumeroFilaExcel = 12;

            for (int i = 0; i < UnicosEnLaLista.Count(); i++)
            {
                decimal Debe  = 0;
                decimal Haber = 0;
                decimal Saldo = 0;

                workSheet.Cell(NumeroFilaExcel, "A").Value           = UnicosEnLaLista[i];
                workSheet.Cell(NumeroFilaExcel, "A").Style.Font.Bold = true;
                NumeroFilaExcel++;

                workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                    ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                    ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                workSheet.Cell(NumeroFilaExcel, "A").Value = "RUT";
                workSheet.Cell(NumeroFilaExcel, "B").Value = "NOMBRE";
                workSheet.Cell(NumeroFilaExcel, "C").Value = "FECHA";
                workSheet.Cell(NumeroFilaExcel, "D").Value = "COMPROBANTE";
                workSheet.Cell(NumeroFilaExcel, "E").Value = "DOCUMENTO";
                workSheet.Cell(NumeroFilaExcel, "F").Value = "VENCIMIENTO";
                workSheet.Cell(NumeroFilaExcel, "G").Value = "DEBE";
                workSheet.Cell(NumeroFilaExcel, "H").Value = "HABER";
                workSheet.Cell(NumeroFilaExcel, "I").Value = "SALDO";

                NumeroFilaExcel++;

                foreach (var ItemCtaCte in lstCtaCorriente)
                {
                    if (ItemCtaCte.CuentaContable.nombre == UnicosEnLaLista[i])
                    {
                        Debe  += ItemCtaCte.Debe;
                        Haber += ItemCtaCte.Haber;

                        workSheet.Cell(NumeroFilaExcel, "A").Value = ItemCtaCte.RutPrestador;
                        workSheet.Cell(NumeroFilaExcel, "B").Value = ItemCtaCte.NombrePrestador;
                        workSheet.Cell(NumeroFilaExcel, "C").Value = ItemCtaCte.Fecha;
                        workSheet.Cell(NumeroFilaExcel, "D").Value = ItemCtaCte.Comprobante;
                        workSheet.Cell(NumeroFilaExcel, "E").Value = ItemCtaCte.Documento;
                        workSheet.Cell(NumeroFilaExcel, "F").Value = "";
                        workSheet.Cell(NumeroFilaExcel, "G").Value = ItemCtaCte.Debe;
                        workSheet.Cell(NumeroFilaExcel, "H").Value = ItemCtaCte.Haber;
                        workSheet.Cell(NumeroFilaExcel, "I").Value = ItemCtaCte.Saldo;



                        workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                            ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                        workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                            ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                        NumeroFilaExcel++;
                    }
                }
                workSheet.Cell(NumeroFilaExcel, "F").Value           = "TOTAL";
                workSheet.Cell(NumeroFilaExcel, "F").Style.Font.Bold = true;
                workSheet.Cell(NumeroFilaExcel, "G").Value           = Debe;
                workSheet.Cell(NumeroFilaExcel, "G").Style.Font.Bold = true;
                workSheet.Cell(NumeroFilaExcel, "H").Value           = Haber;
                workSheet.Cell(NumeroFilaExcel, "H").Style.Font.Bold = true;

                Saldo = Haber - Debe;

                workSheet.Cell(NumeroFilaExcel, "I").Value           = Math.Abs(Saldo);
                workSheet.Cell(NumeroFilaExcel, "I").Style.Font.Bold = true;

                workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                    ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                workSheet.Range("A" + NumeroFilaExcel + ":I" + NumeroFilaExcel).Rows
                    ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                TotalHaber += Haber;
                TotalDebe  += Debe;
                TotalSaldo += Saldo;

                NumeroFilaExcel += 2;
            }

            workSheet.Cell(NumeroFilaExcel, "F").Value           = "TOTAL FINAL:";
            workSheet.Cell(NumeroFilaExcel, "F").Style.Font.Bold = true;
            workSheet.Cell(NumeroFilaExcel, "G").Value           = TotalDebe;
            workSheet.Cell(NumeroFilaExcel, "G").Style.Font.Bold = true;
            workSheet.Cell(NumeroFilaExcel, "H").Value           = TotalHaber;
            workSheet.Cell(NumeroFilaExcel, "H").Style.Font.Bold = true;
            workSheet.Cell(NumeroFilaExcel, "I").Value           = TotalSaldo;
            workSheet.Cell(NumeroFilaExcel, "I").Style.Font.Bold = true;

            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);
        }
        if (ExcelByteArray == null)
        {
            return(null);
        }
        else
        {
            return(ExcelByteArray);
        }
    }
コード例 #8
0
    public static byte[] GetExcelEstadoComp(List <EstadoResultadoComparativoViewModel> lstEstadoComp,
                                            List <DateTime> FechasConsultadas, List <decimal> ResultadoGanancia,
                                            List <decimal> ResultadoPerdida, List <decimal> ResultadoDelEjercicio,
                                            ClientesContablesModel objCliente, bool InformarMembrete, int AnioDesde, int AnioHasta,
                                            bool BusquedaPorAnio, int Anio)
    {
        string RutaEsteExcel = ParseExtensions.Get_AppData_Path("EstadoResultadoComparativo.xlsx");

        byte[] ExcelByteArray = null;
        using (XLWorkbook excelFile = new XLWorkbook(RutaEsteExcel))
        {
            var workSheet = excelFile.Worksheet(1);

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = objCliente.RUTEmpresa;
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A4").Value = objCliente.Direccion;
                workSheet.Cell("A5").Value = objCliente.Ciudad;
                workSheet.Cell("A6").Value = objCliente.Representante;
                workSheet.Cell("A7").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A4").Value = string.Empty;
                workSheet.Cell("A5").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
            }
            if (AnioDesde > 0 && AnioHasta > 0 && BusquedaPorAnio == true)
            {
                workSheet.Cell("C8").Value = "Estado Resultado Comparativo" + "  " + AnioDesde + "  " + "Hasta: " + AnioHasta;
            }
            else if (BusquedaPorAnio == false)
            {
                workSheet.Cell("C8").Value = "Estado Resultado Comparativo" + "  " + Anio;
            }


            workSheet.Column("B").Width = 35;


            int NumeroFilaColumnas = 12;
            workSheet.Cell(NumeroFilaColumnas, "A").Value = "Codigo";
            workSheet.Cell(NumeroFilaColumnas, "B").Value = "Cuentas";
            int UltimaColumna = FechasConsultadas.Count() + 3;
            for (int i = 0; i < FechasConsultadas.Count(); i++)
            {
                if (AnioDesde > 0 && AnioHasta > 0 && BusquedaPorAnio == true)
                {
                    workSheet.Cell(NumeroFilaColumnas, i + 3).Value = "Año: " + FechasConsultadas[i].Year.ToString();
                }
                else if (BusquedaPorAnio == false)
                {
                    workSheet.Cell(NumeroFilaColumnas, i + 3).Value = ParseExtensions.obtenerNombreMes(FechasConsultadas[i].Month);
                }
            }
            workSheet.Cell(NumeroFilaColumnas, UltimaColumna).Value = "Totales";

            workSheet.Columns(3, UltimaColumna).Style.NumberFormat.Format = "#,##0 ;(#,##0)";
            workSheet.Columns(3, UltimaColumna).Width = 13;

            int NumeroFilaExcel = 13;
            foreach (EstadoResultadoComparativoViewModel ItemGanancia in lstEstadoComp.Where(x => x.CodigoSubClasiMarca.StartsWith("5")))
            {
                workSheet.Cell(NumeroFilaExcel, "A").Value = ItemGanancia.CodigoCta;
                workSheet.Cell(NumeroFilaExcel, "B").Value = ItemGanancia.NombreCtaContable;
                List <decimal> lstSaldo = ItemGanancia.Saldo;
                for (int i = 0; i < lstSaldo.Count(); i++)
                {
                    workSheet.Cell(NumeroFilaExcel, 3 + i).Value = lstSaldo[i];
                }
                NumeroFilaExcel++;
            }

            NumeroFilaExcel++;
            foreach (EstadoResultadoComparativoViewModel ItemPerdida in lstEstadoComp.Where(x => x.CodigoSubClasiMarca.StartsWith("4")))
            {
                workSheet.Cell(NumeroFilaExcel, "A").Value = ItemPerdida.CodigoCta;
                workSheet.Cell(NumeroFilaExcel, "B").Value = ItemPerdida.NombreCtaContable;
                List <decimal> lstSaldo = ItemPerdida.Saldo;
                for (int i = 0; i < lstSaldo.Count(); i++)
                {
                    workSheet.Cell(NumeroFilaExcel, 3 + i).Value = lstSaldo[i];
                }
                NumeroFilaExcel++;
            }

            NumeroFilaExcel++;
            workSheet.Cell(NumeroFilaExcel, "B").Value = "RESULTADO GANANCIA: ";
            for (int i = 0; i < ResultadoGanancia.Count(); i++)
            {
                workSheet.Cell(NumeroFilaExcel, i + 3).Value = ResultadoGanancia[i];
            }

            NumeroFilaExcel++;
            workSheet.Cell(NumeroFilaExcel, "B").Value = "RESULTADO PERDIDA: ";
            for (int i = 0; i < ResultadoPerdida.Count(); i++)
            {
                workSheet.Cell(NumeroFilaExcel, i + 3).Value = ResultadoPerdida[i];
            }

            NumeroFilaExcel++;
            workSheet.Cell(NumeroFilaExcel, "B").Value = "RESULTADO DEL EJERCICIO: ";
            for (int i = 0; i < ResultadoDelEjercicio.Count(); i++)
            {
                workSheet.Cell(NumeroFilaExcel, i + 3).Value = ResultadoDelEjercicio[i];
            }
            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);
        }
        if (ExcelByteArray == null)
        {
            return(null);
        }
        else
        {
            return(ExcelByteArray);
        }
    }
コード例 #9
0
    //public static List<CatorceTerViewModel> GetCatorceTerDesdeVoucher(FacturaPoliContext db, ClientesContablesModel ObjCliente)
    //{
    //    IQueryable<VoucherModel> QueryIandE = db.DBVoucher.Where(x => x.)
    //    return null;
    //}

    public static byte[] GetExcelCatorceTer(List <CatorceTerViewModel> lstCatorceTer, ClientesContablesModel objCliente, bool InformarMembrete, SessionParaExcel Fechas)
    {
        string RutaEsteExcel = ParseExtensions.Get_AppData_Path("14Ter.xlsx");

        byte[] ExcelByteArray = null;
        using (XLWorkbook excelFile = new XLWorkbook(RutaEsteExcel))
        {
            var workSheet = excelFile.Worksheet(1);

            if (InformarMembrete == true)
            {
                workSheet.Cell("A1").Value = objCliente.RazonSocial;
                workSheet.Cell("A2").Value = objCliente.RUTEmpresa;
                workSheet.Cell("A3").Value = objCliente.Giro;
                workSheet.Cell("A4").Value = objCliente.Direccion;
                workSheet.Cell("A5").Value = objCliente.Ciudad;
                workSheet.Cell("A6").Value = objCliente.Representante;
                workSheet.Cell("A7").Value = objCliente.RUTRepresentante;
            }
            else
            {
                workSheet.Cell("A1").Value = string.Empty;
                workSheet.Cell("A2").Value = string.Empty;
                workSheet.Cell("A3").Value = string.Empty;
                workSheet.Cell("A4").Value = string.Empty;
                workSheet.Cell("A5").Value = string.Empty;
                workSheet.Cell("A6").Value = string.Empty;
                workSheet.Cell("A7").Value = string.Empty;
            }

            if (string.IsNullOrWhiteSpace(Fechas.Mes) && string.IsNullOrWhiteSpace(Fechas.Anio))
            {
                workSheet.Cell("F8").Value = "Informe 14 Ter";
            }
            else if (!string.IsNullOrWhiteSpace(Fechas.Mes) && !string.IsNullOrWhiteSpace(Fechas.Anio))
            {
                workSheet.Cell("F8").Value = "Informe 14 Ter" + "  " + ParseExtensions.obtenerNombreMes(Convert.ToInt32(Fechas.Mes)) + "  " + Fechas.Anio;
            }
            else if (!string.IsNullOrWhiteSpace(Fechas.Anio) && string.IsNullOrWhiteSpace(Fechas.Mes))
            {
                workSheet.Cell("F8").Value = "Informe 14 Ter" + "  " + Fechas.Anio;
            }
            workSheet.Column("B").Style.DateFormat.Format          = "dd-MM-yyyy";
            workSheet.Columns("G:H").Style.NumberFormat.Format     = "#,##0 ;-#,##0";
            workSheet.Columns("A", "K").Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left;


            int NumeroFilaExcel = 13;
            int Correlativo     = 1;
            foreach (var itemTer in lstCatorceTer)
            {
                if (itemTer.TotalIngreso > 0 || itemTer.TotalEgreso > 0)
                {
                    workSheet.Cell(NumeroFilaExcel, "F").Value = "TOTAL:";
                    workSheet.Cell(NumeroFilaExcel, "G").Value = itemTer.TotalIngreso;
                    workSheet.Cell(NumeroFilaExcel, "H").Value = itemTer.TotalEgreso;
                }
                else
                {
                    workSheet.Cell(NumeroFilaExcel, "A").Value = Correlativo;
                    workSheet.Cell(NumeroFilaExcel, "B").Value = itemTer.Fecha;
                    if (itemTer.TipoDocumento != 0)
                    {
                        workSheet.Cell(NumeroFilaExcel, "C").Value = itemTer.TipoDocumento.ToString();
                    }
                    else
                    {
                        workSheet.Cell(NumeroFilaExcel, "C").Value = "Otros";
                    }
                    workSheet.Cell(NumeroFilaExcel, "D").Value = itemTer.Folio;
                    workSheet.Cell(NumeroFilaExcel, "E").Value = itemTer.NombreReceptor;
                    workSheet.Cell(NumeroFilaExcel, "F").Value = itemTer.RutReceptor;
                    workSheet.Cell(NumeroFilaExcel, "G").Value = itemTer.Ingreso;
                    workSheet.Cell(NumeroFilaExcel, "H").Value = itemTer.Egreso;
                    workSheet.Cell(NumeroFilaExcel, "I").Value = itemTer.CuentaContable;
                }

                workSheet.Range("A" + NumeroFilaExcel + ":K" + NumeroFilaExcel).Rows
                    ().Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
                workSheet.Range("A" + NumeroFilaExcel + ":K" + NumeroFilaExcel).Rows
                    ().Style.Border.InsideBorder = XLBorderStyleValues.Thin;

                Correlativo++;
                NumeroFilaExcel++;
            }

            ExcelByteArray = ParseExtensions.GetExcelStream(excelFile);
        }
        if (ExcelByteArray == null)
        {
            return(null);
        }
        else
        {
            return(ExcelByteArray);
        }
    }
コード例 #10
0
    //public const string SubjectCorreoIntercambio = "e-factu / PROCESO INTERCAMBIO DTE";



    public static bool SendMail_Generic(List <string> TO, string FROM, string SUBJECT, string TITLE_TEXT, string MSG_BODY, bool IS_BODY_HTML)
    {
        //Verificar remitentes y destinatarios
        bool DestinosSonEMAIL = TO.All(r => r.IsValidEMail());
        bool OrigenEsEMAIL    = FROM.IsValidEMail();

        if (OrigenEsEMAIL == false || DestinosSonEMAIL == false)
        {
            return(false);
        }

        //Verificar que subject no sea vacio
        if (string.IsNullOrWhiteSpace(SUBJECT))
        {
            return(false);
        }

        //Si BODY y TITLE son vacios, porque se estaria enviando un correo?
        if (string.IsNullOrWhiteSpace(TITLE_TEXT) && string.IsNullOrWhiteSpace(MSG_BODY))
        {
            return(false);
        }

        string RutaTemplateMailPasswordRecovery = ParseExtensions.Get_AppData_Path("MailBody.html");

        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        doc.Load(RutaTemplateMailPasswordRecovery);

        var node = doc.GetElementbyId("mainMessage");

        node.InnerHtml = MSG_BODY;

        node           = doc.GetElementbyId("mainTitle");
        node.InnerHtml = TITLE_TEXT;

        //aca se envia el correo
        MailMessage mail = new MailMessage();

        mail.Subject = SUBJECT;
        mail.From    = new MailAddress(FROM);
        foreach (string Destinatarios in TO)
        {
            mail.To.Add(Destinatarios);
        }
        mail.Body       = doc.DocumentNode.OuterHtml;
        mail.IsBodyHtml = IS_BODY_HTML;

        SmtpClient        smtp   = new SmtpClient();
        NetworkCredential netCre = new NetworkCredential(FROM, "mierda42.5");

        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
        smtp.EnableSsl             = true;
        smtp.Host                  = "smtp.zoho.com";
        smtp.Port                  = 587;
        smtp.UseDefaultCredentials = false;
        smtp.Credentials           = netCre;

        try
        {
            smtp.Send(mail);
            return(true);
        }
        catch (Exception ex)
        {
            // Handle exception here
            #if DEBUG
            Debug.Assert(false, "Mail failed");
            #endif
            return(false);
        }
    }