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

📄 reader.cpp

📁 图书馆借阅管理系统
💻 CPP
字号:
#include <stdafx.h>
#include "Reader.h"
#include "Library.h"
//在此引用应用类中的theApp来获取库连接指针
extern CLibraryApp theApp;   


CReader::CReader()
{}

CReader::~CReader()
{}

int CReader::BorrowBook(CBook CurrentBook)
{	
	if(!CurrentBook.IsValidBook())
	{
		try
		{
			CString SQLText;
			SQLText.Format("Update TB_BookInfo set Borrowed=%s where BookID=%s",ReaderID,CurrentBook.BookID);
			theApp.pConn->Execute(_bstr_t(SQLText),NULL,adExecuteNoRecords);
			
			SQLText.Format("Insert into TB_BorrowInfo(BookID,ReaderID) values(%s,%s)",CurrentBook.BookID,ReaderID);
			theApp.pConn->Execute(_bstr_t(SQLText),NULL,adExecuteNoRecords);
			return 1;
		}
		catch(_com_error *e)
		{
			AfxMessageBox(e->ErrorMessage());
			return 0;
		}
	}
	else
		return 0;
}

//读取读者信息
int CReader::ReadReaderInfo(CString strReaderID)
{
	CString SQLText;

	_RecordsetPtr pRst(__uuidof(Recordset)); 

	SQLText.Format("select * from V_ReaderInfo where Deleted=0 and ReaderID='%s'",strReaderID);

	try
	{
		//SQL Server数据库
		pRst=theApp.pConn->Execute(_bstr_t(SQLText),NULL,adCmdText);

		if(!pRst->BOF)
		{
			_variant_t vReaderID	= pRst->GetCollect("ReaderID");
			_variant_t vReaderName	= pRst->GetCollect("ReaderName");
			_variant_t vClassName	= pRst->GetCollect("ClassName");
			_variant_t vClassID		= pRst->GetCollect("ReaderClass");
			_variant_t vAddress		= pRst->GetCollect("Address");
			_variant_t vContent		= pRst->GetCollect("Content");

			ReaderID	=	vReaderID.bstrVal;
			Name		=	vReaderName.bstrVal;
			ReaderClass	=	vClassID.intVal;
			ClassName	=	vClassName.bstrVal;
			if(vAddress.vt!=VT_NULL)
				Address	=	vAddress.bstrVal;
			if(vContent.vt!=VT_NULL)
				Content	=	vContent.bstrVal;

			return 1;
		}
		else
		{
			::MessageBox(NULL,"没有相关记录","提示",MB_OK);
			return 0;
		}
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
		return 0;
	}
	
	pRst->Close();
	pRst.Release();
}

⌨️ 快捷键说明

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