-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathChangPswd.cpp
102 lines (90 loc) · 2.32 KB
/
ChangPswd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// ChangPswd.cpp : implementation file
//
#include "stdafx.h"
#include "Bank.h"
#include "ChangPswd.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChangPswd dialog
extern CString g_CustomerID;
CChangPswd::CChangPswd(CWnd* pParent /*=NULL*/)
: CDialog(CChangPswd::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangPswd)
m_NewPswd = _T("");
m_NewPswd2 = _T("");
m_OldPswd = _T("");
//}}AFX_DATA_INIT
}
void CChangPswd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangPswd)
DDX_Text(pDX, IDC_NEWPASSWORD, m_NewPswd);
DDX_Text(pDX, IDC_NEWPASSWORD2, m_NewPswd2);
DDX_Text(pDX, IDC_OLDPASSWORD, m_OldPswd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangPswd, CDialog)
//{{AFX_MSG_MAP(CChangPswd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChangPswd message handlers
void CChangPswd::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(m_OldPswd=="")
{
AfxMessageBox("请输入原始密码");
return;
}
if(m_NewPswd=="")
{
AfxMessageBox("请输入新密码");
return;
}
if(m_NewPswd2=="")
{
AfxMessageBox("请确认新密码");
return;
}
_bstr_t pswdSQL="Select * from account where account_number='"+g_CustomerID+"'";
_bstr_t vSQL="Update account set account_pswd='"+m_NewPswd+"' where\
account_number='"+g_CustomerID+"'";
CADOConn m_adoConn;
_RecordsetPtr m_pRecordset;//定义记录集指针
m_adoConn.OnInitADOConn();
//核实密码
m_pRecordset=m_adoConn.GetRecordset(pswdSQL);
CString strPswd;
_variant_t theValue;
theValue=m_pRecordset->GetCollect("account_pswd");
if(theValue.vt!=VT_NULL)
strPswd=(char *)_bstr_t(theValue);
if(strPswd!=m_OldPswd)//密码不正确
{
AfxMessageBox("原始密码不正确,无法修改");
GetDlgItem(IDC_PASSWORD)->SetWindowText("");
GetDlgItem(IDC_NEWPASSWORD)->SetWindowText("");
GetDlgItem(IDC_NEWPASSWORD2)->SetWindowText("");
return;
}
if(m_NewPswd!=m_NewPswd2)
{
AfxMessageBox("两次输入的密码不一致,请重新输入");
GetDlgItem(IDC_NEWPASSWORD)->SetWindowText("");
GetDlgItem(IDC_NEWPASSWORD2)->SetWindowText("");
return;
}
m_adoConn.ExecuteSQL(vSQL);
AfxMessageBox("修改密码成功");
m_adoConn.ExitConnect();
CDialog::OnOK();
}