Exemple #1
0
        public void MostrarFormulario(int id)
        {
            if (id == 0)
            {
                this.dtFechaDeAltaSocio.Enabled = false;
                this.labelDevuelto.Visible      = false;
                this.dtDevuelto.Visible         = false;
                this.btnDevolver.Visible        = false;
                this.cbSocio.SelectedIndex      = -1;
                this.cbTitulo.SelectedIndex     = -1;
                this.dtPrestado.Value           = DateTime.Now;
            }
            else
            {
                this.Prestamo = BDPrestamo.BuscarPorId(id);
                this.CargarPrestamo();
                this.dtFechaDeAltaSocio.Enabled = false;
                this.btnPrestar.Enabled         = false;
                this.cbSocio.Enabled            = false;
                this.cbTitulo.Enabled           = false;
                this.labelDevuelto.Visible      = true;
                this.dtDevuelto.Visible         = true;
                if (this.Prestamo.Activo == true)
                {
                    this.dtDevuelto.Value = DateTime.Now;
                }
                else
                {
                    this.dtDevuelto.Value = this.Prestamo.FechaDevolucion;
                }
            }

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.ShowDialog();
        }
Exemple #2
0
        private void btnPrestar_Click(object sender, EventArgs e)
        {
            // Validaciones.
            if (this.cbSocio.SelectedIndex == -1)
            {
                MessageBox.Show("Es necesario seleccionar un Socio.");
                return;
            }
            else if (this.cbTitulo.SelectedIndex == -1)
            {
                MessageBox.Show("Es necesario seleccionar un Libro.");
                return;
            }

            DialogResult resultado = MessageBox.Show("¿Está seguro que desea realizar este préstamo?", "Sr. Usuario:", MessageBoxButtons.OKCancel);

            if (resultado == DialogResult.OK)
            {
                if (this.Prestamo == null)
                {
                    this.Prestamo                 = new Prestamo();
                    this.Prestamo.Socio           = (Socio)this.cbSocio.SelectedItem;
                    this.Prestamo.Libro           = (Libro)this.cbTitulo.SelectedItem;
                    this.Prestamo.FechaSalida     = this.dtPrestado.Value;                 // ¿Conviene poner directamente el valor Now?
                    this.Prestamo.FechaDevolucion = DateTime.MinValue;
                    this.Prestamo.Activo          = true;
                }

                BDPrestamo.Guardar(Prestamo);
                this.Close();
            }
        }
Exemple #3
0
        private void ListaPrestamo_Load(object sender, EventArgs e)
        {
            DataTable tabla;

            tabla = BDPrestamo.CargarTabla();

            this.dgPrestamo.DataSource = tabla;
        }