火车票查询系统代码

合集下载

c语言火车票管理系统基本代码

c语言火车票管理系统基本代码

#include<conio.h>#include<stdio.h>#include<stdlib.h>#include<string.h>int shoudsave = 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;int bookNum;};struct man{char num[10];char name[10];int bookNum;};typedef struct node{struct train data;struct node * next;}Node, *Link;typedef struct people{struct man data;struct people*next;}bookMan, *bookManLink;void printInterface(){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("********************************************************"); }/*添加一个火车信息*/void InsertTraininfo(Link linkhead){struct node *p, *r, *s;char num[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;}}void printTrainInfo(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, char findmess[], 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;}void QueryTrain(Link l){Node *p;int sel;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!");}}}void BookTicket(Link l, bookManLink k){Node*r[10], *p;char ch, dem;bookMan*v, *h;int i = 0, t = 0;char str[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(bookManLink k, char findmess[]){bookMan*r;r = k->next;while (r){if (strcmp(r->data.num, findmess) == 0){mark = 1;return r;}r = r->next;}return 0;}/*修改火车信息*/void UpdateInfo(Link l){Node*p;char findmess[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;}}void AdvicedTrains(Link l){Node*r;char str[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");}void SaveTrainInfo(Link l){FILE*fp;Node*p;int count = 0, flag = 1;fp = fopen("D:\\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);}void SaveBookmanInfo(bookManLink k){FILE*fp;bookMan*p;int count = 0, flag = 1;fp = fopen("D:\\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;int sel;l = (Node*)malloc(sizeof(Node));l->next = NULL;r = l;k = (bookMan*)malloc(sizeof(bookMan));k->next = NULL;h = k;fp1 = fopen("D:\\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("D:\\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;}。

火车票查询系统

火车票查询系统

火车票查询系统摘要随着网络时代的快速发展,中国网民人数的持续增加,电子商务的普及以及中国现代物流的飞速发展,互联网法律法规的逐步完善,电子商务的环境已经初步形成,网上购物系统作为电子商务的一种主要实现形式必将得到进一步的普及和应用。

该系统主要为用户提供了会员注册、网上查询等功能;在设计方面,系统是典型的电子商务平台, 其开发基于B/S模式的网上销售的实现,采用的是ASP + ACCESS 模式。

该系统设计上采用三层结构、Web Service技术,使之在选用平台、采用技术上具有先进性、前瞻性、扩充性,从而保证建成的系统具有良好的稳定性、可扩充性。

从功能上来说,系统是比较完备的,系统以Web界面与用户交互,为用户提供信息并接受其操作,同时通过数据库管理系统来存储信息数据。

系统实现了对信息数据的浏览、查询、编辑和管理等基本数据库操作,采用了模块化设计方法,根据用户的需求及程序的应用与维护的易用性,将各个部分置于不同的模块当中,方便了程序的扩展与维护,同时建立了程序功能复用的基础。

本文所做火车票网上查询系统是一个根据现有的网上查询系统的现状而设计开发的电子商务平台,可以减少成本,提高工作效率。

