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 Boolean Guardar(clsPagoDetalle Det)
        {
            try
            {
                int id = getIdSiguiente();
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    PagoDet pago = new PagoDet()
                    {
                        NumLinea = id,
                        IdMedioPago = Det.IdMedioPago,
                        Monto = Det.Monto,
                        NumeroCuenta = Det.NumeroCuenta,
                        IdEmpresa = Det.IdEmpresa,
                        IdBanco = Det.IdBanco,
                        NumComprobante = Det.NumComprobante,
                        //  NumComision =Det.NumComision,
                        //   NumNominaCab=Det.NumNominaCab ,
                        NumPago = Det.NumPago,

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

                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public void Modificar(clsPagoDetalle Det)
        {
            using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
            {
                var x = (from q in ent.PagoDet where q.NumPago == Det.NumPago select q).First();

                x.NumLinea = Det.NumLinea;
                x.IdMedioPago = Det.IdMedioPago;
                x.Monto = Det.Monto;
                x.IdEmpresa = Det.IdEmpresa;
                x.IdBanco = Det.IdBanco;
                x.NumComprobante = Det.NumComprobante;
                // x.NumComision = Det.NumComision;
                // x.NumNominaCab = Det.NumNominaCab;
                x.NumPago = Det.NumPago;

                ent.SaveChanges();

            }
        }
        public Boolean Eliminar(clsPagoDetalle Det)
        {
            try
            {
                using (CuentasPorPagarEntities ent = new CuentasPorPagarEntities())
                {

                    var x = (from q in ent.PagoDet where q.NumLinea == Det.NumLinea select q).First();

                    //   var y = (from q in ent.PagoDet where q.NumPago  == Det.NumPago select q).First();
                    ent.DeleteObject(x);

                    ent.SaveChanges();

                }
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }