untBeijing.~pas
资源名称:DS-1.ZIP [点击查看]
上传用户:wysk38707
上传日期:2007-06-18
资源大小:801k
文件大小:21k
源码类别:
交通/航空行业
开发平台:
Delphi
- unit untBeijing;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, Buttons, jpeg, ComCtrls, Menus,main, DB,
- DBTables, Grids, DBGrids, DBCtrls, Spin, Mask;
- type
- TfrmBeijing = class(TForm)
- PageControl1: TPageControl;
- TabSheet1: TTabSheet;
- TabSheet2: TTabSheet;
- Image1: TImage;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- BitBtn6: TBitBtn;
- BitBtn7: TBitBtn;
- Panel1: TPanel;
- Label1: TLabel;
- Button1: TButton;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- Button2: TButton;
- BitBtn8: TBitBtn;
- GroupBox1: TGroupBox;
- ListBox1: TListBox;
- BitBtn9: TBitBtn;
- GroupBox2: TGroupBox;
- BitBtn11: TBitBtn;
- GroupBox3: TGroupBox;
- GroupBox4: TGroupBox;
- BitBtn12: TBitBtn;
- Label5: TLabel;
- Label6: TLabel;
- Label7: TLabel;
- Label8: TLabel;
- Label9: TLabel;
- Label10: TLabel;
- Label11: TLabel;
- Label12: TLabel;
- Label13: TLabel;
- Label14: TLabel;
- Label15: TLabel;
- Label16: TLabel;
- Label17: TLabel;
- Label18: TLabel;
- PopupMenu1: TPopupMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- N3: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- N6: TMenuItem;
- N7: TMenuItem;
- N8: TMenuItem;
- GroupBox5: TGroupBox;
- ListBox2: TListBox;
- Label19: TLabel;
- BitBtn13: TBitBtn;
- BitBtn14: TBitBtn;
- Memo4: TMemo;
- GroupBox6: TGroupBox;
- Button3: TButton;
- Label20: TLabel;
- Edit1: TEdit;
- GroupBox7: TGroupBox;
- GroupBox9: TGroupBox;
- BitBtn15: TBitBtn;
- PopupMenu2: TPopupMenu;
- N9: TMenuItem;
- N10: TMenuItem;
- N11: TMenuItem;
- N12: TMenuItem;
- ListBox3: TListBox;
- ListBox4: TListBox;
- ListBox5: TListBox;
- N13: TMenuItem;
- qstation: TQuery;
- qtrain: TQuery;
- qticket: TQuery;
- BitBtn16: TBitBtn;
- BitBtn10: TBitBtn;
- BitBtn17: TBitBtn;
- BitBtn18: TBitBtn;
- BitBtn19: TBitBtn;
- BitBtn20: TBitBtn;
- DataSource1: TDataSource;
- DBGrid1: TDBGrid;
- DBNavigator1: TDBNavigator;
- Table1: TTable;
- Label21: TLabel;
- MaskEdit1: TMaskEdit;
- Label22: TLabel;
- SpinEdit1: TSpinEdit;
- Button4: TButton;
- ComboBox1: TComboBox;
- Label23: TLabel;
- procedure BitBtn12Click(Sender: TObject);
- procedure N9Click(Sender: TObject);
- procedure N10Click(Sender: TObject);
- procedure N12Click(Sender: TObject);
- //procedure Button1Click(Sender: TObject);
- //procedure Button2Click(Sender: TObject);
- procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- //procedure BitBtn1Click(Sender: TObject);
- procedure BitBtn7MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn6MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn2MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure N1Click(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure N3Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- procedure N6Click(Sender: TObject);
- procedure N13Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure BitBtn16Click(Sender: TObject);
- procedure BitBtn17Click(Sender: TObject);
- procedure Label2DblClick(Sender: TObject);
- procedure Label4DblClick(Sender: TObject);
- procedure BitBtn8Click(Sender: TObject);
- procedure BitBtn9Click(Sender: TObject);
- procedure BitBtn11Click(Sender: TObject);
- procedure BitBtn10Click(Sender: TObject);
- procedure N2Click(Sender: TObject);
- procedure N8Click(Sender: TObject);
- procedure BitBtn18Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure BitBtn19Click(Sender: TObject);
- procedure BitBtn15Click(Sender: TObject);
- procedure BitBtn20Click(Sender: TObject);
- procedure BitBtn13Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure TabSheet2Show(Sender: TObject);
- procedure qtrainBeforeDelete(DataSet: TDataSet);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- frmBeijing: TfrmBeijing;
- //variants for interface design
- stationName:string;
- //startName:string;
- //desName:string;
- startpoint:string;
- despoint:string;
- //variants for inner class
- stationclass:Cstation;
- ticketclass:Cticket;
- trainclass:Ctrain;
- tickets:ticketRec;
- ackNo:word;
- implementation
- {$R *.dfm}
- uses
- untchangsha,untchengdu,untchongqing,untwuhan,untzhuzhou,untguangzhou;
- procedure TfrmBeijing.BitBtn12Click(Sender: TObject);
- begin
- //if(messageDlg('确定要退出!', mtConfirmation,[mbOKCancel], 0)=mrOK)then
- BitBtn16Click(nil);
- end;
- procedure TfrmBeijing.N9Click(Sender: TObject);
- begin
- if((listBox3.itemIndex>=0) and (Label4.Caption<>listbox3.Items[listBox3.itemIndex]))then
- begin
- Label2.Caption:=listbox3.Items[listBox3.itemIndex];
- startpoint:=Label2.Caption;
- end
- end;
- procedure TfrmBeijing.N10Click(Sender: TObject);
- begin
- if((listBox3.itemIndex>=0) and (Label2.Caption<>listbox3.Items[listBox3.itemIndex]))then
- begin
- Label4.Caption:=listbox3.Items[listBox3.itemIndex];
- despoint:=Label4.Caption;
- end;
- end;
- procedure TfrmBeijing.N12Click(Sender: TObject);
- begin
- listbox3.Items.Delete(listbox3.ItemIndex)
- end;
- procedure TfrmBeijing.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn7MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn6MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.BitBtn2MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- if(button=mbRight)then
- begin
- stationName:=(Sender as TBitbtn).Caption;
- popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
- end;
- end;
- procedure TfrmBeijing.N1Click(Sender: TObject);
- var
- i:integer;
- Flag:boolean;
- begin
- //first we judge whether it has been in listBox3
- Flag:=True;
- //showmessage(inttostr(listBox3.Items.Count));
- if(listBox3.Items.Count>=1)then
- for i:=1 to listBox3.Items.Count do
- begin
- if(listBox3.Items[i-1]=StationName)then
- Flag:=false;
- end;
- if(flag=true)then
- listbox3.Items.Add(StationName);
- end;
- procedure TfrmBeijing.Button1Click(Sender: TObject);
- begin
- N9Click(nil);
- end;
- procedure TfrmBeijing.Button2Click(Sender: TObject);
- begin
- N10Click(nil);
- end;
- procedure TfrmBeijing.N3Click(Sender: TObject);
- begin
- if(despoint<>stationName)then
- begin
- //startName:=stationName;
- startpoint:=stationName;
- Label2.Caption:=startpoint;
- //Label2.Enabled:=false;
- popupMenu1.Items.Items[3].Enabled:=false;
- popupMenu1.Items.Items[4].Enabled:=true;
- end;
- end;
- procedure TfrmBeijing.N5Click(Sender: TObject);
- begin
- if(startpoint<>stationName)then
- begin
- //desName:=stationName;
- despoint:=stationName;
- label4.Caption:=despoint;
- //label4.Enabled:=false;
- popupMenu1.Items.Items[5].Enabled:=true;
- popupMenu1.Items.Items[4].Enabled:=false;
- end;
- end;
- procedure TfrmBeijing.N6Click(Sender: TObject);
- var
- trains:Carrayword;
- i:integer;
- begin
- popupMenu1.Items.Items[3].Enabled:=true;
- popupMenu1.Items.Items[4].Enabled:=false;
- popupMenu1.Items.Items[5].Enabled:=false;
- Label2.Enabled:=true;
- label4.Enabled:=true;
- listbox1.Clear;
- listbox4.Clear;
- if((startpoint<>'')and(despoint<>''))then
- begin
- trains:=Carrayword.Create();
- trainclass.getArrive(stationclass.getNo(startpoint),stationclass.getNo(despoint),trains);
- //showmessage(inttostr(trains.Num));
- if (trains.Num>0)then
- begin
- for i:=1 to trains.Num do
- begin
- listbox1.Items.Add(inttostr(trains.warray[i]));
- end;
- end
- else
- showmessage('没有查到相关信息!');
- trains.Free;
- end
- else
- begin
- showmessage('请选定起点站和终点站!');
- end;
- end;
- procedure TfrmBeijing.N13Click(Sender: TObject);
- begin
- //popupMenu1.Items.Items[3].Enabled:=true;
- bitbtn19.Click();
- end;
- procedure TfrmBeijing.FormCreate(Sender: TObject);
- begin
- trainclass:=Ctrain.Create();
- stationclass:=Cstation.Create();
- ticketclass:=Cticket.Create();
- ticketclass.myCtrain:=trainclass;
- trainclass.setQuery(qtrain);
- trainclass.localstation:=3;
- ticketclass.setQuery(qticket);
- ticketclass.settable('ticket3.db');
- ticketclass.localstation:=3;
- stationclass.setQuery(qstation);
- tickets.Num:=0;
- end;
- procedure TfrmBeijing.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- ticketclass.query.Close;
- stationclass.query.Close;
- trainclass.query.Close;
- ticketclass.Free;
- stationclass.Free;
- trainclass.Free;
- end;
- procedure TfrmBeijing.BitBtn16Click(Sender: TObject);
- begin
- if(Bitbtn11.Enabled=false)then
- BitBtn17Click(nil);
- begin
- Label2.Caption:='';
- Label4.Caption:='';
- Label6.Caption:='';
- Label7.Caption:='';
- Label9.Caption:='';
- Label16.Caption:='';
- Label17.Caption:='';
- listBox1.Items.Clear;
- listBox3.Items.Clear;
- listBox4.Items.Clear;
- //listBox5.Items.Clear;
- bitbtn10.Enabled:=false;
- bitbtn17.Enabled:=false;
- end
- end;
- procedure TfrmBeijing.BitBtn17Click(Sender: TObject);
- begin
- bitbtn11.Enabled:=true;
- //ack ticket falg=false
- ticketclass.ackTicket(stationclass.getNo(Label6.Caption),stationclass.getNo(Label7.Caption),strtoint(label9.Caption),(strtoint(label16.Caption)*128+strtoint(label17.Caption)),ackNo,false);
- bitbtn10.Enabled:=false;
- bitbtn17.Enabled:=false;
- label6.Caption:='';
- label7.Caption:='';
- label9.Caption:='';
- label16.Caption:='';
- label17.Caption:='';
- end;
- procedure TfrmBeijing.Label2DblClick(Sender: TObject);
- begin
- Label2.Caption:='';
- end;
- procedure TfrmBeijing.Label4DblClick(Sender: TObject);
- begin
- Label4.Caption:='';
- end;
- procedure TfrmBeijing.BitBtn8Click(Sender: TObject);
- var
- trains:Carrayword;
- i:integer;
- begin
- Label2.Enabled:=true;
- label4.Enabled:=true;
- listbox1.Clear;
- listbox4.Clear;
- if((label2.Caption<>'')and(label4.Caption<>''))then
- begin
- trains:=Carrayword.Create();
- trainclass.getArrive(stationclass.getNo(label2.Caption),stationclass.getNo(label4.Caption),trains);
- //showmessage(inttostr(trains.Num));
- if (trains.Num>0)then
- begin
- for i:=1 to trains.Num do
- begin
- listbox1.Items.Add(inttostr(trains.warray[i]));
- end;
- end
- else
- showmessage('没有查到相关信息!');
- trains.Free;
- end
- else
- begin
- showmessage('请选定起点站和终点站!');
- end;
- end;
- procedure TfrmBeijing.BitBtn9Click(Sender: TObject);
- var
- stations:Carrayword;
- i:integer;
- begin
- //consult all info about the checked train
- listbox4.Clear;
- if(listbox1.ItemIndex>=0)then
- begin
- stations:=Carrayword.Create;
- //showmessage(inttostr(listbox1.ItemIndex));
- i:=trainclass.getRoute(strtoint(listBox1.Items[listbox1.ItemIndex]),stations);
- //showmessage(inttostr(stations.Num));
- if(i=0)then
- begin
- for i:=1 to stations.Num do
- begin
- listbox4.Items.Add(stationclass.getName(stations.warray[i]));
- end;
- end
- else
- begin
- showmessage('请选定起点站和终点站!');
- end;
- stations.Free;
- end
- else
- begin
- showmessage('清首先选定一辆列车!');
- end;
- end;
- procedure TfrmBeijing.BitBtn11Click(Sender: TObject);
- var
- ticketNo:word;
- begin
- if(listBox1.ItemIndex>=0)then
- begin
- ticketNo:=0;
- ackNo:=ticketclass.getTicket(stationclass.getNo(label2.Caption),stationclass.getNo(label4.Caption),strtoint(listbox1.Items[listBox1.ItemIndex]),ticketNo);
- //showmessage(inttostr(ticketNo));
- if(ticketNo<>0)then
- begin
- bitbtn11.Enabled:=false;
- bitbtn10.Enabled:=true;
- bitbtn17.Enabled:=true;
- Label6.Caption:=startpoint;
- Label7.Caption:=despoint;
- Label9.Caption:=listbox1.Items[listbox1.ItemIndex];
- label16.Caption:=inttostr(ticketNo div 128);
- label17.Caption:=inttostr(ticketNo mod 128);
- end
- else
- showmessage('没有车票可买了!');
- end;// listBox1.ItemIndex>=0
- end;
- procedure TfrmBeijing.BitBtn10Click(Sender: TObject);
- begin
- bitbtn11.Enabled:=true;
- //record the ticket in listbox5
- tickets.Num:=tickets.Num+1;
- tickets.ticketNo[tickets.Num]:=strtoint(Label16.Caption)*128+strtoint(label17.Caption);
- tickets.trainNo[tickets.Num]:=strtoint(Label9.Caption);
- tickets.SName[tickets.Num]:=Label6.Caption;
- tickets.DName[tickets.Num]:=Label7.Caption;
- tickets.ackNo[tickets.Num]:=ackNo;
- listbox5.Items.Add(tickets.SName[tickets.Num]+'-->'+tickets.DName[tickets.Num]+' '+label9.caption+'次 '+label16.caption+'车厢 '+label17.Caption+'座');
- bitbtn10.Enabled:=false;
- bitbtn17.Enabled:=false;
- label6.Caption:='';
- label7.Caption:='';
- label9.Caption:='';
- label16.Caption:='';
- label17.Caption:='';
- end;
- procedure TfrmBeijing.N2Click(Sender: TObject);
- var
- stations:Carrayword;
- stationNo:word;
- i:integer;
- begin
- popupmenu1.Items[1].Enabled:=false;
- stations:=Carrayword.Create;
- stationNo:=stationclass.getNo(stationName);
- //stationNo:word;var stations:Carrayword
- trainclass.getLink(stationNo,stations);
- //bitbtn1.Brush.Color:=clRed;
- //bitbtn1.Font.Color:=clRed;
- //bitbtn1.Repaint;
- listbox3.Clear;
- for i:=1 to stations.Num do
- begin
- case stations.warray[i] of
- 1:Bitbtn1.Font.Color:=clRed;
- 2:Bitbtn7.Font.Color:=clRed;
- 3:Bitbtn2.Font.Color:=clRed;
- 4:Bitbtn3.Font.Color:=clRed;
- 5:Bitbtn4.Font.Color:=clRed;
- 6:Bitbtn5.Font.Color:=clRed;
- 7:Bitbtn6.Font.Color:=clRed;
- end;
- listbox3.Items.Add(stationclass.getName(stations.warray[i]));
- end;
- stations.Free;
- end;
- procedure TfrmBeijing.N8Click(Sender: TObject);
- var
- i:integer;
- begin
- popupmenu1.Items[1].Enabled:=true;
- for i:=1 to 7 do
- begin
- bitbtn1.Font.Color:=clBlack;
- bitbtn2.Font.Color:=clBlack;
- bitbtn3.Font.Color:=clBlack;
- bitbtn4.Font.Color:=clBlack;
- bitbtn5.Font.Color:=clBlack;
- bitbtn6.Font.Color:=clBlack;
- bitbtn7.Font.Color:=clBlack;
- end;
- end;
- procedure TfrmBeijing.BitBtn18Click(Sender: TObject);
- var
- stations:Carrayword;
- i:integer;
- begin
- if tickets.Num>0 then
- begin
- for i:=1 to tickets.Num do
- begin
- stations:=Carrayword.Create;
- trainclass.getRoute(tickets.trainNo[i],stations);
- ticketclass.ackTicket(stationclass.getNo(tickets.SName[i]),stationclass.getNo(tickets.DName[i]),tickets.trainNo[i],tickets.ticketNo[i],tickets.ackNo[i],true);
- tickets.Num:=0;
- bitbtn16.Click();
- listBox5.Clear;
- showmessage('第 '+inttostr(i)+' 张票处理完毕!');
- end;
- end
- else
- begin
- showmessage('没有车票可以打印!');
- end;
- stations.Free;
- end;
- procedure TfrmBeijing.Button4Click(Sender: TObject);
- begin
- try
- if(ticketclass.addfull(stationclass.getNo(combobox1.Text),strtoint(edit1.Text),strtoint(maskedit1.Text),strtoint(spinEdit1.Text))=0)then
- showmessage('票据加入成功!')
- else
- showmessage('票据加入出错!');
- table1.Refresh;
- except
- showmessage('请检查输入!');
- end;
- end;
- procedure TfrmBeijing.BitBtn19Click(Sender: TObject);
- begin
- Label2.Caption:='';
- startpoint:='';
- Label4.Caption:='';
- despoint:='';
- listbox1.Clear;
- listbox4.Clear;
- listbox3.Clear;
- bitbtn11.Enabled:=true;
- label6.Caption:='';
- Label7.Caption:='';
- Label9.Caption:='';
- Label16.Caption:='';
- Label17.Caption:='';
- listbox1.Clear;
- listbox4.Clear;
- popupmenu1.Items[3].Enabled:=true;
- popupmenu1.Items[4].Enabled:=false;
- popupmenu1.Items[5].Enabled:=false;
- end;
- procedure TfrmBeijing.BitBtn15Click(Sender: TObject);
- var
- trains:Carrayword;
- i:integer;
- begin
- button3.Enabled:=false;
- listbox2.Clear;
- trains:=Carrayword.Create;
- if(trainclass.getPass(trainclass.localstation,trains)=0)then
- begin
- for i:=1 to trains.Num do
- begin
- listbox2.Items.Add(inttostr(trains.warray[i]));
- listbox2.Items.Add(inttostr(trains.warray[i]+1));
- end;
- end
- else
- showmessage('ERROR!');
- trains.Free;
- end;
- procedure TfrmBeijing.BitBtn20Click(Sender: TObject);
- begin
- button3.Enabled:=false;
- listbox2.Clear;
- Memo4.Clear;
- end;
- procedure TfrmBeijing.BitBtn13Click(Sender: TObject);
- var
- trains:Carrayword;
- i:integer;
- begin
- button3.Enabled:=true;
- listbox2.Clear;
- trains:=Carrayword.Create;
- if(trainclass.getStart(trainclass.localstation,trains)<>1)then
- begin
- for i:=1 to trains.Num do
- begin
- listbox2.Items.Add(inttostr(trains.warray[i]));
- listbox2.Items.Add(inttostr(trains.warray[i]+1));
- end;
- end
- else
- showmessage('ERROR!');
- trains.Free;
- end;
- procedure TfrmBeijing.Button3Click(Sender: TObject);
- begin
- if(listbox2.ItemIndex>=0)then
- Edit1.Text:=listbox2.Items[listbox2.Itemindex];
- end;
- procedure TfrmBeijing.TabSheet2Show(Sender: TObject);
- begin
- table1.Refresh;
- end;
- procedure TfrmBeijing.qtrainBeforeDelete(DataSet: TDataSet);
- begin
- showmessage('dfhtytr');
- end;
- end.