private void dgv_turnos_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex != -1) { if (dgv_turnos.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar")) { var f = new FormActualizarTurnos(); f.Show(); var turno = new Clases.Turno(); int turno_id = int.Parse(dgv_turnos.Rows[e.RowIndex].Cells[7].Value.ToString()); var tabla_turno = turno.BuscarPorCodigo(turno_id); if (tabla_turno.Rows.Count == 1) { FormActualizarTurnos.MyForm.txt_apellidos.Text = tabla_turno.Rows[0]["APELLIDOS"].ToString(); FormActualizarTurnos.MyForm.txt_nombre.Text = tabla_turno.Rows[0]["NOMBRE"].ToString(); FormActualizarTurnos.MyForm.cbo_turno.Text = tabla_turno.Rows[0]["TURNOO"].ToString(); FormActualizarTurnos.MyForm.dtp_fecha.Text = tabla_turno.Rows[0]["FECHA"].ToString(); FormActualizarTurnos.MyForm.cbo_horaEntrada.Text = tabla_turno.Rows[0]["HORA_ENTRADA"].ToString(); FormActualizarTurnos.MyForm.cbo_horaSalida.Text = tabla_turno.Rows[0]["HORA_SALIDA"].ToString(); FormActualizarTurnos.MyForm.turnoId_TEMP = turno_id; } } if (dgv_turnos.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar")) { int turno_id = int.Parse(dgv_turnos.Rows[e.RowIndex].Cells[7].Value.ToString()); DialogResult res = MessageBox.Show("Deseas eliminar este Turno?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { var turno = new Clases.Turno(turno_id); if (turno.Eliminar()) { // ELIMINAR DE DATAGRIDVIEW Y DE LA BASE DE DATOS dgv_turnos.Rows.RemoveAt(e.RowIndex); } else { MessageBox.Show("Error al eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void FormActualizarTurnos_FormClosed(object sender, FormClosedEventArgs e) { _myForm = null; }