void dlgForeignKey::OnAddRef(wxCommandEvent &ev) { wxString col=cbColumns->GetValue(); wxString ref=cbRefColumns->GetValue(); if (!col.IsEmpty() && !ref.IsEmpty()) { lstColumns->AppendItem(columnFactory.GetIconId(), col, ref); cbColumns->Delete(cbColumns->GetCurrentSelection()); cbRefColumns->Delete(cbRefColumns->GetCurrentSelection()); cbReferences->Disable(); if (cbColumns->GetCount()) cbColumns->SetSelection(0); if (cbRefColumns->GetCount()) cbRefColumns->SetSelection(0); OnSelChangeRefCol(ev); CheckChange(); } }
void dlgForeignKey::OnSelChangeRef(wxCommandEvent &ev) { cbRefColumns->Clear(); wxString tab = cbReferences->GetValue(); wxString nsp; if (tab.Find('.') >= 0) { nsp = tab.BeforeFirst('.'); tab = tab.AfterFirst('.'); } else nsp = database->GetDefaultSchema(); pgSet *set = connection->ExecuteSet( wxT("SELECT attname\n") wxT(" FROM pg_attribute att, pg_class cl, pg_namespace nsp\n") wxT(" WHERE attrelid=cl.oid AND relnamespace=nsp.oid\n") wxT(" AND nspname=") + qtDbString(nsp) + wxT("\n AND relname=") + qtDbString(tab) + wxT("\n AND attnum > 0\n") wxT("\n AND NOT attisdropped\n") wxT("\n ORDER BY attnum")); if (set) { while (!set->Eof()) { cbRefColumns->Append(set->GetVal(0)); set->MoveNext(); } delete set; if (cbRefColumns->GetCount()) cbRefColumns->SetSelection(0); } OnSelChangeRefCol(ev); }