changeuserpwddlg.cpp
来自「初学VC,编写的一个机房管理系统,功能基本上完善,但代码可读性不强.」· C++ 代码 · 共 113 行
CPP
113 行
// ChangeUserPwdDlg.cpp : implementation file
//
#include "stdafx.h"
#include "server.h"
#include "ChangeUserPwdDlg.h"
#include "userSet.h"
#include "admactionSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString glbname;
extern bool changepwdorfreeze;
/////////////////////////////////////////////////////////////////////////////
// CChangeUserPwdDlg dialog
CChangeUserPwdDlg::CChangeUserPwdDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChangeUserPwdDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChangeUserPwdDlg)
xuehao = _T("");
//}}AFX_DATA_INIT
}
void CChangeUserPwdDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChangeUserPwdDlg)
DDX_Text(pDX, IDC_XUEHAO, xuehao);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChangeUserPwdDlg, CDialog)
//{{AFX_MSG_MAP(CChangeUserPwdDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChangeUserPwdDlg message handlers
void CChangeUserPwdDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(xuehao.IsEmpty())
{ MessageBox("请输入学号!","提醒",MB_OK);
return;
}
CUserSet user;
bool tag=false;
CString *pxuehao;
pxuehao=new CString;
pxuehao->Format("xuehao='%s'",xuehao);
CTime currenttime=CTime::GetCurrentTime();
CString mtime=currenttime.Format("%#Y年%#m月%#d日%#H时%#M分%#S秒");
user.m_strFilter=*pxuehao;
user.Open();
delete pxuehao;
if(user.GetRecordCount())
{
user.Edit();
if(changepwdorfreeze)
user.m_password=xuehao;
else
user.m_mark=true;
user.Update();
tag=true;
}
user.Close();
if(tag)
{
CAdmactionSet admaction;
admaction.Open();
admaction.AddNew();
admaction.m_name=glbname;
admaction.m_date=mtime;
if(changepwdorfreeze)
admaction.m_action=xuehao+"找回密码";
else
admaction.m_action="冻结账户:"+xuehao;
admaction.Update();
admaction.Close();
if(changepwdorfreeze)
MessageBox("密码已还原为学号,请及时更改!","提示",MB_OK);
else
MessageBox("冻结成功","提示",MB_OK);
}
else
{
MessageBox("该账户不存在,请核对!","提示",MB_OK);
}
CDialog::OnOK();
}
BOOL CChangeUserPwdDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(!changepwdorfreeze)
{
SetWindowText("冻结账户");
CWnd *pwnd=GetDlgItem(IDC_XUE);
pwnd->SetWindowText("请输入需要冻结的账户号码:");
}
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?