Example #1
0
        private void btnPrestamo_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            clsPrestamo objPrestamo = new clsPrestamo();

            objPrestamo.CodigoLibro         = txtCodLibro.Text;
            objPrestamo.DocumentoEstudiante = txtDocEstudiante.Text;
            if (objPrestamo.PrestarLibro())
            {
                if (objPrestamo.Error.Equals("0"))
                {
                    lblError.Text = "El libro no esta disponible.";
                }
                else if (objPrestamo.Error.Equals("1"))
                {
                    lblError.Text = "Préstamo registrado exitosamente.";
                }
                else if (objPrestamo.Error.Equals("2"))
                {
                    Form.ActiveForm.Visible = false;
                    frmEstudiante frmEstudiante = new frmEstudiante();
                    frmEstudiante.Show();
                }
            }
            txtCodLibro.Clear();
            txtDocEstudiante.Clear();
            objPrestamo = null;
            //objPrestamo.cargarPrestamos(GridViewPrestamos);
        }
        public List<clsPrestamo> ConsultPrestamo()
        {
            try
            {
                List<clsPrestamo> Lista = new List<clsPrestamo >();
                RecursosHumanosEntities ent = new RecursosHumanosEntities();
                var con = from p in ent.Prestamo
                          join per in ent.Persona on p.IdPersona equals per.IdPersona
                          where p.IdPersona ==per .IdPersona
                          select new {
                                         IdPrestamo=p.IdPrestamo ,
                                         IdPersona=p.IdPersona ,
                                         Cedula=per.Identificacion  ,
                                         Nombre=per .NombreRazonSocial ,
                                         Apellido=per .Apellido ,
                                         Fecha =p.FechaModificacion ,
                                         Monto=p.Monto ,
                                         Pago=p.Pago ,
                                         Interes=p.Interes ,
                                         Total=p.Total ,
                                         Periodos=p.Periodos ,
                                         TotalPagado=p.TotalPagado ,
                                         IdEstado=p.IdEstado ,
                                         IdEmpresa=p.IdEmpresa
                          };
                foreach (var item in con)
                {
                    clsPrestamo  clas = new clsPrestamo();
                    clas.IdPrestamo = item.IdPrestamo ;
                    clas .IdPersona =item .IdPersona ;
                    clas.Identificacion =Convert .ToInt64 ( item.Cedula);
                    clas.Nombre = item.Nombre;
                    clas.Apellido = item.Apellido;
                    clas .FechaModificacion =Convert .ToDateTime ( item.Fecha);
                    clas .Monto =item .Monto;
                    clas .Pago =item .Pago ;
                    clas .Interes =item.Interes ;
                    clas .Total =item .Total ;
                    clas.Periodos =item .Periodos ;
                    clas.TotalPagado = item.TotalPagado;
                    clas .IdEstado =item .IdEstado ;
                    clas.IdEmpresa = item.IdEmpresa;

                    Lista.Add(clas);

                }
                return Lista;
            }
            catch (Exception)
            {
                return null;
            }
        }
Example #3
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            clsPrestamo objConsultaPrestamo = new clsPrestamo();

            objConsultaPrestamo.CodigoLibro = txtCodLibro.Text;
            objConsultaPrestamo.consultarPrestamo(GridViewPrestamos);

            if (txtCodLibro.Text == "")
            {
                objConsultaPrestamo.cargarPrestamos(GridViewPrestamos);
            }
            txtCodLibro.Clear();
        }
Example #4
0
        private void btnDevolverLibro_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            clsPrestamo objPrestamo = new clsPrestamo();

            objPrestamo.CodigoLibro         = txtCodLibro.Text;
            objPrestamo.DocumentoEstudiante = txtDocEstudiante.Text;
            if (objPrestamo.DevolverLibro())
            {
                if (objPrestamo.Error.Equals("1"))
                {
                    lblError.Text = "Devolucion registrado exitosamente.";
                }
            }
            txtCodLibro.Clear();
            txtDocEstudiante.Clear();
            objPrestamo = null;
        }
