コード例 #1
0
        private void grillaLibros_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currentRow = grillaLibros.SelectedRows[0];
            Ejemplar        ejemplar   = biblioteca.buscarEjemplar(currentRow.Cells[0].Value.ToString());

            if (ejemplar.estaPrestado || !libro.tieneParaPrestar())
            {
                MessageBox.Show("No es posile realizar el prestamo de este ejemplar");
            }
            else
            {
                Libro     lib   = biblioteca.buscarLibro(currentRow.Cells[0].Value.ToString());
                FPrestamo prest = new FPrestamo();
                prest.biblioteca              = biblioteca;
                prest.isbn                    = isbn;
                prest.labTitulo.Text          = lib.titulo;
                prest.labCodigo.Text          = currentRow.Cells[0].Value.ToString();
                prest.labAutores.Text         = lib.autores;
                prest.labEstado.Text          = "Disponilbe";
                prest.txtBusqEjemplar.Enabled = false;
                prest.btnBusqEjemplar.Enabled = false;
                prest.ejemplar                = ejemplar;
                prest.ShowDialog();
                CargarLabels();
            }
        }
コード例 #2
0
        private void grillaPrestamos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow currentRow = grillaPrestamos.SelectedRows[0];

            if (currentRow.Cells.Count > 0)
            {
                bool rowIsEmpty = true;

                foreach (DataGridViewCell cell in currentRow.Cells)
                {
                    if (cell.Value != null)
                    {
                        rowIsEmpty = false;
                        break;
                    }
                }

                if (rowIsEmpty)
                {
                    FPrestamo fPrestamos = new FPrestamo();
                    fPrestamos.usuario               = user;
                    fPrestamos.biblioteca            = biblioteca;
                    fPrestamos.txtBusqUser.Enabled   = false;
                    fPrestamos.btnBuscarUser.Enabled = false;
                    fPrestamos.ShowDialog();
                }
                else
                {
                    user.RemovePrestamo(currentRow.Cells[1].Value.ToString());
                }
            }

            ActualizarLabs();
        }