www.pudn.com > classSystem(c++).rar > UserChangePs.cpp


// UserChangePs.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "ClassSystem.h" 
#include "UserChangePs.h" 
#include "UserNode.h" 
#include "UserList.h" 
 
extern CUserNode curUser; 
extern CUserList userlist; 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CUserChangePs dialog 
 
 
CUserChangePs::CUserChangePs(CWnd* pParent /*=NULL*/) 
	: CDialog(CUserChangePs::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CUserChangePs) 
	m_oldPassword = _T(""); 
	m_newPassword1 = _T(""); 
	m_newPassword2 = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void CUserChangePs::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CUserChangePs) 
	DDX_Text(pDX, IDC_EDIT_OLD_PS, m_oldPassword); 
	DDX_Text(pDX, IDC_EDIT_NEW_PS2, m_newPassword1); 
	DDX_Text(pDX, IDC_EDIT_NEW_PS1, m_newPassword2); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CUserChangePs, CDialog) 
	//{{AFX_MSG_MAP(CUserChangePs) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CUserChangePs message handlers 
 
void CUserChangePs::OnOK()  
{ 
	// TODO: Add extra validation here 
	UpdateData(); 
 
	if(m_oldPassword == "") 
	{ 
		MessageBox("请输入原密码!"); 
		return ; 
	} 
	if(m_newPassword1 == "") 
	{ 
		MessageBox("请确认新密码!"); 
		return ; 
	} 
	if(m_newPassword2=="") 
	{ 
		MessageBox("请输入新密码!"); 
		return ; 
	} 
 
	if(m_newPassword2 != m_newPassword1) 
	{ 
		MessageBox("两次输入的密码不一致!"); 
		return ; 
	} 
	if(m_oldPassword != curUser.m_password) 
	{ 
		MessageBox("原密码不正确!"); 
		return ; 
	} 
	curUser.m_password = m_newPassword2; 
	if(userlist.modifyPs(curUser.m_key,curUser)) 
	{ 
		MessageBox("密码修改成功,下次登陆请用新密码"); 
	} 
	else 
	{ 
		MessageBox("发生未知错误,密码修改不成功!"); 
	} 
 
 
	CDialog::OnOK(); 
}