public List<clsPagoDetalle> consultaNumPago(int NumPago)
        {
            try
            {
                List<clsPagoDetalle> lista = new List<clsPagoDetalle>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.PagoDet where w.NumPago == NumPago select w;
                foreach (var item in con)
                {
                    clsPagoDetalle clas = new clsPagoDetalle();
                    clas.NumLinea = item.NumLinea;
                    clas.IdMedioPago = item.IdMedioPago;
                    clas.Monto = (item.Monto);
                    clas.NumeroCuenta = item.NumeroCuenta;
                    clas.IdEmpresa = item.IdEmpresa;
                    clas.IdBanco = item.IdBanco;
                    clas.NumComprobante = item.NumComprobante;
                    // clas.NumComision =Convert.ToInt32 ( item.NumComision);
                    // clas.NumNominaCab =Convert.ToInt32 ( item.NumNominaCab);
                    clas.NumPago = item.NumPago;

                    lista.Add(clas);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsOrdenPagoCab> consulta()
        {
            try
            {
                List<clsOrdenPagoCab> lista = new List<clsOrdenPagoCab>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.OrdenPagoCab select w;
                foreach (var item in con)
                {
                    clsOrdenPagoCab clase = new clsOrdenPagoCab();
                    clase.NumOrdenPago = item.NumOrdenPago;
                    clase.fechadeEmision = item.fechadeEmision;
                    clase.IdPersona = Convert.ToInt32(item.IdPersona);
                    clase.Estado = item.Estado;
                    clase.TotalPagar = item.TotalPagar;
                    clase.TipoOrdenPago = Convert.ToChar(item.TipoOrdenPago);
                    clase.IdUsuario = item.IdUsuario;
                    clase.IdEmpresa = item.IdEmpresa;
                    lista.Add(clase);

                }
                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsImpuesto> consulta()
        {
            try
            {
                List<clsImpuesto > lista = new List<clsImpuesto>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.Impuesto select w;
                foreach (var item in con)
                {
                    clsImpuesto clas = new clsImpuesto();
                    clas.IdImpuesto = item.IdImpuesto;
                    clas.Descripcion = item.Descripcion;
                     clas.Porcentaje =Convert.ToDouble (item.Porcentaje);
                    clas.FechaRegistro = (item.FechaRegistro);
                    clas.Estado = item.Estado;
                        clas.IdEmpresa = item.IdEmpresa;
                    clas.IdUsuario = item.IdUsuario;

                    lista.Add(clas);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsCuentaPorPagarDetalle> ConsultaDetalleCuentas()
        {
            try
            {
                List<clsCuentaPorPagarDetalle> lista = new List<clsCuentaPorPagarDetalle>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.DeudaDet select w;
                foreach (var item in con)
                {
                    clsCuentaPorPagarDetalle clase = new clsCuentaPorPagarDetalle();
                    clase._IdEmpresa = item.IdEmpresa;
                    clase._NumCuentaPorPagar = item.NumCuentaPorPagar;
                    clase._NumCuentaPorPagarDetalle = item.NumDetalleDeuda;
                    clase._ValorLetra = item.ValorLetra;
                    clase._FechaVencimiento = item.FechaVencimiento;
                    clase._Estado = item.Estado;
                    clase._numeroPagos = 0;
                    clase._totalPagar = 0;
                    clase._AutorizarPago = false;
                    lista.Add(clase);
                }
                return lista;

            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsCuentaPorPagarDetalle> consultaDetalle(int ind)
        {
            try
            {
                List<clsCuentaPorPagarDetalle> lista = new List<clsCuentaPorPagarDetalle>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.DeudaDet where w.NumCuentaPorPagar == ind select w;
                foreach (var item in con)
                {
                    clsCuentaPorPagarDetalle clas = new clsCuentaPorPagarDetalle();
                    clas._IdEmpresa = item.IdEmpresa;
                    clas._NumCuentaPorPagar = item.NumCuentaPorPagar;
                    clas._NumCuentaPorPagarDetalle = item.NumDetalleDeuda;
                    clas._ValorLetra = item.ValorLetra;
                    clas._FechaVencimiento = item.FechaVencimiento;
                    clas._Estado = item.Estado;
                    lista.Add(clas);
                }

                return lista;
            }
            catch (Exception)
            {
                return null;
            }
        }
        public List<clsPago> consulta(int Empresa)
        {
            try
            {
                List<clsPago> lista = new List<clsPago>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.PagoCab where w.IdEmpresa == Empresa select w;
                foreach (var item in con)
                {
                    clsPago clas = new clsPago();
                    clas.NumPago = item.NumPago;
                    clas.FechaIngreso = item.FechaIngreso;
                    clas.NumOrdenPago = Convert.ToInt32(item.NumOrdenPago);

                    clas.TotalPagar = item.TotalPagar;
                    clas.IdUsuario = item.IdUsuario;
                    clas.IdEmpresa = item.IdEmpresa;
                    clas.IdEstado = item.Estado;
                    clas.NumComprobante = item.NumComprobante;
                    lista.Add(clas);

                }
                return lista;

            }
            catch (Exception)
            {
                return null;

            }
        }
        public List<clsCuentaBancaria> consultaPorEmpresa(String idEmpresa)
        {
            try
            {clsCuentaBancaria clas = new clsCuentaBancaria();
                List<clsCuentaBancaria> lista = new List<clsCuentaBancaria>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.CuentaBancaria select w;
                foreach (var item in con)
                {
                    if (idEmpresa == item.IdEmpresaServicio)
                    {
                        clas.Serie = item.Serie;
                        clas.TipoCuenta = item.TipoCuenta;
                        clas.NroCta = (item.NroCta);
                        clas.IdBanco = item.IdBanco;
                        clas.IdEmpresa = item.IdEmpresa;
                        clas.IdEmpresaServicio = item.IdEmpresaServicio;

                        lista.Add(clas);
                    }
                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsFrecuencia> consulta()
        {
            try
            {
                List<clsFrecuencia> lista = new List<clsFrecuencia>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.FrecuenciaPago select w;
                foreach (var item in con)
                {
                    clsFrecuencia clas = new clsFrecuencia();
                    clas._IdFrecuenciaPago = item.IdFrecuenciaPago;
                    clas._Descripcion = item.Descripcion;
                    clas._FechaActual = (item.FechaActual);
                    clas._Estado = item.Estado;
                    clas._IdUsuario = item.IdUsuario;
                    clas._IdEmpresa = item.IdEmpresa;
                    lista.Add(clas);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsImpuestos> consulta()
        {
            try
            {
                List<clsImpuestos> lista = new List<clsImpuestos>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.Impuesto select w;
                foreach (var item in con)
                {
                    clsImpuestos clas = new clsImpuestos();
                    clas.IdImpuesto = item.IdImpuesto;
                    clas.Descripcion = item.Descripcion;
                    clas.FechaRegistro = item.FechaRegistro;
                    clas.IdEstado = item.Estado;
                    clas.naturAcree = item.NatureAcree;
                    clas.Porcentaje = item.Porcentaje;
                    clas.IdUsuario = item.IdUsuario;
                    clas.IdEmpresa = item.IdEmpresa;
                    lista.Add(clas);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public Boolean ConsultaNumeroDetalle(int numero)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.PagoDet where q.NumPago == (numero) select q).First();
                    if (x.IdEmpresa >= 1)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                return false;

            }
        }
        public List<clsEmpresaServicio> consulta()
        {
            try
            {
                List<clsEmpresaServicio> lista = new List<clsEmpresaServicio>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.EmpresaServicio select w;
                foreach (var item in con)
                {
                    clsEmpresaServicio clas = new clsEmpresaServicio();
                    clas.IdEmpresaServicio = Convert.ToString(item.IdEmpresaServicio);
                    clas.fechaRegistro = item.FechaRegistro;
                    clas.RazonSocial = item.RazonSocial;
                    clas.Direccion = item.Direccion;
                    clas.email = item.Email;
                    clas.webpage = item.Webpage;
                    clas.Estado = item.Estado;
                    clas.IdTipoPersona = item.IdTipoPersona;
                    clas.IdEmpresa = item.IdEmpresa;
                    clas.IdUsuario = item.IdUsuario;
                    lista.Add(clas);
                }

                return lista;

            }
            catch (Exception)
            {
                return null;

            }
        }
        public List<clsOrdenPagoDet> Consulta()
        {
            try
            {
                List<clsOrdenPagoDet> lista = new List<clsOrdenPagoDet>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.OrdenPagoDet select w;
                foreach (var item in con)
                {
                    clsOrdenPagoDet clase = new clsOrdenPagoDet();
                    clase.NumLinea = item.NumLinea;
                    clase.NumCuentaPorPagar = item.NumCuentaPorPagar;
                    clase.NumDetalleDeuda = item.NumDetalleDeuda;
                    clase.SaldoDeuda = item.SaldoDeuda;
                    clase.NumeroPagosRealizar = item.NumeroPagosRealizar;
                    clase.NumOrdenPagoCab = item.NumOrdenCab;
                    clase.TotalPagar = item.TotalPagar;
                    clase.IdEmpresa = item.IdEmpresa;

                    lista.Add(clase);
                }
                return lista;

            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsCuentaBancaria> ConsultaCuentaBancaria(int Empresa)
        {
            try
            {
                List<clsCuentaBancaria> lista = new List<clsCuentaBancaria>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.CuentaBancaria where w.idEmpresa == (Empresa) select w;
                foreach (var item in con)
                {
                    clsCuentaBancaria ord = new clsCuentaBancaria();
                    ord.idEmpresa = item.idEmpresa;
                    ord.idCuentaBancaria = item.idCuentaBancaria;
                    ord.idBanco = (item.idBanco);
                    ord.idTitular = Convert.ToInt32(item.idTitular);
                    ord.NumeroCuenta = item.NumeroCuenta;
                    ord.TipoCuenta = (item.TipoCuenta);
                    ord.Saldo = item.Saldo;
                    ord.Estado = (string)(item.Estado);

                    lista.Add(ord);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public Boolean Guardar(clsFrecuenciaPago Frecuencia)
        {
            try
            {
                int id = getIdSiguiente();
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    FrecuenciaPago pago = new FrecuenciaPago()
                    {
                        IdFrecuenciaPago = id,
                        Descripcion = Frecuencia.Descripcion,
                        FechaActual = DateTime.Today,//Frecuencia.FechaActual,
                        Estado = Frecuencia.Estado,
                        IdUsuario =Frecuencia.IdUsuario,
                        IdEmpresa =Frecuencia.IdEmpresa,
                            };
                    ent.AddToFrecuenciaPago(pago);
                    ent.SaveChanges();
                }

                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public List<clsMedioPago> consulta()
        {
            try
            {
                List<clsMedioPago> lista = new List<clsMedioPago>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.MedioPago select w;
                foreach (var item in con)
                {
                    clsMedioPago clas = new clsMedioPago();
                    clas.IdMedioPago = item.IdMedioPago;
                    clas.Descripcion = item.Descripcion;
                    clas.FechaRegistro = (item.fechaRegistro);
                    clas.Estado = item.Estado;
                    clas.IdUsuario = item.IdUsuario;
                    clas.IdEmpresa = item.IdEmpresa;
                   lista.Add(clas);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public List<clsBanco> ConsultaBanco()
        {
            try
            {
                List<clsBanco> lista = new List<clsBanco>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.Banco select w;
                foreach (var item in con)
                {
                    clsBanco ord = new clsBanco();
                    ord.idEmpresa = item.idEmpresa;
                    ord.idBanco = item.idBanco;
                    ord.Nombre = (item.Nombre);
                    ord.Estado = (string)(item.Estado);
                    lista.Add(ord);

                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public clsImpuestos CalcularImp(int indice)
        {
            using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
            {
                var x = (from q in ent.Impuesto where q.IdImpuesto == indice select q).First();

                clsImpuestos impues = new clsImpuestos();
                impues.Porcentaje = x.Porcentaje;
                return impues;
            }
        }
 public int getIdSiguiente()
 {
     try
     {
         CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
         int x = ((from a in ent.FrecuenciaPago select a.IdFrecuenciaPago).Max()) + 1;
         return x;
     }
     catch (Exception e)
     {
         Console.WriteLine("Error: " + e);
         return 1; //en caso de que no exista algun registro
     }
 }
        //=========================================================================================================================
        //============================================CONSULTA EMPRESA DE SERVICIOS================================================
        //=========================================================================================================================
        public List<clsEmpresaServicio> ConsultaEmpresaServicio()
        {
            try
            {
                List<clsEmpresaServicio> EmpresaServicio = new List<clsEmpresaServicio>();
                List<clsDetalleTelefonoCXP> DetalleTelefono = new List<clsDetalleTelefonoCXP>();
                List<clsCtaBancaria2> CuentaBancaria = new List<clsCtaBancaria2>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var lst = from q in ent.EmpresaServicio select q;
                var lst2 = from i in ent.Telefono select i;
                var lst3 = from j in ent.CuentaBancaria2 select j;

                foreach (var item in lst)
                {
                    clsEmpresaServicio cls = new clsEmpresaServicio();
                    cls._IdEmpresaServicio = item.IdEmpresaServicio;
                    cls._FechaRegistro = item.FechaRegistro;
                    cls._RazonSocial = item.RazonSocial;
                    cls._TipoPersona = item.IdTipoPersona;
                    cls._Estado = item.Estado;
                    cls._Direccion = item.Direccion;
                    cls._Email = item.Email;
                    cls._Website = item.Webpage;
                    foreach (var item2 in lst2)
                    {
                        clsDetalleTelefonoCXP det = new clsDetalleTelefonoCXP();
                        det._TipoTelefono = item2.IdTipoTelefono;
                        det._numTelefono = item2.Numero;
                        DetalleTelefono.Add(det);
                    }
                    cls._DetalleTelefono = DetalleTelefono;
                    foreach (var item3 in lst3)
                    {
                        clsCtaBancaria2 det = new clsCtaBancaria2();
                        det._IdBanco = item3.IdBanco;
                        det._TipoCuenta = item3.TipoCuenta;
                        det._NroCuenta = item3.NroCta;
                        CuentaBancaria.Add(det);
                    }
                    cls._CuentaBancaria = CuentaBancaria;
                    EmpresaServicio.Add(cls);
                }
                return EmpresaServicio;
            }
            catch (Exception)
            {
                return null;
            }
        }
        public List<clsCuentaPorPagar> consulta()
        {
            try
            {
                List<clsCuentaPorPagar> lista = new List<clsCuentaPorPagar>();
                CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
                var con = from w in ent.CuentaPorPagar select w;
                foreach (var item in con)
                {
                    clsCuentaPorPagar clas = new clsCuentaPorPagar();
                    clas._NumCuentaPorPagar = item.NumCuentaPorPagar;
                    clas._NumIngresoEgreso = Convert.ToInt32(item.NumIngresoEgreso);
                    clas._FechaIngreso = item.FechaIngreso;
                    clas._Factura = item.NumeroFactura;
                    clas._FechaTransaccion = item.FechaTransaccion;
                    clas._IdProveedor = Convert.ToInt32(item.IdProveedor);
                    clas._IdEmpresaServicio = item.IdEmpresaServicio;
                    clas._Motivo = item.Motivo;
                    clas._Detalle = item.Detalle;
                    clas._Subtotal = item.Subtotal;
                    clas._Descuento = Convert.ToDecimal(item.Descuento);
                    clas._Total = item.Total;
                    clas._FormaPago = item.FormaPago;
                    clas._ValorEntrada = Convert.ToDecimal(item.ValorEntrada);
                    clas._NumeroLetra = Convert.ToInt32(item.NumeroLetra);
                    clas._IdFrecuencia = Convert.ToInt32(item.IdFrecuencia);
                    clas._ValorLetra = Convert.ToDecimal(item.ValorLetra);
                    clas._SaldoDeuda = Convert.ToDecimal(item.SaldoDeuda);
                    clas._IdUsuario = item.IdUsuario;
                    clas._IdEmpresa = item.IdEmpresa;
                    lista.Add(clas);
                }

                return lista;
            }

            catch (Exception)
            {
                return null;
            }
        }
        public Boolean Eliminar(clsImpuesto Imp)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.Impuesto where q.IdImpuesto == Imp.IdImpuesto select q).First();

                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public Boolean Eliminar(clsEmpresaServicio  Empresa)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.EmpresaServicio  where q.IdEmpresaServicio ==( Empresa .IdEmpresaServicio)  select q).First();

                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public Boolean Eliminar(clsCuentaBancaria  Cuenta)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.CuentaBancaria where q.Serie == Cuenta.Serie select q).First();

                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public Boolean Eliminar(clsMedioPago Medio)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.MedioPago where q.IdMedioPago == Medio.IdMedioPago select q).First();

                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
 //=========================================================================================================================
 //===================================================CONSULTA BANCO========================================================
 //=========================================================================================================================
 public List<clsBancosCXP> ConsultaBanco()
 {
     try
     {
         List<clsBancosCXP> Banco = new List<clsBancosCXP>();
         CuentasPorPagarEntities ent = new CuentasPorPagarEntities();
         var lst = from q in ent.Banco select q;
         foreach (var item in lst)
         {
             clsBancosCXP cls = new clsBancosCXP();
             cls._IdBanco = item.idBanco;
             cls._IdEmpresa = item.idEmpresa;
             cls._Estado = item.Estado;
             cls._Nombre = item.Nombre;
             Banco.Add(cls);
         }
         return Banco;
     }
     catch (Exception)
     {
         return null;
     }
 }
        public Boolean Guardar(clsMedioPago Medio)
        {
            try
            {
                int id = getIdSiguiente();
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    MedioPago pago = new MedioPago()
                    {
                        IdMedioPago =id,
                        Descripcion = Medio.Descripcion,
                        fechaRegistro = DateTime.Today, // Medio.FechaRegistro,
                        Estado = Medio.Estado,
                       IdEmpresa =Medio.IdEmpresa,
                        IdUsuario = Medio.IdUsuario,

                    };
                    ent.AddToMedioPago(pago);
                    ent.SaveChanges();
                }

                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public void Modificar(clsMedioPago Medio)
        {
            using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
            {
                var x = (from q in ent.MedioPago where q.IdMedioPago == Medio.IdMedioPago select q).First();

                x.Descripcion = Medio.Descripcion;
                x.fechaRegistro = Medio.FechaRegistro;
                x.Estado =Medio.Estado;
                x.IdEmpresa = Medio.IdEmpresa;
                x.IdUsuario = Medio.IdUsuario;
                ent.SaveChanges();

            }
        }
        public Boolean Eliminar(clsOrdenPagoDet OrdenDet)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.OrdenPagoDet where q.NumLinea == OrdenDet.NumLinea select q).First();

                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
        public Boolean GuardarDetOrdenPago(List<clsOrdenPagoDet> a)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {
                    int aux = a.Count;
                    List<clsOrdenPagoDet> Detalle = a;
                    for (int i = 0; i < aux; i++)
                    {
                        int NumDetOrden = getNumDetOrdenPago();
                        OrdenPagoDeta = new OrdenPagoDet()
                        {
                            NumLinea = Detalle[i].NumLinea,
                            NumCuentaPorPagar = Detalle[i].NumCuentaPorPagar,
                            NumDetalleDeuda = NumDetOrden,
                            SaldoDeuda = Detalle[i].SaldoDeuda,
                            NumeroPagosRealizar = Detalle[i].NumeroPagosRealizar,
                            NumOrdenCab = Detalle[i].NumOrdenPagoCab,
                            TotalPagar = Detalle[i].TotalPagar,
                            IdEmpresa = Detalle[i].IdEmpresa,
                            AutorizarPago = Detalle[i].AutorizarPago,
                        };
                        ent.AddToOrdenPagoDet(OrdenPagoDeta);
                        ent.SaveChanges();
                    }
                }

                return true;

            }
            catch (Exception)
            {
                return false;
            }
        }
        public void Modificar(clsOrdenPagoDet OrdenDet)
        {
            using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
            {
                var x = (from q in ent.OrdenPagoDet where q.NumOrdenCab == OrdenDet.NumOrdenPagoCab select q).First();

                x.NumLinea = OrdenDet.NumLinea;
                x.NumCuentaPorPagar = OrdenDet.NumCuentaPorPagar;
                x.NumDetalleDeuda = OrdenDet.NumDetalleDeuda;
                x.SaldoDeuda = OrdenDet.SaldoDeuda;
                x.NumeroPagosRealizar = OrdenDet.NumeroPagosRealizar;
                x.NumOrdenCab = OrdenDet.NumOrdenPagoCab;
                x.TotalPagar = OrdenDet.TotalPagar;
                x.IdEmpresa = OrdenDet.IdEmpresa;
                ent.SaveChanges();
            }
        }