数据结构课程设计 财务管理系统

#include<iostream>
#include<vector>
#include<fstream>
#include<sstream>
#include<string>
using namespace std;
//报销人员信息
typedef struct bxpeople{
	//报销人工号
	string bxid;
	//姓名
	string name;
	//联系电话
	string phonenumber;
}bxpeople;
//审批人员信息
typedef struct sppeople {
	//审批人工号
	string spid;
	string name;
	string phonenumber;
	//角色(职位)
	string character;
}sppeople;
//额度授权表
typedef struct limittable {
	string character;
	//额度
	string limitmoney;
	//审批人工号
	string spid;
}limittable;
//报销单
typedef struct bxtable {
	//报销单编号
	string billid;
	//提单人工号
	string bxid;
	//提单金额
	string bxmoney;
	//提单日期
	string date;
	//状态
	string state;
	//审批人工号
	string spid;
}bxtable;
vector<bxpeople> bxp;
vector<sppeople> spp;
vector<limittable> ltt;
vector<bxtable> bxt;
void loaddata() {
	ifstream infile;
	//加载报销人员信息
	bxpeople bx1;
	infile.open("D://c++//数据结构课设//报销人员信息.txt", ios::in);
	if (!infile.is_open())
		cout << "读取文件失败1" << endl;
	else {
		while (infile >> bx1.bxid >> bx1.name >> bx1.phonenumber) {
			bxp.push_back(bx1);
		}
	}
	infile.close();

	//加载审批人员信息
	infile.open("D://c++//数据结构课设//审批人员信息.txt", ios::in);
	sppeople sp1;
	if (!infile.is_open())
		cout << "读取文件失败2" << endl;
	else {
		while (infile >> sp1.spid >> sp1.name >> sp1.phonenumber >> sp1.character)
			spp.push_back(sp1);
	}
	infile.close();

	//加载审批人额度授权表
	infile.open("D://c++//数据结构课设//审批人额度授权表.txt", ios::in);
	limittable lt1;
	if (!infile.is_open())
		cout << "读取文件失败3" << endl;
	else {
		while (infile>>lt1.character>>lt1.limitmoney>>lt1.spid) {
			ltt.push_back(lt1);
		}
	}
	infile.close();

	//加载报销单据状态
	infile.open("D://c++//数据结构课设//报销单状态.txt", ios::in);
	bxtable bx2;
	if (!infile.is_open())
		cout << "读取文件失败4" << endl;
	else {
		while (infile >> bx2.billid >> bx2.bxid >> bx2.bxmoney >> bx2.date >> bx2.state >> bx2.spid) {
			bxt.push_back(bx2);
		}
	}
	infile.close();
}
//欢迎界面
void welcome() {
	cout << "\t\t\t* 欢迎来到财务报销管理系统 *\n";
	cout << "\t*********************************************************** *\n";
	cout << "\t* [1] 增加员工信息                 [2] 删除员工信息         *\n";
	cout << "\t* [3] 修改员工信息                 [4] 查询员工信息         *\n";
	cout << "\t* [5] 添加审批人                   [6] 修改审批人额度       *\n";
	cout << "\t* [7] 提交报销单                   [8] 审批报销单           *\n";
	cout << "\t* [9] 查询报销单表                 [10] 退出管理系统        *\n";
	cout << "\t************************************************************\n";
	cout << "\t左边数字对应功能选择,请选1-8:";
	loaddata();
}
//增加新员工
void addInfo() {
	string bxid, name, phonenumber;
	cout << "请输入你要添加员工的信息:";
	cin >> bxid >> name >> phonenumber;
	bxp.push_back({ bxid,name,phonenumber });
	cout << "添加成功!" << endl;
}
//给出工号删除员工
void deleteInfo() {
	string bxid;
	cout << "请输入你要删除的员工的工号:";
	int flag = 0;
	while (flag == 0) {
		cin >> bxid;
		for (int i = 1; i < bxp.size(); i++) {
			if (bxp[i].bxid == bxid) {
				flag = 1;
				cout << "已找到该员工,其信息为:" << bxp[i].bxid << " " << bxp[i].name << bxp[i].phonenumber << endl;
				bxp.erase(bxp.begin() + i);
				cout << "删除成功!" << endl;
			}
		}
		if (flag == 0)
			cout << "未找到输入工号,请重新输入" << endl;
	}
}
//给出工号编辑该员工的信息
void editInfo() {
	string bxid;
	cout << "请输入你要修改的员工的工号:";
	int flag = 0;
	while (flag == 0) {
		cin >> bxid;
		for (int i = 1; i < bxp.size(); i++) {
			if (bxp[i].bxid == bxid) {
				flag = 1;
				cout << "已找到该员工,其当前信息为:" << bxp[i].bxid << " " << bxp[i].name << bxp[i].phonenumber << endl;
				cout << "请输入修改后的内容:";
				cin >> bxp[i].bxid >> bxp[i].name >> bxp[i].phonenumber;
				cout << "修改成功!" << endl;
			}
		}
		if (flag == 0)
			cout << "未找到输入工号,请重新输入" << endl;
	}
}
//给出工号查找该员工的信息
void findInfo() {
	string bxid;
	cout << "请输入你要查找的员工的工号:";
	int flag = 0;
	while (flag == 0) {
		cin >> bxid;
		for (int i = 1; i < bxp.size(); i++) {
			if (bxp[i].bxid == bxid) {
				flag = 1;
				cout << "已找到该员工,其信息为:" << bxp[i].bxid << " " << bxp[i].name <<"  " << bxp[i].phonenumber << endl;
			}
		}
		if (flag == 0)
			cout << "未找到输入工号,请重新输入" << endl;
	}
}
//增加新的审批人
void addspp() {
	string spid, name, phone, character;
	string money;
	cout << "请输入你要添加审批人的信息:";
	cin >> spid >> name >> phone >> character>>money;
	spp.push_back({ spid, name, phone, character });
	ltt.push_back({ character,money,spid });
	cout << "添加成功!" << endl;
}
//修改审批人额度授权
void editlimit() {
	string spid;
	cout << "请输入你要修改的审批人工号:";
	int flag = 0;
	while (flag == 0) {
		cin >> spid;
		for (int i = 1; i < ltt.size(); i++) {
			if (ltt[i].spid == spid) {
				flag = 1;
				cout << "已找到该审批人,其信息为:";
				cout << ltt[i].spid << " " << ltt[i].character << " " << ltt[i].limitmoney << endl;
				cout << "请输入你要修改的额度:";
				cin >> ltt[i].limitmoney;
				cout << "修改成功!" << endl;
			}
		}
		if (flag == 0)
			cout << "你输入的工号不存在,请重新输入" << endl;
	}
}
string code = "20220000";
//提交报销单
void submit() {
	string bxid,date,state,spid;
	string billid = code;
	cout << "请输入提单人的工号:";
	cin >> bxid;
	string money;
	cout << "请输入提单金额:";
	cin >> money;
	cout << "请输入提单日期:";
	cin >> date;
	state = "创建";
	spid = bxid;
	bxt.push_back({ billid,bxid,money,date,state,spid });
	code += 1;
	cout << "提交成功!" << endl;
}
//审批报销单
void spbxd() {
	string spid;
	cout << "请输入处理人工号:";
	cin >> spid;
	cout << "这是待你处理的报销单:" << endl;
	for (int i = 0; i < bxt.size(); i++) {
		if (bxt[i].spid == spid) {
			cout << "报销单编号:" << bxt[i].billid << " 提单人:" << bxt[i].bxid << " 提单金额:" << bxt[i].bxmoney << " 提单日期:" << bxt[i].date << " 状态:" << bxt[i].state << " 处理人:" << bxt[i].spid<<endl;
		}
	}
	string billid;
		cout << "请输入你要处理的报销单编号:";
		cin >> billid;
		for (int i = 0; i < bxt.size(); i++) {
			if (bxt[i].billid == billid) {
				cout << "请输入你的审批结果:(通过/驳回)";
				string state;
				cin >> state;
				if (state == "通过") {
					if (bxt[i].state == "创建") {
						bxt[i].state = "部门审批";
						if (bxt[i].bxmoney <= "50000") {
							for (int i = 0; i < spp.size(); i++) {
								if (spp[i].character == "部门副主管")
									spid = spp[i].spid;
							}
						}
						else if (bxt[i].bxmoney > "50000" && bxt[i].bxmoney <= "100000") {
							for (int i = 0; i < spp.size(); i++) {
								if (spp[i].character == "部门主管")
									spid = spp[i].spid;
							}
						}
					}
					else if (bxt[i].state == "部门审批") {
						bxt[i].state = "财务审批";
						if (bxt[i].bxmoney <= "50000") {
							for (int i = 0; i < spp.size(); i++) {
								if (spp[i].character == "财务副主管")
									spid = spp[i].spid;
							}
						}
						else if (bxt[i].bxmoney > "50000" && bxt[i].bxmoney <= "100000") {
							for (int i = 0; i < spp.size(); i++) {
								if (spp[i].character == "财务主管")
									spid = spp[i].spid;
							}
						}
					}
					else if (bxt[i].state == "财务审批") {
						bxt[i].state = "付款结束";
						bxt[i].spid = "";
					}
				}
				else {
					bxt[i].state = "创建";
				}
				cout << "处理成功!该报销单修改后的状态为:"<<bxt[i].state << endl;
			}
		}
}
//查询报销单表
void searchProcess() {
	string billid;
	int flag = 0;
	cout << "请输入你要查询的报销单编号:";
	cin >> billid;
	while (flag == 0) {
		for (int i = 0; i < bxt.size(); i++) {
			if (billid == bxt[i].billid) {
				flag = 1;
				cout << "这是你要查询的报销单:" << endl;
				cout << "报销单编号:" << bxt[i].billid << " 提单人:" << bxt[i].bxid << " 提单金额:" << bxt[i].bxmoney << " 提单日期:" << bxt[i].date << " 状态:" << bxt[i].state << " 处理人:" << bxt[i].spid<<endl;
			}
		}
	}
}
//选择执行的操作
void Menu_select() {
	//保存操作序号
	int index;
	while (true) {
		cin >> index;
		if (index < 1 || index>10) {
			cout << "输入的操作不存在,请重新输入:" << endl;
			continue;
		}
		//		操作对应的函数
		switch (index) {
			//增加员工信息
		case 1: {
			cout << "\t\t\t* 增加员工信息 *\n" << endl;
			addInfo();
			break;
		}
			  //删除员工信息
		case 2: {
			cout << "\t\t\t* 删除员工信息 *\n" << endl;
			deleteInfo();
			break;
		}
			  //修改员工信息
		case 3: {
			cout << "\t\t\t* 修改员工信息 *\n" << endl;
			editInfo();
			break;
		}
			  //查询员工信息
		case 4: {
			cout << "\t\t\t* 查询员工信息 *\n" << endl;
			findInfo();
			break;
		}
			  //添加审批人
		case 5: {
			cout << "\t\t\t* 添加审批人 *\n" << endl;
			addspp();
			break;
		}
			  //修改审批人额度授权
		case 6: {
			cout << "\t\t\t* 修改审批人额度授权 *\n" << endl;
			editlimit();
			break;
		}
			  //提交报销单
		case 7: {
			cout << "\t\t\t* 提交报销单 *\n" << endl;
			submit();
			break;
		}
			  //审批报销单
		case 8: {
			cout << "\t\t\t* 审批报销单 *\n" << endl;
			spbxd();
			break;
		}
			  //查询报销单表
		case 9: {
			cout << "\t\t\t* 查询报销单表 *\n" << endl;
			searchProcess();
			break;
		}
			  //退出管理系统
		case 10: {
			cout << "\t\t\t* 退出管理系统 *\n" << endl;
			return;
		}
		}
	}
}
	
