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

📄 passworddlg.cpp

📁 本源码非常详细的实现了一个运动员信息管理系统 其中包括管理员
💻 CPP
字号:
// PasswordDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AthleteInfo.h"
#include "PasswordDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPasswordDlg dialog


CPasswordDlg::CPasswordDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPasswordDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPasswordDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPasswordDlg)
	DDX_Control(pDX, IDC_NEW, m_strNew);
	DDX_Control(pDX, IDC_EDIT_USERNAME, m_strusername);
	DDX_Control(pDX, IDC_EDIT_PASSWORD, m_strpassword);
	DDX_Control(pDX, IDC_CONFIRM, m_strConfirm);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CPasswordDlg message handlers

void CPasswordDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString username,password,newpassword,confirmpassword;
	m_strusername.GetWindowText(username);
	m_strpassword.GetWindowText(password);
	m_strNew.GetWindowText(newpassword);
	m_strConfirm.GetWindowText(confirmpassword);
    if(newpassword.IsEmpty()||confirmpassword.IsEmpty()){
		MessageBox("密码不为空");
	}
	else{
		if(newpassword!=confirmpassword){
			MessageBox("两次输入密码不一致,请重新输入新密码");
			m_strNew.SetWindowText("");
            m_strConfirm.SetWindowText("");
			m_strNew.SetFocus();
		}
		else{
			if(!m_database.IsOpen()){
		        if(m_database.Open(_T("athleteinfo"))){
			        m_recordSet.m_pDatabase=&m_database;
			        CString strSQL;
			        strSQL.Format("select * from userinfo where user_name='%s' and user_password='%s' and active_status='Y'",username,password);
			        m_recordSet.Open(CRecordset::forwardOnly,strSQL);
			        if(m_recordSet.GetRecordCount()==0){
				         MessageBox("密码错误,请重新输入","密码错误",MB_OK|MB_ICONWARNING);
				         //m_strpassword.SetWindowText("");
						 m_strNew.SetWindowText("");
                         m_strConfirm.SetWindowText("");
			             m_strNew.SetFocus();
					}
			        else{
				         strSQL.Format("update userinfo set user_password='%s' where user_name='%s'",newpassword,username);
						 m_database.ExecuteSQL(strSQL);
						 MessageBox("修改密码成功");
                         CDialog::OnOK();
					}
			        m_recordSet.Close();
			        m_database.Close();
				}
		   else
			    MessageBox("不能打开数据库");
			}

		}
	}


	
	//CDialog::OnOK();
}

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

⌨️ 快捷键说明

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