private void modificar() { if (!SeEstaModificando) { btnAgregar.Enabled = false; txtEliminar.Enabled = false; int posicion = dataGridView1.SelectedCells[0].RowIndex; tempId = dataGridView1.Rows[posicion].Cells[0].Value.ToString(); btnModificar.Text = "Guardar"; SeEstaModificando = true; SqlDataReader reader = basicService.Buscar(tempId); if (reader.Read()) { Diagnostico diagnosticoT = new Diagnostico(reader.GetString(2), reader.GetInt32(0), reader.GetString(1)); txtCodigo.Text = Convert.ToString(diagnosticoT.IdPaciente); txtDiagnostico.Text = diagnosticoT.DiagnosticoFinal; } } else { if (Validador()) { btnModificar.Text = "Modificar"; SeEstaModificando = false; string cod = txtCodigo.Text; string diag = txtDiagnostico.Text; string query = "UPDATE " + _tableName + " SET" + " ID_PACIENTE1='" + cod + "', DESCRIPCION_DIAGNOSTICO='" + diag + "' where " + _idColName + " = " + tempId; if (basicService.Actualizar(query)) { SetDataList(basicService.MostrarTodo()); } tempId = ""; txtCodigo.Clear(); txtDiagnostico.Clear(); btnAgregar.Enabled = true; txtEliminar.Enabled = true; } } }