关键词:网上查询;电子商务;ASP;交互AbstractWith the increasing number of netizens, the emergence of third--party payment means as well as the rapid development of modern logistic and the improvement of laws and regulations, the environment of e-commerce has formed in china. The shop online system which acted as one way to implement of electronic commerce will become more and more popular in the future.This system mainly to provide users with a registered member, preview tourist attractions, tickets online, provides the ticket for the administrator management, customer information management and information management, advertising spots link management etc. Function. In the design, system is a typical e-commerce sales platform, its development based on B/S model, online sales by ASP + ACCESS mode. Choose ACCESS database of backstage supporter's database. This system is used on three-layer structure design, Web Service technology, make in selecting, using the platform with advanced technology, prospectie, expand, and ensure the completion of the system has a good stability and extensibility. Using software component, system structure, development, business and separated, logic and data: In a unified service interface standard as the core, the use of open standards. From the function, system is relatively complete system with Web interface and the user interaction, and provide information and accept its operation, and through a database management system to store information and data. System of data to browse, query, editing and management database, the basic operating modular design methods, according to user's requirements and procedures of application and maintenance of facility, and the different parts will be placed among modules, convenient maintenance and expansion of the program, and established the basic program function reuse.The tourist attractions do online ticketing system is an online ticketing system according to the current situation of the development and design of e-commerce platform. It not only can expand the scale and influence the market business, and can reduce the operating costs, improve work efficiency.Key words:Online ticketing; e-commerce;ASP; interacti目录1绪论 (4)1.1课题现状 (4)1.2课题开发目的 (4)1.3课题关键技术 (5)1.3.1 ASP简介 (5)1.3.2 Dreamweaver (5)1.3.3 ACCESS (6)1.3.4 HTML(Hyper Text Markup Language) (6)2 可行性研究 (6)2.1资源可行性 (7)2.2技术可行性 (7)2.3经济可行性 (7)2.4社会的可行性 (7)3 系统需求分析 (8)3.1目标和任务 (8)3.2系统功能分析 (8)3.2.1 查询功能分析 (8)3.2.2 网站的界面设计 (8)3.3网站业务流程 (9)3.3.1 火车票网上查询系统的业务流程介绍 (9)3.3.2 系统的设计流程图 (9)4 系统概要设计 (10)4.1系统结构设计目标 (10)4.1.1 系统HIPO图 (10)4.1.2 系统功能模块介绍 (11)4.1.2.1登录模块 (11)4.1.2.2 注册模块 (11)4.1.2.3查询模块 (11)4.1.2.4用户管理模块 (11)4.2数据库结构设计 (11)4.2.1 数据库概念结构设计 (11)4.2.2数据库逻辑结构 (13)5 系统详细设计 (14)5.1系统总体结构图 (14)5.2过程设计 (15)5.2.1.系统用户权限的系统主处理流程 (16)5.2.2.车次信息查询处理流程 (17)6 系统运行与测试 (18)6.1系统调试 (18)6.2测试与运行 (18)6.2.1.系统管理员登陆首页 (18)6.2.2系统用户登陆注册首页 (19)6.2.3.车次查询界面 (19)6.2.4.车次查询结果 (20)结束语 (20)致谢 (21)参考文献 (21)附录 (21)1 绪论网上查询,相对于传统查询方式而言,是随着现代信息技术的发展而产生的一种新型查询方式,是一种消费者和工作人员分离的、非面对面的查询方式,是一种跨地区的查询模式。

火车票购票系统实验报告

火车票购票系统实验报告

火车票售票系统一、实验目的:1、熟练掌握数据库设计原理及模型构建软件PowerDesignerd 的使用。

2、熟练掌握Visual Studio 2008的使用。

3、实现方便、快捷使用火车票购票系统查票、购票、退票等功能。

4、实现系统的安全性设置,使系统具有一定的维护功能。

二、实验设备及软件:PC 机一台、Visual Studio 2008、SQL SERVER 2000三、需求分析: 3.1 功能分析:功能模块图教师评阅意见:签名: 年 月 日实验成绩:火车票售票系统新用户注册 购票 、预约余 票 查询 退 票 票价查询1、新用户注册模块:新用户注册需要新用户填入自己的基本信息包括用户名、密码和确认密码),详细的购票需要信息(包括姓名、性别、出生日期、证件类型、证件号码)以及联系方式(包括手机号码、电子邮箱、地址),只有当所有的信息格式填写正确和填写完全后才能注册成功。

2、购票/预订模块:购票/预订模块需要用户登录后,输入需要购票的出发站、目的站和出发日期后即可显示可购票,选择自己需要的票即可购票,点击购票则购票成功。

3、余票查询模块:余票查询模块需要用户在登录进入售票系统后点击余票查询按钮,按照要求填入出发地、目的地,选择出发日期,选择填入出发车次,完成输入后即可在界面下方看到所有满足要求的查询结果。

4、退票模块:退票模块需要用户在登录后,进入退票界面,即可显示登录用户所有订单,选择需要退票的订单,点击退票按钮即可退票。

5、票价查询模块:票价查询模块同样需要用户在登录进入售票系统后点击余票查询按钮,按照要求填入出发地、目的地,选择出发日期,选择填入出发车次,完成输入后即可在界面下方看到所有满足要求的查询结果。

3.2 流程图:火车票售票系统业务流程图如下图所示:1、新用户注册及登录流程图:新用户填写失败注册信息提交注册成功2、购票/预订流程图:填写失败成功2、余票查询流程图:填写显示3、退票流程图:登陆失 败 显示成功 出 发 站 目 的 站 出 发 日 期 用 户购 票 用 户 出 发 站 目 的 站 出 发 日 期 余 票 信 息用 户 退票界面所 有 订 单 退 票4、票价查询流程图:用户登陆票价查询显示车票票价四、数据库结构设计:4.1 E-R模型的建立:E-R模型由新用户注册、登录界面、购票、余票查询、票价查询这五个实体构成。

12306回参解析

12306回参解析

12306回参解析
12306是中国铁路客户服务中心的官方网站,用于购买火车票和查询相关信息。

回参解析是指对12306网站返回的数据进行解析和处理的过程。

在12306网站上,用户进行车票查询、购票等操作后,系统会返回一段数据,通常是以JSON格式或HTML格式呈现。

回参解析的目的是提取有用的信息,如车次、出发时间、到达时间、座位信息等,并将其展示给用户或进行进一步的处理。

回参解析需要考虑以下几个方面:
1. 数据格式解析,根据返回的数据格式,如JSON或HTML,使用相应的解析方法进行数据提取。

对于JSON格式,可以使用JSON 解析库将数据转化为可操作的对象;对于HTML格式,可以使用HTML解析库进行解析。

2. 数据字段提取,根据业务需求,确定需要提取的字段,并编写相应的代码进行字段提取。

例如,需要提取车次信息,则可以通过遍历数据对象的方式提取出所有的车次信息。

3. 数据清洗和处理,有时候返回的数据可能存在噪声或不完整的情况,需要进行数据清洗和处理。

例如,对于时间字段,可能需要进行格式化或转换为特定的时间格式。

4. 错误处理,在回参解析过程中,可能会出现一些错误,如网络请求失败、数据格式异常等。

需要编写相应的错误处理代码,以确保程序的稳定性和可靠性。

总之,回参解析是对12306网站返回数据的处理过程,通过解析和提取有用的信息,为用户提供准确、完整的车票查询和购票服务。

火车票查询系统代码

火车票查询系统代码

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));

12306火车票查询接口代码文档及返回示例

12306火车票查询接口代码文档及返回示例

12306实时余票查询接口代码文档及返回示例在即将到来的双十二,在聚合数据平台上的12306实时余票查询接口将参与“暖冬不如低价活动”,主打汽车和金融两类数据接口。

此次我们将分享下12306实时余票查询接口代码文档及返回示例,可查询实时火车票余票,包括车次、车次始发站、车次终点站、出发时间、到达时间、车次类型、总历时时间等等。

接口名称:12306实时余票查询接口接口平台:聚合数据接口地址:/train/yp支持格式:JSON/XML请求方式:HTTP GET/POST请求示例:/train/yp?key=申请的KEY&dtype=json&from=%E4%B8%8A%E6%B5%B7%E8%99%B9%E6%A1%A5&to=%E6% B8%A9%E5%B7%9E&date=2014-06-28&tt=接口备注:火车余票查询12306实时余票查询接口调用代码JSON返回示例:{"reason": "查询成功","result": [{"train_no": "D2287", /*车次*/"start_station_name": "上海虹桥", /*车次始发站*/"end_station_name": "深圳北", /*车次终点站*/"from_station_name": "上海虹桥", /*出发站*/"to_station_name": "温州南", /*到达站*/"start_time": "06:25", /*出发时间*/"arrive_time": "10:53", /*到达时间*/"train_class_name": "动车", /*车次类型*/"day_difference": "0", /*历时天数*/"lishi": "04:28", /*总历时时间*/"gr_num": "--", /*高级软卧:-- 说明无该席位*/"qt_num": "--", /*其他*/"rw_num": "--", /*软卧*/"rz_num": "--", /*软座*/"tz_num": "--", /*特等座*/"wz_num": "无", /*无座*/"yw_num": "--", /*硬卧*/"yz_num": "--", /*硬座*/"ze_num": "无", /*二等座*/"zy_num": "无", /*一等座*/"swz_num": "--" /*商务座*/ },{"train_no": "D3203","start_station_name": "上海虹桥","end_station_name": "厦门北","from_station_name": "上海虹桥","to_station_name": "温州南","start_time": "06:30","arrive_time": "11:09","train_class_name": "动车","day_difference": "0","lishi": "04:39","gr_num": "--","qt_num": "--","rw_num": "--","rz_num": "--","tz_num": "--","wz_num": "无","yw_num": "--","yz_num": "--","ze_num": "无","zy_num": "无","swz_num": "--"},{"train_no": "G7501","start_station_name": "上海虹桥","end_station_name": "苍南","from_station_name": "上海虹桥","to_station_name": "温州南","start_time": "07:00","arrive_time": "11:00","train_class_name": "","day_difference": "0","lishi": "04:00","gr_num": "--","qt_num": "--","rw_num": "--","rz_num": "--","tz_num": "--","wz_num": "165","yw_num": "--","yz_num": "--","ze_num": "无","zy_num": "无","swz_num": "15"}],"error_code": 0}。

火车票售票系统源代码

火车票售票系统源代码
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
);

火车票管理系统1

火车票管理系统1
endif
endif
系统进入退票管理也是通过两个方法来实现,用户可以直接进入退票环节,也可以从订单查询环节进入。订票相关信ele * from customer
if this.caption="订票"
this.caption="保存订票记录"
this.parent.tag=str(recno())
对于数据更新,需要得到如下信息:
被更新的关系。
每个关系上的更新操作条件所涉及的属性。
修改操作要改变的属性值。
需要注意的是,数据库上运行的事务会不断的变化、增加或减少,以后需要根据上述设计信息的变化调整数据库的物理结构。
5程序设计与调试及运行5.1火车票管理系统界面
图1火车票管理系统界面
代码如下:
登录系统:
NOTNULL
性别
Char(2)
电话
char(20)
表5订票表
字段名
数据类型
是否可空
说明
订单号
char(20)
NOT NULL
(主键)
订票方式
Char(20)
表6退票表
字段名
数据类型
是否可空
说明
订单号
char(20)
NOT NULL
(主键)
订票方式
Char(20)
表7查询表
字段名
数据类型
是否可空
说明
replace customer.座位号with thisform.Text2.TEXT
messagebox("订票成功!","dp")
else
messagebox("该车票不存在!","dp")

火车站售票管理信息系统

火车站售票管理信息系统


如果用户以已知车次进行购票,那么直接在买 票模块里输入车次就可以进行购票;如果用户买 票时只知道出发地点和到达地点,这时可选择使 用查询功能,在查询功能支持两种查询方式:按 车次查询和按站点查询。按车次查询直接输入车 次就可以查出来该车次的车次信息;按站点查询 又分为三种查询方式:按起始站,按终点站,按 起始站和终点站的组合。
第4章 系统设计
• 系统总体设计 设计目标 • 采用现有的互联网资源,实现B/S结构的火车售票系统。 设计原则 • ◆安全性 未经注册的用户不能登录系统,用户个人信息和购票 信息通过互联网上传输时,要确保信息的安全性。 • ◆时效性 用户对系统进行操作时,系统及时给与响应,一般响 应速度应为秒级。 • ◆可扩展性 对于用户新的需求,能做到只需添加新模块即可满足 用户要求。
• 退票模块 • 现在火车站退票的原则是:在列车开车 前可以退票,只能退还原票价80%的金额。 退票模块分为两种退票方式:退票和退订。 本系统设置的退票,退订返现为票价的 80%,即无论退票还是退订返回给用户的 金额是票价的80%。客户完成退票后,客 户的在订票表的纪录要进行删除,以保证 数据同步。 • 查询模块
• 用户管理功能需求 当高级管理员登录系统时,用户管 理界面入口可见,其他用户登录后则不能 看到用户管理模块。用户管理模块主要有 六个子模块:管理用户,剩余票查询,更 新车次,销售情况统计,新闻管理,留言 管理。 • ◆ 管理用户 系统的用户有三类,管理员,代售点用 户和企业用户,不同的用户权限不同。这 些权限具体体现在提前买票和订票时间上。 除了高级管理员,其他的用户都要先注册 才能使用,不同类型的用户登录系统后操 作界面不太一样。
• 注册功能需求 第一次使用系统时,首先要做的是注册 用户,注册用户模块里主要分两种类型的 注册:代售点注册和企业用户注册。这两 种注册方式的差别体现在所填注册信息上。 • 不同的用户拥有不同的权限 性能需求 • 为了保证客车售票系统能够长期、安全、 稳定、可靠、高效的运行,客车售票系统 应该满足以下的性能需求

国内各火车站代码

国内各火车站代码

国内各火车站代码
以上是国内一些常见火车站的代码列表,这些代码是通过国家铁路总公司统一设定的标识符,用于区分各个火车站。

每个火车站的代码都是独一无二的,方便人们在购票、查询信息时使用。

火车站代码通常由两个字母组成,代表着火车站的名称。

这些代码既可以用于火车票的购买和使用,也可以用于车站的识别和查询。

以北京站为例,其代码为BJ。

当您购买火车票时,可以在购票系统中输入BJ作为目的地代码,系统会自动识别您希望购买去往北京站的车票。

同样地,当您需要了解北京站的列车时刻表、车站位置等信息时,可以输入BJ进行查询。

火车站代码对于铁路运输的管理和运营也非常重要。

通过代码的标识,铁路部门可以高效地进行车票销售、列车调度、站内管理等工作。

车站代码的使用使得信息传递更加准确和便捷。

需要注意的是,虽然这份文档列举了一些常见火车站的代码,但并不代表全部。

中国境内有众多火车站,每个火车站都有自己的代码。

