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

📄 logindlg.cpp

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

#include "stdafx.h"
#include "AthleteInfo.h"
#include "LoginDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CLoginDlg dialog


CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLoginDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CLoginDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
//	m_strUserName.SetFocus();
}


void CLoginDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CLoginDlg)
	DDX_Control(pDX, IDC_PASSWORD, m_strPassword);
	DDX_Control(pDX, IDC_USERNAME, m_strUserName);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CLoginDlg message handlers

void CLoginDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString username,password;
	m_strUserName.GetWindowText(username);
	m_strPassword.GetWindowText(password);
	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_strPassword.SetFocus();
			}
			else{
				m_recordSet.GetFieldValue("user_level",m_userLevel);
                CDialog::OnOK();
			}
			m_recordSet.Close();
			m_database.Close();
		}
		else
			MessageBox("不能打开数据库");
	}

}

void CLoginDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	if(MessageBox("真的要退出系统吗?","退出询问",MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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