private void btnElimina(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { DialogResult k = MessageBox.Show("Estas seguro de eliminar este registro?", "aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); int rpta = 0; if (k == DialogResult.Yes) { //capturar la fila del id para poder eliminar int IDChofer = (int)dataGridView1.CurrentRow.Cells["ID"].Value; rpta = new LChofer().Delete(IDChofer); if (rpta > 0) { MessageBox.Show("datos eliminados correctamente", "aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning); mostrar_datos(); } } } else { MessageBox.Show("debe seleccionar un elemento"); } }
private void button1_Click(object sender, EventArgs e) { if (!MyValidation()) { return; } EChofer obj = new EChofer { ID = txtID.Text.Length == 0 ? 0 : int.Parse(txtID.Text), Nombre_completo = txtNombres.Text.Trim().ToUpper(), DNI = txtDNI.Text, Edad = int.Parse(txtEdad.Text), Sexo = boxSexo.Text, placa = (lblIDBus.Text), Estado = chkEstado.Checked }; int rpta; if (operacion == (byte)MisConstantes.OPERACION.Insercion) { rpta = new LChofer().Create(obj); } else { rpta = new LChofer().Update(obj); } if (rpta > 0) { MessageBox.Show("operacion realizada correctamente", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } this.DialogResult = DialogResult.OK; this.Close(); }