Exemplo n.º 1
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     if (txtID.Text.Length > 0 && txtNombre.Text.Length > 0 && txtPrimerApellido.Text.Length > 0 && txtSegundoApellido.Text.Length > 0 && txtCorreo.Text.Length > 0 && cbxDepartamento.Text.Length > 0 && picfoto.Image != null)
     {
         EmpleadoBLL oEmpleadoBLL = new EmpleadoBLL();
         EmpleadoDAL oEmpleadoDAL = new EmpleadoDAL();
         oEmpleadoBLL            = RecuperarInformacion();
         dgvEmpleados.DataSource = null;
         if (oEmpleadoDAL.Agregar(oEmpleadoBLL))
         {
             dgvEmpleados.DataSource = oEmpleadoDAL.CargarDataGridView();
             if (dgvEmpleados.Rows.Count > 0)
             {
                 actualizarBotones(true, true);
             }
             MessageBox.Show("El registro se agregó correctamente", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("ERROR\nEl registro no se puede agregar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("ERROR\nEl registro no se puede agregar,\nel campo 'ID' o 'Departamento' está vacío", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 2
0
        private void frmEmpleados_Load(object sender, EventArgs e)
        {
            EmpleadoDAL oEmpleadoDAL = new EmpleadoDAL();

            dgvEmpleados.AutoGenerateColumns = false;
            dgvEmpleados.DataSource          = oEmpleadoDAL.CargarDataGridView();

            foreach (DataGridViewColumn columna in dgvEmpleados.Columns)
            {
                columna.Width = 88;
            }
            if (dgvEmpleados.Rows.Count > 0)
            {
                actualizarBotones(true, true);
            }
        }