UntWuhan.~pas
上传用户:wysk38707
上传日期:2007-06-18
资源大小:801k
文件大小:21k
源码类别:

交通/航空行业

开发平台:

Delphi

  1. unit UntWuhan;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, ExtCtrls, Buttons, jpeg, ComCtrls, Menus,main, DB,
  6.   DBTables, Grids, DBGrids, DBCtrls, Spin, Mask;
  7. type
  8.   TfrmWuhan = class(TForm)
  9.     PageControl1: TPageControl;
  10.     TabSheet1: TTabSheet;
  11.     TabSheet2: TTabSheet;
  12.     Image1: TImage;
  13.     BitBtn1: TBitBtn;
  14.     BitBtn2: TBitBtn;
  15.     BitBtn3: TBitBtn;
  16.     BitBtn4: TBitBtn;
  17.     BitBtn5: TBitBtn;
  18.     BitBtn6: TBitBtn;
  19.     BitBtn7: TBitBtn;
  20.     Panel1: TPanel;
  21.     Label1: TLabel;
  22.     Button1: TButton;
  23.     Label2: TLabel;
  24.     Label3: TLabel;
  25.     Label4: TLabel;
  26.     Button2: TButton;
  27.     BitBtn8: TBitBtn;
  28.     GroupBox1: TGroupBox;
  29.     ListBox1: TListBox;
  30.     BitBtn9: TBitBtn;
  31.     GroupBox2: TGroupBox;
  32.     BitBtn11: TBitBtn;
  33.     GroupBox3: TGroupBox;
  34.     GroupBox4: TGroupBox;
  35.     BitBtn12: TBitBtn;
  36.     Label5: TLabel;
  37.     Label6: TLabel;
  38.     Label7: TLabel;
  39.     Label8: TLabel;
  40.     Label9: TLabel;
  41.     Label10: TLabel;
  42.     Label11: TLabel;
  43.     Label12: TLabel;
  44.     Label13: TLabel;
  45.     Label14: TLabel;
  46.     Label15: TLabel;
  47.     Label16: TLabel;
  48.     Label17: TLabel;
  49.     Label18: TLabel;
  50.     PopupMenu1: TPopupMenu;
  51.     N1: TMenuItem;
  52.     N2: TMenuItem;
  53.     N3: TMenuItem;
  54.     N4: TMenuItem;
  55.     N5: TMenuItem;
  56.     N6: TMenuItem;
  57.     N7: TMenuItem;
  58.     N8: TMenuItem;
  59.     GroupBox5: TGroupBox;
  60.     ListBox2: TListBox;
  61.     Label19: TLabel;
  62.     BitBtn13: TBitBtn;
  63.     BitBtn14: TBitBtn;
  64.     Memo4: TMemo;
  65.     GroupBox6: TGroupBox;
  66.     Button3: TButton;
  67.     Label20: TLabel;
  68.     Edit1: TEdit;
  69.     GroupBox7: TGroupBox;
  70.     GroupBox9: TGroupBox;
  71.     BitBtn15: TBitBtn;
  72.     PopupMenu2: TPopupMenu;
  73.     N9: TMenuItem;
  74.     N10: TMenuItem;
  75.     N11: TMenuItem;
  76.     N12: TMenuItem;
  77.     ListBox3: TListBox;
  78.     ListBox4: TListBox;
  79.     ListBox5: TListBox;
  80.     N13: TMenuItem;
  81.     qstation: TQuery;
  82.     qtrain: TQuery;
  83.     qticket: TQuery;
  84.     BitBtn16: TBitBtn;
  85.     BitBtn10: TBitBtn;
  86.     BitBtn17: TBitBtn;
  87.     BitBtn18: TBitBtn;
  88.     BitBtn19: TBitBtn;
  89.     BitBtn20: TBitBtn;
  90.     DataSource1: TDataSource;
  91.     DBGrid1: TDBGrid;
  92.     DBNavigator1: TDBNavigator;
  93.     Table1: TTable;
  94.     Label21: TLabel;
  95.     MaskEdit1: TMaskEdit;
  96.     Label22: TLabel;
  97.     SpinEdit1: TSpinEdit;
  98.     Button4: TButton;
  99.     ComboBox1: TComboBox;
  100.     Label23: TLabel;
  101.     procedure BitBtn12Click(Sender: TObject);
  102.     procedure N9Click(Sender: TObject);
  103.     procedure N10Click(Sender: TObject);
  104.     procedure N12Click(Sender: TObject);
  105.     //procedure Button1Click(Sender: TObject);
  106.     //procedure Button2Click(Sender: TObject);
  107.     procedure BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
  108.       Shift: TShiftState; X, Y: Integer);
  109.     //procedure BitBtn1Click(Sender: TObject);
  110.     procedure BitBtn7MouseUp(Sender: TObject; Button: TMouseButton;
  111.       Shift: TShiftState; X, Y: Integer);
  112.     procedure BitBtn6MouseUp(Sender: TObject; Button: TMouseButton;
  113.       Shift: TShiftState; X, Y: Integer);
  114.     procedure BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;
  115.       Shift: TShiftState; X, Y: Integer);
  116.     procedure BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
  117.       Shift: TShiftState; X, Y: Integer);
  118.     procedure BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
  119.       Shift: TShiftState; X, Y: Integer);
  120.     procedure BitBtn2MouseUp(Sender: TObject; Button: TMouseButton;
  121.       Shift: TShiftState; X, Y: Integer);
  122.     procedure N1Click(Sender: TObject);
  123.     procedure Button1Click(Sender: TObject);
  124.     procedure Button2Click(Sender: TObject);
  125.     procedure N3Click(Sender: TObject);
  126.     procedure N5Click(Sender: TObject);
  127.     procedure N6Click(Sender: TObject);
  128.     procedure N13Click(Sender: TObject);
  129.     procedure FormCreate(Sender: TObject);
  130.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  131.     procedure BitBtn16Click(Sender: TObject);
  132.     procedure BitBtn17Click(Sender: TObject);
  133.     procedure Label2DblClick(Sender: TObject);
  134.     procedure Label4DblClick(Sender: TObject);
  135.     procedure BitBtn8Click(Sender: TObject);
  136.     procedure BitBtn9Click(Sender: TObject);
  137.     procedure BitBtn11Click(Sender: TObject);
  138.     procedure BitBtn10Click(Sender: TObject);
  139.     procedure N2Click(Sender: TObject);
  140.     procedure N8Click(Sender: TObject);
  141.     procedure BitBtn18Click(Sender: TObject);
  142.     procedure Button4Click(Sender: TObject);
  143.     procedure BitBtn19Click(Sender: TObject);
  144.     procedure BitBtn15Click(Sender: TObject);
  145.     procedure BitBtn20Click(Sender: TObject);
  146.     procedure BitBtn13Click(Sender: TObject);
  147.     procedure Button3Click(Sender: TObject);
  148.     procedure TabSheet2Show(Sender: TObject);
  149.     procedure qtrainBeforeDelete(DataSet: TDataSet);
  150.   private
  151.     { Private declarations }
  152.   public
  153.     { Public declarations }
  154.   end;
  155. var
  156.   frmWuhan: TfrmWuhan;
  157.   //variants for interface design
  158.   stationName:string;
  159.   //startName:string;
  160.   //desName:string;
  161.   startpoint:string;
  162.   despoint:string;
  163.   //variants for inner class
  164.   stationclass:Cstation;
  165.   ticketclass:Cticket;
  166.   trainclass:Ctrain;
  167.   tickets:ticketRec;
  168.   ackNo:word;
  169. implementation
  170. {$R *.dfm}
  171. procedure TfrmWuhan.BitBtn12Click(Sender: TObject);
  172. begin
  173.     //if(messageDlg('确定要退出!', mtConfirmation,[mbOKCancel], 0)=mrOK)then
  174.     BitBtn16Click(nil);
  175. end;
  176. procedure TfrmWuhan.N9Click(Sender: TObject);
  177. begin
  178.     if((listBox3.itemIndex>=0) and (Label4.Caption<>listbox3.Items[listBox3.itemIndex]))then
  179.         begin
  180.             Label2.Caption:=listbox3.Items[listBox3.itemIndex];
  181.             startpoint:=Label2.Caption;
  182.         end
  183. end;
  184. procedure TfrmWuhan.N10Click(Sender: TObject);
  185. begin
  186.     if((listBox3.itemIndex>=0) and (Label2.Caption<>listbox3.Items[listBox3.itemIndex]))then
  187.         begin
  188.             Label4.Caption:=listbox3.Items[listBox3.itemIndex];
  189.             despoint:=Label4.Caption;
  190.         end;
  191. end;
  192. procedure TfrmWuhan.N12Click(Sender: TObject);
  193. begin
  194.     listbox3.Items.Delete(listbox3.ItemIndex)
  195. end;
  196. procedure TfrmWuhan.BitBtn1MouseUp(Sender: TObject; Button: TMouseButton;
  197.   Shift: TShiftState; X, Y: Integer);
  198. begin
  199.     if(button=mbRight)then
  200.         begin
  201.     stationName:=(Sender as TBitbtn).Caption;
  202.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  203.         end;
  204. end;
  205. procedure TfrmWuhan.BitBtn7MouseUp(Sender: TObject; Button: TMouseButton;
  206.   Shift: TShiftState; X, Y: Integer);
  207. begin
  208.     if(button=mbRight)then
  209.         begin
  210.     stationName:=(Sender as TBitbtn).Caption;
  211.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  212.         end;
  213. end;
  214. procedure TfrmWuhan.BitBtn6MouseUp(Sender: TObject; Button: TMouseButton;
  215.   Shift: TShiftState; X, Y: Integer);
  216. begin
  217.     if(button=mbRight)then
  218.         begin
  219.     stationName:=(Sender as TBitbtn).Caption;
  220.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  221.         end;
  222. end;
  223. procedure TfrmWuhan.BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;
  224.   Shift: TShiftState; X, Y: Integer);
  225. begin
  226.     if(button=mbRight)then
  227.         begin
  228.     stationName:=(Sender as TBitbtn).Caption;
  229.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  230.         end;
  231. end;
  232. procedure TfrmWuhan.BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
  233.   Shift: TShiftState; X, Y: Integer);
  234. begin
  235.     if(button=mbRight)then
  236.         begin
  237.     stationName:=(Sender as TBitbtn).Caption;
  238.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  239.         end;
  240. end;
  241. procedure TfrmWuhan.BitBtn3MouseUp(Sender: TObject; Button: TMouseButton;
  242.   Shift: TShiftState; X, Y: Integer);
  243. begin
  244.     if(button=mbRight)then
  245.         begin
  246.     stationName:=(Sender as TBitbtn).Caption;
  247.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  248.         end;
  249. end;
  250. procedure TfrmWuhan.BitBtn2MouseUp(Sender: TObject; Button: TMouseButton;
  251.   Shift: TShiftState; X, Y: Integer);
  252. begin
  253.     if(button=mbRight)then
  254.         begin
  255.     stationName:=(Sender as TBitbtn).Caption;
  256.     popupMenu1.Popup((Sender as tbitbtn).left+X,(Sender as tbitbtn).top+Y);
  257.         end;
  258. end;
  259. procedure TfrmWuhan.N1Click(Sender: TObject);
  260. var
  261.     i:integer;
  262.     Flag:boolean;
  263. begin
  264.     //first we judge whether it has been in listBox3
  265.     Flag:=True;
  266.     //showmessage(inttostr(listBox3.Items.Count));
  267.     if(listBox3.Items.Count>=1)then
  268.         for i:=1 to listBox3.Items.Count do
  269.             begin
  270.               if(listBox3.Items[i-1]=StationName)then
  271.                 Flag:=false;
  272.             end;
  273.     if(flag=true)then
  274.         listbox3.Items.Add(StationName);
  275. end;
  276. procedure TfrmWuhan.Button1Click(Sender: TObject);
  277. begin
  278.     N9Click(nil);
  279. end;
  280. procedure TfrmWuhan.Button2Click(Sender: TObject);
  281. begin
  282.     N10Click(nil);
  283. end;
  284. procedure TfrmWuhan.N3Click(Sender: TObject);
  285. begin
  286.     if(despoint<>stationName)then
  287.         begin
  288.     //startName:=stationName;
  289.     startpoint:=stationName;
  290.     Label2.Caption:=startpoint;
  291.     //Label2.Enabled:=false;
  292.     popupMenu1.Items.Items[3].Enabled:=false;
  293.     popupMenu1.Items.Items[4].Enabled:=true;
  294.         end;
  295. end;
  296. procedure TfrmWuhan.N5Click(Sender: TObject);
  297. begin
  298.     if(startpoint<>stationName)then
  299.         begin
  300.             //desName:=stationName;
  301.             despoint:=stationName;
  302.             label4.Caption:=despoint;
  303.             //label4.Enabled:=false;
  304.             popupMenu1.Items.Items[5].Enabled:=true;
  305.             popupMenu1.Items.Items[4].Enabled:=false;
  306.         end;
  307. end;
  308. procedure TfrmWuhan.N6Click(Sender: TObject);
  309. var
  310.     trains:Carrayword;
  311.     i:integer;
  312. begin
  313.     popupMenu1.Items.Items[3].Enabled:=true;
  314.     popupMenu1.Items.Items[4].Enabled:=false;
  315.     popupMenu1.Items.Items[5].Enabled:=false;
  316.     Label2.Enabled:=true;
  317.     label4.Enabled:=true;
  318.     listbox1.Clear;
  319.     listbox4.Clear;
  320.     if((startpoint<>'')and(despoint<>''))then
  321.         begin
  322.             trains:=Carrayword.Create();
  323.             trainclass.getArrive(stationclass.getNo(startpoint),stationclass.getNo(despoint),trains);
  324.             //showmessage(inttostr(trains.Num));
  325.             if (trains.Num>0)then
  326.                 begin
  327.                     for i:=1 to trains.Num do
  328.                         begin
  329.                             listbox1.Items.Add(inttostr(trains.warray[i]));
  330.                         end;
  331.                 end
  332.              else
  333.                 showmessage('没有查到相关信息!');
  334.             trains.Free;
  335.         end
  336.     else
  337.         begin
  338.             showmessage('请选定起点站和终点站!');
  339.         end;
  340. end;
  341. procedure TfrmWuhan.N13Click(Sender: TObject);
  342. begin
  343.     //popupMenu1.Items.Items[3].Enabled:=true;
  344.     bitbtn19.Click(); 
  345. end;
  346. procedure TfrmWuhan.FormCreate(Sender: TObject);
  347. begin
  348.     trainclass:=Ctrain.Create();
  349.     stationclass:=Cstation.Create();
  350.     ticketclass:=Cticket.Create();
  351.     ticketclass.myCtrain:=trainclass;
  352.     trainclass.setQuery(qtrain);
  353.     trainclass.localstation:=4;
  354.     ticketclass.setQuery(qticket);
  355.     ticketclass.settable('ticket4.db');
  356.     ticketclass.localstation:=4;
  357.     stationclass.setQuery(qstation);
  358.     tickets.Num:=0;
  359. end;
  360. procedure TfrmWuhan.FormClose(Sender: TObject; var Action: TCloseAction);
  361. begin
  362.     ticketclass.query.Close;
  363.     stationclass.query.Close;
  364.     trainclass.query.Close;
  365.     ticketclass.Free;
  366.     stationclass.Free;
  367.     trainclass.Free;
  368. end;
  369. procedure TfrmWuhan.BitBtn16Click(Sender: TObject);
  370. begin
  371.     if(Bitbtn11.Enabled=false)then
  372.         BitBtn17Click(nil);
  373.       begin
  374.         Label2.Caption:='';
  375.         Label4.Caption:='';
  376.         Label6.Caption:='';
  377.         Label7.Caption:='';
  378.         Label9.Caption:='';
  379.         Label16.Caption:='';
  380.         Label17.Caption:='';
  381.         listBox1.Items.Clear;
  382.         listBox3.Items.Clear;
  383.         listBox4.Items.Clear;
  384.         //listBox5.Items.Clear;
  385.         bitbtn10.Enabled:=false;
  386.         bitbtn17.Enabled:=false;
  387.       end
  388. end;
  389. procedure TfrmWuhan.BitBtn17Click(Sender: TObject);
  390. begin
  391.     bitbtn11.Enabled:=true;
  392.     //ack ticket falg=false
  393.     ticketclass.ackTicket(stationclass.getNo(Label6.Caption),stationclass.getNo(Label7.Caption),strtoint(label9.Caption),(strtoint(label16.Caption)*128+strtoint(label17.Caption)),ackNo,false);
  394.     bitbtn10.Enabled:=false;
  395.     bitbtn17.Enabled:=false;
  396.     label6.Caption:='';
  397.     label7.Caption:='';
  398.     label9.Caption:='';
  399.     label16.Caption:='';
  400.     label17.Caption:='';
  401. end;
  402. procedure TfrmWuhan.Label2DblClick(Sender: TObject);
  403. begin
  404.     Label2.Caption:='';
  405. end;
  406. procedure TfrmWuhan.Label4DblClick(Sender: TObject);
  407. begin
  408.     Label4.Caption:='';
  409. end;
  410. procedure TfrmWuhan.BitBtn8Click(Sender: TObject);
  411. var
  412.     trains:Carrayword;
  413.     i:integer;
  414. begin
  415.     Label2.Enabled:=true;
  416.     label4.Enabled:=true;
  417.     listbox1.Clear;
  418.     listbox4.Clear;
  419.     if((label2.Caption<>'')and(label4.Caption<>''))then
  420.         begin
  421.             trains:=Carrayword.Create();
  422.             trainclass.getArrive(stationclass.getNo(label2.Caption),stationclass.getNo(label4.Caption),trains);
  423.             //showmessage(inttostr(trains.Num));
  424.             if (trains.Num>0)then
  425.                 begin
  426.                     for i:=1 to trains.Num do
  427.                         begin
  428.                             listbox1.Items.Add(inttostr(trains.warray[i]));
  429.                         end;
  430.                 end
  431.              else
  432.                 showmessage('没有查到相关信息!');
  433.             trains.Free;
  434.         end
  435.     else
  436.         begin
  437.             showmessage('请选定起点站和终点站!');
  438.         end;
  439. end;
  440. procedure TfrmWuhan.BitBtn9Click(Sender: TObject);
  441. var
  442.     stations:Carrayword;
  443.     i:integer;
  444. begin
  445. //consult all info about the checked train
  446.     listbox4.Clear;
  447.     if(listbox1.ItemIndex>=0)then
  448.         begin
  449.             stations:=Carrayword.Create;
  450.             //showmessage(inttostr(listbox1.ItemIndex));
  451.             i:=trainclass.getRoute(strtoint(listBox1.Items[listbox1.ItemIndex]),stations);
  452.             //showmessage(inttostr(stations.Num));
  453.             if(i=0)then
  454.                 begin
  455.                     for i:=1 to stations.Num do
  456.                         begin
  457.                             listbox4.Items.Add(stationclass.getName(stations.warray[i]));
  458.                         end;
  459.                 end
  460.             else
  461.                 begin
  462.                     showmessage('请选定起点站和终点站!');
  463.                 end;
  464.             stations.Free; 
  465.         end
  466.     else
  467.         begin
  468.             showmessage('清首先选定一辆列车!');
  469.         end;
  470. end;
  471. procedure TfrmWuhan.BitBtn11Click(Sender: TObject);
  472. var
  473.     ticketNo:word;
  474. begin
  475.     if(listBox1.ItemIndex>=0)then
  476.         begin
  477.     ticketNo:=0;
  478.     ackNo:=ticketclass.getTicket(stationclass.getNo(label2.Caption),stationclass.getNo(label4.Caption),strtoint(listbox1.Items[listBox1.ItemIndex]),ticketNo);
  479.     //showmessage(inttostr(ticketNo));
  480.     if(ticketNo<>0)then
  481.         begin
  482.             bitbtn11.Enabled:=false;
  483.             bitbtn10.Enabled:=true;
  484.             bitbtn17.Enabled:=true;
  485.             Label6.Caption:=startpoint;
  486.             Label7.Caption:=despoint;
  487.             Label9.Caption:=listbox1.Items[listbox1.ItemIndex];
  488.             label16.Caption:=inttostr(ticketNo div 128);
  489.             label17.Caption:=inttostr(ticketNo mod 128);
  490.         end
  491.     else
  492.         showmessage('没有车票可买了!');
  493.         end;// listBox1.ItemIndex>=0
  494. end;
  495. procedure TfrmWuhan.BitBtn10Click(Sender: TObject);
  496. begin
  497.     bitbtn11.Enabled:=true;
  498.     //record the ticket in listbox5
  499.     tickets.Num:=tickets.Num+1;
  500.     tickets.ticketNo[tickets.Num]:=strtoint(Label16.Caption)*128+strtoint(label17.Caption);
  501.     tickets.trainNo[tickets.Num]:=strtoint(Label9.Caption);
  502.     tickets.SName[tickets.Num]:=Label6.Caption;
  503.     tickets.DName[tickets.Num]:=Label7.Caption;
  504.     tickets.ackNo[tickets.Num]:=ackNo;
  505.     listbox5.Items.Add(tickets.SName[tickets.Num]+'-->'+tickets.DName[tickets.Num]+' '+label9.caption+'次 '+label16.caption+'车厢 '+label17.Caption+'座');
  506.     bitbtn10.Enabled:=false;
  507.     bitbtn17.Enabled:=false;
  508.     label6.Caption:='';
  509.     label7.Caption:='';
  510.     label9.Caption:='';
  511.     label16.Caption:='';
  512.     label17.Caption:='';
  513. end;
  514. procedure TfrmWuhan.N2Click(Sender: TObject);
  515. var
  516.     stations:Carrayword;
  517.     stationNo:word;
  518.     i:integer;
  519. begin
  520.     popupmenu1.Items[1].Enabled:=false;  
  521.     stations:=Carrayword.Create;
  522.     stationNo:=stationclass.getNo(stationName);
  523.     //stationNo:word;var stations:Carrayword
  524.     trainclass.getLink(stationNo,stations);
  525.     //bitbtn1.Brush.Color:=clRed;
  526.     //bitbtn1.Font.Color:=clRed;
  527.     //bitbtn1.Repaint;
  528.     listbox3.Clear;
  529.     for i:=1 to stations.Num do
  530.         begin
  531.             case stations.warray[i] of
  532.                 1:Bitbtn1.Font.Color:=clRed;
  533.                 2:Bitbtn7.Font.Color:=clRed;
  534.                 3:Bitbtn2.Font.Color:=clRed;
  535.                 4:Bitbtn3.Font.Color:=clRed;
  536.                 5:Bitbtn4.Font.Color:=clRed;
  537.                 6:Bitbtn5.Font.Color:=clRed;
  538.                 7:Bitbtn6.Font.Color:=clRed;
  539.             end;
  540.             listbox3.Items.Add(stationclass.getName(stations.warray[i]));  
  541.         end;
  542.     stations.Free;
  543. end;
  544. procedure TfrmWuhan.N8Click(Sender: TObject);
  545. var
  546.     i:integer;
  547. begin
  548.     popupmenu1.Items[1].Enabled:=true;  
  549.     for i:=1 to 7 do
  550.         begin
  551.             bitbtn1.Font.Color:=clBlack;
  552.             bitbtn2.Font.Color:=clBlack;
  553.             bitbtn3.Font.Color:=clBlack;
  554.             bitbtn4.Font.Color:=clBlack;
  555.             bitbtn5.Font.Color:=clBlack;
  556.             bitbtn6.Font.Color:=clBlack;
  557.             bitbtn7.Font.Color:=clBlack;
  558.         end;
  559. end;
  560. procedure TfrmWuhan.BitBtn18Click(Sender: TObject);
  561. var
  562.     stations:Carrayword;
  563.     i:integer;
  564. begin
  565.     if tickets.Num>0 then
  566.         begin
  567.             for i:=1 to tickets.Num do
  568.                 begin
  569.     stations:=Carrayword.Create;
  570.     trainclass.getRoute(tickets.trainNo[i],stations);
  571.     ticketclass.ackTicket(stationclass.getNo(tickets.SName[i]),stationclass.getNo(tickets.DName[i]),tickets.trainNo[i],tickets.ticketNo[i],tickets.ackNo[i],true);
  572.     tickets.Num:=0;
  573.     bitbtn16.Click();
  574.     listBox5.Clear;
  575.                     showmessage('第 '+inttostr(i)+' 张票处理完毕!');
  576.                 end;
  577.         end
  578.     else
  579.         begin
  580.             showmessage('没有车票可以打印!');
  581.         end;
  582.     stations.Free;
  583. end;
  584. procedure TfrmWuhan.Button4Click(Sender: TObject);
  585. begin
  586.     try
  587.         if(ticketclass.addfull(stationclass.getNo(combobox1.Text),strtoint(edit1.Text),strtoint(maskedit1.Text),strtoint(spinEdit1.Text))=0)then
  588.             showmessage('票据加入成功!')
  589.         else
  590.             showmessage('票据加入出错!');
  591.         table1.Refresh; 
  592.     except
  593.         showmessage('请检查输入!');
  594.     end;
  595. end;
  596. procedure TfrmWuhan.BitBtn19Click(Sender: TObject);
  597. begin
  598.     Label2.Caption:='';
  599.     startpoint:='';
  600.     Label4.Caption:='';
  601.     despoint:='';
  602.     listbox1.Clear;
  603.     listbox4.Clear;
  604.     listbox3.Clear;
  605.     bitbtn11.Enabled:=true;
  606.     label6.Caption:='';
  607.     Label7.Caption:='';
  608.     Label9.Caption:='';
  609.     Label16.Caption:='';
  610.     Label17.Caption:='';
  611.     listbox1.Clear;
  612.     listbox4.Clear;
  613.     popupmenu1.Items[3].Enabled:=true;
  614.     popupmenu1.Items[4].Enabled:=false;
  615.     popupmenu1.Items[5].Enabled:=false;
  616. end;
  617. procedure TfrmWuhan.BitBtn15Click(Sender: TObject);
  618. var
  619.     trains:Carrayword;
  620.     i:integer;
  621. begin
  622.     button3.Enabled:=false; 
  623.     listbox2.Clear;
  624.     trains:=Carrayword.Create;
  625.     if(trainclass.getPass(trainclass.localstation,trains)=0)then
  626.         begin
  627.             for i:=1 to trains.Num do
  628.                 begin
  629.                     listbox2.Items.Add(inttostr(trains.warray[i]));
  630.                     listbox2.Items.Add(inttostr(trains.warray[i]+1));
  631.                 end;
  632.         end
  633.     else
  634.         showmessage('ERROR!');
  635.     trains.Free;
  636. end;
  637. procedure TfrmWuhan.BitBtn20Click(Sender: TObject);
  638. begin
  639.     button3.Enabled:=false; 
  640.     listbox2.Clear;
  641.     Memo4.Clear;
  642. end;
  643. procedure TfrmWuhan.BitBtn13Click(Sender: TObject);
  644. var
  645.     trains:Carrayword;
  646.     i:integer;
  647. begin
  648.     button3.Enabled:=true; 
  649.     listbox2.Clear;
  650.     trains:=Carrayword.Create;
  651.     if(trainclass.getStart(trainclass.localstation,trains)<>1)then
  652.         begin
  653.             for i:=1 to trains.Num do
  654.                 begin
  655.                     listbox2.Items.Add(inttostr(trains.warray[i]));
  656.                     listbox2.Items.Add(inttostr(trains.warray[i]+1));
  657.                 end;
  658.         end
  659.     else
  660.         showmessage('ERROR!');
  661.     trains.Free;
  662. end;
  663. procedure TfrmWuhan.Button3Click(Sender: TObject);
  664. begin
  665. if(listbox2.ItemIndex>=0)then
  666.     Edit1.Text:=listbox2.Items[listbox2.Itemindex];  
  667. end;
  668. procedure TfrmWuhan.TabSheet2Show(Sender: TObject);
  669. begin
  670.     table1.Refresh; 
  671. end;
  672. procedure TfrmWuhan.qtrainBeforeDelete(DataSet: TDataSet);
  673. begin
  674.     showmessage('dfhtytr');
  675. end;
  676. end.