📄 passwd.cpp
字号:
// Passwd.cpp : implementation file
//
#include "stdafx.h"
#include "people2.h"
#include "Passwd.h"
#include "people.h"
#include "people2Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Passwd dialog
Passwd::Passwd(CWnd* pParent /*=NULL*/)
: CDialog(Passwd::IDD, pParent)
{
//{{AFX_DATA_INIT(Passwd)
m_PasswdEdit1 = _T("");
m_PasswdEdit2 = _T("");
m_PasswdEdit3 = _T("");
m_PasswdEdit4 = _T("");
//}}AFX_DATA_INIT
}
void Passwd::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Passwd)
DDX_Text(pDX, IDC_EDIT1, m_PasswdEdit1);
DDV_MaxChars(pDX, m_PasswdEdit1, 6);
DDX_Text(pDX, IDC_EDIT2, m_PasswdEdit2);
DDV_MaxChars(pDX, m_PasswdEdit2, 6);
DDX_Text(pDX, IDC_EDIT3, m_PasswdEdit3);
DDV_MaxChars(pDX, m_PasswdEdit3, 6);
DDX_Text(pDX, IDC_EDIT4, m_PasswdEdit4);
DDV_MaxChars(pDX, m_PasswdEdit4, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Passwd, CDialog)
//{{AFX_MSG_MAP(Passwd)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_BN_CLICKED(ID_Update, OnUpdate)
ON_BN_CLICKED(ID_CANCEL, OnCancel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Passwd message handlers
void Passwd::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void Passwd::OnUpdate()
{
// TODO: Add your control notification handler code here
UpdateData(true);
//检查数据有效性
if(m_PasswdEdit1=="")
{
MessageBox("请输入编号!");
}
if(m_PasswdEdit4=="")
{
MessageBox("请输入原始密码!");
return;
}
if(m_PasswdEdit2=="")
{
MessageBox("请输入新密码!");
return;
}
if(m_PasswdEdit2!=m_PasswdEdit3)
{
MessageBox("两次输入新密码不同,请重新输入!");
return;
}
//定义CUsers 对象,用于从表中读取数据
//CPeople2Dlg a;
Cpeople user;
user.GetData(m_PasswdEdit1);
//user.GetData1(m_PasswdEdit4);
//如果读入数据与用户输入密码不同,则返回
if(user.GetNumber()!=m_PasswdEdit1)
{
MessageBox("编号不正确!");
return;
}
if(user.GetPasswd()!=m_PasswdEdit4)
{
MessageBox("原始密码错误!");
return;
}
//a.HaveNumber(m_PasswdEdit1,m_PasswdEdit4);
else{
user.SetPasswd(m_PasswdEdit2);
user.sql_updatePwd(m_PasswdEdit1);
MessageBox("密码修改成功!");
MessageBox("下次登陆请使用新密码!");}
OnInitDialog() ;
CDialog::OnOK();
}
void Passwd::OnCancel()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -