/[H6]/h6-udlånssystemDlg.cpp
ViewVC logotype

Diff of /h6-udlånssystemDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 31 by torben, Sun Sep 3 10:10:19 2006 UTC revision 57 by torben, Tue Sep 12 17:48:20 2006 UTC
# Line 8  Line 8 
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"
16    #include "mysqllayer.h"
17    #include "postgreslayer.h"
18    
19  #ifdef _DEBUG  #ifdef _DEBUG
20  #define new DEBUG_NEW  #define new DEBUG_NEW
# Line 109  BOOL Ch6udlnssystemDlg::OnInitDialog() Line 114  BOOL Ch6udlnssystemDlg::OnInitDialog()
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          try {          try {
127                  DatabaseLayer *dbl = new DatabaseLayer;                  DatabaseLayer *dbl = 0;
128                    if (config.driver.MakeLower() == "mysql")
129                            dbl = new MySQLLayer(config);
130                    else if (config.driver.MakeLower() == "postgresql")
131                            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                  CommonStorage::Instance()->setDBLayer(dbl);                  CommonStorage::Instance()->setDBLayer(dbl);
141          } catch (...) {          } catch (CDBException *ex) {
142                  MessageBox(CString("Could not establish connection to the database server\r\n") +                  MessageBox(CString("Could not establish connection to the database server\r\n") +
143                                     "Please contact your network administrator\r\n" +                                     "Please contact your network administrator\r\n\r\n" +
144                                     "(This application shuts down automatically)");                                     "ODBC Returned the following message:\r\n" +
145                                       ex->m_strError);
146                    
147                    OnOK();
148            } catch (...) {
149                    MessageBox("Unknown DB exception");
150                  OnOK();                  OnOK();
151          }          }
152    
153            CString title = "H6-Udlånssystem - ";
154            title += config.driver;
155            SetWindowText(title);
156    
157          // TODO: Add extra initialization here          // TODO: Add extra initialization here
158                    
# Line 177  HCURSOR Ch6udlnssystemDlg::OnQueryDragIc Line 210  HCURSOR Ch6udlnssystemDlg::OnQueryDragIc
210    
211  void Ch6udlnssystemDlg::OnHelpAbout()  void Ch6udlnssystemDlg::OnHelpAbout()
212  {  {
213          MessageBox("DA6H :: Udlånssystem\r\nLavet af:\r\nKevin, Hedin & Torben");          CAboutDlg about;
214            about.DoModal();
215  }  }
216    
217  void Ch6udlnssystemDlg::OnFileExit()  void Ch6udlnssystemDlg::OnFileExit()

Legend:
Removed from v.31  
changed lines
  Added in v.57

  ViewVC Help
Powered by ViewVC 1.1.20