Example #5
0
        private void frmPrestamo_Load(object sender, EventArgs e)
        {
            clsPrestamo objPrestamos = new clsPrestamo();

            objPrestamos.cargarPrestamos(GridViewPrestamos);
        }
 private void btnNumero_Click_1(object sender, EventArgs e)
 {
     frmPConsultaPrestamo cPre = new frmPConsultaPrestamo();
     tsbGuardar.Enabled = false;
     btnCalcular.Enabled = false;
     tsbModificar.Enabled = true;
     cPre.ShowDialog();
     clasPrestamo = cPre.p;
     Set();
     txtNumero.Enabled = false;
     txtCedula.Enabled=false ;
     txtNombre.Enabled =false ;
     deFecha.Enabled=false;
     txtPrestamo.Enabled =false;
     txtPagos.Enabled=false;
     txtTotalPrestamo.Enabled=false;
     txtInteres.Enabled=false;
     txtPeriodo.Enabled=false;
     txtTotalPagado.Enabled =false;
     tsbNuevo.Enabled = true;
     tsbGuardar.Enabled = false;
     btnBuscarEmpleado.Enabled = false;
 }
        public Decimal ConsultTotalPagado(int IdPersona)
        {
            try
            {
               // List<clsPrestamo> Lista = new List<clsPrestamo>();
                Decimal Totpag=0;

                RecursosHumanosEntities ent = new RecursosHumanosEntities();

                var con = from p in ent.Prestamo
                          where p.IdPersona == IdPersona
                          select new
                          {

                              TotalPagado = p.TotalPagado,

                          };
                foreach (var item in con)
                {
                    clsPrestamo clas = new clsPrestamo();

                    clas.TotalPagado = item.TotalPagado;

                    Totpag = item.TotalPagado;

                }
                return Totpag ;
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public void ModificarTotalPago(int idper,Decimal tp)
        {
            using (RecursosHumanosEntities ent = new RecursosHumanosEntities())
            {
                int   id;
                try
                {

                    var con = from p in ent.Prestamo
                              where p.IdPersona == idper
                              select new{
                                    idpersona=p.IdPersona
                              };
                    foreach (var item in con)
                {

                }
                  //  if (id != null ){
                        var x = (from q in ent.Prestamo where q.IdPersona == idper select q).First();

                        clsPrestamo pr = new clsPrestamo();

                        x.TotalPagado = tp;

                        ent.SaveChanges();
                    }

                catch (Exception)
                {

                }

            }
        }
        public void Modificar(clsPrestamo pr)
        {
            using (RecursosHumanosEntities ent = new RecursosHumanosEntities())
            {

                var x = (from q in ent.Prestamo  where q.IdPrestamo  == pr.IdPrestamo  select q).First();
                x.IdPrestamo  = pr .IdPrestamo ;
                x.IdPersona =pr .IdPersona;
                x. FechaModificacion = pr.FechaModificacion;
                x.Monto =pr.Monto;
                x.Pago =pr.Pago ;
                x.Interes =pr.Interes;
                x.Total =pr.Total;
                x.Periodos =pr.Periodos ;
                x.TotalPagado =pr.TotalPagado;
                x.IdEmpresa = pr.IdEmpresa;
                x.IdEstado = pr.IdEstado;
                ent.SaveChanges();

            }
        }
        public Boolean Guardar(clsPrestamo p)
        {
            try
            {
                using (RecursosHumanosEntities ent = new RecursosHumanosEntities())
                {

                   Prestamo  pre = new Prestamo()
                    {
                        IdPrestamo  = p.IdPrestamo ,
                        IdPersona = p.IdPersona,
                        FechaModificacion = p.FechaModificacion ,
                        Monto =p.Monto ,
                        Pago =p.Pago ,
                        Interes =p.Interes,
                        Total =p.Total,
                        Periodos =p.Periodos ,
                        TotalPagado =p.TotalPagado ,
                        IdEmpresa = p.IdEmpresa,
                        IdEstado = p.IdEstado,

                    };
                    ent.AddToPrestamo (pre );
                    ent.SaveChanges();
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }