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

📄 changepswdlg.cpp

📁 一个通信录程序
💻 CPP
字号:
// ChangePswDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Address.h"
#include "ChangePswDlg.h"
#include "PswdSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CChangePswDlg dialog


CChangePswDlg::CChangePswDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CChangePswDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CChangePswDlg)
	m_oldpassword = _T("");
	m_newpassword = _T("");
	m_qurenpassword = _T("");
	//}}AFX_DATA_INIT
}


void CChangePswDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChangePswDlg)
	DDX_Control(pDX, IDC_EDIT1, m_ctrloldpassword);
	DDX_Text(pDX, IDC_EDIT1, m_oldpassword);
	DDX_Text(pDX, IDC_EDIT2, m_newpassword);
	DDX_Text(pDX, IDC_EDIT3, m_qurenpassword);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////
//名称:OnOk
//功能:更改用户口令
//作者:赵权(fhiesc@163.com)
//日期:2003.12
////////////////////////////////////////////////////////////////////////
void CChangePswDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);//读入用户输入的密码
	CDBVariant varValue;
	CPswdSet m_recordset(&m_database);
	CString strSQL;
	strSQL.Format("select * from password where PASSWORD='%s'",m_oldpassword);
	m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
	//int temp=0;
	//m_recordset.GetFieldValue(temp,varValue);
	//如果输入的密码与数据库中的不一致,则弹出提示框
	if(m_recordset.GetRecordCount()==0)
	//if(m_oldpassword.Compare(varValue.m_pstring->GetBuffer(1))!=0)
	{
		MessageBox("原密码错误!","提示",MB_OK|MB_ICONINFORMATION);
		m_oldpassword.Empty();
		m_newpassword.Empty();
		m_qurenpassword.Empty();
		m_ctrloldpassword.SetFocus();
		UpdateData(FALSE);//清空所输入的内容
	}
	//如果原密码正确,两次新密码不同
	else
	{
		if(m_newpassword.Compare(m_qurenpassword)!=0)
		{
			MessageBox("新密码错误!","提示",MB_OK|MB_ICONINFORMATION);
			m_oldpassword.Empty();
			m_newpassword.Empty();
			m_qurenpassword.Empty();
			UpdateData(FALSE);//清空所输入的内容
		}
		else
		{
			strSQL.Format("update password set PASSWORD='%s' where PASSWORD='%s'",m_newpassword,m_oldpassword); 
			m_database.ExecuteSQL(strSQL);
			CDialog::OnOK();
			MessageBox("恭喜,口令更改成功!下次登录请使用口令: "+m_newpassword+"  ","提示",MB_OK|MB_ICONINFORMATION);
		}
	}
}


/////////////////////////////////////////////////////////////////////////
//名称:OnInitDialog
//功能:更改口令对话框初始化
//作者:赵权(fhiesc@163.com)
//日期:2003.12
////////////////////////////////////////////////////////////////////////
BOOL CChangePswDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_ctrloldpassword.SetFocus();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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