ChangePwdDlg.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:2k
源码类别:
数据库系统
开发平台:
Visual C++
- // ChangePwdDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "ChangePwdDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CChangePwdDlg dialog
- CChangePwdDlg::CChangePwdDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CChangePwdDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CChangePwdDlg)
- m_NewPwd1 = _T("");
- m_NewPwd2 = _T("");
- m_OldPwd = _T("");
- m_UserName = _T("");
- //}}AFX_DATA_INIT
- }
- void CChangePwdDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CChangePwdDlg)
- DDX_Text(pDX, IDC_NEWPWD1_EDIT, m_NewPwd1);
- DDX_Text(pDX, IDC_NEWPWD2_EDIT, m_NewPwd2);
- DDX_Text(pDX, IDC_OLDPWD_EDIT, m_OldPwd);
- DDX_Text(pDX, IDC_USERNAME_STATIC, m_UserName);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CChangePwdDlg, CDialog)
- //{{AFX_MSG_MAP(CChangePwdDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CChangePwdDlg message handlers
- void CChangePwdDlg::OnOK()
- {
- //将对话框中编辑框的数据读取到成员变量中
- UpdateData(TRUE);
- //检查数据有效性
- if (m_OldPwd == "")
- {
- MessageBox("请输入旧密码");
- return;
- }
- if (m_NewPwd1 == "")
- {
- MessageBox("请输入新密码");
- return;
- }
- if (m_NewPwd1 != m_NewPwd2)
- {
- MessageBox("两次输入的新密码不同");
- return;
- }
- //定义CUsers对象,用于从表Users中读取数据
- CUsers user;
- user.GetData(m_UserName);
- //如果读取的数据与用户输入数据不同,则返回
- if (user.GetPwd() != m_OldPwd)
- {
- MessageBox("用户密码不正确!");
- return;
- }
- user.SetPwd(m_NewPwd1);
- user.sql_updatePwd(m_UserName);
- MessageBox("密码修改成功,下次登录请使用新密码");
- CDialog::OnOK();
- }