📄 userdlg.cpp
字号:
// UserDlg.cpp : implementation file
//
#include "stdafx.h"
#include "clientmain.h"
#include "UserDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUserDlg dialog
CUserDlg::CUserDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUserDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUserDlg)
m_strUserName = _T("");
m_strNewPsw = _T("");
m_strOkPsw = _T("");
m_strOldPsw = _T("");
//}}AFX_DATA_INIT
}
void CUserDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserDlg)
DDX_Control(pDX, IDC_EDIT_OLDPSW, m_OldPsw);
DDX_Control(pDX, IDC_EDIT_OKPSW, m_OkPsw);
DDX_Control(pDX, IDC_EDIT_NEWPSW, m_NewPsw);
DDX_Control(pDX, IDC_EDIT_NAME, m_UserName);
DDX_Control(pDX, IDC_BTN_YES, m_btnYes);
DDX_Control(pDX, IDC_BTN_CANCEL, m_btnCancel);
DDX_Text(pDX, IDC_EDIT_NAME, m_strUserName);
DDX_Text(pDX, IDC_EDIT_NEWPSW, m_strNewPsw);
DDX_Text(pDX, IDC_EDIT_OKPSW, m_strOkPsw);
DDX_Text(pDX, IDC_EDIT_OLDPSW, m_strOldPsw);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUserDlg, CDialog)
//{{AFX_MSG_MAP(CUserDlg)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
ON_BN_CLICKED(IDC_BTN_YES, OnBtnYes)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUserDlg message handlers
void CUserDlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
void CUserDlg::OnCancel()
{
// TODO: Add extra cleanup here
// CDialog::OnCancel();
}
BOOL CUserDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// 为对话框添加图标
HICON hIcon = AfxGetApp()->LoadIcon(IDI_USER);
ASSERT(hIcon != NULL);
SetIcon(hIcon, TRUE);
m_UserName.SetFocus();
return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CUserDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_RETURN)
{
//CEdit *pEdit=(CEdit*)GetDlgItem(IDC_EDIT_USERNAME);
if(pMsg->hwnd == m_UserName.GetSafeHwnd())
{
m_OldPsw.SetFocus();
m_OldPsw.SetSel(0, -1);
return FALSE;
}
if(pMsg->hwnd == m_OldPsw.GetSafeHwnd())
{
m_NewPsw.SetFocus();
m_NewPsw.SetSel(0, -1);
return FALSE;
}
if(pMsg->hwnd == m_NewPsw.GetSafeHwnd())
{
m_OkPsw.SetFocus();
m_OkPsw.SetSel(0, -1);
return FALSE;
}
if(pMsg->hwnd == m_OkPsw.GetSafeHwnd())
{
m_btnYes.SetFocus();
return FALSE;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CUserDlg::OnBtnCancel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
void CUserDlg::OnBtnYes()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_strUserName != g_strUserName)
{
MessageBox("用户输入有误!", NULL, MB_OK);
m_UserName.SetFocus();
m_UserName.SetSel(0, -1);
return;
}
if(m_strOldPsw != g_strUserPsw)
{
MessageBox("密码输入有误!", NULL, MB_OK);
m_OldPsw.SetFocus();
m_OldPsw.SetSel(0, -1);
return;
}
if(m_strOkPsw != m_strNewPsw)
{
MessageBox("新密码输入不一致,请重新输入!", NULL, MB_OK);
m_NewPsw.SetFocus();
m_NewPsw.SetSel(0, -1);
return;
}
_bstr_t strSql("select * from T_Users where Name = '" + m_strUserName + "'" );
g_pAdoServer->CloseRecordset();
g_pAdoServer->OpenRecordset(strSql);
g_pAdoServer->Field["Password"] = LPCSTR(m_strNewPsw);
g_pAdoServer->Update();
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -