C++课程设计之快件管理系统

面向对象程序课程设计任务书

【题目】快件管理系统

【目的】

通过设计一个小型的快件管理系统,训练综合运用所学知识处理实际问题的能力,强化面向对象的程序设计理念,使自己的程序设计与调试水平有一个明显的提高。

【要求】

1、每个学生必须独立完成;
2、课程设计时间为1周;
3、设计语言采用C++;
4、学生有事离校必须请假。课程设计期间,无故缺席按旷课处理;缺席时间达四分之一以上者,未按规定上交实验报告的学生,其成绩按不及格处理。

【内容简介】

有一个快递服务代收点,现在需要你为这个服务代收点开发一个简单的快件管理系统,使收件人能够查询自己的快件情况,服务人员能够使用该系统管理该点代收的所有快件,并通知收件人取件,加快工作效率,提高服务质量。

【考核标准】

该系统为两种角色的用户提供服务,一种是代收点服务人员,一种是收件人。代收点服务人员根据账号、密码登录系统。收件人无需登录即可使用系统。
1、 代收点服务人员可将快件信息录入系统,快件信息包括快递单号、快递公司、收件人、收件人联系电话、收件人地址、邮编、寄件人、寄件人联系电话、寄件人地址、邮编,系统可自动为该快件生成取件号。如收件人来取件,服务人员可根据手机号或者取件号查询到该快件并标记取件成功。收件人可以通过手机号查询自己在该代收点的快件的取件号以及是否收取的情况,成绩≥60;
2、 系统退出后能保存当天的快件信息,要求每天一个文档,文档名按照日期命名。代收点服务人员可以根据快递单号查找、删除、修改某个快件,还可以查询所有未取快件,成绩≥70;
3、 系统可根据历史记录对收取件情况进行统计,根据服务人员的输入日期统计某天的收取件情况并显示,包括当天的收件量、各快递公司的收件量、取件量、各快递公司的取件量、未取件数量、各快递公司的未取件数量,成绩≥80;
4、 取件号可以根据快件的大小、快递公司等信息实现自动编码,成绩≥90;
要求:
用面向对象的程序设计方法设计该系统。本系统涉及的基本对象有快件对象、快件管理对象、系统界面对象。实现对这些对象的合理抽象和封装,正确定义类之间的关系。界面合理,代码文件组织清晰,命名符合规范,代码注释清楚,课设报告书质量高。

【工作内容及工作计划】

工作内容及工作计划

面向对象程序课程设计任务书

目 录
这是简略版,完整内容请下载附件查看

一、 题目

快件管理系统

二、 需求分析

这是简略版,完整内容请下载附件查看

三、 系统结构图

这是简略版,完整内容请下载附件查看

四、 类的设计

这是简略版,完整内容请下载附件查看

五、 程序代码与说明

Cdate.h

#ifndef CDATE_H
#define CDATE_H

#include <time.h>
#include <string>
using namespace std;

class Cdate
{
private:
	int year, month, day;
public:
	int GetYear() { return year; }
	int GetMonth() { return month; }
	int GetDay() { return day; }
	string DateToString(int y, int m, int d);
	void DatetoCdate(string date);
	string NowDate();
	bool IsLeapYear();
};

#endif

Locker.h

#ifndef LOCKER_H
#define LOCKER_H

#include <vector>
#include "Package.h"
#include <map>

using namespace std;

class Locker
{
private:
	vector<Package> Locker_Floor[6];	//5层
	string LockerID;
	int Size_All;				//总容量
	int Size_Floor[6];			//每层容量
public:
	Locker();
	void SetLockerID(string id) { LockerID = id; }
	string GetLockerID() { return LockerID; }
	void Stock_In(Package& P);
	bool SearchPackage(Package** P,string method);
	bool IsLockerFull();
	bool IsFloorFull(int Floor);
	bool IsLockerEmpty();
	void ReadInfo(Package& P);
	void SaveInfo();
	void WaybillSearch(int flag,string Waybill);
};

#endif

Manager.h

#ifndef MANAGER_H
#define MANAGER_H

#include <string>
#include "Package.h"
#include <map>

using namespace std;

class Manager
{
private:
	string Username = "admin";
	string Password = "admin";
public:
	void SetUsername(string text) { Username = text; }
	void SetPassword(string text) { Password = text; }
	string GetUsername() { return Username; }
	string GetPassword() { return Password; }
	bool Stock_In(Package& P);
	void SearchPackage(Package** SP,string method);
	void ReadInfo(Package& P);
	void SaveInfo();
	void WaybillSearch(Package** SP, string method);
};

#endif

Package.h

#ifndef PACKAGE_H
#define PACKAGE_H

#include <string>
using namespace std;

/*
	快件信息
	快递单号、快递公司;
	收件人:姓名、联系电话、地址、邮编;
	寄件人:姓名、联系电话、地址、邮编;
*/

class Package
{
private:
	string WaybillNum;			//快递单号
	string ExpressCompany;		//快递公司
	string Recipient;			//收件人
	string RecPhone;			//收件人联系方式
	string RecAddress;			//收件人地址
	string RecZip;				//收件人邮编
	string Sender;				//寄件人
	string SenPhone;			//寄件人联系方式
	string SenAddress;			//寄件人地址
	string SenZip;				//寄件人邮编
	string SearchID;			//取件码
	string Date;
	bool State;					//状态:true已取件 false未取件
	bool Stores = false;
public:
	Package();

	void SetWaybillNum(const string& text) { WaybillNum = text; }
	void SetExpressCompany(const string& text) { ExpressCompany = text; }
	void SetRecipient(const string& text) { Recipient = text; }
	void SetRecPhone(const string& text) { RecPhone = text; }
	void SetRecAddress(const string& text) { RecAddress = text; }
	void SetRecZip(const string& text) { RecZip = text; }
	void SetSender(const string& text) { Sender = text; }
	void SetSenPhone(const string& text) { SenPhone = text; }
	void SetSenAddress(const string& text) { SenAddress = text; }
	void SetSenZip(const string& text) { SenZip = text; }
	void SetSearchID(const string& text) { SearchID = text; }
	void SetDate(const string& text) { Date = text; }
	void SetState(bool flag) { State = flag; }
	void SetStores(bool flag) { Stores = flag; }
	string GetWaybillNum() { return WaybillNum; }
	string GetExpressCompany() { return ExpressCompany; }
	string GetRecipient() { return Recipient; }
	string GetRecPhone() { return RecPhone; }
	string GetRecAddress() { return RecAddress; }
	string GetRecZip() { return RecZip; }
	string GetSender() { return Sender; }
	string GetSenPhone() { return SenPhone; }
	string GetSenAddress() { return SenAddress; }
	string GetSenZip() { return SenZip; }
	string GetSearchID() { return SearchID; }
	bool GetState() { return State; }
	bool GetStores() { return Stores; }
	string GetDate() { return Date; }
	void ShowInfo();

	bool operator==(Package &temp);     

};

#endif

System.h

/*
	用来显示各操作界面
*/

#ifndef SYSTEM_H
#define SYSTEM_H

#include "Package.h"

class System
{
public:
	void Frame();				//初始边框
	void Start();				//身份选择
	void Error(int flag);		//错误界面
	void Exit();				//退出程序
	bool SignIn();				//登录系统
	void SignOut();				//登出系统
	void ManagerMeun();			//管理员界面
	void Stock_In();  //快件入库
	void Stock_Pick();			//快件出库
	void SearchPackage(string text);
	void RecipientMeun();
	void ReadSurplusInfo();
	void SaveInfo();
	void StatisticsInfo();
	void WayBillSearch(int type);
	void CheckPackage(int type);

};

#endif

Cdate.cpp

#include "Cdate.h"
#include <string>

using namespace std;

string Cdate::DateToString(int y, int m, int d)
{
	// format  xxxx-xx-xx
	string yy, mm, dd, nowdate;
	yy = to_string(y);
	if (m < 10) mm = "0";
	else mm = "";
	mm += to_string(m);
	if (d < 10) dd = "0";
	else dd = "";
	dd += to_string(d);
	nowdate = yy + "-" + mm + "-" + dd;
	return nowdate;
}
void Cdate::DatetoCdate(string date)
{
	string y(date, 0, 4);
	string m(date, 5, 2);
	string d(date, 8, 2);
	int yy, mm, dd;
	yy = atoi(y.c_str());
	mm = atoi(m.c_str());
	dd = atoi(d.c_str());
	year = yy; month = mm; day = dd;
}
string Cdate::NowDate()
{
	time_t nowdate = time(0);
	struct tm dateinfo;
	localtime_s(&dateinfo, &nowdate);
	string yy, mm, dd, today;
	yy = to_string(dateinfo.tm_year + 1900);
	if (dateinfo.tm_mon + 1 < 10) mm = "0";
	else mm = "";
	mm += to_string(dateinfo.tm_mon + 1);
	if (dateinfo.tm_mday < 10) dd = "0";
	else dd = "";
	dd += to_string(dateinfo.tm_mday);
	today = yy + "-" + mm + "-" + dd;
	return today;
}
bool Cdate::IsLeapYear()
{
	if (year % 4 == 0 && year % 100 != 0) return 1;
	else if (year % 400 == 0) return 1;
	else return 0;
}

Locker.cpp

#include "Locker.h"
#include "Cdate.h"
#include <fstream>
#include <sstream>

using namespace std;
extern Cdate Date;

