车票管理系统源代码

合集下载

《C语言程序设计》公交车管理系统源码

《C语言程序设计》公交车管理系统源码

《C语言程序设计》公交车管理系统源码#include<stdio.h>main(){int ticket=0,stops=0,symbol=0,cardnumber=0,cardmoney=0,num=0; int i=0,balance=0,maxindex=0;int cnum[20]={0},cmoney[20]={0},cbalance[20]={0},flag[20]={0}; char choose='\0';while(1){ clrscr();printf("\n\t\t||=======================================||"); printf("\n\t\t||---------------------------------------||"); printf("\n\t\t||-------------Welcome-------------------||"); printf("\n\t\t||----------use bus traffic--------------||"); printf("\n\t\t||--------------Card---------------------||"); printf("\n\t\t||---------------------------------------||"); printf("\n\t\t||=======================================||"); printf("\n\n\n\n");printf("\n\t\t||---------------------------------------||"); printf("\n\t\t||----------Please input(0-8)------------||"); printf("\n\t\t||---------------------------------------||"); printf("\n\t\t| 1.Add new Card |");printf("\n\t\t| 2.Logout Card |");printf("\n\t\t| 3.Modify Card |");printf("\n\t\t| 4.Read card |");printf("\n\t\t| 5.Save money |");printf("\n\t\t| 6.Stat.max money |");printf("\n\t\t| 7.Display |");printf("\n\t\t| 8.Delete Data File |");printf("\n\t\t| 0.Exit |");printf("\n\t\t|-----------------------------------------|"); printf("\n\t\t");scanf("%c",&choose);switch(choose){ case'1':for(i=0;i<num;i++)if(flag[i]==1)break;cardnumber=i;printf("\n\tHow much money you want to save in your card"); scanf("%d",&cardmoney);cnum[cardnumber]=cardnumber+1;cmoney[cardnumber]=cardmoney;cbalance[cardnumber]=cardmoney;flag[cardnumber]=0;if(cardnumber==num) num++;printf("\n\t|--%5d--|--%5d--|--%5d--|",cnum[i],cmoney[i],cbalance[i]);getch();break;case'2':printf("\n\tPlease input your card number:");scanf("%d",&cardnumber);for(i=0;i<num;i++)if(cnum[i]==cardnumber && flag[i]!=1){printf("\n\tReturu you balance money:%d.",cbalance[i]);do{printf("\n\n\tAre you sure logout the card(y/n)?");scanf("%c",&choose);}while(choose!='y' && choose!='y' && choose!='N' && choose!='n'); if(choose=='y' || choose=='y'){cmoney[i]=0;cbalance[i]=0;flag[i]=1;}break;}if(i==num){printf("\n\ntNo find the card.");getch();}break;case'3':printf("\n\tPlease input card number that you want to modify:"); scanf("%d",&cardnumber);for(i=0;i<num;i++)if(cnum[i]==cardnumber && flag[i]!=1){do{clrscr();printf("\n\t\t-------------------------------------------"); printf("\n\t\t please input modify Item ");printf("\n\t\t-------------------------------------------"); printf("\n\t\t------------ 1.save money------------------"); printf("\n\t\t------------ 2.balance money---------------"); printf("\n\t\t------------ 3.Return----------------------"); printf("\n\t\t-------------------------------------------"); scanf("%c",&choose);switch(choose){case'1':printf("\n\tPlease input new save money:"); scanf("%d%",&cardmoney);cbalance[i]+=cardmoney-cmoney[i];cmoney[i]=cardmoney;break;case'2':printf("\n\tPlease input new balance money:"); scanf("%d%",&balance);cbalance[i]=balance;break;case'3':break;default:printf("\n\tInput error, Please input again!"); getch();continue;}}while(choose!='3');break;}if(i==num){printf("\n\tNo find the card.");getch();}break;case'4':printf("\n\tPlease input your card number:");scanf("%d",&cardnumber);for(i=0;i<num;i++)if(cnum[i]==cardnumber && flag[i]!=1){ while(symbol==0){ printf("\n\tHow many you want to take bus stops:"); scanf("%d",&stops);if(stops<1||stops>30){printf("\n\tInput error.Please input again.");getch();}else if(stops<=10){ticket=1;symbol=1;}else if(stops<=15){ticket=2;symbol=1;}else if(stops<=20){ticket=3;symbol=1;}else if(stops<=25){ticket=4;symbol=1;}else if(stops<=30){ticket=5;symbol=1;}}if(cbalance[i]>=ticket){printf("\n\tBefore:");printf("cnum:%5d cmoner:%5dcbalance:%5d",cnum[i],cmoney[i],cbalance[i]); cbalance[i]-=ticket;printf("\n\tAfter:");printf("cnum:%5d cmoner:%5dcbalance:%5d",cnum[i],cmoney[i],cbalance[i]);getch();}else{printf("\n\tYour card balance money is not enough.Please use cash.");getch();}break;}if(i==num){ printf("\n\tNo find the card");getch();}break;case'5':printf("\n\tPlease input your card number:");scanf("%d",&cardnumber);for(i=0;i<num;i++)if(cnum[i]==cardnumber && flag[i]!=1){ do{ printf("\n\tPlease input you want to save money in thecard:");scanf("%d",&cardmoney);if(cardmoney<=0)printf("\n\tInput error.Please input again.");}while(cardmoney<=0);cmoney[i]=cardmoney;cbalance[i]+=cardmoney;printf("\n\tYour card have already saved money:%5d.",cardmoney); printf("\n\tcnum:% 5d cmoney:%5d cbalance:%5d",cnum[i],cmoney[i],cbalance[i]);getch();break;}if(i==num){ printf("\n\tNo find the card.");getch();}break;case'6':maxindex=0;for(i=1;i<num;i++)if(cmoney[maxindex]<cmoney[i])maxindex=i;printf("\n\tMax save money is:%d.",cmoney[maxindex]);printf("\n\tcnum:%5d cmoney:%5d cbalance:%5d",cnum[maxindex],cmoney[maxindex],cbalance[maxindex]); getch();break;case'7':clrscr();printf("\n\t|---------------------------------------|"); printf("\n\t|--Cardnum--|--Savvemoney--|--Balance-- |"); for(i=0;i<num;i++){ if(flag[i]==1) continue;else{ printf("\n\t|-----------------------------|");printf("\n\t|--%5d--|--%5d--|--%5d--------|");cnum[i],cmoney[i],cbalance[i];if((i+1)%10==0){ getch();printf("Press any key to go on...");}}}printf("\n\t|---------------------------------|");getch();break;case'8':printf("\n\tYou select 8");getch();break;case'0':do{ printf("\n\tAre you sure exit(y/n):");scanf("%c",&choose);}while(choose!='Y' && choose!='y' && choose!='N'&&choose!='n');if(choose=='Y'||choose=='y')exit(0);break;default:printf("\n\tYou input error.Please input again."); getch();}}}。

C语言编程---火车订票系统源代码

C语言编程---火车订票系统源代码

火车订票系统源码(一)#include <conio.h>#include <stdio.h>#include <stdlib.h>#include <string.h>intshoudsave=0 ;int count1=0,count2=0,mark=0,mark1=0 ;/*定义存储火车信息的结构体*/struct train{char num[10];/*列车号*/char city[10];/*目的城市*/char takeoffTime[10];/*发车时间*/char receiveTime[10];/*到达时间*/int price;/*票价*/intbookNum ;/*票数*/};/*订票人的信息*/struct man{charnum[10];/*ID*/char name[10];/*姓名*/intbookNum ;/*需求的票数*/};/*定义火车信息链表的结点结构*/typedefstruct node{struct train data ;struct node * next ;}Node,*Link ;/*定义订票人链表的结点结构*/typedefstruct people{struct man data ;struct people*next ;}bookMan,*bookManLink ;/* 初始界面*/voidprintInterface(){puts("********************************************************"); puts("* Welcome to use the system of booking tickets *");puts("********************************************************"); puts("* You can choose the operation: *");puts("* 1:Insert a train information *");puts("* 2:Inquire a train information *");puts("* 3:Book a train ticket *");puts("* 4:Update the train information *");puts("* 5:Advice to you about the train *");puts("* 6:save information to file *");puts("* 7:quit the system *");puts("********************************************************"); }/*添加一个火车信息*/voidInsertTraininfo(Link linkhead){struct node *p,*r,*s ;charnum[10];r = linkhead ;s = linkhead->next ;while(r->next!=NULL)r=r->next ;while(1){printf("please input the number of the train(0-return)");scanf("%s",num);if(strcmp(num,"0")==0)break ;/*判断是否已经存在*/while(s){if(strcmp(s->data.num,num)==0){printf("the train '%s'has been born!\n",num);return ;}s = s->next ;}p = (struct node*)malloc(sizeof(struct node));strcpy(p->data.num,num);printf("Input the city where the train will reach:");scanf("%s",p->data.city);printf("Input the time which the train take off:");scanf("%s",p->data.takeoffTime);printf("Input the time which the train receive:");scanf("%s",&p->data.receiveTime);printf("Input the price of ticket:");scanf("%d",&p->data.price);printf("Input the number of booked tickets:");scanf("%d",&p->data.bookNum);p->next=NULL ;r->next=p ;r=p ;shoudsave = 1 ;}}/*打印火车票信息*/voidprintTrainInfo(struct node*p){puts("\nThe following is the record you want:");printf(">>number of train: %s\n",p->data.num);printf(">>city the train will reach: %s\n",p->data.city);printf(">>the time the train take off: %s\nthe time the train reach: %s\n",p->data.takeoffTime,p->data.receiveTime);printf(">>the price of the ticket: %d\n",p->data.price);printf(">>the number of booked tickets: %d\n",p->data.bookNum);}struct node * Locate1(Link l,charfindmess[],char numorcity[]){Node*r ;if(strcmp(numorcity,"num")==0){r=l->next ;while(r){if(strcmp(r->data.num,findmess)==0)return r ;r=r->next ;}}else if(strcmp(numorcity,"city")==0){r=l->next ;while(r){if(strcmp(r->data.city,findmess)==0)return r ;r=r->next ;}}return 0 ;}/*查询火车信息*/voidQueryTrain(Link l){Node *p ;intsel ;char str1[5],str2[10];if(!l->next){printf("There is not any record !");return ;}printf("Choose the way:\n>>1:according to the number of train;\n>>2:according to the city:\n");scanf("%d",&sel);if(sel==1){printf("Input the the number of train:");scanf("%s",str1);p=Locate1(l,str1,"num");if(p){printTrainInfo(p);}else{mark1=1 ;printf("\nthe file can't be found!");}}else if(sel==2){printf("Input the city:");scanf("%s",str2);p=Locate1(l,str2,"city");if(p){printTrainInfo(p);}else{mark1=1 ;printf("\nthe file can't be found!");}}}/*订票子模块*/voidBookTicket(Link l,bookManLink k){Node*r[10],*p ;charch,dem ;bookMan*v,*h ;int i=0,t=0 ;charstr[10],str1[10],str2[10];v=k ;while(v->next!=NULL)v=v->next ;printf("Input the city you want to go: ");scanf("%s",&str);p=l->next ;while(p!=NULL){if(strcmp(p->data.city,str)==0){r[i]=p ;i++;}p=p->next ;}printf("\n\nthe number of record have %d\n",i);for(t=0;t<i;t++)printTrainInfo(r[t]);if(i==0)printf("\n\t\t\tSorry!Can't find the train for you!\n"); else{printf("\ndo you want to book it?<1/0>\n");scanf("%d",&ch);if(ch == 1){h=(bookMan*)malloc(sizeof(bookMan)); printf("Input your name: ");scanf("%s",&str1);strcpy(h->,str1);printf("Input your id: ");scanf("%s",&str2);strcpy(h->data.num,str2);printf("Input your bookNum: ");scanf("%d",&dem);h->data.bookNum=dem ;h->next=NULL ;v->next=h ;v=h ;printf("\nLucky!you have booked a ticket!"); getch();shoudsave=1 ;}}}bookMan*Locate2(bookManLinkk,charfindmess[]) {bookMan*r ;r=k->next ;while(r){if(strcmp(r->data.num,findmess)==0){mark=1 ;return r ;}r=r->next ;}return 0 ;}/*修改火车信息*/voidUpdateInfo(Link l){Node*p ;charfindmess[20],ch ;if(!l->next){printf("\nthere isn't record for you to modify!\n"); return ;}else{QueryTrain(l);if(mark1==0){printf("\nDo you want to modify it?\n"); getchar();scanf("%c",&ch);if(ch=='y');{printf("\nInput the number of the train:");scanf("%s",findmess);p=Locate1(l,findmess,"num");if(p){printf("Input new number of train:");scanf("%s",&p->data.num);printf("Input new city the train will reach:");scanf("%s",&p->data.city);printf("Input new time the train take off");scanf("%s",&p->data.takeoffTime);printf("Input new time the train reach:");scanf("%s",&p->data.receiveTime);printf("Input new price of the ticket::");scanf("%d",&p->data.price);printf("Input new number of people who have booked ticket:"); scanf("%d",&p->data.bookNum);printf("\nmodifying record is sucessful!\n");shoudsave=1 ;}elseprintf("\t\t\tcan't find the record!");}}elsemark1=0 ;}}/*系统给用户的提示信息*/voidAdvicedTrains(Link l){Node*r ;charstr[10];int mar=0 ;r=l->next ;printf("Iuput the city you want to go: ");scanf("%s",str);while(r){if(strcmp(r->data.city,str)==0&&r->data.bookNum<200){mar=1 ;printf("\nyou can select the following train!\n");printf("\n\nplease select the fourth operation to book the ticket!\n"); printTrainInfo(r);}r=r->next ;}if(mar==0)printf("\n\t\t\tyou can't book any ticket now!\n");}/*保存火车信息*/voidSaveTrainInfo(Link l){FILE*fp ;Node*p ;int count=0,flag=1 ;fp=fopen("c:\\train.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=l->next ;while(p){if(fwrite(p,sizeof(Node),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf("the number of the record which have been saved is %d\n",count); shoudsave=0 ;}fclose(fp);}/*保存订票人的信息*/voidSaveBookmanInfo(bookManLink k){FILE*fp ;bookMan*p ;int count=0,flag=1 ;fp=fopen("c:\\man.txt","wb");if(fp==NULL){printf("the file can't be opened!");return ;}p=k->next ;while(p){if(fwrite(p,sizeof(bookMan),1,fp)==1){p=p->next ;count++;}else{flag=0 ;break ;}}if(flag){printf("the number of the record which have been saved is %d\n",count); shoudsave=0 ;}fclose(fp);}int main(){FILE*fp1,*fp2 ;Node*p,*r ;char ch1,ch2 ;Link l ;bookManLink k ;bookMan*t,*h ;intsel ;l=(Node*)malloc(sizeof(Node));l->next=NULL ;r=l ;k=(bookMan*)malloc(sizeof(bookMan));k->next=NULL ;h=k ;fp1=fopen("c:\\train.txt","ab+");if((fp1==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp1)){p=(Node*)malloc(sizeof(Node));if(fread(p,sizeof(Node),1,fp1)==1){p->next=NULL ;r->next=p ;r=p ;count1++;}}fclose(fp1);fp2=fopen("c:\\man.txt","ab+");if((fp2==NULL)){printf("can't open the file!");return 0 ;}while(!feof(fp2)){t=(bookMan*)malloc(sizeof(bookMan)); if(fread(t,sizeof(bookMan),1,fp2)==1){t->next=NULL ;h->next=t ;h=t ;count2++;}}fclose(fp2);while(1){system("cls");printInterface();printf("please choose the operation: "); scanf("%d",&sel);system("cls");if(sel==8){if(shoudsave==1){getchar();printf("\nthe file have been changed!do you want to save it(y/n)?\n"); scanf("%c",&ch1);if(ch1=='y'||ch1=='Y'){SaveBookmanInfo(k);SaveTrainInfo(l);}}printf("\nThank you!!You are welcome too\n");break ;}switch(sel){case 1 :InsertTraininfo(l);break ;case 2 :QueryTrain(l);break ;case 3 :BookTicket(l,k);break ;case 4 :UpdateInfo(l);break ;case 5 :AdvicedTrains(l);break ;case 6 :SaveTrainInfo(l);SaveBookmanInfo(k);break ;case 7 :return 0;}printf("\nplease press any key to continue.......");getch();}return 0;}11/11。

