Пример #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dgvPersonal.RowCount > 0)
            {
                Personal LPP = new Personal();
                idPersonal = dgvPersonal.CurrentRow.Cells["CÓDIGO EMPLEADO"].Value.ToString();

                dgvDetalleprestamo.DataSource = LPP.BuscarIDEMP(idPersonal);

                if (dgvDetalleprestamo.RowCount > 0)
                {
                    MessageBox.Show("No puede eliminar el empleado porque ha prestado herramientas", "Validacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (MessageBox.Show("¿Desea eliminar el registro seleccionado?", "Validacion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        P.EliminarPersonal(idPersonal);
                        Botones();
                        ListarPersonal();
                        MessageBox.Show("Registro eliminado correctamente", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimpiarControles();
                    }
                }
            }
        }
Пример #2
0
 private void btnEditar_Click(object sender, EventArgs e)
 {
     if (dgvPersonal.RowCount > 0)
     {
         Seleccionado = false;
         if (txtNombres.Text.Length > 0)
         {
             Seleccionado = true;
         }
         if (Seleccionado == true)
         {
             Personal LPP = new Personal();
             dgvDetalleprestamo.DataSource = LPP.BuscarIDEMP(idPersonal);
             if (dgvDetalleprestamo.RowCount > 0)
             {
                 MessageBox.Show("No puede editar el empleado porque ha prestado herramientas", "Validacion", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 LimpiarControles();
             }
             else
             {
                 dgvPersonal.Enabled = false;
                 ActivarBotones();
                 ActivarControles();
                 Editando  = true;
                 Agregando = false;
             }
         }
         else
         {
             MessageBox.Show("Debe dar clic sobre la fila a editar", "Seleccionado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }