Beispiel #1
0
        public string [] GenerarLayout(string pathTxt, encabezado Encabezado, int idUsuario, List <detallado> Detalle, List <emisoras> emisoras)
        {
            int count = Detalle == null ? 0: Detalle.Count;

            List <int> emi = new List <int>();

            int j = 0;
            int c = 0;


            decimal importetotal = Utils.TruncateDecimalesAbc(Encabezado.ImporteTotal, 2);

            //string imptotal = Regex.Replace(importetotal.ToString(), @".", "");
            string imptotal = importetotal.ToString().Replace(".", "");
            ////validar que el directorio para el txt este creado, sino se crea
            var newruta = ValidarFolderUsuario(idUsuario, pathTxt);

            var grupo    = emisoras.GroupBy(u => u.NoEmisor).Select(grp => grp.FirstOrDefault()).ToList();
            int countEmi = emisoras == null ? 0 : grupo.Count;

            string[] archivoTxt = new string[countEmi];
            foreach (var emisor in grupo)
            {
                //string[] lines = new string[count + 1];
                List <string> lines = new List <string>();
                //int i = 1;

                string encabezadoFinal = Encabezado.TipoRegistro + "" + Encabezado.ClaveServicio + "" + emisor.NoEmisor + "" + Encabezado.fecha + "" + addCeros((Encabezado.consecutivo + c), 2) + "" + addCeros(Encabezado.TotalEmpleados, 6) + "" + addCeros(Convert.ToInt32(imptotal), 15)
                                         + "" + addCeros(0, 6) + "" + addCeros(0, 15) + "" + addCeros(0, 6) + "" + addCeros(0, 15) + "" + addCeros(0, 6) + "" + 0 + "    " + "" + addCeros(0, 8) + "" + addCeros(0, 10) + "" + addCeros(0, 55);
                archivoTxt[j] = pathTxt + "NI" + emisor.NoEmisor + addCeros((Encabezado.consecutivo + c), 2) + ".PAG";
                //lines[0] = encabezadoFinal;
                lines.Add(encabezadoFinal);
                foreach (var d in Detalle.Where(x => x.NoEmisor == emisor.NoEmisor))
                {
                    string impDetalle = Extensores.ToCurrencyFormat(d.Importe);

                    string impDGeneral = impDetalle.ToString().Replace(".", "");
                    impDGeneral = impDGeneral.ToString().Replace(",", "");
                    string detallado = d.TipoRegistro + "" + d.fecha + "" + addCeros(d.NoSiga1, 10) + "                                                                                " + "" + addCeros(Convert.ToInt32(impDGeneral), 15) + "" + addCeros(d.Banco, 3)
                                       + "" + addCeros(d.TipoCuenta, 2) + "" + addCeros(d.CuentaBancaria, 18) + "0 " + "" + addCeros(0, 8) + "                  ";
                    //lines[i] = detallado;
                    lines.Add(detallado);
                    //i++;
                }
                File.WriteAllLines(archivoTxt[j], lines.ToArray());
                j++;
                c++;
            }



            return(archivoTxt);
        }
Beispiel #2
0
        // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


        public string[] GenerarLayout(string pathTxt, encabezado Encabezado, int idUsuario, List <LayoutBanco> Detalle)
        {
            int count = Detalle == null ? 0 : Detalle.Count;

            List <int> emi = new List <int>();

            int j = 0;
            int c = 0;

            var importeTotal = Detalle.Sum(x => x.Importe);
            var emisoras     = Detalle.Select(x => x.NoEmisor);

            decimal importetotal = Utils.TruncateDecimalesAbc(importeTotal, 2);

            string imptotal = importetotal.ToString().Replace(".", "");
            var    newruta  = ValidarFolderUsuario(idUsuario, pathTxt);

            var grupo = emisoras.GroupBy(u => u).Select(grp => grp.FirstOrDefault()).ToList();

            int countEmi = emisoras == null ? 0 : grupo.Count;

            string[] archivoTxt = new string[countEmi];
            foreach (var emisor in grupo)
            {
                List <string> lines = new List <string>();

                string encabezadoFinal = Encabezado.TipoRegistro + "" + Encabezado.ClaveServicio + "" + emisor + "" + Encabezado.Fecha + "" + addCeros((Encabezado.Consecutivo + c), 2) + "" + addCeros(count, 6) + "" + addCeros(Convert.ToInt32(imptotal), 15) + "" + addCeros(0, 6) + "" + addCeros(0, 15) + "" + addCeros(0, 6) + "" + addCeros(0, 15) + "" + addCeros(0, 6) + "" + 0 + "    " + "" + addCeros(0, 8) + "" + addCeros(0, 10) + "" + addCeros(0, 55);
                archivoTxt[j] = pathTxt + idUsuario + "\\" + "NI" + emisor + addCeros((Encabezado.Consecutivo + c), 2) + ".PAG";

                lines.Add(encabezadoFinal);
                foreach (var d in Detalle.Where(x => x.NoEmisor == emisor))
                {
                    string impDetalle = Extensores.ToCurrencyFormat(d.Importe);

                    string impDGeneral = impDetalle.ToString().Replace(".", "");
                    impDGeneral = impDGeneral.ToString().Replace(",", "");
                    var    TipoCuenta = 1;
                    string detallado  = Encabezado.registroDetalle + "" + Encabezado.Fecha + "" + addCeros(Int32.Parse(d.NoSiga.ToString()), 10) + "                                                                                " + "" + addCeros(Convert.ToInt32(impDGeneral), 15) + "" + addCeros(Encabezado.Banco, 3) + "" + addCeros(TipoCuenta, 2) + "" + addCeros(Convert.ToInt32(d.CuentaBancaria), 18) + "0 " + "" + addCeros(0, 8) + "                  ";

                    lines.Add(detallado);
                }
                File.WriteAllLines(archivoTxt[j], lines.ToArray());
                j++;
                c++;
            }
            return(archivoTxt);
        }