当前位置:文档之家› 课程设计票务管理系统

课程设计票务管理系统

通达学院专业课程设计报告题目:汽车客运公司售票系统专业软件工程学生姓名班级学号指导教师指导单位南京邮电大学计算机学院日期2014-6-9至2014-6-20一.课题名称:汽车客运公司售票系统二.设计目标:按照软件工程的规范,以SQL Server或Access为后台数据库,以Delphi 或Visual C++为前端开发工具,设计并实现一个简化的汽车客运公司售票系统。

三.需求描述:某客运公司每日向10个城市各发一个直达班车(中途不停留下客)。

每天都发售今、明、后三天的车票。

系统在磁盘上存储以下信息:1.今、明、后三天每个班次的基本信息,包括:每个班次的班次号、发车时间、终点城市、座位数量;2.今、明、后三天每个班次的旅客登记表,表项有:姓名、身份证号、座位号。

该系统的功能如下:1.添加班次。

开始时添加今、明、后三天每个班次的基本信息,以后每天添加后天一天每个班次的基本信息;2.办理售票,即在旅客登记表中添加旅客信息,座位号不能重复;3.办理退票,即在旅客登记表中删除旅客信息;4.班次查询,显示指定班次的余票数和座位号;5.旅客查询,显示指定班次的旅客登记表(发车前交驾驶员用)。

四.设计概要流程图五.具体设计本次实验以SQL Server 2000为后台数据库,以delphi7.0为前端开发工具,OS为WinXP sp1系统。

票务管理系统用一个数据库和两张表进行存储两张表的内容如下:数据库:票务管理表:1、班次信息表基本信息用于录入存储班次的信息,包括班次号,日期,发车时间,终点城市,座位,余票,票价。

具体设置如下3.旅客信息表基本信息用于录入存储旅客的信息,包括旅客姓名,身份证号,班次号,日期,座位号等其中座位号=座位—余票具体设置如下在前端Delphi开发中最终用到了6个form。

分别为登录,导航,班次管理,旅客查询,订票和退票。

五.详细设计系统自动生成program Project1;usesForms,Unit1 in 'Unit1.pas' {Form1},Unit2 in 'Unit2.pas' {Form2},Unit3 in 'Unit3.pas' {Form3},Unit4 in 'Unit4.pas' {Form4},Unit5 in 'Unit5.pas' {Form5},Unit6 in 'Unit6.pas' {Form6},Unit7 in 'Unit7.pas' {Form7};{$R *.res}beginApplication.Initialize;Application.CreateForm(TForm1, Form1);Application.CreateForm(TForm2, Form2);Application.CreateForm(TForm3, Form3);Application.CreateForm(TForm4, Form4);Application.CreateForm(TForm5, Form5);Application.CreateForm(TForm6, Form6);Application.CreateForm(TForm7, Form7);Application.Run;end.1.Form1登陆界面确认按钮被单击判断edit1和edit2的数据,当为admin密码为admin进入导航(管理员权限)为123密码为123,进入普通用户界面仅支持查询procedure TForm1.Button1Click(Sender: TObject);beginif (Edit1.Text = 'admin') and (Edit2.Text = 'admin') thenbeginForm2.Button1.Enabled := True;Form2.Button3.Enabled := True;Form2.Button5.Enabled := True;Form2.Show;endelse//对于普通用户"123"而言只有查询的权限if(Edit1.Text = '123') and (Edit2.Text = '123') thenbeginForm2.Button1.Enabled := False;Form2.Button3.Enabled := False;Form2.Button5.Enabled := False;Form2.Show;endend;3.导航界面ForM2procedure TForm2.Button1Click(Sender: TObject); beginForm3.show;end;procedure TForm2.Button2Click(Sender: TObject); beginForm4.Show;end;procedure TForm2.Button3Click(Sender: TObject); beginForm5.Show;end;procedure TForm2.Button5Click(Sender: TObject); beginForm6.show;end;end.4.Form3班次管理插入班次procedure TForm3.Button1Click(Sender: TObject);begin//先做好保护工作if edit1.Text = '' thenbeginshowmessage('班次号不能为空!');exit;end;//先查看是否已经有班次信息ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+''' and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery1.Prepared;ADOQuery1.Open;ADOQuery1.Active:=true;if ADOQuery1.RecordCount>0 thenbegin//有该信息就弹出一个提示框,然后推出该函数的执行messageBox(0,'已有该班次的信息','Error!',mb_OK);exit;end;//当不存在该班次信息时ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('insert into 班次 values(');ADOQuery1.SQL.Add(''''+Edit1.Text+''''+','); //班次号ADOQuery1.SQL.Add(''''+datetostr(Datetimepicker1.date)+''''+','); //日期 ADOQuery1.SQL.Add(''''+Edit2.Text+''''+','); //发车时间ADOQuery1.SQL.Add(''''+Edit3.Text+''''+','); // 终点ADOQuery1.SQL.Add(Edit4.text+','); // 座位ADOQuery1.SQL.Add(Edit6.text+','); // 余票ADOQuery1.SQL.Add(Edit5.Text+')'); // 票价ADOQuery1.ExecSQL;//把DBGrid框的内容进行更新ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;procedure TForm3.Button4Click(Sender: TObject);beginForm3.Close;end;procedure TForm3.Button2Click(Sender: TObject);beginif application.MessageBox('您确定要修改数据嘛?','危险',MB_OKCANCEL) =IDCANCEL thenexit;//先查看是否已经有改信息ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+''' and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery1.Prepared;ADOQuery1.Open;ADOQuery1.Active:=true;if ADOQuery1.RecordCount=0 thenbegin//没有该航班信息就弹出一个提示框,然后推出该函数的执行messageBox(0,'无该班次的信息','Error!',mb_OK);exit;end;//当该信息存在时则可以将其信息更新到表中ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('update 班次 set' );ADOQuery1.SQL.Add('班次号='+''''+Edit1.Text+''''+',');ADOQuery1.SQL.Add('日期='+''''+datetostr(Datetimepicker1.date)+''''+','); ADOQuery1.SQL.Add('发车时间='+''''+Edit2.Text+''''+',');ADOQuery1.SQL.Add('终点城市='+''''+Edit3.Text+''''+',');ADOQuery1.SQL.Add('座位='+Edit4.Text+',');ADOQuery1.SQL.Add('余票='+Edit6.Text+',');ADOQuery1.SQL.Add('票价='+edit5.text);ADOQuery1.SQL.Add(' where ');ADOQuery1.SQL.Add('班次号='+''''+Edit1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery1.ExecSQL;ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;修改班次procedure TForm3.Button2Click(Sender: TObject);beginif application.MessageBox('您确定要修改数据嘛?','危险',MB_OKCANCEL) =IDCANCEL thenexit;//先查看是否已经有改信息ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+''' and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery1.Prepared;ADOQuery1.Open;ADOQuery1.Active:=true;if ADOQuery1.RecordCount=0 thenbegin//没有该航班信息就弹出一个提示框,然后推出该函数的执行messageBox(0,'无该班次的信息','Error!',mb_OK);exit;end;//当该信息存在时则可以将其信息更新到表中ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('update 班次 set' );ADOQuery1.SQL.Add('班次号='+''''+Edit1.Text+''''+',');ADOQuery1.SQL.Add('日期='+''''+datetostr(Datetimepicker1.date)+''''+',');ADOQuery1.SQL.Add('发车时间='+''''+Edit2.Text+''''+',');ADOQuery1.SQL.Add('终点城市='+''''+Edit3.Text+''''+',');ADOQuery1.SQL.Add('座位='+Edit4.Text+',');ADOQuery1.SQL.Add('余票='+Edit6.Text+',');ADOQuery1.SQL.Add('票价='+edit5.text);ADOQuery1.SQL.Add(' where ');ADOQuery1.SQL.Add('班次号='+''''+Edit1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery1.ExecSQL;ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;procedure TForm3.Button3Click(Sender: TObject);beginif application.MessageBox('您确定要修改数据嘛?','危险',MB_OKCANCEL) =IDCANCEL thenexit;//先做好保护工作if edit1.Text = '' thenbeginshowmessage('班次号不能为空!');exit;end;ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+ '''');ADOQuery1.Prepared;ADOQuery1.Open;ADOQuery1.Active:=true;if ADOQuery1.RecordCount=0 thenbegin//有该信息就弹出一个提示框,然后推出该函数的执行messageBox(0,'没有该班次的信息','Error!',mb_OK);exit;end;ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('delete from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+ '''and 日期='''+datetostr(Datetimepicker1.date)+''''); //编号ADOQuery1.ExecSQL;//把DBGrid框的内容进行更新ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;end.删除班次procedure TForm3.Button3Click(Sender: TObject);beginif application.MessageBox('您确定要修改数据嘛?','危险',MB_OKCANCEL) =IDCANCEL thenexit;//先做好保护工作if edit1.Text = '' thenbeginshowmessage('班次号不能为空!');exit;end;ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+ '''');ADOQuery1.Prepared;ADOQuery1.Open;ADOQuery1.Active:=true;if ADOQuery1.RecordCount=0 thenbegin//有该信息就弹出一个提示框,然后推出该函数的执行messageBox(0,'没有该班次的信息','Error!',mb_OK);exit;end;ADOQuery1.Close;ADOQuery1.SQL.Clear;ADOQuery1.SQL.Add('delete from 班次');ADOQuery1.SQL.Add('where 班次号='''+Edit1.Text+ '''and 日期='''+datetostr(Datetimepicker1.date)+''''); //编号ADOQuery1.ExecSQL;//把DBGrid框的内容进行更新ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;end.退出按钮procedure TForm3.Button4Click(Sender: TObject);beginForm3.Close;end;5. Form4班次管理查询按钮procedure TForm4.Button1Click(Sender: TObject);beginADOQuery1.Close;Adoquery1.sql.clear;Adoquery1.sql.add('select 班次号,日期,终点城市,余票,(座位-余票) 座位号from 班次');Adoquery1.Open;end;退出按钮procedure TForm4.Button2Click(Sender: TObject); beginform4.Close;end;end.5.Form5订票系统订票按钮procedure TForm5.Button1Click(Sender: TObject);var i:Integer;var j:Integer;begin//先做好保护工作if Edit1.Text = '' thenbeginshowmessage('姓名不能为空');exit;end;if Edit2.Text = '' thenbeginshowmessage('身份证号不能为空');exit;end;if ComboBox1.Text = '' thenbeginshowmessage('班次号不能为空');exit;end;//先查看是否已经有该班次信息ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('select 座位,余票');ADOQuery3.SQL.Add('from 班次');ADOQuery3.SQL.Add('where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery3.Prepared;ADOQuery3.Open;ADOQuery3.Active:=true;if ADOQuery3.RecordCount<1 thenmessageBox(0,'无此班次信息','注意',MB_OKCANCEL)elsebeginif ADOQuery3.Fields[1].AsInteger =0 thenMessageBox(0,'该班次已经售完!','注意',MB_OKCANCEL)elsebegini := ADOQuery3.Fields[0].AsInteger;j := ADOQuery3.Fields[1].AsInteger;//先查看是否已经有顾客信息ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('select *');ADOQuery3.SQL.Add('from 旅客');ADOQuery3.SQL.Add('where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+''''+'and 身份证号='+Edit2.Text);ADOQuery3.Prepared;ADOQuery3.Open;ADOQuery3.Active:=true;if ADOQuery3.RecordCount>=1 thenbeginMessageBox(0,'该顾客已经定过票!','注意',MB_OKCANCEL);exit;end;//将顾客信息插入到custom表中ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('insert into 旅客 values(');ADOQuery3.SQL.Add(''''+Edit1.Text+''''+','); // 顾客姓名ADOQuery3.SQL.Add(''''+Edit2.Text+''''+','); // 身份证号 ADOQuery3.SQL.Add(''''+ComboBox1.Text+''''+','); //班次号ADOQuery3.SQL.Add(''''+datetostr(Datetimepicker1.date)+''''+','); //日期ADOQuery3.SQL.Add(inttostr(i-j+1)+')'); //座位号ADOQuery3.ExecSQL;//更新flight表的"剩余座位数",利用"Update"语句来实现ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('update 班次 set 余票=');ADOQuery3.SQL.Add(inttostr(j-1));ADOQuery3.SQL.Add(' where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery3.ExecSQL;end;end;ADOQuery1.Close;ADOQuery1.Open;ADOQuery1.Active:=true;//把DBGrid框的内容进行更新ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;退票系统procedure TForm5.Button3Click(Sender: TObject);var i:Integer;var j:Integer;begin//先做好保护工作if Edit1.Text = '' thenbeginshowmessage('姓名不能为空');exit;end;if Edit2.Text = '' thenbeginshowmessage('身份证号不能为空');exit;end;if ComboBox1.Text = '' thenbeginshowmessage('班次号不能为空');exit;end;//先查看是否已经有该班次信息ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('select 座位,余票');ADOQuery3.SQL.Add('from 班次');ADOQuery3.SQL.Add('where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery3.Prepared;ADOQuery3.Open;ADOQuery3.Active:=true;if ADOQuery3.RecordCount<1 thenmessageBox(0,'无此班次信息','注意',MB_OKCANCEL)elsebeginbegini := ADOQuery3.Fields[0].AsInteger;j := ADOQuery3.Fields[1].AsInteger;//先查看是否已经有顾客信息ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('select *');ADOQuery3.SQL.Add('from 旅客');ADOQuery3.SQL.Add('where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+''''+'and 身份证号='+Edit2.Text);ADOQuery3.Prepared;ADOQuery3.Open;ADOQuery3.Active:=true;if ADOQuery3.RecordCount<1 thenbeginMessageBox(0,'没有顾客定此票!','注意',MB_OKCANCEL);exit;end;//将顾客信息插入到custom表中ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('delete from 旅客');ADOQuery3.SQL.Add(' where 身份证号='''+edit2.text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery3.ExecSQL;//更新flight表的"剩余座位数",利用"Update"语句来实现ADOQuery3.Close;ADOQuery3.SQL.Clear;ADOQuery3.SQL.Add('update 班次 set 余票=');ADOQuery3.SQL.Add(inttostr(j+1));ADOQuery3.SQL.Add(' where 班次号='''+ComboBox1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');ADOQuery3.ExecSQL;end;end;ADOQuery1.Close;ADOQuery1.Open;ADOQuery1.Active:=true;//把DBGrid框的内容进行更新ADOQuery2.Close;ADOQuery2.Open;ADOQuery2.Active:=true;end;end.6. Form6旅客信息查询查询按钮procedure TForm6.Button1Click(Sender: TObject);beginADOQuery1.Close;Adoquery1.sql.clear;ADOQuery1.SQL.Add('select *');ADOQuery1.SQL.Add('from 旅客');ADOQuery1.SQL.Add('where 班次号='''+edit1.Text+'''and 日期='''+datetostr(Datetimepicker1.date)+'''');Adoquery1.Open;end;procedure TForm6.Button2Click(Sender: TObject);beginclose;end;end六.软件测试七、课程设计总结通过两周的课程设计,在分析设计阶段遇到了一些软件的使用问题。

相关主题