如果您需要查询其他火车站的代码,可以通过官方网站或相关应用程序进行查询,或者咨询售票窗口或客服人员。

火车站代码的标准化使用对旅客和铁路部门都具有重要意义。

通过统一的代码,旅客可以方便地购票、查询信息,并且减少因为乘车目的地名称不同而产生的混淆和错误。

铁路部门也可以更高效地进行管理和运营,提供更好的服务。

希望这份国内各火车站代码文档能为您提供帮助,让您在购票和查询火车信息时更加便捷和准确。

如有任何疑问或需要进一步的信息,请随时与我们联系。

火车票查询系统

火车票查询系统

摘要火车票查询系统是典型的信息管理系统,其开发重要包括后台数据库的建立和维护以及前台应用程序开发两个方面。

对于前者要求建立起数据一致性和完善性强、数据安全性好的库。

而对于后者则要求应用程序功能完备,易使用等特点。

本系统主要用于用户查询火车基本信息,包括站站查询、站点查询、车次查询等。

用户可以根据需求可以查询出自己所需信息,如:站站查询时,用户输入出发站和目的站就可以查出可以乘坐的火车基本信息。

车次查询时:只要用户输入想要查询的火车车次,就可以查出这列火车所经过的所有站点和到各个站点的时间、票价等。

本系统采用了Struts2编写该系统的后台程序,Struts框架的结构清晰,使此次开发流程一目了然,层次性突出。

且采用MySQL来设计数据库,并使用当前优秀的开发工具MyEclipse,它有着最为灵活的数据库结构,对数据库应用有着良好的支持。

关键词:火车票查询;Struts2;MySQL;MyEclipse李文正:火车票查询系统目录摘要 (1)第1章需求分析 (3)1.1 系统功能 (3)1.2 技术分析 (3)1.3 工程进度计划 (4)第2章系统分析与设计 (5)2.1 系统分析 (5)2.1.1 参与者 (5)2.1.2 用例及用例规约 (5)2.1.3 用例图 (8)2.2 系统设计 (9)2.2.1 顺序图 (9)2.2.2 类图 (12)2.2.3 系统体系结构设计 (12)2.3 数据库设计 (13)第3章实现与测试 (15)3.1站站查询模块 (15)3.1.1 活动图 (15)3.1.2 界面 (15)3.1.3 代码 (16)3.1.4 测试用例 (22)3.2 站点查询模块 (24)3.2.1 活动模块 (24)3.2.2 界面 (24)3.2.3 代码 (25)3.2.4 测试用例 (27)3.3 车次查询模块 (29)3.3.1 活动图 (29)3.3.2 界面 (29)3.3.3 代码 (30)3.3.4 测试用例 (32)第4章总结 (34)第1章需求分析1.1 系统功能主要功能:(1)登陆、注册功能:本系统不是所有人都可以使用的,想要使用本系统必须注册成本系统的注册用户,只有成为注册用户才能使用该系统。

火车票真假查询辨别

火车票真假查询辨别

列车时刻表查询:/火车票信息查询:/huochepiao/春运高峰期间,因乘坐火车的旅客急剧增加而导致买票难。

很多票贩子会利用这个机会在火车站附近或是在网上发布一些转让火车票信息,这个现象一直没有得到解决,作为春运外出或是返乡的市民,只有提高警惕,辨别真假火车票,避免买到假车票才是良策。

网友为你整理出了票贩子采用的欺诈手段,现在推荐给大家:票贩子一般采用印刷、挖补、涂改、伪造、骗票等手段制售假票,坑害急于购票出行的旅客。

一、将已到站还未过有效期的中转签字票低价回收,或捡来后重新中转签字,再低价卖给旅客。

这种票大多票面较旧,且已被剪口,在光线明亮处很容易识别。

二、将废票或短途票的日期、票价、到站站名、座别等用涂改液涂掉后,重新进行更改,使短途变长途、废票变“有效”、低价变高价。

三、假装认识站内人员骗手续费。

暑运期间,火车票较为紧张,票贩子假装给售票人员打手机要票,使得旅客以为票贩神通广大,能搞到别人买不到的票,票贩子借机收取介绍费。

其实,看似“走后门”才能买到的票,旅客自己在窗口就能买到。

四、一些票贩子借旅客急于退票之机,低价买入,然后再到车站退票窗口平价退掉,从中牟利。

五、有些非法订票点,打着便民服务旗号,高价收取旅客手续费,坑害旅客。

