⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changepswd.cpp

📁 去年暑假帮朋友企业写的仓库管理软件
💻 CPP
字号:
// ChangePswd.cpp : implementation file
//

#include "stdafx.h"
#include "Material_MIS.h"
#include "ChangePswd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChangePswd dialog


CChangePswd::CChangePswd(CWnd* pParent /*=NULL*/)
	: CDialog(CChangePswd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CChangePswd)
	m_change_name = _T("");
	m_change_newpswd = _T("");
	m_change_oldpswd = _T("");
	//}}AFX_DATA_INIT
}


void CChangePswd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChangePswd)
	DDX_Text(pDX, IDC_CHANGE_NAME, m_change_name);
	DDV_MaxChars(pDX, m_change_name, 15);
	DDX_Text(pDX, IDC_CHANGE_NEWPSWD, m_change_newpswd);
	DDV_MaxChars(pDX, m_change_newpswd, 10);
	DDX_Text(pDX, IDC_CHANGE_OLDPSWD, m_change_oldpswd);
	DDV_MaxChars(pDX, m_change_oldpswd, 10);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CChangePswd, CDialog)
	//{{AFX_MSG_MAP(CChangePswd)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChangePswd message handlers

BOOL CChangePswd::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_change_name = theApp.m_sCurrentUser;
	((CEdit*)GetDlgItem(IDC_CHANGE_OLDPSWD))->SetFocus();
	UpdateData(FALSE);

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CChangePswd::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	// Check the parameter of the dialog;

	m_change_oldpswd.TrimLeft();
	m_change_oldpswd.TrimRight();
	if(m_change_oldpswd.GetLength()<=0)
	{
		AfxMessageBox(_T("请输入旧密码!"),MB_ICONEXCLAMATION);
		return;
	}
	m_change_newpswd.TrimLeft();
	m_change_newpswd.TrimRight();
	if(m_change_newpswd.GetLength()<=0)
	{
		AfxMessageBox(_T("请输入新密码!"),MB_ICONEXCLAMATION);
		return;
	}


	// Update the password of the current user;
	_variant_t strQuery,Holder;
	CString strOldPwd;

	strQuery = "select * from UserInfo where UserID='"+m_change_name+"'";
	theApp.ADOExecute(theApp.m_pADOSet,strQuery);
	Holder = theApp.m_pADOSet->GetCollect("UserPwd");
	strOldPwd = Holder.bstrVal;

	if(strOldPwd == m_change_oldpswd)
	{
		strQuery = "Update UserInfo set UserPwd='"+m_change_newpswd+"'\
					where UserID='"+m_change_name+"'";
		if(theApp.ADOExecute(theApp.m_pADOSet,strQuery))
		{
			AfxMessageBox("修改密码成功!",MB_ICONINFORMATION);
		}
		else
		{
			AfxMessageBox("修改密码失败!",MB_ICONEXCLAMATION);
			return;
		}
	}
	else
	{
			AfxMessageBox("修改密码失败,请检查原密码!",MB_ICONEXCLAMATION);
			return;
	}

	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -