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

📄 sitetosite.pas

📁 基于DELPHI的列车时刻查询系统设计与实现
💻 PAS
字号:
unit SiteToSite;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  se_controls, KsSkinSpeedButtons, KsSkinToolBars, KsSkinPanels,
  KsSkinEdits, KsSkinLabels, KsSkinComboBoxs, Grids, KsSkinGrids, RM_class,
  RM_dset, RM_dbset, StdCtrls;

type
  TfrmSiteToSite = class(TForm)
    SeSkinToolBar1: TSeSkinToolBar;
    btnSerch: TSeSkinSpeedButton;
    btnPrint: TSeSkinSpeedButton;
    btnClose: TSeSkinSpeedButton;
    SeSkinPanel1: TSeSkinPanel;
    DBGrid: TSeSkinStringGrid;
    RMReport1: TRMReport;
    RMDBDataSet1: TRMDBDataSet;
    cbxEndSiteID: TSeSkinComboBox;
    cbxStartSiteID: TSeSkinComboBox;
    cbxEndSite: TComboBox;
    SeSkinLabel10: TSeSkinLabel;
    cbxStartSite: TComboBox;
    SeSkinLabel2: TSeSkinLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnCloseClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure btnSerchClick(Sender: TObject);
    procedure RMReport1GetValue(const ParName: String;
      var ParValue: Variant);
    procedure btnPrintClick(Sender: TObject);
    procedure cbxStartSiteChange(Sender: TObject);
    procedure cbxEndSiteChange(Sender: TObject);
  private
    procedure GetAllList;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmSiteToSite: TfrmSiteToSite;

implementation
{$R *.DFM}

uses DataModule,Main;

procedure TfrmSiteToSite.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  if DataModule1.qrySerchStudent.Active then
  begin
    DataModule1.qrySerchStudent.First ;
    DataModule1.qrySerchStudent.Active := False;
  end;
  Action := caFree;
  frmSiteToSite := nil;
end;

procedure TfrmSiteToSite.btnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TfrmSiteToSite.GetAllList;
begin
  with DataModule1.qrySelect do
  begin
    if Active then Close ;
    sql.Text := 'SELECT ID,Name from SiteBase where Stop = False';
    Open;
    while not eof do
    begin
      cbxStartSite.Items.Add(FieldbyName('Name').AsString);
      cbxStartSiteID.Items.Add(FieldbyName('ID').AsString);
      cbxEndSite.Items.Add(FieldbyName('Name').AsString);
      cbxEndSiteID.Items.Add(FieldbyName('ID').AsString);
      next;
    end;
    First;
    Close;
  end;
end;

procedure TfrmSiteToSite.FormShow(Sender: TObject);
begin
  GetAllList ;
  btnSerch.Click ;
end;

procedure TfrmSiteToSite.btnSerchClick(Sender: TObject);
var
  strSelect: string;
  i : integer;
begin
  I := 1;
  //strSelect := 'Select * from Student where 1 = 1 ';

  strSelect := 'SELECT TrainBase.TrainID, TrainBase.TrainName, TypeBase.Name AS TypeName, SiteBase.Name AS StartSite,';
  strSelect := strSelect + ' SiteBase_1.Name AS EndSite, TrainBase.StartTime, TrainBase.EndTime, TrainBase.Mileage, ';
  strSelect := strSelect + ' TrainBase.SumTime, TrainPrice.GeneralSeat, TypeBase.Name AS TypeBase_Name, ';
  strSelect := strSelect + ' TrainPrice.SoftSeat, TrainPrice.GeneralBed, TrainPrice.SoftBed ';
  strSelect := strSelect + ' FROM TypeBase RIGHT JOIN ((SiteBase RIGHT JOIN (TrainBase LEFT JOIN SiteBase AS SiteBase_1 ON TrainBase.EndSiteID = SiteBase_1.ID) ';
  strSelect := strSelect + ' ON SiteBase.ID = TrainBase.StartSiteID) INNER JOIN TrainPrice ON TrainBase.TrainID = TrainPrice.TrainID) ';
  strSelect := strSelect + ' ON TypeBase.TypeID = TrainBase.TypeID';
  strSelect := strSelect + ' WHERE 1=1';
  if cbxStartSite.ItemIndex <> -1 then
    strSelect := strSelect + ' AND TrainBase.StartSiteID = ' + cbxStartSiteID.Text + '';
  if cbxEndSite.ItemIndex <> -1 then
    strSelect := strSelect + ' AND TrainBase.EndSiteID = ' + cbxEndSiteID.Text + '';
  //strSelect := 'SELECT Student.Num, Student.Birth, Student.Sex, Student.Address, Student.Post, Student.Phone, Student.Email, Student.Name AS Student_Name, Class.Name AS Class_Name, Department.Name AS Department_Name, Profess.Name AS Profess_Name ';
  //strSelect := strSelect + ' FROM ((Department INNER JOIN Student ON Department.ID = Student.DepID) INNER JOIN Profess ON Student.ProID = Profess.ID) INNER JOIN Class ON Student.ClassID = Class.ID ';
  with DataModule1.qrySelect do
  begin
    if Active then Close ;
    Sql.Text := strSelect;
    //inputbox('','',strselect);
    Open;
    DBGrid.RowCount := RecordCount + 1 ;
    DBGrid.ColCount := 14;
    DBGrid.ColWidths[0] := 16;
    DBGrid.ColWidths[1] := 40;
    DBGrid.ColWidths[2] := 80;
    DBGrid.ColWidths[3] := 80;
    DBGrid.ColWidths[4] := 80;
    DBGrid.ColWidths[5] := 80;
    DBGrid.ColWidths[6] := 80;
    DBGrid.ColWidths[7] := 80;
    DBGrid.ColWidths[8] := 60;
    DBGrid.ColWidths[9] := 60;
    DBGrid.ColWidths[10] := 100;
    DBGrid.ColWidths[11] := 100;
    DBGrid.ColWidths[10] := 100;
    DBGrid.ColWidths[11] := 100;
    DBGrid.Cells[1,0] := ' 编号';
    DBGrid.Cells[2,0] := ' 车次';
    DBGrid.Cells[3,0] := ' 类型';
    DBGrid.Cells[4,0] := ' 始发站';
    DBGrid.Cells[5,0] := ' 终点站';
    DBGrid.Cells[6,0] := ' 始发时间';
    DBGrid.Cells[7,0] := ' 到点时间';
    DBGrid.Cells[8,0] := ' 公里数';
    DBGrid.Cells[9,0] := ' 共用时间';
    DBGrid.Cells[10,0] := ' 硬座价格';
    DBGrid.Cells[11,0] := ' 软座价格';
    DBGrid.Cells[12,0] := ' 硬卧价格';
    DBGrid.Cells[13,0] := ' 软卧价格';
    first;
    while not eof do
    begin
      DBGrid.Cells[1,i] := FieldByName('TrainID').AsString;
      DBGrid.Cells[2,i] := FieldByName('TrainName').AsString;
      DBGrid.Cells[3,i] := FieldByName('TypeName').AsString;
      DBGrid.Cells[4,i] := FieldByName('StartSite').AsString;
      DBGrid.Cells[5,i] := FieldByName('EndSite').AsString;
      DBGrid.Cells[6,i] := FieldByName('StartTime').AsString;
      DBGrid.Cells[7,i] := FieldByName('EndTime').AsString;
      DBGrid.Cells[8,i] := FieldByName('Mileage').AsString;
      DBGrid.Cells[9,i] := FieldByName('SumTime').AsString;
      DBGrid.Cells[10,i] := FieldByName('GeneralSeat').AsString;
      DBGrid.Cells[11,i] := FieldByName('SoftSeat').AsString;
      DBGrid.Cells[12,i] := FieldByName('GeneralBed').AsString;
      DBGrid.Cells[13,i] := FieldByName('SoftBed').AsString;
      i:= i+1;
      next;
    end;
    first;
    Close;
  end;
end;

procedure TfrmSiteToSite.RMReport1GetValue(const ParName: String;
  var ParValue: Variant);
//var
  //i: integer;
begin
{  //for i:= 0 to DBGrid.RowCount do
  //begin
    if ParName = 'Num' then
      ParValue := DBGrid.Cells[1,i];
    if ParName = 'Name' then
      ParValue := DBGrid.Cells[2,i];
    if ParName = 'Dep' then
      ParValue := DBGrid.Cells[3,i];
    if ParName = 'Class' then
      ParValue := DBGrid.Cells[4,i];
    if ParName = 'Profess' then
      ParValue := DBGrid.Cells[5,i];
    if ParName = 'Birth' then
      ParValue := DBGrid.Cells[6,i];
    if ParName = 'Sex' then
      ParValue := DBGrid.Cells[7,i];
    if ParName = 'Address' then
      ParValue := DBGrid.Cells[8,i];
    if ParName = 'Post' then
      ParValue := DBGrid.Cells[9,i];
    if ParName = 'Phone' then
      ParValue := DBGrid.Cells[10,i];
    if ParName = 'Email' then
      ParValue := DBGrid.Cells[11,i];
  //end;  }
end;

procedure TfrmSiteToSite.btnPrintClick(Sender: TObject);
begin
  //RMReport1.Title := '学生花名册';
  //RMReport1.LoadFromFile(ExtractFilePath(Application.exename)+ 'AllStudent.rmf');
  //RMReport1.ShowReport ;
end;

procedure TfrmSiteToSite.cbxStartSiteChange(Sender: TObject);
begin
  cbxStartSiteID.ItemIndex := cbxStartSite.ItemIndex;
end;

procedure TfrmSiteToSite.cbxEndSiteChange(Sender: TObject);
begin
 cbxEndSiteID.ItemIndex := cbxEndSite.ItemIndex;
end;

end.



⌨️ 快捷键说明

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