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

📄 passdlg.cpp

📁 大学班务管理系统
💻 CPP
字号:
// PassDlg.cpp : implementation file
//

#include "stdafx.h"
#include "教学管理信息系统.h"
#include "PassDlg.h"
#include "UserRecordSet.h"
#include <stdlib.h>
#include "adminRecordSet1.h"
#include "Public.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPassDlg dialog


CPassDlg::CPassDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPassDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPassDlg)
	m_username = _T("");
	m_userpwd = _T("");
	m_userid = _T("");
	//}}AFX_DATA_INIT
}


void CPassDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPassDlg)
	DDX_Text(pDX, IDC_EDITUSERNAME, m_username);
	DDX_Text(pDX, IDC_EDITPASSWORD, m_userpwd);
	DDX_CBString(pDX, IDC_COMBOuserid, m_userid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPassDlg, CDialog)
	//{{AFX_MSG_MAP(CPassDlg)
	ON_BN_CLICKED(IDC_BUTTONOK, OnButtonok)
	ON_BN_CLICKED(IDC_BUTTONCANCEL, OnButtoncancel)
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPassDlg message handlers

void CPassDlg::OnButtonok() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	CUserRecordSet m_UserRecordSet;
	CadminRecordSet m_adminrecordset;
	if(m_username.IsEmpty())
   {
	   MessageBox("用户名不能为空!");
	
   }
    	if(m_userid.IsEmpty())
   {
	   MessageBox("请选择用户身份!");
   }

	try
	{
		if(m_userid=="普通用户")
		{
		CPublic::or=2;//将全局变量设为2
		if(m_UserRecordSet.IsOpen())
			m_UserRecordSet.Close();
		m_UserRecordSet.m_strFilter.Format("用户名='%s'and 密码='%s'",
			m_username,m_userpwd);
		m_UserRecordSet.Open(CRecordset::snapshot,NULL,CRecordset::none);
		if(m_UserRecordSet.IsEOF())
		{
			m_UserRecordSet.Close();
			AfxMessageBox("密码错误,请重试!!");
            
		}
		else
		{
			m_UserRecordSet.Close();
			AfxMessageBox("密码正确,登录成功!");
			CDialog::OnCancel();
		}
		}
		else if(m_userid=="管理员")
					{
		
		if(m_adminrecordset.IsOpen())
			m_adminrecordset.Close();
		m_adminrecordset.m_strFilter.Format("admin='%s'and pasword='%s'",
			m_username,m_userpwd);
		m_adminrecordset.Open(CRecordset::snapshot,NULL,CRecordset::none);
		if(m_adminrecordset.IsEOF())
		{
			m_adminrecordset.Close();
			AfxMessageBox("密码错误,请重试!!");

		}
		else
		{
			m_adminrecordset.Close();
			AfxMessageBox("密码正确,登录成功!");
			CDialog::OnCancel();
		}
		
	//	((CWnd*)GetDlgItem(IDC_BUTTONadd))->EnableWindow(FALSE);//按钮不可用
		}

	}
	catch(CDBException*e)
	{
		e->ReportError();
		return;
	}
	//CDialog::OnCancel();
	//GetDlgItem(IDC_BUTTONadd)->EnableWindow(FALSE);
}

void CPassDlg::OnButtoncancel() 
{
	// TODO: Add your control notification handler code here
 exit(0);
//AfxGetMainWnd()->PostMessage(WM_QUIT);//

}

void CPassDlg::OnDestroy() 
{

	
	// TODO: Add your message handler code here
	CDialog::OnCancel();
}

BOOL CPassDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message==WM_KEYDOWN)
    return 0;
	return CDialog::PreTranslateMessage(pMsg);
}

BOOL CPassDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	((CComboBox*)GetDlgItem(IDC_COMBOuserid))->AddString("普通用户");
	((CComboBox*)GetDlgItem(IDC_COMBOuserid))->AddString("管理员");
	
	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 + -