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

📄 managerdlg.cpp

📁 图书管理系统,主要功能有图书的借还,增加,查询等
💻 CPP
字号:
// Managerdlg.cpp : implementation file
//

#include "stdafx.h"
#include "图书管理系统.h"
#include "Managerdlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CManagerdlg dialog
extern CMyApp theApp;

CManagerdlg::CManagerdlg(CWnd* pParent /*=NULL*/)
	: CDialog(CManagerdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CManagerdlg)
	m_muser = _T("");
	m_mpassword = _T("");
	//}}AFX_DATA_INIT
}


void CManagerdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CManagerdlg)
	DDX_Text(pDX, IDC_MNAME, m_muser);
	DDX_Text(pDX, IDC_MPASSWORD, m_mpassword);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CManagerdlg message handlers

void CManagerdlg::OnOK() 
{
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	UpdateData(TRUE);
	if (m_muser.IsEmpty() || m_mpassword.IsEmpty())
	{
		MessageBox("用户名称或密码不能为空", "用户登录信息");
		GetDlgItem(IDC_MNAME)->SetFocus();
		return;
	}
	sql.Format("select * from Manager where id = '%s' and password = '%s'",m_muser,m_mpassword);  	
	try
	{
		m_pRecordset->Open(sql.AllocSysString(),                // 查询数据库表中所有字段
							theApp.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
							adOpenDynamic,
							adLockOptimistic,
							adCmdText);
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	try
	{
		if (!m_pRecordset->BOF)
			{
				pass = true;
				EndDialog(0);
			}	
		else
			{
				m_muser="";
				m_mpassword="";
				MessageBox("用户名或密码不正确.","提示",64);
				UpdateData(FALSE);
				GetDlgItem(IDC_MNAME)->SetFocus();
			}
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	m_pRecordset->Close();
	m_pRecordset=NULL;
}

void CManagerdlg::OnCancel() 
{
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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