Locker::Locker()
{
	LockerID = "00";
	for (int i = 0; i < 6; i++) while (!Locker_Floor[i].empty()) Locker_Floor[i].pop_back();
	Size_All = 0;
	for (int i = 0; i < 6; i++) Size_Floor[i] = 0;
}
void Locker::Stock_In(Package& P)
{
	int F = 1;
	while (F < 6 && Size_Floor[F] >= 10) F++;
	Size_Floor[F]++;
	Size_All++;
	string SearchIDEven = LockerID + to_string(0) + to_string(F) + P.GetSearchID();
	P.SetSearchID(SearchIDEven);
	P.SetDate(Date.NowDate());
	P.SetStores(false);
	Locker_Floor[F].push_back(P);
}
bool Locker::SearchPackage(Package** P,string method)
{
	vector<Package>::iterator it;
	if (method == "SearchID")
	{
		string Floor((*P)->GetSearchID(), 2, 2);
		int F = atoi(Floor.c_str());
		for (it = Locker_Floor[F].begin(); it != Locker_Floor[F].end(); it++)
		{
			if (it->GetSearchID() == (*P)->GetSearchID())
			{
				delete* P;
				*P = &*it;
				return true;
			}
		}
		*P = NULL;
		return false;
	}
	else
	{
		for (int F = 1; F < 6; F++)
		{
			if (Locker_Floor[F].empty()) continue;
			for (it = Locker_Floor[F].begin(); it != Locker_Floor[F].end();it++)
			{
				if (it->GetRecPhone() == (*P)->GetRecPhone())
				{
					delete* P;
					*P = &*it;
					return true;
				}
			}
		}
		return false;
	}
}
bool Locker::IsLockerFull()
{
	if (Size_All >= 50) return true;
	else return false;
}
bool Locker::IsFloorFull(int Floor)
{
	if (Size_Floor[Floor] >= 10) return true;
	else return false;
}
bool Locker::IsLockerEmpty()
{
	if (Size_All == 0) return true;
	else return false;
}
void Locker::ReadInfo(Package& P)
{
	string Floor(P.GetSearchID(), 2, 2);
	int F = atoi(Floor.c_str());
	Size_Floor[F]++;
	Size_All++;
	Locker_Floor[F].push_back(P);
}
void Locker::SaveInfo()
{
	string today = Date.NowDate();
	string local = "history\\" + today + ".csv";
	fstream ioFile;
	ioFile.open(local, ios::app);
	vector<Package>::iterator it;
	for (int F = 1; F < 6; F++)
	{
		if (Locker_Floor[F].empty()) continue;
		for (it = Locker_Floor[F].begin(); it != Locker_Floor[F].end(); it++)
		{
			if (it->GetStores() == false && it->GetDate() == today)
			{
				it->SetStores(true);
				ioFile << it->GetWaybillNum() << ",";
				ioFile << it->GetExpressCompany() << ",";
				ioFile << it->GetRecipient() << ",";
				ioFile << it->GetRecPhone() << ",";
				ioFile << it->GetSenAddress() << ",";
				ioFile << it->GetRecZip() << ",";
				ioFile << it->GetSender() << ",";
				ioFile << it->GetSenPhone() << ",";
				ioFile << it->GetSenAddress() << ",";
				ioFile << it->GetSenZip() << ",";
				ioFile << it->GetSearchID() << ",";
				ioFile << it->GetState() << ",";
				ioFile << it->GetDate() << ",";
				ioFile << it->GetStores() << endl;
			}
		}
	}
	ioFile.close();
	string path = "surplus.csv";
	ioFile.open(path, ios::out);
	for (int F = 1; F < 6; F++)
	{
		if (Locker_Floor[F].empty()) continue;
		for (it = Locker_Floor[F].begin(); it != Locker_Floor[F].end(); it++)
		{
			if (it->GetState() == false)
			{
				ioFile << it->GetWaybillNum() << ",";
				ioFile << it->GetExpressCompany() << ",";
				ioFile << it->GetRecipient() << ",";
				ioFile << it->GetRecPhone() << ",";
				ioFile << it->GetSenAddress() << ",";
				ioFile << it->GetRecZip() << ",";
				ioFile << it->GetSender() << ",";
				ioFile << it->GetSenPhone() << ",";
				ioFile << it->GetSenAddress() << ",";
				ioFile << it->GetSenZip() << ",";
				ioFile << it->GetSearchID() << ",";
				ioFile << it->GetState() << ",";
				ioFile << it->GetDate() << ",";
				ioFile << it->GetStores() << endl;
			}
		}
	}
	ioFile.close();
}

Manager.cpp

#include <string>
#include "Manager.h"
#include "Locker.h"
#include "Package.h"
#include <map>

using namespace std;

extern Locker Lock[21];

bool Manager::Stock_In(Package& P)
{
	int LockNum = 1;
	string ID;
	while (LockNum<=20 && Lock[LockNum].IsLockerFull()) LockNum++;
	if (LockNum == 21) return false;
	Lock[LockNum].Stock_In(P);
	return true;
}
void Manager::SearchPackage(Package** SP,string method)
{
	if (method == "SearchID")
	{
		string LockNum((*SP)->GetSearchID(), 0, 2);
		int L = atoi(LockNum.c_str());
		Lock[L].SearchPackage(SP,method);
		return;
	}
	else
	{
		for (int L = 1; L < 21; L++)
		{
			if (Lock[L].IsLockerEmpty()) continue;
			bool flag = Lock[L].SearchPackage(SP, method);
			if (flag) return;
		}
		*SP = NULL;
		return;
	}

	
}
void Manager::ReadInfo(Package& P)
{
	string LockNum(P.GetSearchID(), 0, 2);
	int L = atoi(LockNum.c_str());
	Lock[L].ReadInfo(P);
}
void Manager::SaveInfo()
{
	for (int i = 1; i < 21; i++)
	{	
		Lock[i].SaveInfo();
	}
}

Package.cpp

#include <cstdlib>
#include "Package.h"
#include <ctime>
#include <iostream>

using namespace std;

Package::Package()
{
	srand((unsigned)time(0));
	SearchID = to_string((rand() % 9000) + 1000);
	State = false;
}
bool Package::operator==(Package& temp)
{
	if (RecPhone == temp.GetRecPhone()) return true;
	else if (SearchID == temp.GetSearchID()) return true;
	else return false;
}
void Package::ShowInfo()
{
	cout << "-----------------------------------" << endl;
	cout << "  快递单号:" << WaybillNum << endl;
	cout << "  快递公司:" << ExpressCompany << endl;
	cout << "  收件人:" << Recipient << endl;
	cout << "  收件人手机号:" << RecPhone << endl;
	cout << "  收件人地址:" << RecAddress << endl;
	cout << "  收件人邮编:" << RecZip << endl;
	cout << "  寄件人" << Sender << endl;
	cout << "  寄件人手机号" << SenPhone << endl;
	cout << "  寄件人地址" << SenAddress << endl;
	cout << "  寄件人邮编" << SenZip << endl;
	cout << "  取件码:" << SearchID << endl;
	cout << "  取件状态:" << (State == true ? "已取件" : "未取件") << endl;
}

System.cpp

