美发店管理系统
功能介绍
用户可以在主页面选择自己的身份(顾客/管理员),或者退出系统。如果选择顾客,则输入顾客的会员卡号进入美发项目菜单页面,选择想要做的美发项目或者退出系统,根据顾客选择的美发项目显示可以可为其服务的员工名单,顾客根据名单选择为其服务的员工,选择成功后,顾客的消费额对应增加,员工的收入对应增加。如果选择管理员,则需要输入管理员密码确认身份,共有3次输入密码的机会,确认身份后,进入美发店信息管理菜单,选择管理顾客信息或者员工信息或者退出系统,如果选择管理顾客,则进入顾客信息管理菜单,可以根据提示选择对顾客信息进行增加、删除、修改、查找和按消费金额排序等操作;如果选择管理员工,则进入员工信息管理菜单,可以根据提示对员工信息进行增加、删除、修改、查找和按收入排序等操作。
概要设计
美发店管理系统涉及顾客、员工、美发、管理四个对象,面向顾客和管理员两种角色,顾客具有选择美发项目、选择服务的员工等功能,管理员具有添加、查询、显示、编辑、删除、保存、读取顾客和员工信息的功能,还具有根据顾客的消费额、员工的收入进行排序的功能。
详细设计
定义存放顾客信息的结点
//定义存放顾客信息的结点
typedef struct CustomerNode //定义存放顾客信息的结构体
{
int Number; //会员卡号
string Name; //姓名
string Sex; //性别
string PhoneNumber; //电话号码
int Consumption; //消费额
struct CustomerNode *next; //指针域
}CustomerNode;
定义存放员工信息的结点
//定义存放员工信息的结点
typedef struct WorkerNode //定义存放员工信息的结构体
{
int Number; //编号
string Name; //姓名
string Sex; //性别
string PhoneNumber; //电话号码
string item; //美发项目
struct WorkerNode *next; //指针域
int Income; //收入
}WorkerNode;
声明顾客类
//声明顾客类
class Customer
{
private:
int m; //顾客总人数
public:
CustomerNode *LoadRecordFile(); //从文件中加载顾客信息
void Display(CustomerNode *head); //输出所有顾客的信息
void SaveRecordFile(CustomerNode *head); //保存顾客信息到文件
CustomerNode *AddCustomer(CustomerNode *head); //增加顾客信息
CustomerNode *FindRecordNumber(CustomerNode *head,int a); //查找
CustomerNode *DeleteRecord(CustomerNode *head); //删除顾客信息
CustomerNode *UpdateRecord(CustomerNode *head); //修改顾客信息
CustomerNode *Count(CustomerNode *head); //统计并按消费额排序
};
声明员工类
//声明员工类
class Worker
{
private:
int m; //员工总人数
public:
WorkerNode *LoadRecordFile(); //从文件中加载员工信息
void Display(WorkerNode *head); //输出所有员工的信息
void SaveRecordFile(WorkerNode *head); //保存员工信息到文件
WorkerNode *AddWorker(WorkerNode *head); //增加员工信息
WorkerNode *FindRecordNumber(WorkerNode *head,int a); //查找
WorkerNode *DeleteRecord(WorkerNode *head); //删除员工信息
WorkerNode *UpdateRecord(WorkerNode *head); //修改员工信息
WorkerNode *Count(WorkerNode *head); //统计并按收入排序
};
声明管理类
//声明管理类
class Manger
{
public:
Customer c; //定义一个顾客类对象
Worker w; //定义一个员工类对象
CustomerNode *h1,*p1; //定义指针变量h1,p1
WorkerNode *h2,*p2; //定义指针变量h2,p2
void Init(); //将h1,h2赋值为NULL
void MainMenu(); //管理功能主菜单
void CustomerMenu(); //顾客管理菜单
void WorkerMenu(); //员工管理菜单
};
声明美发类
//声明美发类
class ItemMenu()
{
public:
Customer cus; //定义一个顾客类对象
Worker work; //定义一个员工类对象
CustomerNode *h1,*c1; //定义指针变量h1,c1
WorkerNode *h2,*w1; //定义指针变量h2,w1
void Init(); //为h1,h2赋值
void ItemMenu(); //美发项目菜单
int WorkerShow(string a,int cost); //选择服务的员工
};
声明菜单选择函数
//声明菜单选择函数
void Salonmeun(); //菜单选择函数
主函数
//主函数
int main() //主函数
{
Salonmeun();
return 0;
}
源程序清单
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
typedef struct CustomerNode //定义存放顾客信息的结构体
{
int Number; //会员卡号
string Name; //姓名
string Sex; //性别
string PhoneNumber; //电话号码
int Consumption; //消费额
struct CustomerNode *next; //指针域
}CustomerNode;
typedef struct WorkerNode //定义存放员工信息的结构体
{
int Number; //编号
string Name; //姓名
string Sex; //性别
string PhoneNumber; //电话号码
string item; //美发项目
struct WorkerNode *next; //指针域
int Income; //收入
}WorkerNode;
class Customer //定义顾客类
{
private:
int m; //记录顾客的人数
public:
CustomerNode *LoadRecordFile() //从文件中加载顾客信息
{
m=0;
CustomerNode *p1,*p2;
CustomerNode *head;
head=NULL;
ifstream ifile; //定义输入文件对象
ifile.open("D:\\Customer.txt",ios::in);//以读的方式打开文件Customer.txt
if(!ifile)
{
cout<<"文件不存在,加载不成功!"<<endl;
return NULL; //文件打开错误
}
char s[50];
ifile.getline(s,50); //读取文件指针当前行数据
while(!ifile.eof())
{
p1=new CustomerNode; //创建一个新的结点
m++; //顾客人数加1
ifile>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->Consumption;//将数据从文件中读取到新的结点中
p1->next=NULL; //新结点的指针域为空
if(head==NULL) //将新结点插入到链表中
{
head=p1;
p2=p1;
}
else
{
p2->next=p1;
p2=p1;
}
}
ifile.close(); //关闭文件对象
cout<<"加载成功!"<<endl;
return head;
}
void Display(CustomerNode *head) //输出所有顾客的信息
{
CustomerNode *p;
p=head;
cout<<"=============================================="<<endl;
if(p==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
}
else
{
while(p)
{
cout<<p->Number<<'\t'<<p->Name<<'\t'<<p->Sex
<<'\t'<<p->PhoneNumber<<'\t'<<p->Consumption<<endl;
p=p->next;
}
}
cout<<"=============================================="<<endl;
}
void SaveRecordFile(CustomerNode *head)//保存顾客信息到文件
{
CustomerNode *ptr;
ofstream ofile;//定义输出文件对象
ofile.open("D:\\Customer.txt",ios::out);//以写的方式打开文件Customer.txt
if(!ofile)
{
cout<<"数据文件打开错误,没有将数据写入文件!"<<endl;//文件打开错误
return ;
}
while(head)
{
ofile<<endl<<head->Number<<' '<<head->Name<<' '<<head->Sex
<<' '<<head->PhoneNumber<<' '<<head->Consumption;
ptr=head;
head=head->next;
delete ptr;
}
ofile.close();
cout<<"保存成功!"<<endl;
}
CustomerNode *AddCustomer(CustomerNode *head)//增加顾客信息
{
CustomerNode *p1,*p2;
CustomerNode *ptr1,*p;
int flag=1;
if(head!=NULL)
{
p2=head;
while(p2->next!=NULL) //判断头指针是否为空
p2=p2->next;
}
cout<<"请依次输入会员的信息!"<<endl;
cout<<"会员卡号 姓名 性别 电话 消费金额"<<endl;
cout<<"当输入的姓名为#时,结束输入!"<<endl;
cout<<"==================================="<<endl;
p1=new CustomerNode;
cin>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->Consumption;
p1->next=NULL;
while(p1->Name!="#") //顾客的名字为‘#’结束增加顾客
{
flag=1;
ptr1=head;
if(head==NULL)
{
head=p1;
p2=p1;
}
else
{
while(ptr1!=NULL)
{
if(ptr1->Number==p1->Number)
{
cout<<"添加的顾客的会员卡号已存在!请重新添加顾客信息!"<<endl;
flag=0;
break;
} //判断添加的顾客的会员卡号是否唯一
ptr1=ptr1->next;
}
if(flag)
{
p2->next=p1;
p2=p1;
m++;
}
else
{
delete p1;
}
}
cout<<"会员卡号 姓名 性别 电话 消费金额"<<endl;
p1= new CustomerNode;
cin>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->Consumption;
p1->next=NULL;
}
delete p1;
cout<<"==================================="<<endl;
return head;
}
CustomerNode *FindRecordNumber(CustomerNode *head,int a)//根据卡号查找顾客
{
CustomerNode *p1;
p1=head;
if(head==NULL)
{
return p1;
}
while(head!=NULL&&p1!=NULL)
{
if(p1->Number==a)
{
break;
}
p1=p1->next;
}
return p1;
}
CustomerNode *DeleteRecord(CustomerNode *head)//删除顾客信息
{
CustomerNode *p1,*p2;
int num;
cout<<"==================================="<<endl;
if(head==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return head;
}
cout<<"请输入想要删除的顾客的会员卡号!"<<endl;
cin>>num;
p1=p2=head;
while(p1!=NULL&&p1->Number!=num)
{
p2=p1;
p1=p1->next;
}
if(p1!=NULL)
{
if(p1==head)
head=head->next;
else
p2->next=p1->next;
m--;
delete p1;
cout<<"删除成功!"<<endl;
}
else
{
cout<<"抱歉,没有该顾客的信息!"<<endl;
}
cout<<"==================================="<<endl;
return head;
}
CustomerNode *UpdateRecord(CustomerNode *head)//修改顾客信息
{
CustomerNode *p1,*p2,*ptr;
int num;
int flag=1;
int c;
ptr=new CustomerNode;
cout<<"==================================="<<endl;
if(head==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return head;
}
cout<<"请输入想要修改的顾客的会员卡号!"<<endl;
cin>>num;
p1=p2=head;
while(p1!=NULL&&p1->Number!=num)
p1=p1->next;
if(p1!=NULL)
{
cout<<"是否要修改会员卡号!(1是2否)"<<endl;
cin>>c;
if(c==1)
{
cout<<"请输入修改后的顾客信息!"<<endl;
cout<<"会员卡号 姓名 性别 电话 消费金额"<<endl;
cin>>ptr->Number>>ptr->Name>>ptr->Sex
>>ptr->PhoneNumber>>ptr->Consumption;
while(p2!=NULL)
{
if(p2->Number==ptr->Number)//判断修改后的会员卡号是否唯一
{
cout<<"添加的顾客的会员卡号已存在!"<<endl;
flag=0;
break;
}
p2=p2->next;
}
if(flag)
{
p1->Number=ptr->Number;
p1->Name=ptr->Name;
p1->Sex=ptr->Sex;
p1->PhoneNumber=p1->PhoneNumber;
p1->Consumption=ptr->Consumption;
cout<<"修改成功!"<<endl;
}
else
cout<<"修改失败!"<<endl;
delete ptr;
}
else
{
cout<<"请输入修改后的顾客信息!"<<endl;
cout<<"姓名 性别 电话 消费金额"<<endl;
cin>>p1->Name>>p1->Sex>>p1->PhoneNumber>>p1->Consumption;
cout<<"修改成功!"<<endl;
}
}
else
cout<<"修改失败!"<<endl;
cout<<"==================================="<<endl;
return head;
}
CustomerNode *Count(CustomerNode *head)//统计并按消费额排序
{
CustomerNode *ph;
ph=head;
if(ph==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return NULL;
}
if(ph->next==NULL)
{
cout<<ph->Number<<'\t'<<ph->Name<<'\t'<<ph->Sex<<'\t'
<<ph->PhoneNumber<<'\t'<<ph->Consumption<<endl;
return NULL;
}
CustomerNode *max_pre,*max,*tmp,*new_list,*tail_sort;
max_pre=NULL;
max=ph;
tmp=ph;
new_list=NULL;
tail_sort=NULL;
while(ph)
{
max=ph;
tmp=ph;
while(tmp->next)
{
if(max->Consumption<tmp->next->Consumption)
{
max=tmp->next;
max_pre=tmp;
}
tmp=tmp->next;
}
if(max==ph)
ph=ph->next;
else
{
max_pre->next=max->next;
max->next=NULL;
}
if(new_list==NULL)
{
new_list=max;
tail_sort=new_list;
}
else
{
tail_sort->next=max;
tail_sort=max;
}
}
return new_list;
}
};
class Worker//定义员工类
{
private:
int m;//记录结点的个数
public:
WorkerNode *LoadRecordFile()//从文件中加载员工信息
{
m=0;
WorkerNode *p1,*p2;
WorkerNode *head;
head=NULL;
ifstream ifile; //定义输入文件对象
ifile.open("D:\\Worker.txt",ios::in);//以读的方式打开文件Worker.txt
if(!ifile)
{
cout<<"文件不存在,加载不成功!"<<endl;
return NULL; //文件打开错误
}
char s[50];
ifile.getline(s,50);
while(!ifile.eof())
{
p1=new WorkerNode;//创建一个新的结点
m++;
ifile>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->item>>p1->Income;
//将数据从文件中读取到新的结点中
p1->next=NULL; //新结点的指针域为空
if(head==NULL) //将新结点插入到链表中
{
head=p1;
p2=p1;
}
else
{
p2->next=p1;
p2=p1;
}
}
ifile.close(); //关闭文件对象
cout<<"加载成功!"<<endl;
return head;
}
void Display(WorkerNode *head) //输出所有员工的信息
{
WorkerNode *p;
p=head;
cout<<"==========================================================="<<endl;
if(p==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
}
else
{
while(p)
{
cout<<p->Number<<'\t'<<p->Name<<'\t'<<p->Sex
<<'\t'<<p->PhoneNumber<<'\t'<<p->item<<'\t'<<p->Income<<endl;
p=p->next;
}
}
cout<<"==========================================================="<<endl;
}
void SaveRecordFile(WorkerNode *head)//保存员工信息到文件
{
WorkerNode *ptr;
ofstream ofile;//定义输出文件对象
ofile.open("D:\\Worker.txt",ios::out);//以写的方式打开文件Worker.txt
if(!ofile)
{
cout<<"数据文件打开错误,没有将数据写入文件!"<<endl;
return ;
}
while(head)
{
ofile<<endl<<head->Number<<' '<<head->Name<<' '<<head->Sex
<<' '<<head->PhoneNumber<<' '<<head->item<<' '<<head->Income;
ptr=head;
head=head->next;
delete ptr;
}
cout<<"保存成功!"<<endl;
ofile.close();
}
WorkerNode *AddWorker(WorkerNode *head)//增加员工信息
{
WorkerNode *p1,*p2;
WorkerNode *ptr1,*p;
int flag=1;
if(head!=NULL)
{
p2=head;
while(p2->next!=NULL)
p2=p2->next;
}
cout<<"请依次输入员工的信息!"<<endl;
cout<<"编号 姓名 性别 电话 美发项目 收入"<<endl;
cout<<"当输入的姓名为#时,结束输入!"<<endl;
cout<<"==================================="<<endl;
p1=new WorkerNode;
cin>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->item>>p1->Income;
p1->next=NULL;
while(p1->Name!="#")//当姓名为‘#’结束输入
{
flag=1;
ptr1=head;
if(head==NULL)
{
head=p1;
p2=p1;
}
else
{
while(ptr1!=NULL)
{
if(ptr1->Number==p1->Number)
{
cout<<"添加的员工的编号已存在!请重新添加员工信息!"<<endl;
flag=0;
break;
} //判断添加的员工的编号是否唯一
ptr1=ptr1->next;
}
if(flag)
{
p2->next=p1;
p2=p1;
m++;
}
else
{
delete p1;
}
}
cout<<"编号 姓名 性别 电话 美发项目 收入"<<endl;
p1= new WorkerNode;
cin>>p1->Number>>p1->Name>>p1->Sex
>>p1->PhoneNumber>>p1->item>>p1->Income;
p1->next=NULL;
}
delete p1;
cout<<"==================================="<<endl;
return head;
}
WorkerNode *FindRecordNumber(WorkerNode *head,int a)//根据编号查找员工
{
WorkerNode *p1;
p1=head;
if(head==NULL)
{
return p1;
}
while(head!=NULL&&p1!=NULL)
{
if(p1->Number==a)
{
break;
}
p1=p1->next;
}
return p1;
}
WorkerNode *DeleteRecord(WorkerNode *head)//删除员工信息
{
WorkerNode *p1,*p2;
int num;
cout<<"==================================="<<endl;
if(head==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return head;
}
cout<<"请输入想要删除的员工的编号!"<<endl;
cin>>num;
p1=p2=head;
while(p1!=NULL&&p1->Number!=num)
{
p2=p1;
p1=p1->next;
}
if(p1!=NULL)
{
if(p1==head)
head=head->next;
else
p2->next=p1->next;
m--;
delete p1;
cout<<"删除成功!"<<endl;
}
else
{
cout<<"抱歉,没有该员工的信息!"<<endl;
}
cout<<"==================================="<<endl;
return head;
}
WorkerNode *UpdateRecord(WorkerNode *head)//修改员工信息
{
WorkerNode *p1,*p2,*ptr;
int num;
int flag=1;
int c;
ptr=new WorkerNode;
cout<<"==================================="<<endl;
if(head==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return head;
}
cout<<"请输入想要修改的员工的编号!"<<endl;
cin>>num;
p1=p2=head;
while(p1!=NULL&&p1->Number!=num)
p1=p1->next;
if(p1!=NULL)
{
cout<<"是否要修改员工的编号!(1是2否)"<<endl;
cin>>c;
if(c==1)
{
cout<<"请输入修改后的员工信息!"<<endl;
cout<<"编号 姓名 性别 电话 美发项目 收入"<<endl;
cin>>ptr->Number>>ptr->Name>>ptr->Sex
>>ptr->PhoneNumber>>ptr->item>>ptr->Income;;
while(p2!=NULL)
{
if(p2->Number==ptr->Number)
{
cout<<"添加的员工的编号已存在!"<<endl;
flag=0;
break;
} //判断修改后的员工信息的编号是否唯一
p2=p2->next;
}
if(flag)
{
p1->Number=ptr->Number;
p1->Name=ptr->Name;
p1->Sex=ptr->Sex;
p1->PhoneNumber=ptr->PhoneNumber;
p1->item=ptr->item;
p1->Income=ptr->Income;
cout<<"修改成功!"<<endl;
}
else
cout<<"修改失败!"<<endl;
delete ptr;
}
else
{
cout<<"请输入修改后的员工信息!"<<endl;
cout<<"姓名 性别 电话 美发项目 收入"<<endl;
cin>>p1->Name>>p1->Sex>>p1->PhoneNumber
>>p1->item>>p1->Income;
cout<<"修改成功!"<<endl;
}
}
else
cout<<"修改失败!"<<endl;
cout<<"==================================="<<endl;
return head;
}
WorkerNode *Count(WorkerNode *head)//统计并按收入排序
{
WorkerNode *ph;
ph=head;
if(ph==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return NULL;
}
if(ph->next==NULL)
{
cout<<ph->Number<<'\t'<<ph->Name<<'\t'<<ph->Sex<<'\t'
<<ph->PhoneNumber<<'\t'<<ph->item<<'\t'<<ph->Income;
return NULL;
}
WorkerNode *max_pre,*max,*tmp,*new_list,*tail_sort;
max_pre=NULL;
max=ph;
tmp=ph;
new_list=NULL;
tail_sort=NULL;
while(ph)
{
max=ph;
tmp=ph;
while(tmp->next)
{
if(max->Income<tmp->next->Income)
{
max=tmp->next;
max_pre=tmp;
}
tmp=tmp->next;
}
if(max==ph)
ph=ph->next;
else
{
max_pre->next=max->next;
max->next=NULL;
}
if(new_list==NULL)
{
tail_sort=max;
new_list=tail_sort;
}
else
{
tail_sort->next=max;
tail_sort=max;
}
}
return new_list;
}
};
class Manger
{
public:
Customer c; //定义一个顾客类对象
Worker w; //定义一个员工类对象
CustomerNode *h1,*p1; //定义指针变量h1,p1
WorkerNode *h2,*p2; //定义指针变量h2,p2
void Init() //将h1,h2赋值为NULL
{
h1=NULL;
h2=NULL;
MainMenu();
}
void MainMenu() //管理功能主菜单
{
int c1;
cout<<" **************************"<<endl;
cout<<" *** 美发店管理系统 ***"<<endl;
cout<<" **************************"<<endl;
cout<<"**************************美发店管理功能菜单***************************"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<" -- 1.顾客 2.员工 --"<<endl;
cout<<" -- 3.退出系统 --"<<endl;
cout<<" -- 选择选项后,按回车确认 --"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<"***********************************************************************"<<endl;
cin>>c1;
system("cls");
switch(c1)
{
case 1:
{
CustomerMenu();
break;
}
case 2:
{
WorkerMenu();
break;
}
case 3:
{
break;
}
}
}
void CustomerMenu() 顾客管理菜单
{
int choice1;
cout<<"**************************顾客信息管理菜单******************************"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<" -- 1.读取顾客信息 2.保存顾客信息 --"<<endl;
cout<<" -- 3.显示所有顾客信息 4.查找顾客信息 --"<<endl;
cout<<" -- 5.添加顾客信息 6.编辑顾客信息 --"<<endl;
cout<<" -- 7.删除顾客信息 8.统计顾客消费额 --"<<endl;
cout<<" -- 9.返回 --"<<endl;
cout<<" -- 选择选项后,按回车确认 --"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<"***********************************************************************"<<endl;
cin>>choice1;
system("cls");
switch(choice1)
{
case 1:
{
h1=c.LoadRecordFile();
CustomerMenu();
break;
}
case 2:
{
c.SaveRecordFile(h1);
CustomerMenu();
break;
}
case 3:
{
c.Display(h1);
CustomerMenu();
break;
}
case 4:
{
p1=NULL;
int nb;
cout<<"请输入要查询的顾客的会员卡号!"<<endl;
cin>>nb;
p1=c.FindRecordNumber(h1,nb);
if(p1!=NULL)
{
cout<<"会员卡号:"<<p1->Number<<'\t'<<"姓名:"<<p1->Name<<'\t'
<<"性别:"<<p1->Sex<<'\t'<<"电话:"<<p1->PhoneNumber<<'\t'
<<"消费金额:"<<p1->Consumption<<endl;
}
else
cout<<"没有找到对应的顾客!"<<endl;
CustomerMenu();
break;
}
case 5:
{
h1=c.AddCustomer(h1);
CustomerMenu();
break;
}
case 6:
{
h1=c.UpdateRecord(h1);
CustomerMenu();
break;
}
case 7:
{
h1=c.DeleteRecord(h1);
CustomerMenu();
break;
}
case 8:
{
CustomerNode *hh;
hh=c.Count(h1);
while(hh!=NULL)
{
cout<<hh->Number<<'\t'<<hh->Name<<'\t'
<<hh->Sex<<'\t'<<hh->PhoneNumber<<'\t'<<hh->Consumption<<endl;
hh=hh->next;
}
CustomerMenu();
break;
}
case 9:
{
MainMenu();
break;
}
default:
{
cout<<"ERROR!"<<endl;
CustomerMenu();
break;
}
}
}
void WorkerMenu() //员工管理菜单
{
int choice1;
cout<<"**************************员工信息管理菜单******************************"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<" -- 1.读取员工信息 2.保存员工信息 --"<<endl;
cout<<" -- 3.显示所有员工信息 4.查找员工信息 --"<<endl;
cout<<" -- 5.添加员工信息 6.编辑员工信息 --"<<endl;
cout<<" -- 7.删除员工信息 8.统计员工收入额 --"<<endl;
cout<<" -- 9.返回 --"<<endl;
cout<<" -- 选择选项后,按回车确认 --"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<"***********************************************************************"<<endl;
cin>>choice1;
system("cls");
switch(choice1)
{
case 1:
{
h2=w.LoadRecordFile();
WorkerMenu();
break;
}
case 2:
{
w.SaveRecordFile(h2);
WorkerMenu();
break;
}
case 3:
{
w.Display(h2);
WorkerMenu();
break;
}
case 4:
{
p2=NULL;
int nb;
cout<<"请输入要查询的员工的编号!"<<endl;
cin>>nb;
p2=w.FindRecordNumber(h2,nb);
if(p2!=NULL)
{
cout<<"编号:"<<p2->Number<<'\t'<<"姓名:"<<p2->Name<<'\t'
<<"性别:"<<p2->Sex<<'\t'<<"电话:"<<p2->PhoneNumber<<'\t'
<<"美发项目:"<<p2->item<<'\t'<<"收入:"<<p2->Income<<endl;
}
else
cout<<"没有找到对应的员工!"<<endl;
WorkerMenu();
break;
}
case 5:
{
h2=w.AddWorker(h2);
WorkerMenu();
break;
}
case 6:
{
h2=w.UpdateRecord(h2);
WorkerMenu();
break;
}
case 7:
{
h2=w.DeleteRecord(h2);
WorkerMenu();
break;
}
case 8:
{
WorkerNode *pp;
pp=w.Count(h2);
while(pp!=NULL)
{
cout<<pp->Number<<'\t'<<pp->Name<<'\t'
<<pp->Sex<<'\t'<<pp->PhoneNumber<<'\t'
<<pp->item<<'\t'<<pp->Income<<endl;
pp=pp->next;
}
WorkerMenu();
break;
}
case 9:
{
MainMenu();
break;
}
default:
{
cout<<"ERROR!"<<endl;
WorkerMenu();
break;
}
}
}
};
class Item
{
public:
Customer cus; //定义一个顾客类对象
Worker work; //定义一个员工类对象
CustomerNode *h1,*c1; //定义指针变量h1,c1
WorkerNode *h2,*w1; //定义指针变量h2,w1
void Init() //为h1,h2赋值
{
h1=NULL;
h2=NULL;
h1=cus.LoadRecordFile();
h2=work.LoadRecordFile();
ItemMenu();
}
void ItemMenu() //美发项目菜单
{
int choice1;
int num;
int cost;
int res;
string pro;
cout<<"请输入您的会员卡号!"<<endl;
cin>>num;
c1=cus.FindRecordNumber(h1,num);
if(c1==NULL)
{
cout<<"抱歉,没有此会员卡号的顾客信息!"<<endl;
ItemMenu();
return ;
}
else
{
cout<<c1->Number<<'\t'<<c1->Name<<endl;
}
cout<<"****************************美发项目菜单******************************"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<" -- 1.洗发 15元 2.理发 25元 --"<<endl;
cout<<" -- 3.烫发 300元 4.染发 500元 --"<<endl;
cout<<" -- 5.退出系统 --"<<endl;
cout<<" -- 选择选项后,按回车确认 --"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<"***********************************************************************"<<endl;
cin>>choice1;
system("cls");
switch(choice1)
{
case 1:
{
pro="洗发";
cost=15;
res=WorkerShow(pro,cost);
if(res==1)
{
c1->Consumption=c1->Consumption+cost;
cout<<"谢谢惠顾!"<<endl;
cus.SaveRecordFile(h1);
work.SaveRecordFile(h2);
}
break;
}
case 2:
{
pro="理发";
cost=25;
res=WorkerShow(pro,cost);
if(res==1)
{
c1->Consumption=c1->Consumption+cost;
cout<<"谢谢惠顾!"<<endl;
cus.SaveRecordFile(h1);
work.SaveRecordFile(h2);
}
break;
}
case 3:
{
pro="烫发";
cost=300;
res=WorkerShow(pro,cost);
if(res==1)
{
c1->Consumption=c1->Consumption+cost;
cout<<"谢谢惠顾!"<<endl;
cus.SaveRecordFile(h1);
work.SaveRecordFile(h2);
}
break;
}
case 4:
{
pro="染发";
cost=500;
res=WorkerShow(pro,cost);
if(res==1)
{
c1->Consumption=c1->Consumption+cost;
cout<<"谢谢惠顾!"<<endl;
cus.SaveRecordFile(h1);
work.SaveRecordFile(h2);
}
break;
}
case 5:
{
break;
}
default:
{
cout<<"ERROR!"<<endl;
ItemMenu();
break;
}
}
}
int WorkerShow(string a,int cost) //选择服务的员工
{
w1=NULL;
int cc;
WorkerNode *p;
p=h2;
if(p==NULL)
{
cout<<"抱歉,没有任何记录!"<<endl;
return 0;
}
cout<<"以下员工可为您服务:"<<endl;
while(p!=NULL)
{
if(p->item==a)
cout<<p->Number<<'\t'<<p->Name<<'\t'<<p->Sex<<endl;
p=p->next;
}
cout<<"请输入员工编号选择为您服务的员工!"<<endl;
cin>>cc;
w1=work.FindRecordNumber(h2,cc);
if(w1!=NULL)
{
cout<<w1->Number<<'\t'<<w1->Name<<endl;
w1->Income=w1->Income+cost;
return 1;
}
else
{
cout<<"没有输入正确的可为您服务的员工编号!"<<endl;
cout<<"选择服务失败!"<<endl;
return 2;
}
}
};
void Salonmeun() //菜单选择函数
{
Manger m;
Item it;
int cc;
cout<<" **************************"<<endl;
cout<<" *** 美发店管理系统 ***"<<endl;
cout<<" **************************"<<endl;
cout<<"*****************************请选择您的身份****************************"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<" -- 1.顾客 2.管理员 --"<<endl;
cout<<" -- 3.退出系统 --"<<endl;
cout<<" -- 选择选项后,按回车确认 --"<<endl;
cout<<" ----------------------------------------------------------"<<endl;
cout<<"***********************************************************************"<<endl;
cin>>cc;
system("cls");
switch(cc)
{
case 1:
{
it.Init();
break;
}
case 2:
{
int password;
int flag=0;
cout<<"****************************************"<<endl;
cout<<"请输入管理员密码!(提示:4位密码)(共3次机会)"<<endl;
for(int i=1;i<=3;i++)
{
cin>>password;
if(password!=6666)
{
cout<<"密码错误!"<<endl;
continue;
}
else
{
cout<<"密码正确!"<<endl;
cout<<"****************************************"<<endl;
flag=1;
break;
}
}
if(flag==0)
{
cout<<"正在退出管理系统!"<<endl;
cout<<"****************************************"<<endl;
}
if(flag==1)
{
m.Init();
}
break;
}
case 3:
{
cout<<"正在退出管理系统!"<<endl;
cout<<"****************************************"<<endl;
break;
}
default:
{
Salonmeun();
break;
}
}
}
int main() //主函数
{
Salonmeun();
return 0;
}
报告下载地址
课程设计报告+代码+测试文件
下载地址:https://download.csdn.net/download/gouyinghong/20087440