--- h6-udlÃ¥nssystemDlg.cpp 2006/09/03 10:10:19 31 +++ h6-udlÃ¥nssystemDlg.cpp 2006/09/07 06:43:32 48 @@ -8,8 +8,13 @@ #include "h6-udlånssystemDlg.h" #include ".\h6-udlånssystemdlg.h" +#include "ConfigFile.h" #include "commonstorage.h" + #include "databaselayer.h" +#include "microsoftdblayer.h" +#include "mysqllayer.h" +#include "postgreslayer.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -109,17 +114,38 @@ m_tabs.Init(); m_tabs.SetCurSel(0); + ConfigFile config; + try { + config.Read(); + } catch(...) { + MessageBox("Could not open config file"); + OnOK(); + } try { - DatabaseLayer *dbl = new DatabaseLayer; + DatabaseLayer *dbl = 0; + if (config.driver.MakeLower() == "mysql") + dbl = new MySQLLayer(config); + else if (config.driver.MakeLower() == "postgresql") + dbl = new PostgresLayer(config); + else if (config.driver.MakeLower() == "microsoftsql") + dbl = new MicrosoftDBLayer(config); + else { + CString tmp; + tmp.Format("Unsupported driver: %s", config.driver); + MessageBox(tmp); + OnOK(); + } CommonStorage::Instance()->setDBLayer(dbl); } catch (...) { MessageBox(CString("Could not establish connection to the database server\r\n") + - "Please contact your network administrator\r\n" + - "(This application shuts down automatically)"); + "Please contact your network administrator"); OnOK(); } + CString title = "H6-Udlånssystem - "; + title += config.driver; + SetWindowText(title); // TODO: Add extra initialization here @@ -177,7 +203,8 @@ void Ch6udlnssystemDlg::OnHelpAbout() { - MessageBox("DA6H :: Udlånssystem\r\nLavet af:\r\nKevin, Hedin & Torben"); + CAboutDlg about; + about.DoModal(); } void Ch6udlnssystemDlg::OnFileExit()