#include "System.h"
#include "Cdate.h"
#include <iostream>
#include <string>
#include <conio.h>
#include <windows.h>
#include "Manager.h"
#include <fstream>
#include <sstream>
#include <vector>
#include <map>
#include <iomanip>

using namespace std;

extern HANDLE hOut;
extern CONSOLE_CURSOR_INFO _Close_Cursor;
extern CONSOLE_CURSOR_INFO _Open_Cursor;
extern Manager MAN;
extern Cdate Date;

void System::Frame()
{
	system("cls");
	COORD pos;
	string num1(60, '*');
	pos = { 0,0 };
	SetConsoleCursorPosition(hOut, pos);
	cout << num1;
	for (SHORT i = 1; i < 19; i++)
	{
		pos = { 0,i };
		SetConsoleCursorPosition(hOut, pos);
		cout << "*";
		pos = { 59,i };
		SetConsoleCursorPosition(hOut, pos);
		cout << "*";
	}
	pos = { 0,19 };
	SetConsoleCursorPosition(hOut, pos);
	cout << num1;
}
void System::Start()
{
	Frame();
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	pos = { 20,3 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "欢迎使用快件管理系统";
	pos = { 22,4 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "日期:" << Date.NowDate();
	pos = { 23,5 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请选择您的身份";
	pos = { 26,8 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "1.管理员";
	pos = { 26,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "2.取件人";
	pos = { 26,12 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "3.退出系统";
	pos = { 19,15 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入您的选择:【   】";
	pos = { 37,15 };
	SetConsoleCursorPosition(hOut, pos);
}
void System::Error(int flag)
{
	Frame();
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	if (flag == 1)
	{
		pos = { 25,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "输入错误!";
	}
	else if(flag == 2)
	{
		pos = { 18,9 };
		SetConsoleCursorPosition(hOut,pos);
		cout << "错误次数过多,请稍后再试";
	}
	else if(flag == 3)
	{
		pos = { 21,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "货架已满未找到空位";
	}
	else
	{
		pos = { 25,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "查无此件!";
	}
	
	cin.get();
	cin.get();
}
void System::Exit()
{
	Frame();
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	pos = { 23,8 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "感谢您的使用";
	pos = { 27,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "Bye!";
	Sleep(1000);
	exit(0);
}
bool System::SignIn()
{
	string Username;
	string Password;
	Frame();
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	pos = { 19,8 };
	SetConsoleCursorPosition(hOut,pos);
	cout << "请输入账号: ";
	cin >> Username;
	pos = { 19,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入密码: ";
	cin >> Password;
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	if (Username == MAN.GetUsername() && Password == MAN.GetPassword())
	{
		Frame();
		pos = { 25,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "登陆成功";
		Sleep(500);
		return true;
	}
	else
	{
		Frame();
		pos = { 24,9 };
		SetConsoleCursorPosition(hOut, pos);
		if (Username != MAN.GetUsername())
		{
			cout << "该账号不存在";
			Sleep(1500);
			return false;
		}
		else
		{
			cout << "密码输入错误";
			Sleep(1500);
			return false;

		}
	}
}
void System::SignOut()
{
	Frame();
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	pos = { 25,9 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "登出成功";
	Sleep(1000);
}
void System::ManagerMeun()
{
	Frame();
	COORD pos;
	int choise = 0;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	pos = { 19,2 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "当前身份:管理员 " << MAN.GetUsername();
	pos = { 22,3 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "日期:" << Date.NowDate();
	pos = { 25,4 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "功能列表";
	pos = { 14,6 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "1.录入快件";
	pos = { 36,6 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "2.取出快件";
	pos = { 14,8 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "3.查找快件";
	pos = { 36,8 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "4.删除快件";
	pos = { 14,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "5.修改快件";
	pos = { 36,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "6.查询未取快件";
	pos = { 14,12 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "7.查询新进快件";
	pos = { 36,12 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "8.查询已取快件";
	pos = { 14,14 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "9.统计信息";
	pos = { 36,14 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "0.退出登录";
	pos = { 20,16 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请选择功能: 【   】";
	pos = { 35,16 };
	SetConsoleCursorPosition(hOut, pos);
}
void System::Stock_In()
{
	Frame();
	Package* P = new Package;
	char state = 'n';
	string temp;
	COORD pos;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	while (state == 'n')
	{
		Frame();
		pos = { 10,3 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入快递单号: ";
		cin >> temp;	P->SetWaybillNum(temp);
		pos = { 10,4 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入快递公司: ";
		cin >> temp;	P->SetExpressCompany(temp);
		pos = { 10,5 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入收件人: ";
		cin >> temp;	P->SetRecipient(temp);
		pos = { 10,6 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入收件人联系方式: ";
		cin >> temp;	P->SetRecPhone(temp);
		pos = { 10,7 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入收件人地址: ";
		cin >> temp;	P->SetRecAddress(temp);
		pos = { 10,8 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入收件人邮编: ";
		cin >> temp;	P->SetRecZip(temp);
		pos = { 10,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入寄件人: ";
		cin >> temp;	P->SetSender(temp);
		pos = { 10,10 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入寄件人联系方式: ";
		cin >> temp;	P->SetSenPhone(temp);
		pos = { 10,11 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入寄件人地址: ";
		cin >> temp;	P->SetSenAddress(temp);
		pos = { 10,12 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入寄件人邮编: ";
		cin >> temp;	P->SetSenZip(temp);
		Sleep(100);
		Frame();
		pos = { 10,4 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "快递单号:" << P->GetWaybillNum();
		pos = { 10,5 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "快递公司:" << P->GetExpressCompany();
		pos = { 10,6 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "收件人:" << P->GetRecipient();
		pos = { 10,7 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "收件人联系方式:" << P->GetRecPhone();
		pos = { 10,8 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "收件人地址:" << P->GetRecAddress();
		pos = { 10,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "收件人邮编:" << P->GetRecZip();
		pos = { 10,10 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "寄件人:" << P->GetSender();
		pos = { 10,11 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "寄件人联系方式:" << P->GetSenPhone();
		pos = { 10,12 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "寄件人地址:" << P->GetSenAddress();
		pos = { 10,13 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "寄件人邮编:" << P->GetSenZip();
		pos = { 15,15 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请确认输入是否正确(y/n): ";
		cin >> state;
	}
	Frame();
	if (MAN.Stock_In(*P))
	{
		SetConsoleCursorInfo(hOut, &_Close_Cursor);
		pos = { 25,8 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "录入成功";
		pos = { 20,10 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "取件码: " << P->GetSearchID();
		delete P;
		cin.get();
		cin.get();
	}
	else Error(3);
}
void System::SearchPackage(string text)
{
	Frame();
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	Package* SP = new Package;
	string temp;
	COORD pos;
	
	if (text == "Manager")
	{
		int state = 0;
		pos = { 10,4 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入查询方式:【   】";
		pos = { 10,5 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "1.手机号 2.取件码";
		pos = { 29,4 };
		SetConsoleCursorPosition(hOut, pos);
		cin >> state;
		if (state == 1)
		{
			pos = { 10,6 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "请输入手机号: ";
			cin >> temp;
			SP->SetRecPhone(temp);
			MAN.SearchPackage(&SP, "phone");
		}
		else
		{
			pos = { 10,6 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "请输入取件码: ";
			cin >> temp;
			SP->SetSearchID(temp);
			MAN.SearchPackage(&SP, "SearchID");
		}

	}
	else
	{
		pos = { 10,4 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "请输入手机号: ";
		cin >> temp;
		SP->SetRecPhone(temp);
		MAN.SearchPackage(&SP, "phone");
	}
	Frame();
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	if (SP != NULL)
	{
		if (text == "Manager")
		{
			pos = { 10,5 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件人手机号:" << (SP)->GetRecPhone();
			pos = { 10,7 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件码:" << (SP)->GetSearchID();
			pos = { 10,9 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件成功";
			(SP)->SetState(true);
		}
		else
		{
			pos = { 10,7 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件人手机号:" << (SP)->GetRecPhone();
			pos = { 10,9 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件码:" << (SP)->GetSearchID();
			pos = { 10,11 };
			SetConsoleCursorPosition(hOut, pos);
			cout << "取件状态:";
			if ((SP)->GetState()) cout << "已取件";
			else cout << "未取件";
		}
		SP = NULL;
		cin.get();
		cin.get();
	}
	else Error(4);
}
void System::RecipientMeun()
{
	Frame();
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	COORD pos;
	int choise = 1;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	pos = { 19,2 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "当前身份:取件人 " << MAN.GetUsername();
	pos = { 25,4 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "功能列表";
	pos = { 25,7 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "1.查询快件";
	pos = { 25,9 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "2.返回";
	pos = { 20,11 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请选择功能: 【   】";
	pos = { 35,11 };
	SetConsoleCursorPosition(hOut, pos);
}
void System::ReadSurplusInfo()
{
	fstream ioFile;
	ioFile.open("surplus.csv", ios::in);
	string line;
	while (getline(ioFile, line))
	{
		istringstream sin(line);
		Package* P = new Package;
		vector<string> fields;
		string field;
		fields.clear();
		while (getline(sin, field, ','))
		{
			fields.push_back(field);
		}
		P->SetWaybillNum(fields[0]);
		P->SetExpressCompany(fields[1]);
		P->SetRecipient(fields[2]);
		P->SetRecPhone(fields[3]);
		P->SetRecAddress(fields[4]);
		P->SetRecZip(fields[5]);
		P->SetSender(fields[6]);
		P->SetSenPhone(fields[7]);
		P->SetSenAddress(fields[8]);
		P->SetSenZip(fields[9]);
		P->SetSearchID(fields[10]);
		if (fields[11] == "0") P->SetState(false);
		else P->SetState(true);
		P->SetDate(fields[12]);
		if (fields[13] == "0") P->SetStores(false);
		else P->SetStores(true);

		MAN.ReadInfo(*P);
	}
	ioFile.close();

}
void System::SaveInfo()
{
	MAN.SaveInfo();
	system("cls");
}
void System::StatisticsInfo()
{
	Frame();
	string begin, end;
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	COORD pos;
	pos = { 21,7 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入查询起止日期";
	pos = { 17,9 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入开始日期:";
	pos = { 33,9 };
	SetConsoleCursorPosition(hOut, pos);
	cin >> begin;
	pos = { 17,11 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入结束日期:";
	pos = { 33,11 };
	SetConsoleCursorPosition(hOut, pos);
	cin >> end;

	system("cls");
	vector<Package> StatisticsInfo;
	StatisticsInfo.clear();
	int RecCount = 0, PickCount = 0, NoPickCount = 0;
	map<string, int> ExpRecCount; ExpRecCount.clear();
	map<string, int> ExpPickCount;	ExpPickCount.clear();
	map<string, int> ExpNoPickCount;	ExpNoPickCount.clear();
	map<int, int > mon = { {1,31},{2,28},{3,31},{4,30},{5,31},{6,30},{7,31},{8,31},{9,30},{10,31},{11,30},{12,31} };
	vector<string> time;
	Cdate Begin, End,Now;
	Begin.DatetoCdate(begin);
	End.DatetoCdate(end);
	time.clear();
	if (Begin.IsLeapYear()) mon[2]++;
	for (int y = Begin.GetYear(); y <= End.GetYear(); y++)
	{
		for (int m = Begin.GetMonth(); m <= ((y == End.GetYear()) ? End.GetMonth() : 12); m++)
		{
			for (int d = Begin.GetDay(); d <= ((y == End.GetYear() && m == End.GetMonth()) ? End.GetDay() : mon[m]); d++)
			{
				time.push_back(Now.DateToString(y, m, d));
			}
		}
	}
	fstream ioFile;
	vector<string>::iterator it;
 	for (it = time.begin(); it != time.end(); it++)   //读入数据至StatisticsInfo中
	{
		string path = "history\\" + *it + ".csv";
		ioFile.open(path, ios::in);
		string line;
		while (getline(ioFile, line))
		{
			istringstream sin(line);
			Package* P = new Package;
			vector<string> fields;
			string field;
			fields.clear();
			while (getline(sin, field, ','))
			{
				fields.push_back(field);
			}
			P->SetWaybillNum(fields[0]);
			P->SetExpressCompany(fields[1]);
			P->SetRecipient(fields[2]);
			P->SetRecPhone(fields[3]);
			P->SetRecAddress(fields[4]);
			P->SetRecZip(fields[5]);
			P->SetSender(fields[6]);
			P->SetSenPhone(fields[7]);
			P->SetSenAddress(fields[8]);
			P->SetSenZip(fields[9]);
			P->SetSearchID(fields[10]);
			if (fields[11] == "0") P->SetState(false);
			else P->SetState(true);
			P->SetDate(fields[12]);
			if (fields[13] == "0") P->SetStores(false);
			else P->SetStores(true);
			StatisticsInfo.push_back(*P);
		}
		ioFile.close();
	}

	vector<Package>::iterator Pit;
	for (Pit = StatisticsInfo.begin(); Pit != StatisticsInfo.end(); Pit++)
	{
		RecCount++;
		ExpRecCount[Pit->GetExpressCompany()]++;
		if (Pit->GetState())
		{
			PickCount++;
			ExpPickCount[Pit->GetExpressCompany()]++;
		}
		else
		{
			NoPickCount++;
			ExpNoPickCount[Pit->GetExpressCompany()]++;
		}
	}

	Frame();
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	pos = { 24,3 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "收件量: " << RecCount;
	pos = { 24,4 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "取件量: " << PickCount;
	pos = { 24,5 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "未取件量: " << NoPickCount;
	pos = { 16,8 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     取件量    取件量    未取件量" << endl;
	cout << setiosflags(ios::right);
	pos = { 2,9 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     中国邮政" << setw(10) << ExpRecCount["EMS"] << setw(10) << ExpPickCount["EMS"] << setw(10) << ExpNoPickCount["EMS"];
	pos = { 2,10 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     顺丰快递" << setw(10) << ExpRecCount["顺丰"] << setw(10) << ExpPickCount["顺丰"] << setw(10) << ExpNoPickCount["顺丰"];
	pos = { 2,11 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     中通快递" << setw(10) << ExpRecCount["中通"] << setw(10) << ExpPickCount["中通"] << setw(10) << ExpNoPickCount["中通"];
	pos = { 2,12 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     圆通快递" << setw(10) << ExpRecCount["圆通"] << setw(10) << ExpPickCount["圆通"] << setw(10) << ExpNoPickCount["圆通"];
	pos = { 2,13 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     申通快递" << setw(10) << ExpRecCount["申通"] << setw(10) << ExpPickCount["申通"] << setw(10) << ExpNoPickCount["申通"];
	pos = { 2,14 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     韵达快递" << setw(10) << ExpRecCount["韵达"] << setw(10) << ExpPickCount["韵达"] << setw(10) << ExpNoPickCount["韵达"];
	pos = { 2,15 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     百世快递" << setw(10) << ExpRecCount["百世"] << setw(10) << ExpPickCount["百世"] << setw(10) << ExpNoPickCount["百世"];
	pos = { 2,16 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "     其他快递" << setw(10) << RecCount - ExpRecCount["EMS"] - ExpRecCount["顺丰"] - ExpRecCount["中通"] - ExpRecCount["圆通"] - ExpRecCount["申通"] - ExpRecCount["韵达"] - ExpRecCount["百世"] << setw(10) << PickCount - ExpPickCount["EMS"] - ExpPickCount["顺丰"] - ExpPickCount["中通"] - ExpPickCount["圆通"] - ExpPickCount["申通"] - ExpPickCount["韵达"] - ExpPickCount["百世"] << setw(10) << NoPickCount - ExpNoPickCount["EMS"] - ExpNoPickCount["顺丰"] - ExpNoPickCount["中通"] - ExpNoPickCount["圆通"] - ExpNoPickCount["申通"] - ExpNoPickCount["韵达"] - ExpNoPickCount["百世"];
	cin.get();
	cin.get();
}
void System::WayBillSearch(int type)
{
	SaveInfo();
	SetConsoleCursorInfo(hOut, &_Open_Cursor);
	Frame();
	COORD pos;
	string waybill;
	vector<Package> order;		order.clear();
	pos = { 26,2 };
	SetConsoleCursorPosition(hOut, pos);
	if (type == 1) cout << "查询订单";
	else if (type == 2) cout << "修改订单";
	else cout << "删除订单";
	pos = { 10,3 };
	SetConsoleCursorPosition(hOut, pos);
	cout << "请输入订单号:";
	pos = { 24,3 };
	SetConsoleCursorPosition(hOut, pos);
	cin >> waybill;
	fstream ioFile;
	string today = Date.NowDate();
	string path = "history\\" + today + ".csv";
	ioFile.open(path, ios::in);
	string line;
	while (getline(ioFile, line))
	{
		istringstream sin(line);
		Package* P = new Package;
		vector<string> fields;
		string field;
		fields.clear();
		while (getline(sin, field, ','))
		{
			fields.push_back(field);
		}
		P->SetWaybillNum(fields[0]);
		P->SetExpressCompany(fields[1]);
		P->SetRecipient(fields[2]);
		P->SetRecPhone(fields[3]);
		P->SetRecAddress(fields[4]);
		P->SetRecZip(fields[5]);
		P->SetSender(fields[6]);
		P->SetSenPhone(fields[7]);
		P->SetSenAddress(fields[8]);
		P->SetSenZip(fields[9]);
		P->SetSearchID(fields[10]);
		if (fields[11] == "0") P->SetState(false);
		else P->SetState(true);
		P->SetDate(fields[12]);
		if (fields[13] == "0") P->SetStores(false);
		else P->SetStores(true);
		order.push_back(*P);
	}
	ioFile.close();

	int fflag = 1;
	vector<Package>::iterator it;
	string text;
	switch (type)
	{
	case 1:
		fflag = 1;
		SetConsoleCursorInfo(hOut, &_Close_Cursor);
		for (it = order.begin(); it != order.end(); it++)
		{
			if (it->GetWaybillNum() == waybill)
			{
				pos = { 10,5 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "快递单号:" << it->GetWaybillNum();
				pos = { 10,6 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "快递公司:" << it->GetExpressCompany();
				pos = { 10,7 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "收件人:" << it->GetRecipient();
				pos = { 10,8 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "收件人联系方式:" << it->GetRecPhone();
				pos = { 10,9 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "收件人地址:" << it->GetRecAddress();
				pos = { 10,10 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "收件人邮编:" << it->GetRecZip();
				pos = { 10,11 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "寄件人:" << it->GetSender();
				pos = { 10,12 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "寄件人联系方式:" << it->GetSenPhone();
				pos = { 10,13 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "寄件人地址:" << it->GetSenAddress();
				pos = { 10,14 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "寄件人邮编:" << it->GetSenZip();
				pos = { 10,15 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "取件码:" << it->GetSearchID();
				pos = { 10,16 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "是否取件:" << (it->GetState() == true ? "已取件" : "未取件") << endl;
				fflag = 0;
				break;
			}
		}
		if (fflag) Error(4);
		break;
	case 2:
		fflag = 1;
		Frame();
		SetConsoleCursorInfo(hOut, &_Open_Cursor);
		for (it = order.begin(); it != order.end(); it++)
		{
			if (it->GetWaybillNum() == waybill)
			{
				pos = { 10,3 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入新的快递信息:";
				pos = { 10,5 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入快递单号: ";
				cin >> text;	it->SetWaybillNum(text);
				pos = { 10,6 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入快递公司: ";
				cin >> text;	it->SetExpressCompany(text);
				pos = { 10,7 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入收件人: ";
				cin >> text;	it->SetRecipient(text);
				pos = { 10,8 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入收件人联系方式: ";
				cin >> text;	it->SetRecPhone(text);
				pos = { 10,9 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入收件人地址: ";
				cin >> text;	it->SetRecAddress(text);
				pos = { 10,10 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入收件人邮编: ";
				cin >> text;	it->SetRecZip(text);
				pos = { 10,11 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入寄件人: ";
				cin >> text;	it->SetSender(text);
				pos = { 10,12 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入寄件人联系方式: ";
				cin >> text;	it->SetSenPhone(text);
				pos = { 10,13 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入寄件人地址: ";
				cin >> text;	it->SetSenAddress(text);
				pos = { 10,14 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "请输入寄件人邮编: ";
				cin >> text;	it->SetSenZip(text);
				SetConsoleCursorInfo(hOut, &_Close_Cursor);
				pos = { 20,16 };
				SetConsoleCursorPosition(hOut, pos);
				cout << "输入完成";
				fflag = 0;
				break;
			}
		}
		if (fflag) Error(4);
		break;
	case 3:
		fflag = 1;
		SetConsoleCursorInfo(hOut, &_Close_Cursor);
		for (it = order.begin(); it != order.end(); it++)
		{
			if (it->GetWaybillNum() == waybill)
			{
				order.erase(it);
				fflag = 0;
				break;
			}
		}
		Frame();
		pos = { 26,9 };
		SetConsoleCursorPosition(hOut, pos);
		cout << "删除成功";
		if (fflag) Error(4);
		break;
	}
	ioFile.open(path, ios::out);
	for (it = order.begin(); it != order.end(); it++)
	{
		ioFile << it->GetWaybillNum() << ",";
		ioFile << it->GetExpressCompany() << ",";
		ioFile << it->GetRecipient() << ",";
		ioFile << it->GetRecPhone() << ",";
		ioFile << it->GetSenAddress() << ",";
		ioFile << it->GetRecZip() << ",";
		ioFile << it->GetSender() << ",";
		ioFile << it->GetSenPhone() << ",";
		ioFile << it->GetSenAddress() << ",";
		ioFile << it->GetSenZip() << ",";
		ioFile << it->GetSearchID() << ",";
		ioFile << it->GetState() << ",";
		ioFile << it->GetDate() << ",";
		ioFile << it->GetStores() << endl;
	}
	ioFile.close();
	cin.get();
	cin.get();

}
void System::CheckPackage(int type)
{
	system("cls");
	SaveInfo();
	COORD dSize = { 60,5000 };
	SetConsoleCursorInfo(hOut, &_Close_Cursor);
	SetConsoleScreenBufferSize(hOut, dSize);
	vector<Package> NewPackage;	NewPackage.clear();
	vector<Package> PickPackage;	PickPackage.clear();
	vector<Package> NoPickPackage;	NoPickPackage.clear();
	fstream ioFile;
	string today = Date.NowDate();
	string path = "history\\" + today + ".csv";
	ioFile.open(path, ios::in);
	string line;
	while (getline(ioFile, line))
	{
		istringstream sin(line);
		Package* P = new Package;
		vector<string> fields;
		string field;
		fields.clear();
		while (getline(sin, field, ','))
		{
			fields.push_back(field);
		}
		P->SetWaybillNum(fields[0]);
		P->SetExpressCompany(fields[1]);
		P->SetRecipient(fields[2]);
		P->SetRecPhone(fields[3]);
		P->SetRecAddress(fields[4]);
		P->SetRecZip(fields[5]);
		P->SetSender(fields[6]);
		P->SetSenPhone(fields[7]);
		P->SetSenAddress(fields[8]);
		P->SetSenZip(fields[9]);
		P->SetSearchID(fields[10]);
		if (fields[11] == "0") P->SetState(false);
		else P->SetState(true);
		P->SetDate(fields[12]);
		if (fields[13] == "0") P->SetStores(false);
		else P->SetStores(true);

		NewPackage.push_back(*P);
		if (P->GetState()) PickPackage.push_back(*P);
		else NoPickPackage.push_back(*P);
	}
	ioFile.close();
	vector<Package>::iterator it;
	cout << endl;
	switch (type)
	{
	case 1:
		cout << "今日新进快件:" << endl;
		for (it = NewPackage.begin(); it != NewPackage.end(); it++)
		{
			it->ShowInfo();
		}
		break;
	case 2:
		cout << "今日已取快件:" << endl;
		for (it = PickPackage.begin(); it != PickPackage.end(); it++)
		{
			it->ShowInfo();
		}
		break;
	case 3:
		cout << "未取快件" << endl;
		for (it = NoPickPackage.begin(); it != NoPickPackage.end(); it++)
		{
			it->ShowInfo();
		}
		break;
	default:
		break;
	}
	cout << "-----------------------------------" << endl;
	cout << "按Enter键返回"<<endl;
	cin.get();
	cin.get();
}

main.cpp

#include <iostream>
#include <direct.h>
#include <conio.h>
#include <cstdio>
#include <stdlib.h>
#include <windows.h>
#include "System.h"
#include "Package.h"
#include "Locker.h"
#include "Manager.h"
#include "Cdate.h"

using namespace std;

HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO _Close_Cursor = { 1,FALSE };
CONSOLE_CURSOR_INFO _Open_Cursor = { 1,TRUE };

Cdate Date;
System SYS;
Manager MAN;
Locker Lock[21];

int main()
{
	SetConsoleTitle(L"快件管理系统");
	for (int i = 1; i < 21; i++)	//初始化柜台编号
	{
		if (i < 10) Lock[i].SetLockerID(to_string(0) + to_string(i));
		else Lock[i].SetLockerID(to_string(i));
	} 
	system("mode con cols=60 lines=20");
	system("md history");
	SYS.ReadSurplusInfo();
	SYS.Start();
	while (1)
	{	
		system("cls");
		SYS.Start();
		int mode = 1;
		cin >> mode;
		
		if (mode == 1)			//管理员功能
		{
			int flag = 1;	//登录次数  3次超时
			int choice = 10;
			while (!SYS.SignIn() && flag<3)
			{
				flag++;
			}
			if (flag == 3)
			{
				SYS.Error(2);
				continue;
			}
			while (choice != 0)
			{
				SYS.ManagerMeun();
				cin >> choice;
				switch (choice)
				{
				case 0:					//退出登录
					SYS.SaveInfo();
					SYS.SignOut();
					break;
				case 1:					//录入快件
					SYS.Stock_In();
					break;
				case 2:					//查找快件
					SYS.SearchPackage("Manager");
					break;
				case 3:
					SYS.WayBillSearch(1);
					break;
				case 4:
					SYS.WayBillSearch(3);
					break;
				case 5:
					SYS.WayBillSearch(2);
					break;
				case 6:
					SYS.CheckPackage(3);
					break;
				case 7:
					SYS.CheckPackage(1);
					break;
				case 8:
					SYS.CheckPackage(2);
					break;
				case 9:
					SYS.SaveInfo();
					SYS.StatisticsInfo();
					break;
				default:
					SYS.Error(1);
					break;
				}
			}
		}
		else if(mode ==2)		//收件人功能
		{
			int choise = 1;

			while (choise != 2)
			{
				SYS.RecipientMeun();
				cin >> choise;
				switch (choise)
				{
				case 1:
					SYS.SearchPackage("Recipient");
					break;
				default:
					break;
				}
			}
		}
		else if (mode == 3)		//退出系统
		{
			SYS.SaveInfo();
			SYS.Exit();
		}
		else					//错误输入
		{
			SYS.Error(1);
		}
	}
	return 0;
}

六、 运行结果与分析
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

七、 心得与体会
优化:可以将收件人取件人的身份信息等单独抽象成一个类。

这是简略版,完整内容请下载附件查看

附件:
资源下载
资料包括测试数据文件,可执行程序,实验报告,以及源代码
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_30445397/article/details/107890539