Ejemplo n.º 1
0
 public void tipoBotonClic(DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         //si el click es en el boton actualizar
         if (e.ColumnIndex == btnUpdate.Index)
         {
             frmInsertarPersonas frm = new frmInsertarPersonas();
             frm.MdiParent   = this.MdiParent;
             frm.WindowState = FormWindowState.Maximized;
             frm.Show();
             frm.BoxTipoPersona.SelectedItem = "Empleado";
             frm.BoxTipoPersona.Enabled      = false;
             frm.TipoInsercion      = 1;
             frm.TxtFkPersonas.Text = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[0].Value);
             frm.TxtFkGlobal.Text   = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[1].Value);
             frm.TxtNit.Text        = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[2].Value);
             frm.TxtNombre.Text     = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[3].Value);
             frm.TxtDireccion.Text  = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[4].Value);
             frm.TxtTelefono.Text   = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[5].Value);
             frm.TxtCelular.Text    = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[6].Value);
             frm.TxtCorreo.Text     = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[7].Value);
             frm.TxtPassword.Text   = Convert.ToString(tblEmpleados.Rows[e.RowIndex].Cells[8].Value);
         }
         //si el click es en el boton eliminar
         if (e.ColumnIndex == btnEliminar.Index)
         {
             if (MessageBox.Show("Esta seguro de eliminar este registro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 if (MessageBox.Show("Esta totalmente seguro?", "Eliminar Registro", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     int codigo = Convert.ToInt32(tblEmpleados.Rows[e.RowIndex].Cells[0].Value);
                     EmpleadoBLL.DeleteEmpleado(codigo);
                     MessageBox.Show("Registro eliminado");
                     this.cargarDatosEmpleados();
                 }
             }
         }
     }
 }