C++程序设计源代码

C++程序设计源代码

//C++课程设计#include<iostream> //数据流输入、输出#include<fstream> //文件输入、输出#include<string> //字符串操作#include<iomanip> //参数化输入/输出#include <stdio.h>using namespace std; //命名空间class Bus_infor{int No; //班次号static int Bus_No; //静态数据成员,统计当前所有的Bus_infor 对象的数目char start[20]; //起始站char end[20]; //终点站int Bus_order; //班次号int all_tickted; //额定载量int tickted; //已定票人数int Hour_start,Minute_start,Hour_end,Minute_end; //起始时间int Hour,Minute; //行车时间public:Bus_infor();~Bus_infor();Bus_infor *next;int Get_no(){return No;} //返回班次号void input(); //录入函数void input(ifstream & is); //读取函数void output(); //输出函数void output(ofstream & os); //写入函数void GetTime_start(); //录入发车时间void GetTime_end(); //录入到站时间void addr(); //录入起始站int Get_all_tickted(){return all_tickted;} //返回额定载量int Get_tickted(){return tickted;} //返回已定票人数char *Get_start(){ return start;} //返回发车时间char *Get_end(){return end;} //返回到站时间void GetTime(); //获取行车时间void ShowTime(); //显示行车时间int Get_bus_order(){return Bus_order;} //返回当前所有的Bus_infor对象的数目void Order_tickt(int n); //订票函数void Unorder_tickt(int n); //退票函数};int Bus_infor::Bus_No=1;void Bus_infor::input(){cout<<"\t\t\t按提示输入:"<<endl;cout<<"\t\t输入车次: ";cin>>Bus_order;cout<<"请输入车的额定载量: ";cin>>all_tickted;GetTime_start();GetTime_end();GetTime();ShowTime();addr();char a;cout<<"是否清空售票(y/n)?"<<endl;cin>>a;if(a=='y'||a=='Y') tickted=0;}void Bus_infor::input(ifstream & is){is>>Bus_order>>start>>end>>all_tickted>>tickted>>Hour_start>>Minute_start>>Hour_end >>Minute_end>>Hour>>Minute;is.get();}void Bus_infor::output(){cout<<"客车基本信息如下:"<<endl;cout<<" 车次发车时间到站时间行车时间额定载量已订票人数起点站终点站"<<endl;cout<<setw(4)<< Bus_order<<setw(8)<<Hour_start<<":"<< Minute_start<<setw(8)<< Hour_end<<":"<< Minute_end<<setw(8)<<Hour<<":"<<Minute<<setw(10)<<all_tickted<<setw(10)<<tickted<<setw(11)<<start<<setw(10)<<end<<endl;}void Bus_infor::output(ofstream & os){os<<setw(6)<<Bus_order<<setw(15)<<start<<setw(6)<<end<<setw(15)<<all_tickted<<setw(15)<<tickted<<setw(15)<<Hour_start<<setw(15)<<Minute_start<<setw(15)<<Hour_end<<setw(15)<<Minute_end<<setw(15)<<Hour<<setw(15)<<Minute<<endl;}void Bus_infor::GetTime_start(){int NewH=0,NewM=0;cout<<"请输入发车时间:"<<endl;cin>>NewH>>NewM;Hour_start=NewH;Minute_start=NewM;}void Bus_infor::GetTime_end(){int NewH=0,NewM=0;cout<<"请输入到站时间:"<<endl;cin>>NewH>>NewM;Hour_end=NewH;Minute_end=NewM;}void Bus_infor::GetTime(){if(Minute_end>=Minute_start){Minute=(Minute_end-Minute_start);Hour=(Hour_end-Hour_start);}else{Minute=(Minute_end-Minute_start+60);Hour=(Hour_end-Hour_start-1);}}void Bus_infor::ShowTime(){cout<<"显示行车时间"<<endl;cout<<Hour<<":"<<Minute<<endl;}Bus_infor::Bus_infor(){No=Bus_No++;tickted=0;}Bus_infor::~Bus_infor(){ Bus_No--; }void Bus_infor::addr(){cout<<"请输入起点站与终点站:"<<endl;char a[20];char b[20];cin>>a;cin>>b;strcpy(start,a);strcpy(end,b);}void Bus_infor::Order_tickt(int n){tickted=tickted+n;}void Bus_infor::Unorder_tickt(int n){tickted=tickted-n;};class Bus_link{public:Bus_link(){head=new Bus_infor;head->next=NULL;key=0;}void input(); //录入车票信息void mend(); //修改车票信息void del(); //删除车票信息int find(Bus_infor **p,int num,char *pn); //查找函数void found(); //查询车票信息void show(); //显示车票信息void Order(); //订购车票信息void Unorder(); //推定车票信息void save(); //保存车票信息void begin(); //初始化车票信息void clear(); //清楚函数char mainmenu(); //主菜单函数void setkey(int k){ key=k; } //设置系统修改标志int getkey(){ return key;} //返回系统修改标志private:Bus_infor *head; //链表指针int key; //系统修改标志};void Bus_link::input(){Bus_infor *p,*p2=NULL;p=head;int n;while(p->next)p=p->next;while(n){p2=new Bus_infor;p2->input();p->next=p2;p2->next=NULL;p=p->next;Bus_link::setkey(1);cout<<"\t\t\t按1继续,按0返回: ";cin>>n;if(!cin)throw string("数据输入错误");}}void Bus_link::Order(){Bus_infor *p;cout<<"确定购票(y/n)?"<<endl;char X;cin>>X;if(X=='y'){int num;cout<<"\t\t\t输入车次号: ";cin>>num;if( !find(&p,num,"^") ){cout<<"\t\t找不到你要定票的车辆的内容!"<<endl;return;}cout<<"输入要定的票数";int n;cin>>n;p=p->next;if((p->Get_tickted()+n)<=p->Get_all_tickted()){p->Order_tickt(n);cout<<"谢谢使用"<<endl;}else cout<<"对不起,没有足够的票数。

C语言火车票管理系统

C语言火车票管理系统

