Exemplo n.º 1
0
        public ActionResult reprocesarExcel(string[][] data)
        {
            var modelExcel      = new Models.ExcelModel();
            var modelMantenedor = new Models.MantenedorModel();
            //fila,  cuenta,nombre,  empresa,  rubro,  grupo,    descripcion
            List <FilaJson> lista = new List <FilaJson>();

            foreach (string[] fila in data)
            {
                string n           = fila[0];
                string cuenta      = fila[1];
                string nombre      = fila[2];
                string empresa     = fila[3];
                string rubro       = fila[4];
                string grupo       = fila[5];
                string descripcion = fila[6];
                Cuenta c           = new Cuenta();
                c.numero              = cuenta;
                c.nombre              = nombre;
                c.empresa             = new Empresa();
                c.empresa.razonSocial = empresa;
                c.rubro             = new Rubro();
                c.rubro.rubroNombre = rubro;
                c.grupo             = new Grupo();
                c.grupo.grupoNombre = grupo;
                c.descripcion       = descripcion;
                var r = modelMantenedor.IngresarActualizarCuenta(c, SessionHandler.UsuarioId);
                lista.Add(new FilaJson {
                    fila = n, resultado = r.insertUpdate.ToString()
                });
            }


            return(Json(new { response = "success", resultados = Json(lista) }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult reprocesarExcel(string[][] data)
        {
            var modelExcel      = new Models.ExcelModel();
            var modelMantenedor = new Models.MantenedorModel();
            var modelCuentas    = new Models.CuentaActivaModel();

            List <FilaJson> lista = new List <FilaJson>();

            foreach (string[] fila in data)
            {
                string   empresa      = fila[0];
                string   nroCuenta    = fila[1];
                string   total        = fila[2];
                string   analista     = fila[3];
                string   validador    = fila[4];
                string   certificador = fila[5];
                var      dias         = fila[6];
                string[] fecha        = fila[7].Split('/');
                int      mm           = int.Parse(fecha[0]);
                int      yyyy         = int.Parse(fecha[1]);
                string   id           = fila[8];

                CuentaActiva ca = new CuentaActiva();
                ca.numero                = nroCuenta;
                ca.cuentaActivaTotal     = int.Parse(total);
                ca.cuentaActivaDiasPlazo = int.Parse(dias);
                ca.cuentaActivaFecha     = new DateTime(yyyy, mm, 1);

                ca.empresa             = new Empresa();
                ca.empresa.razonSocial = empresa;

                ca.analista        = new Usuario();
                ca.analista.nombre = analista;

                ca.validador        = new Usuario();
                ca.validador.nombre = validador;

                ca.certificador        = new Usuario();
                ca.certificador.nombre = certificador;

                var r = modelCuentas.IngresarActualizarAsignacionCuenta(ca, SessionHandler.UsuarioId);
                lista.Add(new FilaJson {
                    fila = id, resultado = r.insertUpdate.ToString()
                });
            }


            return(Json(new { response = "success", resultados = Json(lista) }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult procesarExcel(string archivo)
        {
            var modelExcel      = new Models.ExcelModel();
            var modelMantenedor = new Models.MantenedorModel();
            var modelCuenta     = new Models.CuentaActivaModel();
            var selectEmpresas  = "";
            var empresas        = modelMantenedor.obtenerEmpresas();
            var selectUsuarios  = "";
            var usuarios        = modelMantenedor.obtenerUsuarios();

            var cuentas       = modelMantenedor.obtenerCuentas();
            var selectCuentas = "";

            foreach (Cuenta fila in cuentas)
            {
                selectCuentas += "<option value='" + fila.id + "'>" + fila.numero + "</option>";
            }
            foreach (Empresa fila in empresas)
            {
                selectEmpresas += "<option value='" + fila.empresaId + "'>" + fila.razonSocial + "</option>";
            }
            foreach (Usuario fila in usuarios)
            {
                selectUsuarios += "<option value='" + fila.usuarioId + "'>" + fila.nombre + "</option>";
            }
            List <CuentaActiva> cuentasActivas;

            cuentasActivas = modelExcel.ObtenerCuentasActivasDesdeArchivo(HostingEnvironment.ApplicationPhysicalPath + "Archivos\\Temporal\\" + archivo);
            string html     = "";
            int    contador = 0;
            bool   errores  = false;

            foreach (CuentaActiva cuenta in cuentasActivas)
            {
                contador++;
                CuentaActiva c = modelCuenta.IngresarActualizarAsignacionCuenta(cuenta, SessionHandler.UsuarioId);

                if (c.cuentaActivaId == -1)
                {
                    html   += "<tr class='danger' id='" + contador + "'>";
                    errores = true;
                }
                else
                {
                    html += "<tr>";
                }
                //html += "<td>" + contador + "</td>";
                html += "<td>";
                var htmlcuenta = "";
                if (c.empresa.empresaId == -1)
                {
                    html       += "<select id='ReprocesarEmpresa' name='empresas' class='form-control' onchange='CargarCuentasPorEmpresa()'>";
                    html       += "<option value=''>" + c.empresa.razonSocial + " (Valor Erroneo) </option>" + selectEmpresas;
                    html       += "</select>";
                    htmlcuenta += "<select id='ReprocesarCuenta' name='cuentas' class='form-control' >";
                    htmlcuenta += "<option value=''> Seleccione... </option>";
                    htmlcuenta += "</select>";
                }
                else
                {
                    html += c.empresa.razonSocial;
                    if (c.id != -1)
                    {
                        htmlcuenta = c.numero;
                    }
                    else
                    {
                        var cuentasEmpresa = modelMantenedor.ObtenerCuentasPorEmpresa(c.empresa.empresaId);
                        htmlcuenta += "<select name='cuentas' class='form-control' >";
                        htmlcuenta += "<option value=''>" + c.numero + " (Valor Erroneo) </option>";
                        foreach (Cuenta fila in cuentasEmpresa)
                        {
                            htmlcuenta += "<option value='" + fila.id + "'>" + fila.numero + "</option>";
                        }
                        htmlcuenta += "</select>";
                    }
                }
                html += "</td>";
                html += "<td>" + htmlcuenta + "</td>";
                html += "<td>" + c.cuentaActivaTotal + "</td>";
                html += "<td>";
                if (c.analista.usuarioId == -1)
                {
                    html += "<select name='analista' class='form-control' >";
                    html += "<option value=''>" + c.analista.nombre + " (Valor Erroneo) </option>" + selectUsuarios;
                    html += "</select>";
                }
                else
                {
                    html += c.analista.nombre;
                }
                html += "</td>";
                html += "<td>";
                if (c.validador.usuarioId == -1)
                {
                    html += "<select name='validador' class='form-control' >";
                    html += "<option value=''>" + c.validador.nombre + " (Valor Erroneo) </option>" + selectUsuarios;
                    html += "</select>";
                }
                else
                {
                    html += c.validador.nombre;
                }
                html += "</td>";
                html += "<td>";
                if (c.certificador.usuarioId == -1)
                {
                    html += "<select name='certificador' class='form-control' >";
                    html += "<option value=''>" + c.certificador.nombre + " (Valor Erroneo) </option>" + selectUsuarios;
                    html += "</select>";
                }
                else
                {
                    html += c.certificador.nombre;
                }
                html += "</td>";
                html += "<td>" + c.cuentaActivaDiasPlazo + "</td>";

                html += "<td>" + StringHelper.DosNumeros(c.cuentaActivaFecha.Month) + "/" + c.cuentaActivaFecha.Year + "</td>";

                html += "<td>";
                if (c.id == -1)
                {
                    html += "FALLIDO <i class='fa fa-times-circle danger'></i>";
                }
                else
                {
                    if (c.insertUpdate)
                    {
                        html += "INSERTADA  <i class='fa fa-plus-circle' style='color:#4f4' ></i>";
                    }
                    else
                    {
                        html += "ACTUALIZADA <i class='fa fa-check-circle' style='color:#4f4' ></i>";
                    }
                }
                html += "</td>";

                html += "</tr>";
            }



            return(Json(new { response = "success", tabla = html, errores = errores }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult procesarExcel(string archivo)
        {
            var modelExcel      = new Models.ExcelModel();
            var modelMantenedor = new Models.MantenedorModel();
            var selectEmpresas  = "";
            var empresas        = modelMantenedor.obtenerEmpresas();
            var selectRubros    = "";
            var rubros          = modelMantenedor.obtenerRubros();
            var selectGrupos    = "";
            var grupos          = modelMantenedor.obtenerGrupos();

            foreach (Empresa fila in empresas)
            {
                selectEmpresas += "<option value='" + fila.empresaId + "'>" + fila.razonSocial + "</option>";
            }
            foreach (Rubro fila in rubros)
            {
                selectRubros += "<option value='" + fila.rubroId + "'>" + fila.rubroNombre + "</option>";
            }
            foreach (Grupo fila in grupos)
            {
                selectGrupos += "<option value='" + fila.grupoId + "'>" + fila.grupoNombre + "</option>";
            }

            List <Cuenta> cuentas;

            cuentas = modelExcel.ObtenerCuentas(HostingEnvironment.ApplicationPhysicalPath + "Archivos\\Temporal\\" + archivo);
            string html     = "";
            int    contador = 0;
            bool   errores  = false;

            foreach (Cuenta cuenta in cuentas)
            {
                contador++;
                Cuenta c = modelMantenedor.IngresarActualizarCuenta(cuenta, SessionHandler.UsuarioId);

                if (c.id == -1)
                {
                    html   += "<tr class='danger' id='" + contador + "'>";
                    errores = true;
                }
                else
                {
                    html += "<tr>";
                }



                html += "<td>" + contador + "</td>";
                html += "<td>" + c.numero + "</td>";
                html += "<td>" + c.nombre + "</td>";

                html += "<td>";
                if (c.empresa.empresaId == -1)
                {
                    html += "<select name='empresas' class='form-control' >";
                    html += "<option value=''>" + c.empresa.razonSocial + " (Valor Erroneo) </option>" + selectEmpresas;
                    html += "</select>";
                }
                else
                {
                    html += c.empresa.razonSocial;
                }
                html += "</td>";


                html += "<td>";
                if (c.rubro.rubroId == -1)
                {
                    html += "<select name='rubros' class='form-control' >";
                    html += "<option value=''>" + c.rubro.rubroNombre + " (Valor Erroneo) </option>" + selectRubros;
                    html += "</select>";
                }
                else
                {
                    html += c.rubro.rubroNombre;
                }
                html += "</td>";

                html += "<td>";
                if (c.grupo.grupoId == -1)
                {
                    html += "<select name='grupos' class='form-control' >";
                    html += "<option value=''>" + c.grupo.grupoNombre + " (Valor Erroneo) </option>" + selectGrupos;
                    html += "</select>";
                }
                else
                {
                    html += c.grupo.grupoNombre;
                }
                html += "</td>";


                html += "<td>" + c.descripcion + "</td>";
                html += "<td>";
                if (c.id == -1)
                {
                    html += "FALLIDO <i class='fa fa-times-circle danger'></i>";
                }
                else
                {
                    if (c.insertUpdate)
                    {
                        html += "INSERTADA  <i class='fa fa-plus-circle' style='color:#4f4' ></i>";
                    }
                    else
                    {
                        html += "ACTUALIZADA <i class='fa fa-check-circle' style='color:#4f4' ></i>";
                    }
                }
                html += "</td>";
                html += "</tr>";
            }



            return(Json(new { response = "success", tabla = html, errores = errores }, JsonRequestBehavior.AllowGet));
        }