34 DIALOG_SHIM( aParent, wxID_ANY,
_(
"Generate Database Connection" ), wxDefaultPosition,
35 wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
37 wxBoxSizer* topSizer =
new wxBoxSizer( wxVERTICAL );
40 std::vector<std::string> dsns;
41 DATABASE_CONNECTION::ListDataSources( dsns );
43 for(
const std::string& d : dsns )
48 topSizer->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Data Source Name" ) ), 0, wxALL, 5 );
49 topSizer->Add(
m_dsnChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
51 wxFlexGridSizer*
grid =
new wxFlexGridSizer( 2, 2, 5, 5 );
52 grid->AddGrowableCol( 1, 1 );
54 grid->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Username" ) ), 0, wxALIGN_CENTER_VERTICAL );
58 grid->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Password" ) ), 0, wxALIGN_CENTER_VERTICAL );
59 m_passCtrl =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
63 grid->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Timeout" ) ), 0, wxALIGN_CENTER_VERTICAL );
69 grid->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Connection String" ) ), 0,
70 wxALIGN_CENTER_VERTICAL );
74 topSizer->Add(
grid, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
76 m_testButton =
new wxButton(
this, wxID_ANY,
_(
"Test Connection" ) );
79 topSizer->Add(
new wxStaticText(
this, wxID_ANY,
_(
"Tables" ) ), 0, wxLEFT | wxRIGHT, 5 );
82 topSizer->Add(
m_tableChoice, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
84 SetSizerAndFit( topSizer );
134 std::unique_ptr<DATABASE_CONNECTION> conn;
143 conn = std::make_unique<DATABASE_CONNECTION>( dsn.ToStdString(), user.ToStdString(), pass.ToStdString(),
148 conn = std::make_unique<DATABASE_CONNECTION>(
m_connStrCtrl->GetValue().ToStdString(),
152 if( !conn->Connect() )
154 wxMessageBox(
_(
"Unable to connect to database" ),
_(
"Database Error" ), wxOK | wxICON_ERROR,
159 std::vector<std::string> tables;
161 if( conn->GetTables( tables ) )
163 for(
const std::string& t : tables )
166 if( !tables.empty() )
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)