不管票贩子使用何种手段,大家辨别出火车票的真假才是关键,针对有可能出现的假火车票,总结了以下几条鉴别方法,供大家参考:1. 车票的纸质:火车票的印刷纸质表面光滑,且具有良好的韧性,不轻易折破,轻揉车票有清脆的声响。

2. 车票的印刷:印刷火车票所用油墨,打印后车票字迹清晰,用水不可轻易洗掉;假火车票票面油墨不均匀、字体大小不一样,票的边沿裁剪不整齐。

3. 水印:火车票背面对光可以看到有一个个“火车头”的水印图案,或放验钞机如同钞票不作报警信号;若仔细辨认或稍作转换角度,即可见“中国铁路”的缩写“CR”等防伪隐形文字及字符。

4. 辅助工具:将火车票置于紫光灯下,可以看到一段段分布不均的荧光线条;5. 注意挖补票:用手轻刮车票票面,防有挖补过的车票,这种假火车票近期比较多出现,特别注意!据介绍,目前假火车票一般分为“挖补”假票和整版假票两种。

火车票查询系统代码

火车票查询系统代码

#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;}}else{cout<<"请输入正确的日期格式!"<<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"))。

火车票订票系统代码C

火车票订票系统代码C

break;Βιβλιοθήκη }}if (p==NULL)
cout&lt;&lt;&quot;未找到!&quot;&lt;&lt;endl;
}
void Busman::ExitTicket()
{
string s,t;
node *p;
cout&lt;&lt;&quot;退票的班次是:&quot;;
cin&gt;&gt;s;
&quot;&lt;&lt;endl;
for (p=Busman::BusHead; p!=NULL; p=p-&gt;Next)
{
if ((sel==1 &amp;&amp; p-&gt;Num==s) || (sel==2 &amp;&amp; p-&gt;EndPlace==s))
{
cout&lt;&lt;p-&gt;Num&lt;&lt;&quot;\t&quot;&lt;&lt;p-&gt;SetoutTime&lt;&lt;&quot;\t&quot;&lt;&lt;
if (time &gt;= p-&gt;SetoutTime) cout&lt;&lt;&quot;(已发车)&quot;&lt;&lt;endl;
else cout&lt;&lt;&quot;(未发车)&quot;&lt;&lt;endl;

WebService火车查询系统

WebService火车查询系统

WebService火车查询系统一、开发环境:装有VS10软件的PC机一台二、系统功能:火车查询系统主要用于提供火车时刻表和车次所经站点的查询服务:1、输入用户的始发站和终点站,点击查询按钮,系统会提供路经这条路线的所有车次,并显示该车次的始发站、终点站、在本站的出发时间、里程和所需时间;2、输入某车次,点击查询按钮,可以查询到该车次的始发站、终点站、始发站出发时间、终点站到达时间、里程和所需要的时间;并且可以通过模糊查询,查询到包含输入车次字符的车次的这些信息;3、输入某车次,点击查询按钮,系统可以显示该车次途经的所有站点、到达该站点的时间、从该站点出发的时间和从始发站到达该站点的距离。

三、系统设计:系统主要包括服务端和用户端:服务端通过编写代码,提供了用户查询信息的各种方法,并返回用户查询的相关信息;用户端主要包括用户界面、服务调用和控件设置:用户界面为用户查询信息提供了窗口;服务调用通过引用Web服务,编写代码,调用了Web服务里的方法;控件设置首先是选择合适的控件,并引入,通过属性设置完善控件的视觉效果,通过代码触发事件,完成控件的功能。

四、运行结果:运行结果显示调试后的最初界面和输入参数后的查询结果。

点击调试后,系统向用户提供一个火车查询界面,用户可以根据界面提示输入需要的参数进行查询工作,输入完参数,只需点击查询按钮,就可以看到想查询的信息。

界面可以显示火车时刻表和列车经由的站点,其中火车时刻表包括两个:1、给定始发站和终点站,途经这条路线的所有火车时刻表;2、给定某一车次,显示该车次的时刻表。

五、核心代码:用户端代码:using System;using System.Data;using System.Windows.Forms;namespace TrainInquiry{public partial class Form1 : Form{private.webxml.webservice.TrainTimeWebServiceTrain = null;private string Path =Application.StartupPath;public Form1(){InitializeComponent();Train = new.webxml.webservice.TrainTimeWebService();}private void button1_Click(object sender, EventArgs e){string StartStation = textBox3.Text;string ArriveStation= textBox4.Text;DataSet ds = new DataSet();ds =Train.getStationAndTimeByStationName(StartStation,ArriveStation ,"");dataGridView1.DataSource =ds.Tables[0].DefaultView;}private void button2_Click(object sender, EventArgs e){string TrainNumber = textBox2.Text ;DataSet ds = new DataSet();ds =Train.getStationAndTimeDataSetByLikeTrainCode(TrainNumber , "");dataGridView2.DataSource =ds.Tables[0].DefaultView;}private void button3_Click(object sender, EventArgs e){string TrainNumber = textBox1.Text;DataSet ds=new DataSet();ds =Train.getDetailInfoByTrainCode(TrainNumber, "");dataGridView3.DataSource =ds.Tables[0].DefaultView;}服务端的方法:∙getDetailInfoByTrainCode通过火车车次查询列车经由车站明细DataSet输入参数:车次代号字符串,空字符串默认上海到北京D32次,UserID = 商业用户ID(普通用户不需要);返回数据:DataSet,Item.(TrainStation)=车站名称、Item.(ArriveTime)=到站时间、Item.(StartTime)=发车时间、Item.(KM)=里程(KM)∙getStationAndTimeByStationName通过发车站和到达站查询火车时刻表DataSet输入参数:StartStation = 发车站,ArriveStation = 到达站(支持第一个字匹配模糊查询),空字符串默认发车站上海和到达站北京,UserID = 商业用户ID(普通用户不需要);返回数据:DataSet,Item.(TrainCode)=车次、Item.(FirstStation)=始发站、Item.(LastStation)=终点站、Item.(StartStation)=发车站、Item.(StartTime)=发车时间、Item.(ArriveStation)=到达站、Item.(ArriveTime)=到达时间、Item.(KM)=里程(KM)、Item.(UseDate)=历时getStationAndTimeDataSetByLikeTrainCode通过火车车次查询本火车时刻表(支持模糊查询)DataSet输入参数:车次代号字符串(支持模糊查询),空字符串默认上海到北京D32次,UserID = 商业用户ID(普通用户不需要);返回数据:DataSet,Item.(TrainCode)=车次、Item.(FirstStation)=始发站、Item.(LastStation)=终点站、Item.(StartStation)=发车站、Item.(StartTime)=发车时间、Item.(ArriveStation)=到达站、Item.(ArriveTime)=到达时间、Item.(KM)=里程(KM)、Item.(UseDate)=历时六、结果分析及存在的问题:火车查询系统主要用于为外出人员提供车次查询服务,可以使人们方便地查找到可乘坐的火车车次,不需要亲自到火车站询问信息,并且可以根据自己的情况,依据火车时刻表确定自己的出发时间,为生活、工作和旅行等提供了方便。

火车售票系统完整代码

火车售票系统完整代码

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");。

火车票查询系统实习报告

火车票查询系统实习报告

摘要:随着时代的不断进步,人们出行次数增加,那么一个火车站怎样才能快捷高效的为乘客们服务变成了一个很重要的问题。

伴随着电脑的普及,运用电脑进行数据的保存与管理已经成为一件再寻常不过的事情,因此建立一个火车票查询预订系统将会是一个很好的解决方法。

一个火车票查询预订系统的设计可以使工作人员实现电脑管理,减轻工作量,并且可以节约人力和物力,从而使得火车票管理更加的便捷和高效。

一个火车票查询预订系统应该有火车票的查询,添加或删除,管理员的管理等功能。

关键字:火车票查询;火车票预订;管理员管理;便捷;高效目录1 课题综述 (1)1.1 课题来源 (1)1.2 程序所实现的功能 (1)软硬件运行环境及开发工具 (1)2 系统分析 (1)2.1 主要模块功能 (1)功能模块图 (1)3 系统设计 (1)3.1 数据库设计 (1)3.2 火车票信息处理对话框的设计 (1)3.3 火车票销售对话框的设计................................................................ 错误!未定义书签。

4 代码编写 (4)4.1 命令按钮的过程代码添加方法........................................................ 错误!未定义书签。

4.2 具体代码 (1)5 程序调试 (3)5.1 上机过程中出现的问题和解决方案 (1)5.2 程序的扩展方案 (1)6 程序运行界面 (1)1 课题综述1.1 课题来源本次软件实习将用C#制作一个火车票查询预订系统,具有一般系统的数据处理功能,如数据录入、增加、修改、删除等。

1.2 程序所实现的功能本系统通过C# Winforms技术完成的功能如下:〔1〕可以实现火车票信息的增加、删除。

〔2〕可以实现火车票的基本信息的浏览。

〔3〕可以实现火车票的预订及预订信息的删除、修改〔4〕管理员登录密码的修改本次软件设计的运行环境:Windows XP操作系统,Microsoft Visual Studio 2005以上编译环境。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

strcpy(chufatime,chufa); strcpy(daodatime,daoda); price=price2; booknum=booknum2; } }; typedef struct node 构 { train data ; struct node * next ; }Node,*Link ; void tianjiatrain(Link linkhead) //添加火车信息 { char num[10]; // 列车号 char city[10]; // 目的城市 char chufatime[10]; // 出发时间 char daodatime[10]; // 到达时间 double price; // 票价 int booknum ; struct node *p,*r,*s ;//定义指向火车信息链表的3个指针 r = linkhead ; s = linkhead->next ; while(r->next!=NULL) r=r->next ; while(1) { cout<<" 请输入列车号 (0 是返回)"; cin>>num; if(strcmp(num,"0")==0) //strcmp,串 比较函数,用于判断num是否为0 break ; while(s) // 判断是否已经存在 { if(strcmp(s->data.getnum(),num)==0)//strcmp,串 比较函数,用于判断data->num是否与num相同 { cout<<" 车次"<<num<<"已经存在"<<endl; return ; } // 定义火车信息链表的结点结
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));
s=s->next ; } p = (struct node*)malloc(sizeof(struct node)); //malloc,内存分配函数 cout<<" 请输入火车到达的城市:"; cin>>city; cout<<" 请输入火车出发的时间:"; cin>>chufatime; cout<<" 请输入火车到达的时间:"; cin>>daodatime; cout<<" 请输入火车票的价格:"; cin>>price; cout<<" 请输入您需要的票的数目:"; cin>>booknum; p>data.fuzhi(num,city,chufatime,daodatime,price,booknum); p->next=NULL ; r->next=p ; r=p ; shoudsave = 1 ; } } void showtrainxinxi(struct node*p) { cout<<" \n下面是您需要的火车的信息:" ; cout<<"\n 车次: "<<p->data.getnum()<<endl <<" 火车到达的城市: "<<p->data.getcity()<<endl <<" 火车出发的时间: "<<p->data.getchufatime()<<endl <<" 火车到达的时间: "<<p->data.getdaodatime()<<endl <<" 火车票的价格: "<<p->data.getprice()<<endl <<" 所提供的票数: "<<p->data.getbooknum() <<endl; } struct node * Locate1(Link numorcity[])//查询方式子函数 { Node*r ; l,char findmess[],char // 输出火车票信息
if(strcmp(numorcity,"num")==0) 于判断 {
//strcmp,串比较函数,用
r=l->next ; 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;
cout<<" * 4: 退出 *" <<endl; cout<<" \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3"<<endl; cin>>sel; switch(sel) {case 1 : tianjiatrain(l);break ; case 2 : baocuntrain(l);break ; case :return 0; } } return 0; }
//malloc,内存分配函
数,c库函数 l->next=NULL ; r=l ; fp1=fopen("E:\\train.txt","ab+");//fopen,打开一个流,c 库函数 if((fp1==NULL)) { cout<<" 文件无法打开!" ; return 0 ; } while(!feof(fp1)) //检测流上(fp1)的文件结束符 ,c库函数 { p=(Node*)malloc(sizeof(Node)); if(fread(p,sizeof(Node),1,fp1)==1) //从一个流中 读数据 ,c库函数 { p->next=NULL ; r->next=p ; r=p ; } } fclose(fp1); while(1) {cout<<" ****************************************" <<endl; cout<<" * 欢迎使用火车票查询系统 *"<<endl; cout<<" \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3 \3\3"<<endl; cout<<" * 请选择操作 *" <<endl; cout<<" * 1: 插入火车信息 *" <<endl; cout<<" * 2: 保存火车信息 *" <<endl; cout<<" * 3: 查询火车信息 *" <<endl;
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream.h> int shoudsave=0 ,mark=0 ; class train { char num[10]; // 列车号 char city[10]; // 目的城市 char chufatime[10]; // 出发时间 char daodatime[10]; // 到达时间 double price; // 票价 int booknum ; // 票数 public: train() { } train(train &t) { strcpy(num,t.num); strcpy(city,t.city); strcpy(chufatime,t.chufatime); strcpy(daodatime,t.daodatime); price=t.price; booknum=t.booknum; } ~train(){} char *getnum(){return num;} char *getcity(){return city;} char *getchufatime(){return chufatime;} char *getdaodatime(){return daodatime;} double getprice(){return price;} int getbooknum (){return booknum;} void fuzhi(char *num2,char *city2,char *chufa, char *daoda,double price2,int booknum2) { strcpy(num,num2); strcpy(city,city2);
相关文档
最新文档