forked from boyuanH/Bank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DelUserDlg.cpp
94 lines (81 loc) · 1.96 KB
/
DelUserDlg.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
// DelUserDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Bank.h"
#include "DelUserDlg.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDelUserDlg dialog
CDelUserDlg::CDelUserDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDelUserDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDelUserDlg)
m_AccountNum = _T("");
//}}AFX_DATA_INIT
}
void CDelUserDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDelUserDlg)
DDX_Text(pDX, IDC_ACCOUNTNUM, m_AccountNum);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDelUserDlg, CDialog)
//{{AFX_MSG_MAP(CDelUserDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDelUserDlg message handlers
void CDelUserDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(!CheckAccountNum())
{
AfxMessageBox("该账户不存在");
GetDlgItem(IDC_ACCOUNTNUM)->SetWindowText("");
return;
}
if(MessageBox("确认要注销该账号吗?注销将删除该账号所有交易记录","警告",MB_YESNO)==IDYES)
{
DeleteAccount();
AfxMessageBox("成功注销该用户");
}
CDialog::OnOK();
}
int CDelUserDlg::CheckAccountNum()
{
_bstr_t vSQL;
vSQL="select * from account where account_number='"+m_AccountNum+"'";
CADOConn m_ADOConn;
_RecordsetPtr m_Recordset;
m_ADOConn.OnInitADOConn();
m_Recordset=m_ADOConn.GetRecordset(vSQL);
if(m_Recordset->adoEOF)//记录集空
{
m_ADOConn.ExitConnect();
return 0;
}
else
{
m_ADOConn.ExitConnect();
return 1;
}
}
void CDelUserDlg::DeleteAccount()
{
_bstr_t dSQL,vSQL;
dSQL="delete from depositor where account_number='"+m_AccountNum+"'";
vSQL="delete from account where account_number='"+m_AccountNum+"'";
CADOConn m_ADOConn;
_RecordsetPtr m_Recordset;
m_ADOConn.OnInitADOConn();
m_ADOConn.ExecuteSQL(dSQL);
m_ADOConn.ExecuteSQL(vSQL);
m_ADOConn.ExitConnect();
}