📄 chpwd.cpp
字号:
// ChPwd.cpp : implementation file
//
#include "stdafx.h"
#include "aoManage.h"
#include "ChPwd.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChPwd dialog
CChPwd::CChPwd(CWnd* pParent /*=NULL*/)
: CParentDlg(CChPwd::IDD, pParent)
{
//{{AFX_DATA_INIT(CChPwd)
m_strOldPwd = _T("");
m_strNewPwd = _T("");
m_strNewPwdS = _T("");
//}}AFX_DATA_INIT
m_pUser=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CChPwd::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChPwd)
DDX_Text(pDX, IDC_EDIT1, m_strOldPwd);
DDV_MaxChars(pDX, m_strOldPwd, 6);
DDX_Text(pDX, IDC_EDIT2, m_strNewPwd);
DDV_MaxChars(pDX, m_strNewPwd, 6);
DDX_Text(pDX, IDC_EDIT3, m_strNewPwdS);
DDV_MaxChars(pDX, m_strNewPwdS, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChPwd, CParentDlg)
//{{AFX_MSG_MAP(CChPwd)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChPwd message handlers
BOOL CChPwd::OnInitDialog()
{
CParentDlg::OnInitDialog();
m_pUser->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from user");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CChPwd::OnButton1()
{
UpdateData(TRUE);
if (strcmp(m_strNewPwd,m_strNewPwdS))
{
MessageBox("两次输入的新密码应相同");
return;
}
if (!m_strNewPwd.GetLength())
{
MessageBox("新设密码不能为空");
return;
}
if (m_strNewPwd.GetLength()<6)
{
MessageBox("新设密码长度应为6位");
return;
}
CString strUser=((CMainFrame*)AfxGetMainWnd())->m_strOperator;
CString strFilter;
if (m_strOldPwd.GetLength())
strFilter="name='"+strUser+"' and password='"+m_strOldPwd+"'";
else
strFilter="name='"+strUser+"' and password=NULL";
if (!m_pUser->FindFirst(strFilter))
{
MessageBox("密码不正确");
return;
}
m_pUser->Edit();
m_pUser->SetFieldValue("password",(LPCTSTR)m_strNewPwd);
m_pUser->Update();
MessageBox("已成功更改密码");
m_strOldPwd="";
m_strNewPwd="";
m_strNewPwdS="";
UpdateData(FALSE);
}
void CChPwd::OnButton2()
{
OnCancel();
}
void CChPwd::OnClose()
{
if (m_pUser->IsOpen())
m_pUser->Close();
CParentDlg::OnClose();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -