⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untchongqing.pas

📁 一个简单的火车售票系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
procedure Tfrmchongqing.N13Click(Sender: TObject);
begin
    //popupMenu1.Items.Items[3].Enabled:=true;
    bitbtn19.Click(); 
end;

procedure Tfrmchongqing.FormCreate(Sender: TObject);

begin
    trainclass:=Ctrain.Create();
    stationclass:=Cstation.Create();
    ticketclass:=Cticket.Create();
    ticketclass.myCtrain:=trainclass;
    trainclass.setQuery(qtrain);
    trainclass.localstation:=2;
    ticketclass.setQuery(qticket);
    ticketclass.settable('ticket2.db');
    ticketclass.localstation:=2;
    stationclass.setQuery(qstation);
    tickets.Num:=0;
end;

procedure Tfrmchongqing.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    ticketclass.query.Close;
    stationclass.query.Close;
    trainclass.query.Close;
    ticketclass.Free;
    stationclass.Free;
    trainclass.Free;
end;

procedure Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.Label2DblClick(Sender: TObject);
begin
    Label2.Caption:='';
end;

procedure Tfrmchongqing.Label4DblClick(Sender: TObject);
begin
    Label4.Caption:='';
end;

procedure Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.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 Tfrmchongqing.BitBtn20Click(Sender: TObject);
begin
    button3.Enabled:=false;
    listbox2.Clear;
    Memo4.Clear;
end;

procedure Tfrmchongqing.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 Tfrmchongqing.Button3Click(Sender: TObject);
begin
if(listbox2.ItemIndex>=0)then
    Edit1.Text:=listbox2.Items[listbox2.Itemindex];  
end;

procedure Tfrmchongqing.TabSheet2Show(Sender: TObject);
begin
    table1.Refresh; 
end;

procedure Tfrmchongqing.qtrainBeforeDelete(DataSet: TDataSet);
begin
    showmessage('dfhtytr');
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -