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

📄 cbooks.cpp

📁 图书管理系统 所有图书管理功能都有,包括借书 还书 查询
💻 CPP
字号:
// CBooks.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "CBooks.h"

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

IMPLEMENT_SERIAL(CBooks,CObject,1)//宏

CBooks::CBooks()
{
	m_serialNumber="0";
	m_category="0";
	m_title="0";
	m_auther="0";
	m_press="0";

	m_publicDate.m_year=0;
	m_publicDate.m_month=0;
	m_publicDate.m_day=0;

	m_price=0.0;

	m_purchaseDate.m_year=0;
	m_purchaseDate.m_month=0;
	m_purchaseDate.m_day=0;  

	m_lender.m_name="0";
	m_lender.m_certificateNo="0";
	m_lender.m_sex=0;
	m_lender.m_type=0;

	m_lendDate.m_year=0;
	m_lendDate.m_month=0;
	m_lendDate.m_day=0;

	m_returnDate.m_year=0;
	m_returnDate.m_month=0;
	m_returnDate.m_day=0;
}

CBooks::~CBooks()
{}

void CBooks::AddBook(char *serialNumber,char *category,char *title,char *auther,char *press,int pYear,
		int pMonth,int pDay,double price,int bYear,int bMonth,int bDay,char *name,
		char *certificateNo,BOOL sex,int type,int lYear,int lMonth,int lDay,int rYear,
		int rMonth,int rDay)
{
	m_serialNumber=serialNumber;//编号
	m_category=category;//类别
	m_title=title;//书名
	m_auther=auther;//作者
	m_press=press;//出版社
	//出版日期
	m_publicDate.m_year=pYear;
	m_publicDate.m_month=pMonth;
	m_publicDate.m_day=pDay;
	//价格
	m_price=price;
	//购书时间
	m_purchaseDate.m_year=bYear;
	m_purchaseDate.m_month=bMonth;
	m_purchaseDate.m_day=bDay;
	//借阅者的姓名、证号、性别与型别(大学生、研究生还是教师)
	m_lender.m_name=name;
	m_lender.m_certificateNo=certificateNo;
	m_lender.m_sex=sex;
	m_lender.m_type=type;
	//借书日期
	m_lendDate.m_year=lYear;
	m_lendDate.m_month=lMonth;
	m_lendDate.m_day=lDay;
	//还书日期
	m_returnDate.m_year=rYear;
	m_returnDate.m_month=rMonth;
	m_returnDate.m_day=rDay;
}

void CBooks::Serialize(CArchive &ar)
{
	CObject::Serialize(ar);
	//IsStoring的状态值为非0时,把数据保存到存档文件,否则从存档文件读取数据
	if(ar.IsStoring())
	{	//把数据保存到存档文件
		ar<<m_serialNumber<<m_category<<m_title
			<<m_auther<<m_press<<m_price;
		ar<<m_lender.m_name<<m_lender.m_certificateNo
			<<m_lender.m_sex<<m_lender.m_type;
		ar<<m_publicDate.m_year<<m_publicDate.m_month<<m_publicDate.m_day;
		ar<<m_lendDate.m_year<<m_lendDate.m_month<<m_lendDate.m_day;
		ar<<m_returnDate.m_year<<m_returnDate.m_month<<m_returnDate.m_day;
		ar<<m_purchaseDate.m_year<<m_purchaseDate.m_month<<m_purchaseDate.m_day;
	}
	else
	{	//从存档文件读取数据
		ar>>m_serialNumber>>m_category>>m_title
			>>m_auther>>m_press>>m_price;
		ar>>m_lender.m_name>>m_lender.m_certificateNo
			>>m_lender.m_sex>>m_lender.m_type;
		ar>>m_publicDate.m_year>>m_publicDate.m_month>>m_publicDate.m_day;
		ar>>m_lendDate.m_year>>m_lendDate.m_month>>m_lendDate.m_day;
		ar>>m_returnDate.m_year>>m_returnDate.m_month>>m_returnDate.m_day;
		ar>>m_purchaseDate.m_year>>m_purchaseDate.m_month>>m_purchaseDate.m_day;
	}
}

⌨️ 快捷键说明

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