Пример #1
0
        private void dataGridViewUsuarios_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridViewUsuarios.Columns[e.ColumnIndex].Name == "boton_eliminar")
            {
                DialogResult dr = MessageBox.Show("Seguro que desea eliminar?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (dr == DialogResult.Yes)
                {
                    var id = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[3].Value.ToString();
                    ag.eliminarUsuario(id);
                    RefresVista();
                }
            }
            else if (this.dataGridViewUsuarios.Columns[e.ColumnIndex].Name == "boton_Editar")
            {
                EditarUsuario editar = new EditarUsuario(this);
                editar.UpdateEventArgsHandler += edit_usuario_UpdateHadler; //  metodo la cual me permite actualizar la grilla cuando termine de guardar los cambios

                editar.text_nombre.Text      = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[6].Value.ToString();
                editar.textBox_contras.Text  = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[8].Value.ToString();
                editar.textBox_dni.Text      = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[3].Value.ToString(); // dni lo tomamos como pk de la tabla no es valido poder modificarlo
                editar.textBox_mail.Text     = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[4].Value.ToString();
                editar.check_esadmin.Checked = bool.Parse(this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[7].Value.ToString());

                editar.Show();
            }
            else if (this.dataGridViewUsuarios.Columns[e.ColumnIndex].Name == "boton_desbloquear")
            {
                DialogResult dr = MessageBox.Show("Seguro que desea Desbloquear?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                if (dr == DialogResult.Yes)
                {
                    var id = this.dataGridViewUsuarios.Rows[e.RowIndex].Cells[3].Value.ToString();
                    ag.desbloquearUsuario(id);
                    RefresVista();
                }
            }
        }