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

📄 modidlg.cpp

📁 用VC+ADO+ACCESS 做的学生管理系统
💻 CPP
字号:
// ModiDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DataBase.h"
#include "ModiDlg.h"
#include "UserPassSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CModiDlg dialog


CModiDlg::CModiDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModiDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModiDlg)
	m_newpass1 = _T("");
	m_newpass2 = _T("");
	m_oldpass = _T("");
	//}}AFX_DATA_INIT
}


void CModiDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModiDlg)
	DDX_Text(pDX, IDC_EDIT_NEWPASS1, m_newpass1);
	DDX_Text(pDX, IDC_EDIT_NEWPASS2, m_newpass2);
	DDX_Text(pDX, IDC_EDIT_OLDPASS, m_oldpass);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CModiDlg message handlers

void CModiDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	CDBVariant varValue;
	CUserPassSet m_recordset(&m_database);
	CString strSQL;
	strSQL.Format("select * from User where Username='%s'",user);
	m_recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
	m_recordset.GetFieldValue(1,varValue);
	if(m_oldpass.Compare(varValue.m_pstring->GetBuffer(1))!=0)
	{
		MessageBox("原密码输入错误!");
		m_oldpass.Empty();
		m_newpass1.Empty();
		m_newpass2.Empty();
		UpdateData(FALSE);
	}
	else
	{
		if(m_newpass1.Compare(m_newpass2)!=0)
		{
			MessageBox("新密码输入不一致!");
			m_oldpass.Empty();
			m_newpass1.Empty();
			m_newpass2.Empty();
			UpdateData(FALSE);
		}
		else
		{
			strSQL.Format("delete from User where Username='%s'",user);
			m_database.ExecuteSQL(strSQL);
			strSQL.Format("insert into User values('%s','%s')",user,m_newpass1);
			m_database.ExecuteSQL(strSQL);
			MessageBox("密码修改成功!");
			CDialog::OnOK();
		}
	}
}

⌨️ 快捷键说明

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