#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;
}