#include<stdio.h>#include<string.h>#include<stdlib.h>#include<time.h>#include<conio.h>#define N 1000typedef struct TICKET //定义新结构体TICKET {char num[10]; //车次char hour[3];char min[3];char from[10];char to[10];float hours;int max; //车载容量int now; //已售票数}CLASS;int class_num=0;CLASS records[N];int system_time();void message();void ShowTable1();void ShowTable2(int i);void Display();void add();void save();void load(); // 按班次查询void search(); //查询void change(); //修改void quit(); //退出void buyticket(); //售票void deleteticket(); //取消int menu_select(); //菜单int whether(int); //判断购买时间void find(char s1[],char s2[]); //按起点终点查询void deletemessage(); //删除int findnum(char s1[]); //班次查询void get(int,int); //修改及增加班次char*menu[]={" 欢迎使用车票查询系统","\n*******************菜单***********************", "\n 1. 录入班次","\n 2. 浏览班次信息","\n 3. 查询路线","\n 4. 增加班次","\n 5. 售票","\n 6. 退票","\n 7. 修改班次","\n 8. 删除班次","\n 9. 退出"};int main(){system("cls");while(1){switch(menu_select()) //菜单{case 1: message();break;case 2: Display();break;case 3: search();break;case 4: add();break;case 5: buyticket();break;case 6: deleteticket();break;case 7: change();break;case 8: deletemessage();break;case 9: quit();break;}}}int menu_select() //菜单{char s[5];int c,i;system("cls");for(i=0;i<11;i++){printf("%s",menu[i]); //输出菜单}i=0;while(c<0||c>9){printf("\n");printf("\n请输入选项(1-9): ");scanf("%s",s);c=atoi(s);}//输出菜单return c;}void message() //录入{int i=0,j=5,h;char s[5];FILE *fp; //定义文件型指针变量system("cls"); //刷屏if((fp=fopen("d:车票管理系统0.dat","rb"))!=NULL) //fopen打开文件{printf("增加信息\n");printf("请输入任意键返回\n");scanf("%s",s);i=1;}if(i==0){system("cls"); //刷屏printf("请输入班次总数:\n");scanf("%d",&class_num); //指向班次指针system("cls"); //刷屏for(i=0;i<class_num;i++){system("cls"); //刷屏printf("请输入%d班次信息:\n",i+1);h=-1;for(;h!=i;) ///循环输出{printf("请输入班次:\n");scanf("%s",records[i].num);for(h=0;h<i;h++)if(strcmp(records[h].num,records[i].num)==0){printf("该班次已存在\n");break;}}get(i,j); //修改及增加班次j=5;}save(); //调用保存函数}}/*******************************显示所有函数********************************/void Display() //显示所有函数{int i,j;system("cls"); //刷屏load(); // 按班次查询ShowTable1();for(i=0,j=0;i<class_num;i++,j+=2) //按班次顺序输出{if(whether(i)) //判断时间是否超出printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min, records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);elseprintf("|%10s| 已发车|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);}ShowTable2(j);printf("\n按任意键继续\n");getch();}void ShowTable1(){int i=2;system("cls"); //刷屏printf(" 班次信息\n");printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");printf("\n| 班次| 发车时间| 起点站| 终点站|行车时间|额定载量| 已售票|\n");}void ShowTable2(int i){printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");}void search() //查询班次{int i;char s1[10]={'\0'},s2[10]={'\0'};system("cls"); //刷屏printf("1. 按班次查询\n");printf("2. 按终点站查询\n");printf("3. 退出\n");printf("请选择(1-3):\n");scanf("%d",&i);load(); //按班次查询switch(i){case 1: printf("请输入要查询的班次:\n");scanf("%s",s1);find(s1,s2);break;case 2: printf("请输入要查询终点站:\n");scanf("%s",s2);find(s1,s2);break;case 3: break;default : printf("输入错误!\n");break;}printf("按任意键继续\n");getch();}void find(char s1[],char s2[]){int i,h=0,m;ShowTable1();if(s2[0]=='\0')m=1;else m=0;for(i=0;i<class_num;i++)if(strcmp(s1,records[i].num)==0||strcmp(s2,records[i].to)==0){printf("\n");printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min,records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);h+=2;if(m==1)break;}ShowTable2(h);if(h==0)printf("查找的班次不存在\n");}void add(){int i,j=5;load();system("cls");printf("1. 增加班次\n");printf("2. 返回\n");printf("请选择(1-2)\n");scanf("%d",&i);if(i==1){system("cls");printf("1. 输入要增加的班次:\n");scanf("%s",records[class_num].num);for(i=0;i<class_num;i++)if(strcmp(records[class_num].num,records[i].num)==0){printf("输入错误\n");getch();break;}if(i==class_num){get(i,j);class_num++;save();}}}void buyticket(){int i;char num[10];system("cls");printf("1. 售票\n");printf("2. 返回\n");printf("请选择(1-2):\n");scanf("%d",&i);if(i==1){load(); // 按班次查询search();printf("请输入要订票的班次(若无请输入0):\n");scanf("%s",num);for(i=0;i<class_num;i++)if(strcmp(num,records[i].num)==0)if(records[i].max>records[i].now&&whether(i)==1){records[i].now++;printf("通向%s班次为%s的票订票成功\n",records[i].to,records[i].num);save();getch();break;}else{printf("该班次已满或已发出!\n");getch();}}}void deleteticket(){int i;char num[10];system("cls");printf("1. 退票\n");printf("2. 返回\n");printf("请选择(1-2)\n:");scanf("%d",&i);if(i==1){system("cls");load();printf("请输入要退票的班次:\n");scanf("%s",num);i=findnum(num);if(strcmp(num,records[i].num)==0)if(whether(i)){printf("是否确认");scanf("%s",num);if(num[0]=='y'||num[0]=='Y'){records[i].now--;printf("退票成功\n");save();getch();}}else{printf("该班车已发出,无法退票\n");getch();}if(i==class_num){printf("输入错误\n");getch();}}}void change(){char num[10],s[10];int h=0,j=13,i;load();system("cls");printf("请输入要修改的班次:\n");scanf("%s",num);i=findnum(num);if(i==class_num){printf("输入错误\n");getch();}else{printf("确认修改\n");scanf("%s",s);if(s[0]=='y'||s[0]=='Y'){get(i,j);save();}}}void deletemessage(){int i,h=0;char num[10];system("cls");printf("1. 删除班次\n");printf("2. 返回\n");printf("请选择(1-2):\n");scanf("%d",&i);if(i==1){system("cls");printf("请输入要删除的班次:\n");scanf("%s",num);i=findnum(num);if(i==class_num){printf("输入错误\n");getch();}else{printf("是否确认\n");scanf("%s",num);if(num[0]=='y'||num[0]=='Y'){for(;i<class_num-1;i++)records[i]=records[i+1];class_num--;save();printf("删除成功\n");getch();}}}}int findnum(char s1[]){int i,h=0;ShowTable1();for(i=0;i<class_num;i++){if(strcmp(s1,records[i].num)==0){printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|",records[i].num,records[i].h our,records[i].min,records[i].from,records[i].to,records[i].hours,records[i].max,records[i] .now);h+=2;break;}}ShowTable2(h);return i;}void save(){FILE *fp1,*fp2;if((fp1=fopen("d:车票管理系统.dat","wb"))==NULL) //打开文件{printf("文件打开错误!\n");exit(0);}if((fp2=fopen("d:车票管理系统0.dat","wb"))==NULL){printf("文件打开错误!\n");exit(0);}fwrite(&class_num,sizeof(int),1,fp2);fwrite(records,sizeof(CLASS),class_num,fp1);fclose(fp1);fclose(fp2);}void load(){FILE *fp1,*fp2;if((fp1=fopen("d:车票管理系统.dat","rb"))==NULL){system("cls");printf("文件打开错误\n");getch();exit(0);}if((fp2=fopen("d:车票管理系统0.dat","rb"))==NULL) {system("cls");printf("文件打开错误\n");getch();exit(0);}fread(&class_num,sizeof(int),1,fp2);fread(records,sizeof(CLASS),class_num,fp1);fclose(fp1);fclose(fp2);}void quit(){char s[5];printf("确认退出\n");scanf("%s",s);if(s[0]=='y'||s[0]=='Y')exit(0);}void get(int i,int j){for(;;){printf("请输入发车时间(xx xx)");scanf("%s%s",records[i].hour,records[i].min);if((atoi(records[i].hour)<24&&atoi(records[i].hour)>=0)&&(atoi(records[i].min)<60& &atoi(records[i].min)>=0))break;else{printf("输入错误\n");getch();}}printf("请输入起点站:\n");scanf("%s",records[i].from);printf("请输入终点站:\n");scanf("%s",records[i].to);printf("请输入行车时间:\n");scanf("%f",&records[i].hours);printf("请输入额定载量:\n");scanf("%d",&records[i].max);for(;;){printf("请输入已售票数:\n");scanf("%d",&records[i].now);if(records[i].now<=records[i].max) break;else{printf("输入错误\n");getch();}}}int whether(int i){struct tm *local;time_t t;t=time(NULL); //NULL在stdio.h中定义为0local=localtime(&t); /////获取当前系统时间if(local->tm_hour<atoi(records[i].hour)||local->tm_hour==atoi(records[i].hour)&&local->tm_min<atoi(records[i].min))//atoi将字符串转换成一个整数值return 1;elsereturn 0;}。

火车票查询系统代码

火车票查询系统代码

