1 |
// h6-udlånssystemDlg.cpp : implementation file |
/* |
2 |
// |
* Developed by Torben H. Nielsen |
3 |
|
*/ |
4 |
|
|
5 |
|
|
6 |
#include "stdafx.h" |
#include "stdafx.h" |
7 |
#include "h6-udlånssystem.h" |
#include "h6-udlånssystem.h" |
8 |
#include "h6-udlånssystemDlg.h" |
#include "h6-udlånssystemDlg.h" |
9 |
|
#include ".\h6-udlånssystemdlg.h" |
10 |
|
|
11 |
|
#include "ConfigFile.h" |
12 |
|
#include "commonstorage.h" |
13 |
|
|
14 |
|
#include "databaselayer.h" |
15 |
|
#include "microsoftdblayer.h" |
16 |
|
#include "mysqllayer.h" |
17 |
|
#include "postgreslayer.h" |
18 |
|
|
19 |
#ifdef _DEBUG |
#ifdef _DEBUG |
20 |
#define new DEBUG_NEW |
#define new DEBUG_NEW |
65 |
void Ch6udlnssystemDlg::DoDataExchange(CDataExchange* pDX) |
void Ch6udlnssystemDlg::DoDataExchange(CDataExchange* pDX) |
66 |
{ |
{ |
67 |
CDialog::DoDataExchange(pDX); |
CDialog::DoDataExchange(pDX); |
68 |
|
DDX_Control(pDX, IDC_TAB, m_tabs); |
69 |
} |
} |
70 |
|
|
71 |
BEGIN_MESSAGE_MAP(Ch6udlnssystemDlg, CDialog) |
BEGIN_MESSAGE_MAP(Ch6udlnssystemDlg, CDialog) |
73 |
ON_WM_PAINT() |
ON_WM_PAINT() |
74 |
ON_WM_QUERYDRAGICON() |
ON_WM_QUERYDRAGICON() |
75 |
//}}AFX_MSG_MAP |
//}}AFX_MSG_MAP |
76 |
|
ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout) |
77 |
|
ON_COMMAND(ID_FILE_EXIT, OnFileExit) |
78 |
END_MESSAGE_MAP() |
END_MESSAGE_MAP() |
79 |
|
|
80 |
|
|
83 |
BOOL Ch6udlnssystemDlg::OnInitDialog() |
BOOL Ch6udlnssystemDlg::OnInitDialog() |
84 |
{ |
{ |
85 |
CDialog::OnInitDialog(); |
CDialog::OnInitDialog(); |
86 |
|
CWaitCursor wait; |
87 |
|
|
88 |
// Add "About..." menu item to system menu. |
// Add "About..." menu item to system menu. |
89 |
|
|
108 |
SetIcon(m_hIcon, TRUE); // Set big icon |
SetIcon(m_hIcon, TRUE); // Set big icon |
109 |
SetIcon(m_hIcon, FALSE); // Set small icon |
SetIcon(m_hIcon, FALSE); // Set small icon |
110 |
|
|
111 |
|
m_tabs.InsertItem(0,"Search"); |
112 |
|
m_tabs.InsertItem(1,"Result"); |
113 |
|
m_tabs.InsertItem(2,"Administration"); |
114 |
|
m_tabs.Init(); |
115 |
|
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 |
|
} |
124 |
|
|
125 |
|
try { |
126 |
|
DatabaseLayer *dbl = 0; |
127 |
|
if (config.driver.MakeLower() == "mysql") |
128 |
|
dbl = new MySQLLayer(config); |
129 |
|
else if (config.driver.MakeLower() == "postgresql") |
130 |
|
dbl = new PostgresLayer(config); |
131 |
|
else if (config.driver.MakeLower() == "microsoftsql") |
132 |
|
dbl = new MicrosoftDBLayer(config); |
133 |
|
else { |
134 |
|
CString tmp; |
135 |
|
tmp.Format("Unsupported driver: %s", config.driver); |
136 |
|
MessageBox(tmp); |
137 |
|
OnOK(); |
138 |
|
} |
139 |
|
CommonStorage::Instance()->setDBLayer(dbl); |
140 |
|
} catch (...) { |
141 |
|
MessageBox(CString("Could not establish connection to the database server\r\n") + |
142 |
|
"Please contact your network administrator"); |
143 |
|
OnOK(); |
144 |
|
} |
145 |
|
|
146 |
|
CString title = "H6-Udlånssystem - "; |
147 |
|
title += config.driver; |
148 |
|
SetWindowText(title); |
149 |
|
|
150 |
// TODO: Add extra initialization here |
// TODO: Add extra initialization here |
151 |
|
|
152 |
return TRUE; // return TRUE unless you set the focus to a control |
return TRUE; // return TRUE unless you set the focus to a control |
200 |
{ |
{ |
201 |
return static_cast<HCURSOR>(m_hIcon); |
return static_cast<HCURSOR>(m_hIcon); |
202 |
} |
} |
203 |
|
|
204 |
|
void Ch6udlnssystemDlg::OnHelpAbout() |
205 |
|
{ |
206 |
|
CAboutDlg about; |
207 |
|
about.DoModal(); |
208 |
|
} |
209 |
|
|
210 |
|
void Ch6udlnssystemDlg::OnFileExit() |
211 |
|
{ |
212 |
|
// TODO: Add your command handler code here |
213 |
|
OnOK(); |
214 |
|
} |