Beispiel #1
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            Entidades.Prestamo prestamo = new Entidades.Prestamo();
            prestamo.Socio           = Program.ListaSocios.ElementAt(cboSocio.SelectedIndex);
            prestamo.Ejemplar        = Program.ListaLibros.ElementAt(cboLibro.SelectedIndex).ListaEjemplares.ElementAt(cboEjemplar.SelectedIndex);
            prestamo.FechaPrestamo   = clndrPrestamo.Value;
            prestamo.FechaDevolucion = clndrDevo.Value;

            Program.ListaSocios.ElementAt(cboSocio.SelectedIndex).CantidadLibros++;
            //TODO No funciona bien el ejemplar seleccionado
            Program.ListaLibros.ElementAt(cboLibro.SelectedIndex).ListaEjemplares.ElementAt(Convert.ToInt32(cboEjemplar.SelectedItem.ToString())).alquilado();
            Close();
        }
Beispiel #2
0
        private static bool Modificar(Entidades.Prestamo cliente)
        {
            bool     key      = false;
            Contexto contexto = new Contexto();

            try
            {
                contexto.Entry(cliente).State = EntityState.Modified;
                key = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(key);
        }
Beispiel #3
0
        private static bool Insertar(Entidades.Prestamo cliente)
        {
            bool     key      = false;
            Contexto contexto = new Contexto();

            try
            {
                contexto.Prestamo.Add(cliente);
                key = contexto.SaveChanges() > 0;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                contexto.Dispose();
            }
            return(key);
        }