图书管理

来源:互联网 发布:js 联动的二级菜单 编辑:程序博客网 时间:2024/05/04 20:49
#include#include#include #includeusing namespace std;class book;class BookManager; //BookManager类是Book类的友元类class BuyManager; //BuyManager类是buyers类的友元类class buyer; //顾客基类class order; //订单类,是Book和buyer类的友元类class list // 菜单类{public:int list0(int choice0){system("cls");cout<>choice0;return choice0;}int list1(int choice1){system("cls");cout<>choice1;return choice1;}int list2(int choice2){system("cls");cout<<"******************************客户管理**************************"<>choice2;return choice2;}int list3(int choice3){system("cls");cout<<"**************************订单管理**********************"<>choice3;return choice3;}};class Book //Book类{public:Book();Book(char *b_id,char *b_n,char *au,char *pu,double pr,double st,int sa);//构造函数friend class BookManager;friend class order;void display();const char * getbook_ID(); //获得书籍编号const char * getbook_name(); //获得书名const char * getauthor(); //获得书籍作者const char * getpublishing(); //获得书籍出版社double getstore(); //获得书籍库存量double getprice(); //获得书籍价格int getsalenum(); //获得书籍销售数量protected:char book_ID[10];char book_name[80];char author[10];char publishing[80];double store; //库存double price;int salenum; //销售量};Book::Book(char * b_id,char * b_n,char *au,char *pu,double pr,double st,int sa){strcpy(book_ID,b_id);strcpy(book_name,b_n);strcpy(author,au);strcpy(publishing,pu);price=pr;store=st;salenum=sa;}Book::Book(){strcpy(book_ID,"");strcpy(book_name,"");strcpy(author,"");strcpy(publishing,"");price=0;store=0;salenum=0;}void Book::display() //显示函数{cout<<"书号:"< choice ;switch ( choice ){ case 1://追加新记录cout << "书号, 书名, 作者,出版社,单价,数量:(以 Tab键分隔)/n" ;//输入新记录信息cin >>book.book_ID;cin >> book.book_name;cin >>book.author;cin>>book.publishing;cin >> book.price;cin >>book.store;book.salenum=0;b_book[b]=book;BookFile.seekp(b*sizeof(Book)+sizeof(int));BookFile.write((char*)&b_book[b],sizeof(b_book[b]));b++;BookFile.seekp(0,ios::beg);BookFile.write((char*)&b,sizeof(int));break;case 2://修改已有记录库存量{if(b==0){cout<<"暂无书籍!";getchar();getchar();return ;}cout<<"请输入您要修改的书的书号:";cin>>key;//输入书号for(int j=0;j>num ;if (num>0){b_book[p].store += num ;//修改库存量BookFile.seekp(sizeof(int)+sizeof(Book)*p);BookFile.write((char*)&b_book[p],sizeof(b_book[p]));cout<<"入库后的数量:"<>key;int j;for(j=0;j>num;if(num<0){cout<<"售出量应为一个正数!"<> choice ;switch( choice ){case 1://按书号检索{ cout << "书号: " ;cin >> key ;system("cls");for(int j=0;j> choice ;switch( choice ){case 1: //按书号检索{ system("cls");cout << "请输入您要查找的书的书号:";cin >> key ;for(int j=0;j>name;cin>>buyerID;cin>>address;cin>>pay;}void Buyer::display() //显示函数{cout<<"姓名:"<>key;p=0;for(j=0;j>f;}BuyFile.close();}void BuyManager::delebuyer() //删除顾客{Buyer temp;int j=0,p=0,flag,choice;char key[30],f='y';fstream BuyFile("customerfile.txt",ios::binary|ios::out|ios::in);if(c==0){cout<<"暂无客户!";getchar();getchar();return ;}while(f=='Y'||f=='y'){a2:system("cls");cout<<"请选择删除方式/t1.按姓名删除/t2.按编号删除"<>choice;switch(choice){case 1:cout<<"请输入您要删除的客户姓名:"; //按姓名删除cin>>key;for(j=0;j>key;for(j=0;j>f;}BuyFile.close();}void BuyManager::updatebuyer() //更新客户{char choice,key[40] ;Buyer buyer;int flag,p,j;fstream BuyFile( "customerfile.txt ",ios::binary|ios::out|ios::in);if(c==0){cout<<"暂无客户!";getchar();getchar();return ;}while(1) {system("cls");cout<<"/n********** 客户更新**********/n" ;cout<<"请输入客户的编号:/n" ;cin>>key ;for(j=0;j>choice;if(choice=='n'||choice=='N')break;}else{cout<<"您输入的客户编号不存在!"<> choice ;switch( choice ){case 1://按编号检索{ cout << "客户编号: " ;cin >> key ;system("cls");for(int j=0;j>cus_nu;cout<<"请输入所购书的编号:";cin>>book_nu;cout<<"请输入购书人电话";cin>>phone;cout<<"请输入购书数量:";cin>>ordernum;}order orderlist[100]; //定义书籍数组(书籍库)fstream OrderFile; //定义书籍库文件对象ifstream in_order;int d=0;void orderinitial(){d=0;fstream OrderFile( "orderfile.txt",ios::binary|ios::out); OrderFile.seekp(0,ios::beg);OrderFile.write((char*)&d,sizeof(int));order d1("0001","8001","8944533",32);order d2("0002","8002","8976154",10);order d3("0003","8003","15176762415",45);orderlist[d]=d1;OrderFile.write((char*)&orderlist[d],sizeof(orderlist[d]));d++;orderlist[d]=d2;OrderFile.write((char*)&orderlist[d],sizeof(orderlist[d]));d++;orderlist[d]=d3;OrderFile.write((char*)&orderlist[d],sizeof(orderlist[d]));d++;OrderFile.seekp(0,ios::beg);OrderFile.write((char*)&d,sizeof(int));orderlist[0].orderdisplay();cout<>k;if(k=='y'||k=='Y'){p=0;}else{p=1;}}}for(j=0;j>f;system("cls");OrderFile.close();}}void order::deleorder() //删除订单{int j,p=0,flag;char choice='y';char key[30];OrderFile.open( "orderfile.txt",ios::binary|ios::out|ios::in);if(d==0){cout<<"暂无订单!";getchar();getchar();return ;}while(choice=='y'||choice=='Y'){system("cls");cout<<"请输入顾客编号:";cin>>key;for(j=0;j>choice;if(choice=='y'||choice=='Y') //删除{for(j=p;j>choice;}else break;}else{ cout<<"该订单不存在";getchar();getchar(); //未找到记录break;}}OrderFile.close();}void order::scanorder() //浏览订单{OrderFile.open("orderfile.txt",ios::binary|ios::out|ios::in);order temp;in_order.seekg(0,ios::cur);if(d==0){cout<<"暂无订单!";getchar();getchar();return ;}for(int j=0;jadd();break;case 2:m->sale();break;case 3:m->store_search();break;case 4:m->sale_search();break;case 5:system("cls");goto a1 ; //进入主菜单default :cout<<"输入有误,请重新输入:"<addbuyer();break;case 2:t->delebuyer();break;case 3:t->updatebuyer();break;case 4:t->buyersearch();break;case 5:system("cls");goto a1 ;default :cout<<"输入有误,请重新输入:"<addorder();break;case 2:s->deleorder();break;case 3:s->scanorder();getchar();getchar();break; case 4:system("cls");goto a1 ;default:cout<<"输入有误,请重新输入:"<
  • 图书管理
  • 图书管理
  • 图书管理
  • 图书管理
  • 图书管理
  • 图书管理系统论文
  • 图书管理系统(1)
  • 图书管理系统(2)
  • 图书管理系统(3)
  • java-图书管理系统
  • 图书管理系统
  • 图书管理系统
  • 简单图书管理系统
  • 图书管理系统
  • 图书管理摘要
  • 图书管理搜索部份
  • 图书管理系统
  • 图书仓库管理系统
  • wince隐藏任务栏
  • Lucene开发环境配置
  • int、bigint、smallint 和 tinyint
  • 关于合力零点显示的正确显示方式
  • IIS 性能监测
  • 图书管理
  • fstream和ofstream使用上的一点区别
  • Asterisk postgresql voicemail
  • mepg2 TS流
  • sql时间函数大全
  • ABAP DIALOG程序步骤
  • J2ME RMS读写操作
  • linux下c++的编译器g++的基本使用
  • 文件上传
  • 原创粉丝点击