if(strcmp(numorcity,"num")==0) 于判断 {
// ; while(r) { if(strcmp(r->data.getnum(),findmess)==0) return r ; r=r->next ; } } else if(strcmp(numorcity,"city")==0) { r=l->next ; while(r) { if(strcmp(r->data.getcity(),findmess)==0) return r ; r=r->next ; } } return 0 ; } void chaxuntrain(Link l) // 查询火车信息 { char t='y'; while(t=='y') { Node *p ; int sel ; //查询方式代号(1和2) char str1[5],str2[10]; if(!l->next) //指向链表的最后尾段, 即没有记录 {cout<<" 非常抱歉,这里没有相关记录 !"<<endl; return ; } cout<<" 选择查询方式:\n 1:根据车次查询;\n 2:根据到达的城市查询:"<<endl;
if(fp==NULL) { cout<<" 文件无法打开!" ; return ; } p=l->next ; while(p) { if(fwrite(p,sizeof(Node),1,fp)==1) //fwrite,写内 容(Node)到流中,c库函数, { p=p->next ; count++; } else { flag=0 ; break ; } } if(flag) { cout<<" 以上"<<count<<"个train的信息已经被保 存"<<endl; shoudsave=0 ; } fclose(fp); //文件关闭 } int main() { FILE*fp1 ; Node*p,*r ; Link l ; int sel ; l=(Node*)malloc(sizeof(Node));

火车票售票系统源代码

火车票售票系统源代码
jbt1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JFileChooser openfile = new JFileChooser();
p2.add(jtf4);
p2.add(jlb6);
p2.add(jtf5);
p2.add(jlb7);
p2.add(jtf6);
p2.add(jbt1);
p3.add(p1,BorderLayout.NORTH);
p3.add(p2,BorderLayout.CENTER);
inputfile = new FileInputStream(filename);
int len = 0;
// 如下为依次读取文件中的每一行内容,将其加入StringBuffer数据类型便利strBF中
FileReader in = new FileReader(filename.getAbsoluteFile());
JLabel jlb5=new JLabel(" 身份证号");
JLabel jlb6=new JLabel(" 工作");
JLabel jlb7=new JLabel(" 电话");
final JTextField jtf1=new JTextField(10);
final JTextField jtf2=new JTextField(10);
JOptionPane.showMessageDialog(panel, error_message
);

车站售票管理系统SQL源代码

车站售票管理系统SQL源代码

/*插入数据的存储过程 */
create proc car_proc
@carid char(10),@cartype int,@platenumber char(10),@carhole char(6),@outsettime datetime
as
insert into car (carid,cartype,platenumber,carhole,outsettime) values(@carid,@cartype,@platenumber,@carhole,@outsettime)
go
create table price
(terminalid char(10) constraint p_PRI PRIMARY KEY,outstation char(10),terminal char(6),carid char(10) FOREIGN KEY REFERENCES car(carid) ,ticketprice int)
@terminalid char(10),@outstation char(10),@terminal char(6),@carid char(10) ,@ticketprice int
as
insert into price (terminalid,outstation,terminal,carid,ticketprice) values(@terminalid,@outstation,@terminal,@carid,@ticketprice)
/*建立存储过程实现单表查询*/
/*建立名为“单表查询1”的存储过程,用来查询某辆客车的信息*/
create proc 单表查询1
@carid char(10)

长途客运站管理系统(数据库课程设计)汇编

长途客运站管理系统(数据库课程设计)汇编
UPDATE M_Route SET AddT='d 线' WHERE Destination='芜湖'; ③删除 ALTER TABLE M_Vehicle DROP COLUMN Depature;
2.数据查询相关 SQL 语句 SELECT * FROM M_TInfo;
SELECT * FROM M_Route;
目录
1.设计背景及目的 ........................................................................................1 2.设计内容及要求 ................................................................................................1 3.设计过程 ............................................................................................................2
编程语言可由小组根据自己的情况选择,但一般情况下应该是小组的每 个成员都对该语言较熟悉。避免把学习语言的时间放在设计期SQL_Server 2005 等。 系统功能的基本要求:
线路信息,包括出发地、目的地、出发时间、所需时间等。 汽车信息:包括汽车的种类及相应的票价、最大载客量等。
图 3.2.4
余票数量 TRest
1
线路信息
N
行驶
1
车辆信息
N
供应
票务信息
图 3.2.5
关系图:
M_Vehicle Vno char(8) PRIMARY KEY VType char(20) TPrice int VLoad int Rno varchar(5)

汽车售票管理信息系统

汽车售票管理信息系统
三、系统设计
系统设计的主要工作有:
1、总体设计,包括信息系统流程图设计、功能结构图设计和功能模块图设计等.
2、代码设计和设计规范的制定.
3、系统物理配置方案设计,包括设备配置、通信网络的选择和设计以及数据库管理系统的选择等.
4、数据存储设计,包括数据库设计、数据库的安全保密设计等。
5、计算机处理过程设计,包括输出设计、输入设计、处理流程图设计以及编写程序设计说明书等。
购票操作
别名
输入数据流
车票信息+购票时间+座位号
输出数据流

处理
处理过程名称
更新
编号
D3
含义说明
改变系统信息
别名
输入数据流
变更信息
输出数据流
再次查询信息
处理
插入各项数据项、删除某数据项、查询某数据项
处理过程名称
用户权限认证
编号
D4
含义说明
别名
输入数据流
用户名,密码,身份
输出数据流
系统主菜单
处理
用户登录
1.4开发计划
日期
主要任务
11月30日—-12月12日
确定题目。
需求分析。
编写数据字典。
绘制E—R图.
12月12日——12月22日
完善数据字典。修改E-R图。
进行详细调查.
完成组织结构图、业务流程图、数据流程图。
12月26日——1月5日
进行代码设计等。
完善设计。
二、系统分析
2。1系统需求分析
调查组织结构的总体情况:
ﻩ·管理人员:GLRY ****.如GLRY0001代表编号为0001的管理人员.
3。2.3 汽车代码

订票系统的源代码

订票系统的源代码

订票系统的源代码import java.util.*;import java.io.*;import ng.*;import java.text.*;import java.sql.*;import java.sql.Connection;class Stream{Scanner sc=new Scanner(System.in);String a[][]=new String [100][7];String id,starttime,departurepoint,destination,lasttime,fixnum,fixednum;public String input(int s){switch(s){case 0:{System.out.println("输入班次");return id=sc.next();}case 1:{System.out.println("输入起点");return departurepoint=sc.next();}case 2:{System.out.println("输入发车时间");return starttime=sc.next();}case 3:{System.out.println("输入终点");return destination=sc.next();}case 4:{System.out.println("输入行车时间");return lasttime=sc.next();}case 5:{System.out.println("输入额定载量");return fixnum=sc.next();}case 6:{System.out.println("输入已定票人数");return fixednum=sc.next();}}return id;}public void output1(){System.out.println("***--------------------------------------------------***");System.out.println(" *** ***");System.out.println(" *** 欢迎进入火车订票系统***");System.out.println(" *** ***");System.out.println("***--------------------------------------------------***");System.out.println(" || 请选择您需要的操作:||");System.out.println(" || (1)录入班次信息||");System.out.println(" || (2)查看班次信息||");System.out.println(" || (3)查询行车路线||");System.out.println(" || (4)订票||");System.out.println(" || (5)退票||");System.out.println(" || (0)退出系统||");System.out.println(" || 选择相关操作请输入相对的括号里的阿拉伯数字(0~5)! ||");public void output2(){System.out.println("班次\t\t发车时间\t起点\t\t终点\t行车时间\t额定载量\t已定票人数\n");}}class Information implements Runnable{String a[][]=new String [100][7];String x[]=new String [100];int r[]=new int [10];int b,i,g;String m;Stream sm=new Stream();Scanner sc=new Scanner(System.in);public void loop(int l){String z,s1,s2;s1="y";s2="n";int p=0;do{switch(l){case 1:in();break;case 2:search();break;case 3:order();break;case 4:delete();break;}z=sc.next();do{if(pareTo(s1)!=0&&pareTo(s2)!=0){System.out.println("指令错误!请重新输入:");z=sc.next();p=1;}elsep=0;}while(p==1);}while(pareTo(s1)==0);public void in(){int t=0,p=0;String z,u;u="admin";System.out.println("请输入管理员密码:");z=sc.next();do{if(pareTo(u)!=0){System.out.println("密码错误!请重新输入:");z=sc.next();p=1;}else{System.out.println("数据录入后请按任意键回到主菜单,继续录入请按1键");p=0;do{for(int i=0;i<7;i++){a[b][i]=sm.input(i);}b++;t=sc.nextInt();}while(t==1);}}while(p==1);System.out.println("输入成功\t信息如下:");DispAll();System.out.println("数据录入成功,想继续录入吗(y/n)");}public synchronized void order(){System.out.println("请输入您要订票的班次:");m=sc.next();boolean c=true;for(int i=0;i<b;i++){String x=a[i][0];int s=Integer.parseInt(a[i][5]);int q=Integer.parseInt(a[i][6]);if(pareTo(x)==0){c=false;if (s>q){try{Thread.sleep(10);}catch(Exception e){e.printStackTrace();}q++;System.out.println("该班次的车票已售出:"+q);a[i][6]=String.valueOf(q);}else{System.out.println("对不起,今天的这趟车的票已卖完,请明天再来,谢谢合作!\n");}System.out.println("输入成功\t信息如下:");DispAll();}}if(c==true){System.out.println("对不起,今天没有这趟车,请明天再来,谢谢使用!");}System.out.println("要继续订票吗?(y/n)");}public void run(){while(true){order();delete();}}public synchronized void delete(){System.out.println("请输入您要退票的班次:");m=sc.next();boolean c=true;for(int i=0;i<b;i++){String x=a[i][0];int q=Integer.parseInt(a[i][6]);if(q>0){if(pareTo(x)==0){c=false;q--;System.out.println("您已退票成功!");a[i][6]=String.valueOf(q);}}}if(c==true){System.out.println("对不起,今天没有这趟车或者这趟车已发出,无法完成退票!\n");}System.out.println("要继续退票吗?(y/n)");}public void search(){boolean c=true;System.out.println("===========================");System.out.println("||请选择您需要的操作: ||");System.out.println("===========================");System.out.println("||1.按班次号查询: ||");System.out.println("||2.按起点站查询: ||");System.out.println("||3.按终点站查询: ||");System.out.println("||0.退出||");System.out.println("===========================");System.out.println("||请输入您要修改的选项||:");int k=sc.nextInt();c=false;switch(k){case 1:{System.out.println("请输入班次号:");m=sc.next();for( i=0;i<b;i++){String x=a[i][0];if(pareTo(x)==0){c=false;sm.output2();for (int e=0;e<7;e++){System.out.print(a[i][e]+"\t\t\t");}System.out.println("\t");}}}break;case 2:{System.out.println("请输入起点站:");m=sc.next();for(i=0;i<b;i++){String x=a[i][2];if(pareTo(x)==0){c=false;sm.output2();for (int e=0;e<7;e++){System.out.print(a[i][e]+"\t\t\t");}System.out.println("\t");}}}break;case 3:{System.out.println("请输入终点站:");m=sc.next();for(i=0;i<b;i++){String x=a[i][3];if(pareTo(x)==0){c=false;sm.output2();for (int e=0;e<7;e++){System.out.print(a[i][e]+"\t\t\t");}System.out.println("\t");}}} break;}if(c==true){System.out.println("您要求查询的对象本来就不存在!请检查输入的正确性!");}System.out.println("要继续查询吗?(y/n)");}public void DispAll(){System.out.println("本系统的班次信息如下:");if(b==0){System.out.println("管理系统中没有录入数据或者数据已经被删除!"); }else{sm.output2();for(int i=0;i<b;i++){for (int e=0;e<7;e++){System.out.print(a[i][e]+"\t\t\t");}System.out.println("\t");}}}public void load(){Connection con ;Statement sql;ResultSet rs;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){System.out.print(e);}try{con=DriverManager.getConnection("jdbc:odbc:mydata","","");sql=con.createStatement();rs=sql.executeQuery("SELECT * FROM ticket");while(rs.next()){for(int i=0;i<7;i++){int t=i+1;a[b][i]=rs.getString(t);}b++;}con.close();}catch(SQLException e){System.out.println(e);}r[0]=b;}public void perserve(){Connection con;PreparedStatement ps;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){System.out.print(e);}try{g=r[0];for (int h=0;h<=g;h++){con=DriverManager.getConnection("jdbc:odbc:mydata","","");ps=con.prepareStatement("UPDATE ticket SET fixednum=? WHERE id=?");ps.setString(2,a[h][0]);ps.setString(1,a[h][6]);ps.executeUpdate();ps.close();mit();con.close();}System.out.println("数据库更新完毕!");}catch(SQLException e){System.out.println(e);}}public void perserve1(){Connection con;PreparedStatement pstmt;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){System.out.print(e);}try{g=r[0];for(int u=g;u<b;u++){con=DriverManager.getConnection("jdbc:odbc:mydata","","");pstmt=con.prepareStatement("INSERT INTO ticket(id,starttime,departurepoint,destination,lasttime,fixnum,fixednum) " +"V ALUES(?,?,?,?,?,?,?)");for(int i=0;i<7;i++){int t=i+1;pstmt.setString(t,a[u][i]);}pstmt.executeUpdate();pstmt.close();mit();con.close();}System.out.println("数据库添加信息完毕!");}catch(SQLException e){System.out.println(e);}}}public class hq{public static void main(String args[]){Scanner sc=new Scanner(System.in);int k=0,d,p=0;Information im=new Information();im.load();Stream sm=new Stream();String z,s1,s2;s1="y";s2="n";do{sm.output1();System.out.println("请输入选择");k=sc.nextInt();do{if(k>=0&&k<=5){d=1;}else{System.out.println("指令错误!请重新输入:");k=sc.nextInt();d=0;}}while(d==0);switch (k){case 1:{im.loop(1);im.perserve1();}break;case 2:{im.DispAll();}break;case 3:{im.loop(2);} break;case 4:{im.loop(3);im.perserve();}break;case 5:{im.loop(4);im.perserve();}break;case 0:{System.out.println("谢谢使用!");System.exit(0);}}System.out.println("您想继续进行其他操作吗?(y/n)");z=sc.next();do{if(pareTo(s1)!=0&&pareTo(s2)!=0){System.out.println("指令错误!请重新输入:");z=sc.next();p=1;}elsep=0;}while(p==1);if(pareTo(s2)==0){System.exit(0);}}while(p==0);}}。

c语言火车售票系统课程设计

c语言火车售票系统课程设计

c语言火车售票系统课程设计一、课程目标知识目标:1. 理解C语言中数组、函数、指针、结构体等基本概念,并能运用到火车售票系统的设计与实现中;2. 掌握C语言文件操作,实现火车票信息的存储与读取;3. 理解并掌握C语言中模块化编程思想,将火车售票系统划分为多个功能模块。

技能目标:1. 能够运用C语言编写出具有良好结构和可读性的代码;2. 培养学生分析问题、解决问题的能力,通过设计火车售票系统,学会使用C 语言进行实际项目开发;3. 学会使用调试工具,对火车售票系统进行测试和优化。

情感态度价值观目标:1. 培养学生合作意识,学会在团队中共同解决问题,提高沟通与协作能力;2. 激发学生对计算机编程的兴趣,培养勇于探索、积极创新的精神;3. 培养学生关注社会实际问题的责任感,了解信息技术在实际应用中的作用和价值。

课程性质:本课程为C语言程序设计课程的实践环节,通过设计火车售票系统,让学生将所学理论知识运用到实际项目中。

学生特点:学生已具备C语言基础知识和一定的编程能力,但对实际项目的开发流程和模块化编程思想尚不熟悉。

教学要求:注重理论与实践相结合,引导学生自主探究,培养学生实际编程能力和团队协作能力。

在教学过程中,关注学生的个体差异,提供个性化指导,确保每位学生都能达到课程目标。

通过课程学习,使学生具备独立开发小型项目的能力。

二、教学内容1. 火车售票系统需求分析:介绍项目背景,分析系统功能需求,明确学生需要实现的功能模块,如用户登录、车次查询、购票、退票、余票显示等。

2. C语言基础知识回顾:- 数组:回顾一维数组、二维数组的概念和应用;- 函数:介绍函数定义、调用、参数传递等基本概念;- 指针:讲解指针的定义、使用和指针操作;- 结构体:回顾结构体的定义和使用。

3. 火车售票系统设计:- 系统架构设计:引导学生采用模块化设计思想,将系统划分为多个功能模块;- 数据结构设计:介绍如何使用结构体和数组来存储和管理车次、座位、用户等信息。

汽车售票系统(详细分析)

汽车售票系统(详细分析)

第4章详细设计4.1结构程序设计4.2人机界面设计4.2.1设计问题1. 系统响应时间2. 用户帮助设施3. 出错信息处理4. 命令交互4.2.2处理过程车票汇总:工作人员将一天所售出的票进行统计,包括票数,票类,形成确定的车票记录。

查询:将顾客需要的车票信息输入系统,并查询其是否可供应。

查询顾客信息:为订票所设,将顾客的准确信息记录,为其预定所车票。

处理买票:进行买票交易,把顾客需要的票(可供应)售出,并在系统中作相应记录,确定车票记录。

处理订票:进行订票交易,工作人员为顾客预定其所需车票,并在系统中作相应记录,确定订票记录。

处理退票:进行退票交易,工作人员为顾客办理退票手续,并在系统中作相应记录,确定退票记录。

4.2.3关系模型:车票与顾客之间的联系售票1:N车票(票号,车次,日期,车型,票价,开车时间,票种,座位号,起始站,终点站)顾客(身份证号,银行卡号,票号)退票1:N车票(票号,车次,日期,车型,票价,开车时间,票种,座位号,起始站,终点站)顾客(身份证号,银行卡号,票号,退票时间,退票手续费)订票1:N车票(票号,车次,日期,车型,票价,开车时间,票种,座位号,起始站,终点站)顾客(身份证号,银行卡号,票号,日期,交易时间,交易金额,数量,起始站,终点站)4.2.4数据库结构4.2.5 数据库设计本车站售票系统有两个实体,分别是车票和顾客,利用SQL建表如下:车票顾客4.2.6系统软件结构1.系统功能设计汽车站售票管理系统主要设有五个主要功能模块:分别是车次管理、票价管理、票务管理、用户管理和查询管理。

如图4-1所示。

2.车次管理模块该模块主要实现车次信息的编辑。

车次管理中的数据源为Access数据库中Car表,在此管理部分中,能够使用界面操作实现车次信息的编辑,并将数据库中的数据按照编辑的要求来及时更新数据表中的相关数据。

3.票价管理模块该模块主要实现票价信息的录入、修改与删除以及票价折扣信息的录入、修改与删除。

火车票查询系统代码

火车票查询系统代码

火车票查询系统代码.txt41滴水能穿石,只因为它永远打击同一点。

42火柴如果躲避燃烧的痛苦,它的一生都将黯淡无光。

#include <iostream.h>#include <string.h>void welcome(); //欢迎系统void choose(); //选择系统void time(int year,int month,int day); //时间判断系统void booktickets(); //订票子系统void sealticket(); //售票子系统void sealticket(char begin[10],char end[10],int number);void returntickets(); //退票子系统int statisticstrain(char begin[10],char end[10]); //站站查询 |int statisticstrain1(char trainnum[10]); //车次查询 } 统计子系统int statisticstrain2(char station[10]); //车站查询 |void querytrain(); //查询子系统int generateddata(char begin[10],char end[10]); //站站查询 |int generateddata1(char trainnum[10]); //车次查询 } 生成数据子系统int generateddata2(char station[10]); //车站查询 |void quit(); //退出系统//欢迎系统void welcome(){cout<<"********************************************************"<<endl;cout<<"* 欢 * 迎 * 使 * 用 * 火 * 车 * 票 * 订 * 票 * 系 * 统 *"<<endl;cout<<"********************************************************"<<endl;cout<<"* 本订票系统有以下功能: *"<<endl;cout<<"* 1:订购火车票 *"<<endl;cout<<"* 2:预定火车票 *"<<endl;cout<<"* 3:退订火车票 *"<<endl;cout<<"* 4:查询车票信息 *"<<endl;cout<<"* 5:退出系统 *"<<endl;cout<<"********************************************************"<<endl;cout<<"请选择所要执行的功能: "<<endl;choose();}//选择系统void choose(){int i;cin>>i;switch (i)case 1:booktickets();break;case 2:sealticket();break;case 3:returntickets();break;case 4:querytrain();break;case 5:quit();break;default:cout<<"请在数字 1-5 之间重新您的输入选择!"<<endl; choose();break;}}//时间判断系统void time(int year,int month,int day){int jy = 1;int y = year % 4;if(month == 2){if(year % 4 == 0){if((year/100)%4 != 0){if(day > 29){cout<<"请输入正确的日期格式!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;}}else{if(day > 28){cout<<"请输入正确的日期格式!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;}}}else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){if(day > 31){cout<<"请输入正确的日期格式!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;}}else if(month == 4 || month == 6 || month == 9 || month == 12){if(day > 30){cout<<"请输入正确的日期格式!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;}}elsecout<<"请输入正确的日期格式!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;}}//订票子系统void booktickets(){char begin[10],end[10];int year,month,day;cout<<"请输入出发地:"<<endl;cin>>begin;cout<<"请输入目的地:"<<endl;cin>>end;cout<<"请输入您所要订购的票的出发日期!"<<endl;cout<<"请输入出发年份:"<<endl;cin>>year;cout<<"请输入出发月份:"<<endl;cin>>month;cout<<"请输入出发日期:"<<endl;cin>>day;time(year,month,day); //判断输入的时间是否正确cout<<"出发日期为:"<<year<<"-"<<month<<"-"<<day<<endl; int number;cout<<"请输入所要订购的火车票数量:"<<endl;cin>>number;sealticket(begin,end,number); //调用售票系统(2)}//售票子系统(1)void sealticket(){char begin[10],end[10];cout<<"请输入出发地:"<<endl;cin>>begin;cout<<"请输入目的地:"<<endl;cin>>end;int number;cout<<"请输入所要订购的火车票数量:"<<endl;cin>>number;int j = statisticstrain(begin,end); //调用站站统计子系统if(j == 1){char trainnum[10];cout<<"请选择火车车次:"<<endl;cin>>trainnum;int price;cout<<"请选择票价:"<<endl;cin>>price;cout<<endl;cout<<"您所需要的火车票信息:"<<endl;cout<<"出发地:"<<begin<<'\t'<<"目的地"<<end<<'\t'<<"车次:"<<trainnum<<'\t'<<"票价:"<<price<<endl;cout<<"出发日期为:2010-12-24"<<endl;cout<<"您一共订购了 "<<number<<" 张"<<endl;cout<<endl;cout<<"确认无误后请输入 1 "<<'\t'<<"取消请输入 0 "<<endl;int i;cin>>i;if(i == 1){cout<<endl;cout<<"购买成功!"<<endl;cout<<"继续购买请输入 1 "<<'\t'<<"退出购票系统请输入 0 "<<endl;cin>>end;int j;cin>>j;if(j == 1)sealticket();elsewelcome();}elsewelcome();}else if(j == 0)welcome();}//售票子系统(2)void sealticket(char begin[10],char end[10],int number){int j = statisticstrain(begin,end); //调用站站统计子系统if(j == 1){char trainnum[10];cout<<"请选择火车车次:"<<endl;cin>>trainnum;int price;cout<<"请选择票价:"<<endl;cin>>price;cout<<endl;cout<<"您所需要的火车票信息:"<<endl;cout<<"出发地:"<<begin<<'\t'<<"目的地"<<end<<'\t'<<"车次:"<<trainnum<<'\t'<<"票价:"<<price<<endl;cout<<"您一共订购了 "<<number<<" 张"<<endl;cout<<endl;cout<<"确认无误后请输入 1 "<<'\t'<<"取消请输入 0 "<<endl;int i;cin>>i;if(i == 1){cout<<endl;cout<<"购买成功!"<<endl;cout<<"继续购买请输入 1 "<<'\t'<<"退出购票系统请输入 0 "<<endl;cin>>end;int j;cin>>j;if(j == 1)sealticket();elsewelcome();}elsewelcome();}else if(j == 0)welcome();}//退票子系统void returntickets(){char begin[10],end[10];cout<<"请输入出发地:"<<endl;cin>>begin;cout<<"请输入目的地:"<<endl;cin>>end;char trainnum[10];cout<<"请输入火车车次:"<<endl;cin>>trainnum;int price;cout<<"请选择票价:"<<endl;cin>>price;int number;cout<<"请输入所要退订的火车票数量:"<<endl;cin>>number;cout<<endl;cout<<"您所要退订的火车票信息:"<<endl;cout<<"出发地:"<<begin<<'\t'<<"目的地"<<end<<'\t'<<"车次:"<<trainnum<<"票价:"<<price<<endl;cout<<"您一共退订了 "<<number<<" 张"<<endl;cout<<endl;cout<<"确认无误后请输入 1 "<<'\t'<<"取消请输入 0 "<<endl;int i;cin>>i;if(i == 1){cout<<endl;cout<<"退订成功!"<<endl;cout<<"继续退订请输入 1 "<<'\t'<<"退出退票系统请输入 0 "<<endl;cin>>end;int j;cin>>j;if(j == 1)returntickets();elsewelcome();}elsewelcome();}//查询子系统void querytrain(){int i;cout<<endl;cout<<"请选择您要的查询方式:"<<endl;cout<<"1、(出发)站(到达)站查询"<<endl;cout<<"2、车次查询"<<endl;cout<<"3、车站查询"<<endl;cout<<endl;cin>>i;if(i == 1){char from[10],to[10];cout<<"请输入出发站:"<<endl;cin>>from;cout<<"请输入到达站:"<<endl;cin>>to;cout<<endl;statisticstrain(from,to);cout<<endl;welcome();}else if(i == 2){char trainnum[10];cout<<"请输入车次:"<<endl;cin>>trainnum;cout<<endl;statisticstrain1(trainnum);welcome();}else if(i == 3){char station[10];cout<<"请输入车站:"<<endl;cin>>station;cout<<endl;statisticstrain2(station);welcome();}}//统计子系统——站站查询int statisticstrain(char begin[10],char end[10]) {int i = generateddata(begin,end);cout<<endl;return i;}//生成数据子系统——站站int generateddata(char begin[10],char end[10]){if(!strcmp(begin,"changzhou") && !strcmp(end,"nanjing")){cout<<endl;cout<<"从"<<begin<<"到"<<end<<"的火车有:"<<endl;cout<<endl;cout<<"车次:k8372"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:41"<<'\t'<<"到达时间:02:17"<<'\t'<<"参考价格(元): 硬座:22 软座:34 硬卧(上/中/下):68/73/76 软卧(上/下):103/109"<<endl;cout<<endl;cout<<"车次:2582"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:54"<<'\t'<<"到达时间:02:24"<<'\t'<<"参考价格(元): 硬座:19 软座:31 硬卧(上/中/下):65/70/73 软卧(上/下):100/106"<<endl;cout<<endl;cout<<"车次:g7124"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:07:56"<<'\t'<<"到达时间:08:39"<<'\t'<<"参考价格(元): 一等软座:105"<<endl; return 1;}else{cout<<endl;cout<<"没有从 "<<begin<<" 到 "<<end<<" 的火车!"<<endl;return 0;}}//统计子系统——车次查询int statisticstrain1(char trainnum[10]){int i = generateddata1(trainnum);cout<<endl;return i;}//生成数据子系统——车次int generateddata1(char trainnum[10]){if(!strcmp(trainnum,"k8372")){cout<<endl;cout<<"车次为"<<trainnum<<"的火车有:"<<endl;cout<<endl;cout<<"车次:k8372"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:41"<<'\t'<<"到达时间:02:17"<<'\t'<<"参考价格(元): 硬座:22 软座:34 硬卧(上/中/下):68/73/76 软卧(上/下):103/109"<<endl;return 1;}else if(!strcmp(trainnum,"2582")){cout<<endl;cout<<"车次为"<<trainnum<<"的火车有:"<<endl;cout<<endl;cout<<"车次:2582"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:54"<<'\t'<<"到达时间:02:24"<<'\t'<<"参考价格(元): 硬座:19 软座:31 硬卧(上/中/下):65/70/73 软卧(上/下):100/106"<<endl;return 1;}else if(!strcmp(trainnum,"g7124")){cout<<endl;cout<<"车次为"<<trainnum<<"的火车有:"<<endl;cout<<endl;cout<<"车次:g7124"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:07:56"<<'\t'<<"到达时间:08:39"<<'\t'<<"参考价格(元): 一等软座:105"<<endl; return 1;}else{cout<<endl;cout<<"没有车次为 "<<trainnum<<trainnum[0]<<" 的火车!"<<endl;return 0;}}//统计子系统——车站查询int statisticstrain2(char station[10]){int i = generateddata2(station);cout<<endl;return i;}//生成数据子系统——车站int generateddata2(char station[10]){if(!strcmp(station,"changzhou") || !strcmp(station,"nanjing")){cout<<endl;cout<<"出发站(经过站)为"<<station<<"的火车有:"<<endl;cout<<endl;cout<<"车次:k8372"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:41"<<'\t'<<"到达时间:02:17"<<'\t'<<"参考价格(元): 硬座:22 软座:34 硬卧(上/中/下):68/73/76 软卧(上/下):103/109"<<endl;cout<<endl;cout<<"车次:2582"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:00:54"<<'\t'<<"到达时间:02:24"<<'\t'<<"参考价格(元): 硬座:19 软座:31 硬卧(上/中/下):65/70/73 软卧(上/下):100/106"<<endl;cout<<endl;cout<<"车次:g7124"<<'\t'<<"发站:(过)常州"<<'\t'<<"到站:(过)南京"<<'\t'<<"发车时间:07:56"<<'\t'<<"到达时间:08:39"<<'\t'<<"参考价格(元): 一等软座:105"<<endl; return 1;}else{cout<<endl;cout<<"没有经过 "<<station<<" 的火车!"<<endl;return 0;}}//退出系统void quit(){cout<<endl;cout<<"感谢您的使用!"<<endl;}void main(){welcome();}。

火车售票系统完整代码

火车售票系统完整代码

package com.yue;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextArea;import javax.swing.JTextField;public class BuyPanel extends JPanel {StringBuffer sb = new StringBuffer();private boolean flag = false;JTextArea jtArea = new JTextArea(10, 78);JLabel buyLabel = new JLabel("订票");JTextField fId = new JTextField(7);JTextField ftid = new JTextField(7);JTextField fche = new JTextField(7);JTextField fzhangshu = new JTextField(7);JTextField fbodyId = new JTextField(7);JPasswordField jpField = new JPasswordField(7);public JPanel getBuypn() {JPanel pan = new JPanel();GridBagLayout layout = new GridBagLayout();pan.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 100, 100, GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(buyLabel, con);con = getGridBagConstraints(0, 2, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan3(), con);con = getGridBagConstraints(0, 3, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan4(), con);con = getGridBagConstraints(0, 4, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);pan.add(new pan5(), con);this.setLocation(270, 150);this.add(pan);return pan;}/*** 定义下面购票操作区面板pan3** @author Administrator**/class pan3 extends JPanel {JLabel lId = new JLabel(" 车票号码 ");JLabel ltid = new JLabel(" 车票号码 ");JLabel che = new JLabel(" 车次 ");JLabel lbodyId = new JLabel(" 身份证号 ");JLabel password = new JLabel(" 密码 ");JLabel lzhangshu = new JLabel(" 所需张数 ");JLabel la1 = new JLabel(" ");JLabel la2 = new JLabel(" ");JButton sureButton = new JButton("查询确认");JButton buyButton = new JButton("确认购票");public pan3() {buyButton.addActionListener(new ActionListener(){@Overridepublic void actionPerformed(ActionEvent e) {UpdateUser();if (flag==true){UpdateTrain();System.out.println("hjkasfhjkaf");}}});sureButton.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {select();}});GridBagLayout layout = new GridBagLayout();this.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lId, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fId, con);con = getGridBagConstraints(8, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(la2, con);con = getGridBagConstraints(9, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(sureButton, con);con = getGridBagConstraints(0, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(ltid, con);con = getGridBagConstraints(1, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(ftid, con);con = getGridBagConstraints(2, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(che, con);con = getGridBagConstraints(3, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fche, con);con = getGridBagConstraints(4, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lbodyId, con);con = getGridBagConstraints(5, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fbodyId, con);con = getGridBagConstraints(0, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(password, con);con = getGridBagConstraints(1, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(jpField, con);con = getGridBagConstraints(2, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lzhangshu, con);con = getGridBagConstraints(3, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fzhangshu, con);con = getGridBagConstraints(8, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(la1, con);con = getGridBagConstraints(9, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(buyButton, con);this.setBorder(BorderFactory.createTitledBorder("订票操作区"));}}/*** 定义下面一个JList用于显示车票的所有信息面板pan4** @author Administrator**/class pan4 extends JPanel {JButton btId = new JButton("车票号码");JButton bt1 = new JButton("起点站");JButton bt2 = new JButton("终点站");JButton bt3 = new JButton("车次");JButton bt4 = new JButton("发车时间");JButton bt5 = new JButton("到达时间");JButton bt6 = new JButton("座位类型");JButton bt7 = new JButton("发车日期");JButton bt8 = new JButton("剩余票数");JButton bt9 = new JButton("车票价格");public pan4() {this.setLayout(new GridBagLayout());GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(btId, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(2, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt2, con);con = getGridBagConstraints(3, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt3, con);con = getGridBagConstraints(4, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt4, con);con = getGridBagConstraints(5, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt5, con);con = getGridBagConstraints(6, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt6, con);con = getGridBagConstraints(7, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt7, con);con = getGridBagConstraints(8, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt8, con);con = getGridBagConstraints(9, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt9, con);con = getGridBagConstraints(0, 1, 11, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(jtArea, con);jtArea.setBackground(Color.GREEN);}}/*** 定义最下面的按钮面板pan5** @author Administrator**/class pan5 extends JPanel {JButton bt1 = new JButton("退出登录");JLabel lab1 = new JLabel(" ");public pan5() {GridBagLayout layout = new GridBagLayout();this.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lab1, con);bt1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.exit(0);}});}}/*** 放回一个网格包约束** @param x* @param y* @param width* @param heigh* @param weighx* @param weighy* @param fill* @param anchor* @return*/private GridBagConstraints getGridBagConstraints(int x, int y, int width, int heigh, int weighx, int weighy, int fill, int anchor) { GridBagConstraints con = new GridBagConstraints();con.gridx = x;con.gridy = y;con.gridwidth = width;con.gridheight = heigh;con.weightx = weighx;con.weighty = weighy;con.fill = fill;con.anchor = anchor;return con;}/*** 按车票号码搜索所有的车票信息** @throws SQLException*/private void select() {Connection conn = null;Statement stmt = null;ResultSet ticket = null;try {conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "store", "store");} catch (SQLException e1) {e1.printStackTrace();}try {stmt = conn.createStatement();String text = "select * from train_table " + "where tid=" + "'"+ fId.getText() + "'";ticket = stmt.executeQuery(text);while (ticket.next()) {String starter = ticket.getString("starter");String reacher = ticket.getString("reacher");String ticketNumber = ticket.getString("ticketNumber");String startTime = ticket.getString("startTime");String endTime = ticket.getString("endTime");String seatIdNumber = ticket.getString("seatIdNumber");String busDate = ticket.getString("busDate");int ticketNum = ticket.getInt("ticketNum");double price = ticket.getDouble("price");sb.append(" " + fId.getText() + "\t"+ " " + starter + "\t"+ " " + reacher+ "\t"+ " " + ticketNumber + "\t" + startTime + "\t"+ endTime + "\t" + seatIdNumber + "\t" + busDate + "\t"+ ticketNum + "\t" + price + " " + "\n");}jtArea.setText(sb.toString());if (sb.length() > 0) {sb.delete(1, sb.length());} else {JOptionPane.showMessageDialog(new TestFrame(), "无此车!");}} catch (SQLException e) {} finally {if (ticket != null) {try {ticket.close();} catch (SQLException e) {e.printStackTrace();}}if (stmt != null) {try {stmt.close();} catch (SQLException e) {e.printStackTrace();}}if (conn != null) {try {conn.close();} catch (SQLException e) {e.printStackTrace();}}}}/*** 订票时更新数据库中的车票表*/private void UpdateTrain() {String tId=ftid.getText();int num=0;if (fzhangshu.getText().length()>0){num=Integer.parseInt(fzhangshu.getText());}Connection conn = Getgbc.getconnect();CallableStatement cst = null;try {conn.setAutoCommit(false);cst = conn.prepareCall("call train_proc (?,?)");cst.setString(1, tId);cst.setInt(2, num);cst.execute();mit();} catch (SQLException e1) {try {conn.rollback();JOptionPane.showMessageDialog(new TestFrame(), "客户订票失败!");} catch (SQLException e2) {JOptionPane.showMessageDialog(new TestFrame(), "客户订票失败!");}} finally {if (cst != null) {try {cst.close();} catch (SQLException e1) {e1.printStackTrace();}}if (conn != null) {try {conn.close();} catch (SQLException e1) {e1.printStackTrace();}}}}/*** 订票时更新数据库中的用户表*/private void UpdateUser() {String tId=ftid.getText();String bId=fbodyId.getText();String cID=fche.getText();String pwd=String.valueOf(jpField.getPassword());int num=0;if((bId.equals(EnterFrame.ID))&&(pwd.equals(EnterFrame.password))){ if(fzhangshu.getText().length()>0){num=Integer.parseInt(fzhangshu.getText());}Connection conn = Getgbc.getconnect();Statement cst = null;try {cst = conn.createStatement();cst.executeUpdate("insert into order_table(tid,id_number,t_num,trainsum)"+ " values('"+ tId+ "','"+ bId+ "','"+ cID + "','"+num+"')");JOptionPane.showMessageDialog(new TestFrame(), "客户订票成功!");flag=true;} catch (SQLException e1) {JOptionPane.showMessageDialog(new TestFrame(), "订票失败!");flag=false;} finally {if (cst != null) {try {cst.close();} catch (SQLException e1) {e1.printStackTrace();}}if (conn != null) {try {conn.close();} catch (SQLException e1) {e1.printStackTrace();}}}}else{JOptionPane.showMessageDialog(new TestFrame(), "您的身份证或密码有误!请查证后再订票");}}}package com.yue;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.JTextField;public class CheckPanel extends JPanel {StringBuffer sb = new StringBuffer();JTextField trainField = new JTextField(9);JTextField dateField = new JTextField(9);JTextField stationField = new JTextField(9);JTextField zhiField = new JTextField(9);JTextArea jtArea = new JTextArea(10, 80);JLabel checkLabel = new JLabel("查询");public JPanel getCheckpn() {JPanel pan = new JPanel();GridBagLayout layout = new GridBagLayout();pan.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(checkLabel, con);con = getGridBagConstraints(0, 1, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan2(), con);con = getGridBagConstraints(0, 3, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan4(), con);con = getGridBagConstraints(0, 4, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);pan.add(new pan5(), con);this.setLocation(270, 150);this.add(pan);return pan;}/*** 定义上部查询区面pan2** @author Administrator**/class pan2 extends JPanel {JLabel trainLabel = new JLabel(" 车次 ");JLabel dateLabel = new JLabel(" 日期 ");JLabel stationLabel = new JLabel(" 起点站 ");JLabel zhiLabel = new JLabel(" 终点站 ");JLabel l1 = new JLabel(" ");JLabel l2 = new JLabel(" ");JButton checkButton = new JButton("查询");JButton flushButton = new JButton("清空");JPanel panel1 = new JPanel();JPanel panel2 = new JPanel();JTextArea area = new JTextArea();public pan2() {flushButton.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {trainField.setText(null);stationField.setText(null);zhiField.setText(null);dateField.setText(null);jtArea.setText(null);}});checkButton.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {if (dateField.getText().trim().length() > 0) {if (trainField.getText().trim().length() > 0|| stationField.getText().trim().length() > 0|| zhiField.getText().trim().length() > 0) {jtArea.setText(null);JOptionPane.showMessageDialog(new TestFrame(),"输入有误,请检查输入位置");} else {try {dateSelect();} catch (SQLException e1) {e1.printStackTrace();}}} else if (trainField.getText().trim().length() > 0) { if (dateField.getText().trim().length() > 0|| stationField.getText().trim().length() > 0|| zhiField.getText().trim().length() > 0) {jtArea.setText(null);JOptionPane.showMessageDialog(new TestFrame(),"输入有误,请检查输入位置");} else {try {idSelect();} catch (SQLException e1) {e1.printStackTrace();}}} else if (stationField.getText().trim().length() > 0&& zhiField.getText().trim().length() > 0) {if (dateField.getText().trim().length() > 0|| trainField.getText().trim().length() > 0) { jtArea.setText(null);JOptionPane.showMessageDialog(new TestFrame(),"输入有误,请检查输入位置");} else {try {stationSelect();} catch (SQLException e1) {e1.printStackTrace();}}} else if (dateField.getText().trim().length() <= 0&& stationField.getText().trim().length() <= 0&& zhiField.getText().trim().length() <= 0) {if (dateField.getText().trim().length() > 0|| stationField.getText().trim().length() > 0|| zhiField.getText().trim().length() > 0) {jtArea.setText(null);JOptionPane.showMessageDialog(new TestFrame(),"输入有误,请检查输入位置");} else {try {allSelect();} catch (SQLException e1) {e1.printStackTrace();}}}}});JPanel panel3 = new JPanel(new GridBagLayout());panel1.setBorder(BorderFactory.createTitledBorder("查询区"));panel2.setBorder(BorderFactory.createTitledBorder("售票注意事项"));area.setText("每人每次最多可够买十张火车票,超过十张火车票数的" + "\n"+ "请一定要出示您的相关的证件,一旦经过售票员查" + "\n" + "询核实并且同意后方可购买");panel2.add(area);GridBagLayout layout = new GridBagLayout();panel1.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(trainLabel, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(trainField, con);con = getGridBagConstraints(2, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(dateLabel, con);con = getGridBagConstraints(3, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(dateField, con);con = getGridBagConstraints(4, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(l1, con);con = getGridBagConstraints(5, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(flushButton, con);con = getGridBagConstraints(0, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(stationLabel, con);con = getGridBagConstraints(1, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(stationField, con);con = getGridBagConstraints(2, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(zhiLabel, con);con = getGridBagConstraints(3, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(zhiField, con);con = getGridBagConstraints(4, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(l2, con);con = getGridBagConstraints(5, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel1.add(checkButton, con);con = getGridBagConstraints(0, 0, 6, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);panel3.add(panel1, con);con = getGridBagConstraints(6, 0, 2, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);panel3.add(panel2, con);this.add(panel3);}}/*** 定义下面一个JList用于显示车票的所有信息面板pan4** @author Administrator**/class pan4 extends JPanel {JButton btId = new JButton("车票号码");JButton bt1 = new JButton("起点站");JButton bt2 = new JButton("终点站");JButton bt3 = new JButton("车次");JButton bt4 = new JButton("发车时间");JButton bt5 = new JButton("到达时间");JButton bt6 = new JButton("座位类型");JButton bt7 = new JButton("发车日期");JButton bt8 = new JButton("剩余票数");JButton bt9 = new JButton("车票价格");public pan4() {this.setLayout(new GridBagLayout());GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(btId, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(2, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt2, con);con = getGridBagConstraints(3, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt3, con);con = getGridBagConstraints(4, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt4, con);con = getGridBagConstraints(5, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt5, con);con = getGridBagConstraints(6, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt6, con);con = getGridBagConstraints(7, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt7, con);con = getGridBagConstraints(8, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt8, con);con = getGridBagConstraints(9, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt9, con);con = getGridBagConstraints(0, 1, 11, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(jtArea, con);jtArea.setBackground(Color.CYAN);}}/*** 定义最下面的按钮面板pan5** @author Administrator**/class pan5 extends JPanel {JButton bt1 = new JButton("退出登录");JLabel lab1 = new JLabel(" ");public pan5() {bt1.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {System.exit(0);}});GridBagLayout layout = new GridBagLayout();this.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100, GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lab1, con);}}/*** 放回一个网格包约束** @param x* @param y* @param width* @param heigh* @param weighx* @param weighy* @param fill* @param anchor* @return*/private GridBagConstraints getGridBagConstraints(int x, int y, int width, int heigh, int weighx, int weighy, int fill, int anchor) { GridBagConstraints con = new GridBagConstraints();con.gridx = x;con.gridy = y;con.gridwidth = width;con.gridheight = heigh;con.weightx = weighx;con.weighty = weighy;con.fill = fill;con.anchor = anchor;return con;}/*** 按初始站至终点站搜索车票** @throws SQLException*/private void stationSelect() throws SQLException {Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "store", "store");Statement stmt = conn.createStatement();String sqlText = "select tid,starter,reacher,ticketNumber,startTime,endTime,seatIdNumber,busDate,ticketN um,price from train_table where starter='"+ stationField.getText()+ "' and reacher='"+ zhiField.getText() + "'";ResultSet ticket = stmt.executeQuery(sqlText);while (ticket.next()) {int tid = ticket.getInt("tid");String starter = ticket.getString("starter");String reacher = ticket.getString("reacher");String ticketNumber = ticket.getString("ticketNumber");String startTime = ticket.getString("startTime");String endTime = ticket.getString("endTime");String seatIdNumber = ticket.getString("seatIdNumber");String busDate = ticket.getString("busDate");int ticketNum = ticket.getInt("ticketNum");double price = ticket.getDouble("price");sb.append(" " + tid + "\t" + starter + "\t" + reacher + "\t"+ ticketNumber + "\t" + startTime + "\t" + endTime + "\t"+ seatIdNumber + "\t" + busDate + "\t" + " " + ticketNum + "\t"+ " "+ price + " " + "\n");}jtArea.setText(sb.toString());if (sb.length() > 0) {sb.delete(1, sb.length());}else {JOptionPane.showMessageDialog(new TestFrame(), "无此车!");}ticket.close();stmt.close();conn.close();}/*** 搜索所有的车票信息** @throws SQLException*/private void allSelect() throws SQLException {Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "store", "store");Statement stmt = conn.createStatement();String text = "select * from train_table ";ResultSet ticket = stmt.executeQuery(text);while (ticket.next()) {int tid = ticket.getInt("tid");String starter = ticket.getString("starter");String reacher = ticket.getString("reacher");String ticketNumber = ticket.getString("ticketNumber");String startTime = ticket.getString("startTime");String endTime = ticket.getString("endTime");String seatIdNumber = ticket.getString("seatIdNumber");String busDate = ticket.getString("busDate");int ticketNum = ticket.getInt("ticketNum");double price = ticket.getDouble("price");sb.append(" " + tid + "\t" + starter + "\t" + reacher + "\t"+ ticketNumber + "\t" + startTime + "\t" + endTime + "\t"+ seatIdNumber + "\t" + busDate + "\t" + " "+ ticketNum + "\t"+ " "+ price + " " + "\n");}jtArea.setText(sb.toString());if (sb.length() > 0) {sb.delete(1, sb.length());}else {JOptionPane.showMessageDialog(new TestFrame(), "今天没车!");}ticket.close();stmt.close();conn.close();}/*** 按日期搜索所有的车票信息** @throws SQLException*/private void dateSelect() throws SQLException {Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL", "store", "store");Statement stmt = conn.createStatement();String text = "select * from train_table where busDate='"+ dateField.getText() + "'";ResultSet ticket = stmt.executeQuery(text);while (ticket.next()) {int tid = ticket.getInt("tid");String starter = ticket.getString("starter");String reacher = ticket.getString("reacher");String ticketNumber = ticket.getString("ticketNumber");String startTime = ticket.getString("startTime");String endTime = ticket.getString("endTime");String seatIdNumber = ticket.getString("seatIdNumber");String busDate = ticket.getString("busDate");int ticketNum = ticket.getInt("ticketNum");double price = ticket.getDouble("price");sb.append(" " + tid + "\t" + starter + "\t" + reacher + "\t"+ ticketNumber + "\t" + startTime + "\t" + endTime + "\t"+ seatIdNumber + "\t" + busDate + "\t" + " "+ ticketNum + "\t"+ " "+ price + " " + "\n");}jtArea.setText(sb.toString());if (sb.length() > 0) {sb.delete(1, sb.length());}else {JOptionPane.showMessageDialog(new TestFrame(), "没车!");}ticket.close();stmt.close();conn.close();}/*** 按车次搜索所有的车票信息*。

火车站票务管理信息系统信息管理系统课程设计

火车站票务管理信息系统信息管理系统课程设计

信息科学与技术学院信息系统分析与设计课程设计设计题目:火车站票务管理信息系统学生姓名:学院:信息科学与技术学院专业年级:信息管理与信息系统指导教师:完成日期:火车站票务管理信息系统摘要:随着经济的发展,交通运输越来越便捷,为了提高效率,减轻劳动强度,设计开发高效的铁路信息查询系统就显得颇为重要。

针对火车站的售票实际情况,按照软件工程的结构化设计思想,经过项目的可行性研究和需求分析、总体设计、详细设计,以及编码实现和调试等步骤设计开发了火车票务信息管理系统。

火车售票管理中包含许多内容,有铁路乘客运输的运力问题,有订票管理问题等等。

铁路信息查询系统是企业信息决策和管理的重要的组成部分,是一种典型的管理信息系统(MIS)其开发主要包括后台的数据库的建立、维护以及前端的相应应用程序的开发两个方面的内容,数据库的建立和维护主要要求其管理数据的一致性、完整性安全性等特点,而前台的应用程序开发则要求做到各项功能要完备、操作要简便、易学易用等特点。

工具软件利用VS2010开发工具和SQL Server2008数据库系统来开发火车票务信息管理系统。

该系统主要目的是实现火车站网上售票工作,可以满足火车站网上售票的基本要求,包括查询、订票等模块。

关键字:车票,查询,B/S结构,数据库目录1.1题目 (5)1.2设计时间 (6)1.3其他相关内容 (6)1.4设计资料 (6)1.5工作内容 (6)1.5.1 系统可行性分析和需求分析 (6)1.5.2 系统数据库设计 (7)1.5.3 系统总体设计与详细设计 (7)1.5.4 系统测试 (7)1.6设计成果 (7)1.61火车站票务管理信息系统及数据库 (7)1.62系统的源代码一份 (7)1.63系统软件的安装及系统的演示等视频各一个 (8)1.6.4 系统开发文档一套及毕业论文一份 (8)第二章系统开发可行性分析 (9)2.1技术可行性 (9)2.2经济可行性 (9)2.3操作可行性 (9)第三章开发运行环境 (10)3.1系统开发和运行环境 (10)3.1.1系统开发环境 (10)3.1.2系统运行环境 (10)3.2开发工具介绍 (10)3.2.1 Eclipse (10)3.2.2 WYSQL6.0 (11)第四章需求分析 (12)4.1引言 (12)4.1.1编写目的 (12)4.1.2研究背景 (12)4.2.2设计的目的及意义 (13)4.3功能及技术需求 (13)4.3.1功能需求 (13)4.32技术需求 (13)4.4对系统的其它需求规定 (14)4.5输入输出数据的要求 (14)4.6系统需求UML用例图 (14)4.6.1查询功能时序图如图所示: (15)5.1编写目的 (18)_Toc3770370805.2系统核心流程分析 (18)5.3系统的数据流程分析 (19)5.3.1 系统数据流图 (19)5.32 系统完善后的的业务流程 (20)5.4数据字典 (21)第六章系统设计 (23)6.1系统性能设计 (23)6.1.1 系统功能版块设计 (23)6.1.2系统平台设计 (24)6.1.3 网络模式设计 (25)6.2数据库设计 (26)6.2.1 火车票务信息管理系统部分关系数据模型设计 (26)2)实体属性分配图 (26)6.2.2关系模式设计 (28)6.2.4关系数据库设计 (28)6.3系统I/O设计 (30)6.3.1 输入设计 (31)6.3.2 输出设计 (31)6.4系统非功能结构设计 (31)(1)系统安全设计 (31)第七章系统实现 (33)7.1前台功能的实施及核心代码 (33)7.1.1旅客注册模块 (33)7.1.2登录模块 (34)7.1.3订票模块 (34)7.1.4修改密码模块 (35)7.2系统实施中的问题与解决方案 (35)第八章测试报告 (37)8.1测试目的 (37)8.2测试背景 (37)8.3测试方法 (37)8.4测试内容 (37)8.5维护及软件功能的评价 (39)第九章系统的特点与难点 (40)9.1系统特点 (40)9.2系统难点 (40)9.2.1数据库的构建 (40)9.2.2 系统的维护 (40)9.2.3维护的费用 (41)第十章开发总结 (42)10.1系统需求分析与系统框架设计认识 (42)10.2数据库分析与设计认识 (42)10.3自我学习与提高 (42)10.4不足和提高 (43)参考文献 (44)第一章任务书1.1题目火车站票务管理信息系统1.2 设计时间1 第1-2周搜集、整理、分析相关文献、资料对用户进行需求分析2 第3周系统功能模块分析及其划分、数据库设计系统设计及其编程、实现系统运行调试、修改并撰写文档1.3其他相关内容项目提出者:石河子大学信息科学与技术学院相邻课题情况或子课题情况:管理信息系统结课具体要求软件内容:详见第六章系统设计指导老师:朱东芹老师开发人员:信息科学与技术学院信管2011级王斌(2011508109)软件用户:火车站数据库管理中心1.4设计资料国家标准:《项目开发计划规范》(GB8567——88)《软件需求说明书规范》(GB8567——88)《数据库设计说明书规范》(GB8567——88)《数据要求说明书规范》(GB8567——88)《详细设计说明书规范》(GB8567——88)《操作手册规范》(GB8567——88)《用户手册规范》(GB8567——88)《测试计划、测试分析报告规范》(GB8567——88)《详细设计说明书规范》 (GB8567——88)1.5 工作内容1.5.1 系统可行性分析和需求分析分析系统的可行性,说明该软件开发项目的实现在技术上、经济上和操作上的可行性,评述为了合理地达到开发目标可供选择的各种可能实施方案,说明并论证所选定实施方案的理由。

数据结构课程设计《订票系统(航空)》报告源代码

数据结构课程设计《订票系统(航空)》报告源代码

数据结构课程设计——《订票系统》目录一、设计任务与要求2b5E2RGbCAP1.1 总体目标与任务要求2p1EanqFDPw1.2 题目选择与目地意义2DXDiTa9E3d1.3 所选题目地主要工作2RTCrpUDGiT二、需求分析 25PCzVD7HxA2.1 用户需求分析 2jLBHrnAILg2.2 功能需求分析 3xHAQX74J0X2.3 系统需求分析 3LDAYtRyKfE三、概要设计 4Zzz6ZB2Ltk3.1 各模块地算法设计说明4dvzfvkwMI13.2 存储结构设计说明9rqyn14ZNXI四、详细设计 11EmxvxOtOco五、源代码 12SixE2yXPq5六、运行结果分析236ewMyirQFL七、收获与体会30kavU42VRUs八、主要参考资料30y6v3ALoS89一、设计任务与要求1.1 总体目标与任务要求制作一个订票系统, 通过此系统可以实现如下功能:1)录入:可以录入航班情况<数据可以存储在一个数据文件中, 数据结构、具体数据自定).2)查询:可以查询某个航线地情况<如 , 输入航班号 , 查询起降时间 , 起飞抵达城市 , 航班票价 , 票价折扣 , 确定航班是否满仓);可以输入起飞抵达城市, 查询飞机航班情况.3)订票:可以订票 , 如果该航班已经无票 , 可以提供相关可选择航班 <订票情况可以存在一个数据文件中 , 结构自己设定) .4 )退票:M2ub6vSTnP可退票 , 退票后修改相关数据文件;客户资料有姓名, 证件号 , 订票数量及航班情况 , 订单要有编号 .5 )修改航班信息:0YujCfmUCw当航班信息改变可以修改航班数据文件. 根据以上功能说明, 设计航班信息 ,订票信息地存储结构, 设计程序完成功能 . eUts8ZQVRd1.2 题目选择与目地意义选择这个题目地原因是 , 订票系统在现实生活中应用很广泛 , 通过这个系统可以使订票、退票等变得简便 . 与传统地人工用纸、笔来记录办理订票、退票等相比 , 使用这个系统也会增加工作效率 . 这个题目做出来地系统还是比较实用地 , 所以我选择了订票系统这个题目 . sQsAEJkW5T完成此系统 , 需要综合运用数据结构课程中学到地几种典型数据结构, 以及程序设计语言 <C 语言) , 自行实现一个较为完整地应用系统地设计与开发. 通过课程设计 , 自己通过系统分析、系统设计、编程调试 , 写实验报告等环节 , 进一步掌握应用系统设计地方法和步骤 , 灵活运用并深刻理解典型数据结构在软件开发中地应用 . 学会将知识应用于实际地方法, 提高分析和解决问题地能力, 增加综合能力. GMsIasNXkA1.3 所选题目地主要工作这个题目地主要工作是使订票系统可以录入航班情况, 查询某个航线地情况、办理订票、办理退票、修改航班信息、查询订票信息等. TIrRGchYzg二、需求分析2.1 用户需求分析用户使用此程序所要完成地工作主要为:查询所有航线信息、查看已订票客户信息、查询航线、办理订票业务、办理退票业务. 通过此系统可以方便地进行上述工作 . 7EqZcWLZNX每条航线所涉及地信息有:终点站名、航班号、飞行时间、票价、乘员定额、余票量 .已订票地客户名单信息包括姓名、订票量、舱位等级<1,2 或 3).等候替补地客户名单信息包括姓名、所需票量.查询航线功能可以根据旅客提出地终点站名输出航班号、飞行时间、票价、乘员定额、余票量 .订票业务功能根据客户提出地要求<航班号、订票数额)查询该航班票额情况, 若尚有余票,则为客户办理订票手续,输出座位号;若已满员或余票额少于定票额,则需重新询问客户要求 .若需要 ,可登记排队候补购票 .lzq7IGf02E退票业务功能根据客户提供地情况 <航班号、姓名)为客户办理退票手续 ,然后查询该航班是否有人排队候补 ,首先询问排在第一地客户 ,若所退票额能满足他地要求 ,则为他办理订票手续 ,否则依次询问其他排队候补地客户 .zvpgeqJ1hk2.2 功能需求分析功能需求分析模块图如图 2.2.1功能模块图:图 2.2.1功能模块图2.3 系统需求分析开发环境: PC机Windows XP 系统使用软件:编写实验报告:Microsoft Office Word画图:亿图制作程序:Microsoft Visual C++ 6.0三、概要设计3.1 各模块地算法设计说明1.浏览航线信息功能 , 调用 display 函数进行输出 . 流程图如图 3.1.1 浏览航线信息流程图:图 3.1.1浏览航线信息流程图:其中 display函数地流程图如图 3.1.2 display函数流程图:图3.1.2 display函数流程图2.浏览已订票客户信息功能, 按顺序输出客户信息链表中地信息. 流程图如图 3.1.3浏览已订票客户信息功能流程图:NrpoJac3v1图 3.1.3浏览已订票客户信息功能流程图3.查询航线功能, 根据客户提出地终点站名输出航线信息. 流程图如图3.1.4查询航线流程图:图 3.1.4查询航线流程图4.办理订票业务功能, 根据客户提出地航线信息等进行订票. 流程图如图3.1.5办理订票业务功能流程图:1nowfTG4KI图 3.1.5办理订票业务功能流程图5.办理退票业务功能, 根据客户提出地航线信息等进行退票. 流程图如图3.1.6办理退票业务功能流程图:fjnFLDa5Zo图 3.1.6办理退票业务功能流程图6.主函数流程图如图 3.1.7主函数流程图:图3.1.7主函数流程图3.2 存储结构设计说明typedef struct wat_ros/*单链队列存储等候替补地客户信息*/ {char name[10]。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
cout<<"\t 此班已出发"<<endl;
else
cout<<"\t 此班未出发"<<endl;
}
void Bus_infor::output(ofstream & os)
{
os<<setw(6)<<Bus_order //setw()设置输出宽度
int Get_tickted() { return tickted; } //返回已定票人数
int Get_bus_order() { return Bus_order; } //返回班次号
string Get_end()const; //返回终点站的字符串
{
cout<<Hour_start<<":"<< Minute_start<<"\t";
}
cout<<start<<"\t"<<end<< "\t"<<GoHour<<"\t "<<all_tickted<<"\t "<<tickted;
if(!GetTime())
t=time(NULL);
local=localtime(&t); //获取当前系统时间
if(local->tm_hour<Hour_start||(local->tm_hour==Hour_start && local->tm_min<=Minute_start))
return 1; //比较当前时间与发车时间,获得班次的当前状况,返回表示班次未出发
{
cout << "\n时间输入错误,请重新输入:";
cin.clear();
cin.get();
}
else if(Hour_start<0||Hour_start>24||Minute_start<0||Minute_start>60)
{
is>>Bus_order>>Hour_start>>Minute_start>>start>>end>>GoHour>>all_tickted>>tickted;
is.get();
}
void Bus_infor::output()
int Bus_order; //班次号
int all_tickted; //额定载量
int tickted; //已定票人数
int Hour_start,Minute_start; //发车时间
float GoHour; //行车时间
public:
void clear(); //清除函数
void about(); //关于车票信息
char mainmenu(); //主菜单函数
void setkey(int k){ key=k; } //设置系统修改标志
int getkey(){ return key;} //返回系统修改标志
<<setw(15)<<Hour_start
<<setw(15)<<Minute_start
<<setw(15)<<start
<<setw(6)<<end
<<setw(15)<<GoHour
<<setw(15)<<all_tickted
<<setw(15)<<tickted
{
cout<<"\t\t\t按提示输入:"<<endl;
cout<<"输入班次: ";
while(1)
{
cin>>Bus_order;
if (cin.fail()) //判断输入的数据类型是否有错
{
cout << "\n班次输入错误,请重新输入:";
<<endl;
}
void Bus_infor::GetTime_start()
{
cout<<"请输入始发时间(时分):";
while(1)
{Байду номын сангаас
cin>>Hour_start>>Minute_start;
if (cin.fail()) //判断输入的数据类型是否有错
{
cout<<"客车基本信息如下:"<<endl
<<"班次发车时间 起点站 终点站 行车时间额定载量已定票人数当前状况"<<endl;
#include<iostream> //数据流输入/输出
#include<fstream> //文件输入/输出
#include<string> //字符串操作
#include<iomanip> //参数化输入/输出
#include<time.h> //时间库函数
Bus_infor();
~Bus_infor();
Bus_infor *next;
void input(); //录入函数
void input(ifstream & is); //读取函数
void output(); //输出函数
void output(ofstream & os); //写入函数
void found(); //查询车票信息
void show(); //显示车票信息
void Order(); //定购车票信息
void Unorder(); //退还车票信息
void save(); //保存车票信息
void begin(); //初始化车票信息
~Bus_link(){delete head;} //析构函数
void input(); //录入车票信息
void mend(); //修改车票信息
void del(); //删除车票信息
int find(Bus_infor **p,int num,char *pn); //查找函数
{
cout << "\n座位数输入错误,请重新输入:";
cin.clear();
cin.get();
}
else
break;
}
GetTime_start();
cout<<"请输入行车时间:";
while(1)
private:
Bus_infor *head; //链表指针
int key; //系统修改标志
int password; //管理员登陆标志
{
cin>>GoHour;
if (cin.fail()) //判断输入的数据类型是否有错
{
cout << "\n行车时间输入错误,请重新输入:";
cin.clear();
cin.get();
}
else
break;
};
void Bus_link::input()
{
if(password==1)
{
Bus_infor *p,*p2=NULL;
p=head;
int n=1; //int n;
while(p->next)
}
string Bus_infor::Get_end()const
{
string s=end;
return s;
}
class Bus_link
{
public:
Bus_link(){head=new Bus_infor;head->next=NULL;key=0;} //带参数的构造函数
cout<<"\t\t\t按1继续,按0返回: ";
cin>>n;
if(!cin)
throw string("数据输入错误");
}
}
else
cout<<"\n\t\t对不起,游客不能录入车票信息"<<endl;
}
void Bus_link::show()
}
cout<<"请输入起始站与终点站:";
cin>>start;cin>>end;
cout<<"是否清空售票(y/n)?";
char a;cin>>a;
if(a=='y'||a=='Y') tickted=0;
}
void Bus_infor::input(ifstream & is)
cout<<"\n时间格式出错,请重新输入:"; ////判断时间格式是否出错,小时不能小于大于,分钟不能小于大于
相关文档
最新文档