/[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 4 by torben, Wed Aug 30 08:01:57 2006 UTC revision 53 by torben, Mon Sep 11 14:02:08 2006 UTC
# Line 1  Line 1 
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"  #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
21  #endif  #endif
# Line 64  BEGIN_MESSAGE_MAP(Ch6udlnssystemDlg, CDi Line 74  BEGIN_MESSAGE_MAP(Ch6udlnssystemDlg, CDi
74          ON_WM_QUERYDRAGICON()          ON_WM_QUERYDRAGICON()
75          //}}AFX_MSG_MAP          //}}AFX_MSG_MAP
76          ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)          ON_COMMAND(ID_HELP_ABOUT, OnHelpAbout)
77            ON_COMMAND(ID_FILE_EXIT, OnFileExit)
78  END_MESSAGE_MAP()  END_MESSAGE_MAP()
79    
80    
# Line 72  END_MESSAGE_MAP() Line 83  END_MESSAGE_MAP()
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    
# Line 102  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 {
127                    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);
141            } catch (...) {
142                    MessageBox(CString("Could not establish connection to the database server\r\n") +
143                                       "Please contact your network administrator");
144                    OnOK();
145            }
146    
147            CString title = "H6-Udlånssystem - ";
148            title += config.driver;
149            SetWindowText(title);
150    
151          // TODO: Add extra initialization here          // TODO: Add extra initialization here
152                    
153          return TRUE;  // return TRUE  unless you set the focus to a control          return TRUE;  // return TRUE  unless you set the focus to a control
# Line 158  HCURSOR Ch6udlnssystemDlg::OnQueryDragIc Line 204  HCURSOR Ch6udlnssystemDlg::OnQueryDragIc
204    
205  void Ch6udlnssystemDlg::OnHelpAbout()  void Ch6udlnssystemDlg::OnHelpAbout()
206  {  {
207          MessageBox("DA6H :: Udlånssystem\r\nLavet af:\r\nKevin, Hedin & Torben");          CAboutDlg about;
208            about.DoModal();
209    }
210    
211    void Ch6udlnssystemDlg::OnFileExit()
212    {
213            // TODO: Add your command handler code here
214            OnOK();
215  }  }

Legend:
Removed from v.4  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.20