Пример #1
0
        public DTResultadoOperacionModel <DTErroresExcel> LeerArchivo(List <DTFilasExcel> fileFactura)
        {
            DTResultadoOperacionModel <DTSolped>       _DTResultadoModel = new DTResultadoOperacionModel <DTSolped>();
            DTResultadoOperacionModel <DTErroresExcel> resultado         = new DTResultadoOperacionModel <DTErroresExcel>();

            List <DTSolped>       ListaCargaSolped     = new List <DTSolped>();
            List <DTErroresExcel> ListaCargaIncompleta = new List <DTErroresExcel>();

            try
            {
                List <DTFilasExcel> informacion = (from dt in fileFactura
                                                   where dt.index != 0
                                                   select dt).ToList();

                foreach (var filas in informacion)
                {
                    DTSolped             _MMExcel = new DTSolped();
                    DTFilaValidaciones[] Fila     = new DTFilaValidaciones[26];
                    Fila[0] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.SolNro, Valor = SUPValidaciones.ObtenerValorExcel(0, filas), Validaciones = 1
                    };
                    Fila[1] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.NroOC, Valor = SUPValidaciones.ObtenerValorExcel(1, filas), Validaciones = 0
                    };
                    Fila[2] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.LineaPedido, Valor = SUPValidaciones.ObtenerValorExcel(2, filas), Validaciones = 5
                    };
                    Fila[3] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.NroArticulos, Valor = SUPValidaciones.ObtenerValorExcel(3, filas), Validaciones = 1
                    };
                    Fila[4] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.NroSPE, Valor = SUPValidaciones.ObtenerValorExcel(4, filas), Validaciones = 0
                    };
                    Fila[5] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.HACAT, Valor = SUPValidaciones.ObtenerValorExcel(5, filas), Validaciones = 6
                    };
                    Fila[6] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.PersonaSolicitud, Valor = SUPValidaciones.ObtenerValorExcel(6, filas), Validaciones = 6
                    };
                    Fila[7] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.FechaEnvio, Valor = SUPValidaciones.ObtenerValorExcel(7, filas), Validaciones = 4
                    };
                    Fila[8] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Estado, Valor = SUPValidaciones.ObtenerValorExcel(8, filas), Validaciones = 6
                    };
                    Fila[9] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Tipo, Valor = SUPValidaciones.ObtenerValorExcel(9, filas), Validaciones = 6
                    };
                    Fila[10] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Articulo, Valor = SUPValidaciones.ObtenerValorExcel(10, filas), Validaciones = 0
                    };
                    Fila[11] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Cantidad, Valor = SUPValidaciones.ObtenerValorExcel(11, filas), Validaciones = 3
                    };
                    Fila[12] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.TotalLinea, Valor = SUPValidaciones.ObtenerValorExcel(12, filas), Validaciones = 3
                    };
                    Fila[13] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.CodigoIVA, Valor = SUPValidaciones.ObtenerValorExcel(13, filas), Validaciones = 0
                    };
                    Fila[14] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.CuadroCuentas, Valor = SUPValidaciones.ObtenerValorExcel(14, filas), Validaciones = 6
                    };
                    Fila[15] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.PersonaCreador, Valor = SUPValidaciones.ObtenerValorExcel(15, filas), Validaciones = 6
                    };
                    Fila[16] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.FechaPedido, Valor = SUPValidaciones.ObtenerValorExcel(16, filas), Validaciones = 4
                    };
                    Fila[17] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.FechaCreacion, Valor = SUPValidaciones.ObtenerValorExcel(17, filas), Validaciones = 2
                    };
                    Fila[18] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.FechaEntrega, Valor = SUPValidaciones.ObtenerValorExcel(18, filas), Validaciones = 4
                    };
                    Fila[19] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.FechaCaducidad, Valor = SUPValidaciones.ObtenerValorExcel(19, filas), Validaciones = 4
                    };
                    Fila[20] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Proveedor, Valor = SUPValidaciones.ObtenerValorExcel(20, filas), Validaciones = 6
                    };
                    Fila[21] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Cuenta, Valor = SUPValidaciones.ObtenerValorExcel(21, filas), Validaciones = 0
                    };
                    Fila[22] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.IdOC, Valor = SUPValidaciones.ObtenerValorExcel(22, filas), Validaciones = 5
                    };
                    Fila[23] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.LeandingCostC, Valor = SUPValidaciones.ObtenerValorExcel(23, filas), Validaciones = 6
                    };
                    Fila[24] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.EstadoLinea, Valor = SUPValidaciones.ObtenerValorExcel(24, filas), Validaciones = 0
                    };
                    Fila[25] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraSolped.Divisa, Valor = SUPValidaciones.ObtenerValorExcel(25, filas), Validaciones = 6
                    };

                    foreach (DTFilaValidaciones valores in Fila)
                    {
                        DTErroresExcel Errores = SUPValidaciones.Validacion(valores, filas.index);
                        if (Errores.Mensaje != string.Empty)
                        {
                            ListaCargaIncompleta.Add(Errores);
                        }
                        else
                        {
                            switch (valores.Nombre)
                            {
                            case DTEstructuraSolped.SolNro:
                                _MMExcel.SolNro = Int32.Parse(valores.Valor);
                                break;

                            case DTEstructuraSolped.NroOC:
                                _MMExcel.NroOC = valores.Valor;
                                break;

                            case DTEstructuraSolped.LineaPedido:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.LineaPedido = Int32.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.NroOC = null;
                                }
                                break;

                            case DTEstructuraSolped.NroArticulos:
                                _MMExcel.NroArticulos = Int32.Parse(valores.Valor);
                                break;

                            case DTEstructuraSolped.NroSPE:
                                _MMExcel.NroSPE = valores.Valor;
                                break;

                            case DTEstructuraSolped.HACAT:
                                _MMExcel.HACAT = valores.Valor;
                                break;

                            case DTEstructuraSolped.PersonaSolicitud:
                                _MMExcel.PersonaSolicitud = valores.Valor;
                                break;

                            case DTEstructuraSolped.FechaEnvio:
                                _MMExcel.FechaEnvio = Errores.Fecha;
                                break;

                            case DTEstructuraSolped.Estado:
                                _MMExcel.Estado = valores.Valor;
                                break;

                            case DTEstructuraSolped.Tipo:
                                _MMExcel.Tipo = valores.Valor;
                                break;

                            case DTEstructuraSolped.Articulo:
                                _MMExcel.Articulo = valores.Valor;
                                break;

                            case DTEstructuraSolped.Cantidad:
                                _MMExcel.Cantidad = decimal.Parse(valores.Valor);
                                break;

                            case DTEstructuraSolped.TotalLinea:
                                string valor = valores.Valor.Replace('.', ',');
                                _MMExcel.TotalLinea = decimal.Parse(valor);
                                break;

                            case DTEstructuraSolped.CodigoIVA:
                                _MMExcel.CodigoIVA = valores.Valor;
                                break;

                            case DTEstructuraSolped.CuadroCuentas:
                                _MMExcel.CuadroCuentas = valores.Valor;
                                break;

                            case DTEstructuraSolped.PersonaCreador:
                                _MMExcel.PersonaCreador = valores.Valor;
                                break;

                            case DTEstructuraSolped.FechaPedido:
                                _MMExcel.FechaPedido = Errores.Fecha;
                                break;

                            case DTEstructuraSolped.FechaCreacion:
                                _MMExcel.FechaCreacion = (DateTime)Errores.Fecha;
                                break;

                            case DTEstructuraSolped.FechaEntrega:
                                _MMExcel.FechaEntrega = Errores.Fecha;
                                break;

                            case DTEstructuraSolped.FechaCaducidad:
                                _MMExcel.FechaCaducidad = Errores.Fecha;
                                break;

                            case DTEstructuraSolped.Proveedor:
                                _MMExcel.Proveedor = valores.Valor;
                                break;

                            case DTEstructuraSolped.Cuenta:
                                _MMExcel.Cuenta = valores.Valor;
                                break;

                            case DTEstructuraSolped.IdOC:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.IdOC = Int32.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.NroOC = null;
                                }
                                break;

                            case DTEstructuraSolped.LeandingCostC:
                                _MMExcel.LeandingCostC = valores.Valor;
                                break;

                            case DTEstructuraSolped.EstadoLinea:
                                _MMExcel.EstadoLinea = valores.Valor;
                                break;

                            case DTEstructuraSolped.Divisa:
                                _MMExcel.Divisa = valores.Valor;
                                break;
                            }
                        }
                    }

                    _MMExcel.Fila = filas.index + 1;

                    //Registros Duplicados
                    List <DTSolped> ExisteRegistroDuplicados = (from dt in ListaCargaSolped
                                                                where dt.SolNro == _MMExcel.SolNro && dt.NroArticulos == _MMExcel.NroArticulos
                                                                select dt).ToList();

                    //Validación Registros Duplicados
                    if (ExisteRegistroDuplicados.Count > 0)
                    {
                        DTErroresExcel _Excel1 = new DTErroresExcel();
                        _Excel1.Mensaje = "Se repiten registros.";
                        _Excel1.Fila    = filas.index + 1;
                        _Excel1.Campo   = DTEstructuraSolped.SolNro + ", " + DTEstructuraSolped.NroArticulos;
                        _Excel1.Valor   = _MMExcel.SolNro.ToString() + ", " + _MMExcel.NroArticulos.ToString();
                        ListaCargaIncompleta.Add(_Excel1);

                        foreach (var item in ExisteRegistroDuplicados)
                        {
                            DTErroresExcel _Excel = new DTErroresExcel();
                            _Excel.Mensaje = "Se repiten registros.";
                            _Excel.Fila    = item.Fila;
                            _Excel.Campo   = DTEstructuraSolped.SolNro + ", " + DTEstructuraSolped.NroArticulos;
                            _Excel.Valor   = _MMExcel.SolNro.ToString() + ", " + _MMExcel.NroArticulos.ToString();
                            ListaCargaIncompleta.Add(_Excel);
                            ListaCargaSolped.RemoveAll(c => c.Fila == item.Fila);
                        }
                    }


                    // consultar si la fila no tiene inconvenientes
                    List <DTErroresExcel> ConInformacion = (from dt in ListaCargaIncompleta
                                                            where dt.Fila == (filas.index + 1)
                                                            select dt).ToList();

                    // si no prensentar inconveniente se agrega a la lista de carga bd.
                    if (ConInformacion.Count == 0)
                    {
                        ListaCargaSolped.Add(_MMExcel);
                    }
                }

                //// inserta los exitoso o setea en 0 los estados
                ConvertToDataTable(ListaCargaSolped);

                if (ListaCargaIncompleta.Count > 0)
                {
                    ConvertToXML(ListaCargaIncompleta);
                }
                _DTResultadoModel.Respuesta = true;
                resultado.Respuesta         = _DTResultadoModel.Respuesta;
            }
            catch (Exception ex)
            {
                _DTResultadoModel.Mensaje   = DTMensaje.ObtenerObjetoMensaje(DTCodigoMensajes.MENSAJE008);
                _DTResultadoModel.Respuesta = false;
                GestorLog.RegistrarLogExcepcion(ex);

                resultado.Respuesta = _DTResultadoModel.Respuesta;
                resultado.Mensaje   = _DTResultadoModel.Mensaje;
            }
            return(resultado);
        }
