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

📄 modpswddlg.cpp

📁 用ODBC接口访问access数据库管理系统
💻 CPP
字号:
// ModPswdDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Team2.h"
#include "ModPswdDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CModPswdDlg dialog


CModPswdDlg::CModPswdDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModPswdDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModPswdDlg)
	m_old = _T("");
	m_new = _T("");
	m_confirm = _T("");
	//}}AFX_DATA_INIT
}


void CModPswdDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModPswdDlg)
	DDX_Text(pDX, IDC_EDIT1, m_old);
	DDX_Text(pDX, IDC_EDIT2, m_new);
	DDX_Text(pDX, IDC_EDIT3, m_confirm);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CModPswdDlg message handlers

void CModPswdDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CModPswdDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	if(!db.Open("db1"))return;
	CRecordset rs(&db);
	
	if(table==1){
		rs.Open(CRecordset::forwardOnly,"select * from cab_pswd where id='" + user + "'");
		if(rs.IsEOF()){
			AfxMessageBox("原口令错误!请重新输入!注意大小写");
			m_old=_T("");
			m_new=_T("");
			m_confirm=_T("");
			UpdateData(FALSE);
			db.Close();			
		}
		else{
			if(m_confirm==m_new){
				CString strSQL;
				strSQL="update cab_pswd set pswd='" + m_new + "' where id='" + user + "'";
				db.ExecuteSQL(strSQL);
				db.Close();
				AfxMessageBox("口令修改成功!");
				CDialog::OnOK();
			}
			else{
				AfxMessageBox("确认口令错误!请重新输入!");
				m_old=_T("");
				m_new=_T("");
				m_confirm=_T("");
				UpdateData(FALSE);
				db.Close();
			}
		}
	}
		
	if(table==2){
		rs.Open(CRecordset::forwardOnly,"select * from ins_pswd where id='" + user + "'");
		if(rs.IsEOF()){
			AfxMessageBox("原口令错误!请重新输入!注意大小写");
			m_old=_T("");
			m_new=_T("");
			m_confirm=_T("");
			UpdateData(FALSE);
			db.Close();			
		}
		else{
			if(m_confirm==m_new){
				CString strSQL;
				strSQL="update ins_pswd set pswd='" + m_new + "' where id='" + user + "'";
				db.ExecuteSQL(strSQL);
				db.Close();
				AfxMessageBox("口令修改成功!");
				CDialog::OnOK();
			}
			else{
				AfxMessageBox("确认口令错误!请重新输入!");
				m_old=_T("");
				m_new=_T("");
				m_confirm=_T("");
				UpdateData(FALSE);
				db.Close();
			}
		}
	}
	if(table==3){
		rs.Open(CRecordset::forwardOnly,"select * from stu_pswd where id='" + user + "'");
		if(rs.IsEOF()){
			AfxMessageBox("原口令错误!请重新输入!注意大小写");
			m_old=_T("");
			m_new=_T("");
			m_confirm=_T("");
			UpdateData(FALSE);
			db.Close();			
		}
		else{
			if(m_confirm==m_new){
				CString strSQL;
				strSQL="update stu_pswd set pswd='" + m_new + "' where id='" + user + "'";
				db.ExecuteSQL(strSQL);
				db.Close();
				AfxMessageBox("口令修改成功!");
				CDialog::OnOK();
			}
			else{
				AfxMessageBox("确认口令错误!请重新输入!");
				m_old=_T("");
				m_new=_T("");
				m_confirm=_T("");
				UpdateData(FALSE);
				db.Close();
			}
		}
	}
	if(table==4){
		rs.Open(CRecordset::forwardOnly,"select * from adm_pswd where id='" + user + "'");
		if(rs.IsEOF()){
			AfxMessageBox("原口令错误!请重新输入!注意大小写");
			m_old=_T("");
			m_new=_T("");
			m_confirm=_T("");
			UpdateData(FALSE);
			db.Close();			
		}
		else{
			if(m_confirm==m_new){
				CString strSQL;
				strSQL="update adm_pswd set pswd='" + m_new + "' where id='" + user + "'";
				db.ExecuteSQL(strSQL);
				db.Close();
				AfxMessageBox("口令修改成功!");
				CDialog::OnOK();
			}
			else{
				AfxMessageBox("确认口令错误!请重新输入!");
				m_old=_T("");
				m_new=_T("");
				m_confirm=_T("");
				UpdateData(FALSE);
				db.Close();
			}
		}
	}	
}

⌨️ 快捷键说明

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