/[H6]/UserEditDialog.cpp
ViewVC logotype

Annotation of /UserEditDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 61 - (hide annotations) (download)
Mon Oct 22 13:01:08 2007 UTC (16 years, 6 months ago) by torben
File size: 2649 byte(s)
Removed 2 warnings
1 torben 31 /*
2     * Developed by Torben H. Nielsen
3     */
4 torben 9
5     #include "stdafx.h"
6     #include "h6-udlånssystem.h"
7     #include "UserEditDialog.h"
8     #include ".\usereditdialog.h"
9    
10    
11     // UserEditDialog dialog
12    
13     IMPLEMENT_DYNAMIC(UserEditDialog, CDialog)
14     UserEditDialog::UserEditDialog(CWnd* pParent /*=NULL*/)
15     : CDialog(UserEditDialog::IDD, pParent)
16     {
17     }
18    
19     UserEditDialog::~UserEditDialog()
20     {
21     }
22    
23     void UserEditDialog::DoDataExchange(CDataExchange* pDX)
24     {
25     CDialog::DoDataExchange(pDX);
26     }
27    
28    
29     BEGIN_MESSAGE_MAP(UserEditDialog, CDialog)
30     ON_BN_CLICKED(IDC_ADMIN, OnBnClickedAdmin)
31     ON_BN_CLICKED(IDOK, OnBnClickedOk)
32     END_MESSAGE_MAP()
33    
34    
35     // UserEditDialog message handlers
36    
37     BOOL UserEditDialog::OnInitDialog()
38     {
39     CDialog::OnInitDialog();
40    
41     ((CEdit*)GetDlgItem(IDC_INITS))->SetLimitText(4);
42    
43     if (m_currentPerson.inits != "") {
44     GetDlgItem(IDC_INITS)->SetWindowText(m_currentPerson.inits);
45     GetDlgItem(IDC_NAME)->SetWindowText(m_currentPerson.name);
46     if (m_currentPerson.isadmin == true) {
47     ((CButton*)GetDlgItem(IDC_ADMIN))->SetCheck(true);
48     } else {
49     GetDlgItem(IDC_PASSWORD1)->EnableWindow(false);
50     GetDlgItem(IDC_PASSWORD2)->EnableWindow(false);
51     }
52     } else {
53     GetDlgItem(IDC_PASSWORD1)->EnableWindow(false);
54     GetDlgItem(IDC_PASSWORD2)->EnableWindow(false);
55     }
56    
57     return TRUE; // return TRUE unless you set the focus to a control
58     // EXCEPTION: OCX Property Pages should return FALSE
59     }
60    
61     void UserEditDialog::OnBnClickedAdmin()
62     {
63 torben 61 if (((CButton*)GetDlgItem(IDC_ADMIN))->GetCheck() == BST_CHECKED) {
64 torben 9 GetDlgItem(IDC_PASSWORD1)->EnableWindow(true);
65     GetDlgItem(IDC_PASSWORD2)->EnableWindow(true);
66     } else { //not checked
67     GetDlgItem(IDC_PASSWORD1)->EnableWindow(false);
68     GetDlgItem(IDC_PASSWORD2)->EnableWindow(false);
69     }
70     }
71    
72     void UserEditDialog::OnBnClickedOk()
73     {
74     CString inits,name,password1,password2;
75     bool isAdmin;
76     GetDlgItem(IDC_INITS)->GetWindowText(inits);
77     GetDlgItem(IDC_NAME)->GetWindowText(name);
78     GetDlgItem(IDC_PASSWORD1)->GetWindowText(password1);
79     GetDlgItem(IDC_PASSWORD2)->GetWindowText(password2);
80    
81 torben 61 isAdmin = ( ((CButton*)GetDlgItem(IDC_ADMIN))->GetCheck() == BST_CHECKED);
82 torben 9
83     if (inits == "" || name == "") {
84     MessageBox("You must enter initials and name", "Edit User");
85     return;
86     }
87    
88     if (isAdmin && (password1 != password2) ) {
89     MessageBox("You must enter the same password in the 2 password fields");
90     return;
91     }
92    
93     m_currentPerson.inits = inits;
94     m_currentPerson.name = name;
95     m_currentPerson.isadmin = isAdmin;
96     if (password1 != "") {
97     m_currentPerson.pass = password1;
98     }
99    
100     // TODO: Add your control notification handler code here
101     OnOK();
102     }

  ViewVC Help
Powered by ViewVC 1.1.20