8 |
#include "h6-udlånssystemDlg.h" |
#include "h6-udlånssystemDlg.h" |
9 |
#include ".\h6-udlånssystemdlg.h" |
#include ".\h6-udlånssystemdlg.h" |
10 |
|
|
11 |
|
#include "ConfigFile.h" |
12 |
#include "commonstorage.h" |
#include "commonstorage.h" |
13 |
|
|
14 |
#include "databaselayer.h" |
#include "databaselayer.h" |
15 |
#include "microsoftdblayer.h" |
#include "microsoftdblayer.h" |
16 |
#include "mysqllayer.h" |
#include "mysqllayer.h" |
17 |
|
#include "postgreslayer.h" |
18 |
|
|
19 |
#ifdef _DEBUG |
#ifdef _DEBUG |
20 |
#define new DEBUG_NEW |
#define new DEBUG_NEW |
114 |
m_tabs.Init(); |
m_tabs.Init(); |
115 |
m_tabs.SetCurSel(0); |
m_tabs.SetCurSel(0); |
116 |
|
|
117 |
|
ConfigFile config; |
118 |
|
try { |
119 |
|
config.Read(); |
120 |
|
} catch(...) { |
121 |
|
MessageBox("Could not open config file"); |
122 |
|
OnOK(); |
123 |
|
return true; |
124 |
|
} |
125 |
|
|
126 |
|
DatabaseLayer *dbl = 0; |
127 |
try { |
try { |
128 |
//DatabaseLayer *dbl = new DatabaseLayer; |
if (config.driver.MakeLower() == "mysql") |
129 |
DatabaseLayer *dbl = new MySQLLayer; |
dbl = new MySQLLayer(config); |
130 |
CommonStorage::Instance()->setDBLayer(dbl); |
else if (config.driver.MakeLower() == "postgresql") |
131 |
} catch (...) { |
dbl = new PostgresLayer(config); |
132 |
|
else if (config.driver.MakeLower() == "microsoftsql") |
133 |
|
dbl = new MicrosoftDBLayer(config); |
134 |
|
else { |
135 |
|
CString tmp; |
136 |
|
tmp.Format("Unsupported driver: %s", config.driver); |
137 |
|
MessageBox(tmp); |
138 |
|
OnOK(); |
139 |
|
} |
140 |
|
} catch (CDBException *ex) { |
141 |
MessageBox(CString("Could not establish connection to the database server\r\n") + |
MessageBox(CString("Could not establish connection to the database server\r\n") + |
142 |
"Please contact your network administrator\r\n" + |
"Please contact your network administrator\r\n\r\n" + |
143 |
"(This application shuts down automatically)"); |
"ODBC Returned the following message:\r\n" + |
144 |
|
ex->m_strError); |
145 |
|
|
146 |
|
OnOK(); |
147 |
|
} catch (...) { |
148 |
|
MessageBox("Unknown DB exception"); |
149 |
OnOK(); |
OnOK(); |
150 |
} |
} |
151 |
|
|
152 |
|
CommonStorage::Instance()->setDBLayer(dbl); |
153 |
|
|
154 |
|
CString title = "H6-Udlånssystem - "; |
155 |
|
title += config.driver; |
156 |
|
SetWindowText(title); |
157 |
|
|
158 |
// TODO: Add extra initialization here |
// TODO: Add extra initialization here |
159 |
|
|