void savedata() {
	//重写报销人员信息
	string file_name = "D://c++//数据结构课设//报销人员信息.txt";
	ofstream file_write1(file_name, ios_base::out);
	for (int i = 0; i < bxp.size(); i++) {
		file_write1 << bxp[i].bxid << "   " << bxp[i].name << "   " << bxp[i].phonenumber << "\n";
	}
	file_write1.close();
	 
	//重写审批人员信息
	file_name = "D://c++//数据结构课设//审批人员信息.txt";
	ofstream file_write2(file_name, ios_base::out);
	for (int i = 0; i < spp.size(); i++) {
		file_write2 << spp[i].spid << "   " << spp[i].name << "   " << spp[i].phonenumber << "   " << spp[i].character << "\n";
	}
	file_write2.close();

	//重写审批人额度授权表
	file_name = "D://c++//数据结构课设//审批人额度授权表.txt";
	ofstream file_write3(file_name, ios_base::out);
	for (int i = 0; i < ltt.size(); i++) {
		file_write3 << ltt[i].character << "   " << ltt[i].limitmoney << "   " << ltt[i].spid << "\n";
	}
	file_write3.close();

	//重写报销单状态
	file_name = "D://c++//数据结构课设//报销单状态.txt";
	ofstream file_write4(file_name, ios_base::out);
	for (int i = 0; i < bxt.size(); i++) {
		file_write4 << bxt[i].billid << "   " << bxt[i].bxid << "   " << bxt[i].bxmoney << "   " << bxt[i].date << "   " << bxt[i].state << "   " << bxt[i].spid << "\n";
	}
	file_write4.close();
}
int main() {
	//	向用户展示系统可进行的操作
	welcome();
	//选择执行的操作
	Menu_select();
	savedata();
	cout << "\t\t\t* 欢迎下次使用财务报销管理系统 *\n" << endl;
}

  • 7
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值