Пример #2
0
        public static DTErroresExcel Validacion(DTFilaValidaciones Valores, int NFila)
        {
            Regex Numeros        = new Regex(Constantes.ExpRegSoloNumeros);
            Regex rexNumeroPunto = new Regex(Constantes.ExpRegNumeroPunto);

            DTErroresExcel _Excel = new DTErroresExcel();

            try
            {
                switch (Valores.Validaciones)
                {
                case 0:
                    _Excel.Mensaje = string.Empty;
                    break;

                case 1:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        if (!Numeros.IsMatch(Valores.Valor))
                        {
                            _Excel.Mensaje = "El campo no debe llevar caracteres especiales.";
                            _Excel.Fila    = NFila + 1;
                            _Excel.Campo   = Valores.Nombre;
                            _Excel.Valor   = Valores.Valor;
                        }
                        else
                        {
                            _Excel.Mensaje = string.Empty;
                        }
                    }
                    else
                    {
                        _Excel.Mensaje = "El campo se encuentra vacío.";
                        _Excel.Fila    = NFila + 1;
                        _Excel.Campo   = Valores.Nombre;
                        _Excel.Valor   = Valores.Valor;
                    }
                    break;

                case 2:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        try
                        {
                            DateTime temp = DateTime.ParseExact(Valores.Valor, "dd/MM/yy", CultureInfo.InvariantCulture);
                            _Excel.Fecha   = DateTime.ParseExact(temp.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                            _Excel.Mensaje = string.Empty;
                        }
                        catch (Exception e)
                        {
                            try
                            {
                                DateTime fecha_inicio_anio_actual = DateTime.FromOADate(Convert.ToInt32(Valores.Valor));
                                _Excel.Fecha   = fecha_inicio_anio_actual;
                                _Excel.Mensaje = string.Empty;
                            }
                            catch (Exception)
                            {
                                _Excel.Mensaje = "El campo no tiene el formato correcto.";
                                _Excel.Fila    = NFila + 1;
                                _Excel.Campo   = Valores.Nombre;
                                _Excel.Valor   = Valores.Valor;
                            }
                        }
                    }
                    else
                    {
                        _Excel.Mensaje = "El campo se encuentra vacío.";
                        _Excel.Fila    = NFila + 1;
                        _Excel.Campo   = Valores.Nombre;
                        _Excel.Valor   = Valores.Valor;
                    }
                    break;

                case 3:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        if (!rexNumeroPunto.IsMatch(Valores.Valor))
                        {
                            _Excel.Mensaje = "El campo no debe llevar caracteres especiales.";
                            _Excel.Fila    = NFila + 1;
                            _Excel.Campo   = Valores.Nombre;
                            _Excel.Valor   = Valores.Valor;
                        }
                        else
                        {
                            _Excel.Mensaje = string.Empty;
                        }
                    }
                    else
                    {
                        _Excel.Mensaje = "El campo se encuentra vacío.";
                        _Excel.Fila    = NFila + 1;
                        _Excel.Campo   = Valores.Nombre;
                        _Excel.Valor   = Valores.Valor;
                    }
                    break;

                case 4:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        try
                        {
                            DateTime temp = DateTime.ParseExact(Valores.Valor, "dd/MM/yy", CultureInfo.InvariantCulture);
                            _Excel.Fecha   = DateTime.ParseExact(temp.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                            _Excel.Mensaje = string.Empty;
                        }
                        catch (Exception)
                        {
                            try
                            {
                                DateTime fecha_inicio_anio_actual = DateTime.FromOADate(Convert.ToInt32(Valores.Valor));
                                _Excel.Fecha   = fecha_inicio_anio_actual;
                                _Excel.Mensaje = string.Empty;
                            }
                            catch (Exception)
                            {
                                _Excel.Mensaje = "El campo no tiene el formato correcto.";
                                _Excel.Fila    = NFila + 1;
                                _Excel.Campo   = Valores.Nombre;
                                _Excel.Valor   = Valores.Valor;
                            }
                        }
                    }
                    else
                    {
                        _Excel.Fecha   = default;
                        _Excel.Mensaje = string.Empty;
                    }
                    break;

                case 5:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        if (!Numeros.IsMatch(Valores.Valor))
                        {
                            _Excel.Mensaje = "El campo no debe llevar caracteres especiales.";
                            _Excel.Fila    = NFila + 1;
                            _Excel.Campo   = Valores.Nombre;
                            _Excel.Valor   = Valores.Valor;
                        }
                        else
                        {
                            _Excel.Mensaje = string.Empty;
                        }
                    }
                    else
                    {
                        _Excel.Mensaje = string.Empty;
                    }
                    break;

                case 6:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        _Excel.Mensaje = string.Empty;
                    }
                    else
                    {
                        _Excel.Mensaje = "El campo se encuentra vacío.";
                        _Excel.Fila    = NFila + 1;
                        _Excel.Campo   = Valores.Nombre;
                        _Excel.Valor   = Valores.Valor;
                    }
                    break;

                case 7:
                    if (!string.IsNullOrEmpty(Valores.Valor))
                    {
                        if (!rexNumeroPunto.IsMatch(Valores.Valor))
                        {
                            _Excel.Mensaje = "El campo no debe llevar caracteres especiales.";
                            _Excel.Fila    = NFila + 1;
                            _Excel.Campo   = Valores.Nombre;
                            _Excel.Valor   = Valores.Valor;
                        }
                        else
                        {
                            _Excel.Mensaje = string.Empty;
                        }
                    }
                    else
                    {
                        _Excel.Mensaje = string.Empty;
                    }
                    break;
                }
            }catch (Exception ex)
            {
                throw ex;
            }
            return(_Excel);
        }
        public DTResultadoOperacionModel <DTErroresExcel> LeerArchivo(List <DTFilasExcel> fileFactura, string MesGasto)
        {
            DTResultadoOperacionModel <DTGastos>       _DTResultadoModel = new DTResultadoOperacionModel <DTGastos>();
            DTResultadoOperacionModel <DTErroresExcel> resultado         = new DTResultadoOperacionModel <DTErroresExcel>();

            List <DTGastos>       ListaCarga           = new List <DTGastos>();
            List <DTErroresExcel> ListaCargaIncompleta = new List <DTErroresExcel>();

            try
            {
                List <DTFilasExcel> informacion = (from dt in fileFactura
                                                   where dt.index != 0
                                                   select dt).ToList();

                foreach (var filas in informacion)
                {
                    DTGastos             _MMExcel = new DTGastos();
                    DTFilaValidaciones[] Fila     = new DTFilaValidaciones[8];
                    Fila[0] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.NomCuenta, Valor = SUPValidaciones.ObtenerValorExcel(0, filas), Validaciones = 6, Id = 1
                    };
                    Fila[1] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.NomCentroC, Valor = SUPValidaciones.ObtenerValorExcel(1, filas), Validaciones = 6
                    };
                    Fila[2] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.NroCuenta, Valor = SUPValidaciones.ObtenerValorExcel(2, filas), Validaciones = 6, Id = 2
                    };
                    Fila[3] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.CentroCoste, Valor = SUPValidaciones.ObtenerValorExcel(3, filas), Validaciones = 5
                    };
                    //Fila[4] = new DTFilaValidaciones() { Nombre = DTEstructuraGastos.Concatenar, Valor = SUPValidaciones.ObtenerValorExcel(4, filas), Validaciones = 6 };
                    Fila[4] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.Tipo, Valor = SUPValidaciones.ObtenerValorExcel(5, filas), Validaciones = 6
                    };
                    Fila[5] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.Mes, Valor = SUPValidaciones.ObtenerValorExcel(6, filas), Validaciones = 7
                    };
                    //Fila[6] = new DTFilaValidaciones() { Nombre = DTEstructuraGastos.Cambios, Valor = SUPValidaciones.ObtenerValorExcel(7, filas), Validaciones = 7 };
                    Fila[6] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.Ajustes, Valor = SUPValidaciones.ObtenerValorExcel(7, filas), Validaciones = 7
                    };
                    Fila[7] = new DTFilaValidaciones()
                    {
                        Nombre = DTEstructuraGastos.TotalMes, Valor = SUPValidaciones.ObtenerValorExcel(8, filas), Validaciones = 7
                    };

                    foreach (DTFilaValidaciones valores in Fila)
                    {
                        DTErroresExcel Errores = SUPValidaciones.Validacion(valores, filas.index);
                        if (Errores.Mensaje != string.Empty)
                        {
                            ListaCargaIncompleta.Add(Errores);
                        }
                        else
                        {
                            switch (valores.Nombre)
                            {
                            case DTEstructuraGastos.NomCuenta:
                                if (valores.Id == 1)
                                {
                                    _MMExcel.NomCuenta = valores.Valor;
                                }
                                else if (valores.Id == 2)
                                {
                                    _MMExcel.NroCuenta = valores.Valor;
                                }
                                break;

                            case DTEstructuraGastos.NomCentroC:
                                _MMExcel.NomCentroC = valores.Valor;
                                break;

                            case DTEstructuraGastos.CentroCoste:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.CentroCoste = double.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.CentroCoste = default;
                                }
                                break;

                            //case DTEstructuraGastos.Concatenar:
                            //    _MMExcel.Concatenar = valores.Valor;
                            //    break;
                            case DTEstructuraGastos.Tipo:
                                _MMExcel.Tipo = valores.Valor;
                                break;

                            case DTEstructuraGastos.Mes:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.Mes = decimal.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.Mes = default;
                                }
                                break;

                            case DTEstructuraGastos.Ajustes:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.Ajustes = decimal.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.Ajustes = default;
                                }
                                break;

                            case DTEstructuraGastos.TotalMes:
                                if (!string.IsNullOrEmpty(valores.Valor))
                                {
                                    _MMExcel.TotalMes = decimal.Parse(valores.Valor);
                                }
                                else
                                {
                                    _MMExcel.TotalMes = default;
                                }
                                break;
                            }
                        }
                    }

                    _MMExcel.Fila = filas.index + 1;

                    //Registros Duplicados
                    List <DTGastos> ExisteRegistroDuplicados = (from dt in ListaCarga
                                                                where dt.NroCuenta == _MMExcel.NroCuenta && dt.CentroCoste == _MMExcel.CentroCoste
                                                                select dt).ToList();

                    //Validación Registros Duplicados
                    if (ExisteRegistroDuplicados.Count > 0)
                    {
                        DTErroresExcel _Excel1 = new DTErroresExcel();
                        _Excel1.Mensaje = "Se repiten registros.";
                        _Excel1.Fila    = filas.index + 1;
                        _Excel1.Campo   = DTEstructuraGastos.NroCuenta + ", " + DTEstructuraGastos.CentroCoste;
                        _Excel1.Valor   = _MMExcel.NroCuenta.ToString() + ", " + _MMExcel.CentroCoste.ToString();
                        ListaCargaIncompleta.Add(_Excel1);

                        foreach (var item in ExisteRegistroDuplicados)
                        {
                            DTErroresExcel _Excel = new DTErroresExcel();
                            _Excel.Mensaje = "Se repiten registros.";
                            _Excel.Fila    = item.Fila;
                            _Excel.Campo   = DTEstructuraGastos.NroCuenta + ", " + DTEstructuraGastos.CentroCoste;
                            _Excel.Valor   = _MMExcel.NroCuenta.ToString() + ", " + _MMExcel.CentroCoste.ToString();
                            ListaCargaIncompleta.Add(_Excel);
                            ListaCarga.RemoveAll(c => c.Fila == item.Fila);
                        }
                    }


                    // consultar si la fila no tiene inconvenientes
                    List <DTErroresExcel> ConInformacion = (from dt in ListaCargaIncompleta
                                                            where dt.Fila == (filas.index + 1)
                                                            select dt).ToList();

                    // si no prensentar inconveniente se agrega a la lista de carga bd.
                    if (ConInformacion.Count == 0)
                    {
                        ListaCarga.Add(_MMExcel);
                    }
                }

                //// inserta los exitoso o setea en 0 los estados
                ConvertToDataTable(ListaCarga, MesGasto);

                if (ListaCargaIncompleta.Count > 0)
                {
                    ConvertToXML(ListaCargaIncompleta);
                }
                _DTResultadoModel.Respuesta = true;
                resultado.Respuesta         = _DTResultadoModel.Respuesta;
            }
            catch (Exception ex)
            {
                _DTResultadoModel.Mensaje   = DTMensaje.ObtenerObjetoMensaje(DTCodigoMensajes.MENSAJE008);
                _DTResultadoModel.Respuesta = false;
                GestorLog.RegistrarLogExcepcion(ex);

                resultado.Respuesta = _DTResultadoModel.Respuesta;
                resultado.Mensaje   = _DTResultadoModel.Mensaje;
            }
            return(resultado);
        }