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

📄 unitmainfr.pas

📁 信号机测试信号管理软件 其中含有文件上传及修改数据库数据的功能
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unitmainfr;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, ExtCtrls, Menus, Grids, StdCtrls;

type
  Tmainform = class(TForm)
    Panel1: TPanel;
    MainMenu1: TMainMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    N3: TMenuItem;
    N4: TMenuItem;
    N5: TMenuItem;
    N6: TMenuItem;
    N8: TMenuItem;
    N9: TMenuItem;
    Panel2: TPanel;
    Image1: TImage;
    StatusBar1: TStatusBar;
    GroupBox1: TGroupBox;
    StringGrid1: TStringGrid;
    Timer1: TTimer;
    N7: TMenuItem;
    N11: TMenuItem;
    StringGrid2: TStringGrid;
    Label1: TLabel;
    Label2: TLabel;
    N10: TMenuItem;
    Timer2: TTimer;
    DateTimePicker1: TDateTimePicker;
    DateTimePicker2: TDateTimePicker;
    Label3: TLabel;
    Button1: TButton;
    procedure N2Click(Sender: TObject);
    procedure N4Click(Sender: TObject);
    procedure N3Click(Sender: TObject);
    procedure N8Click(Sender: TObject);
    procedure N9Click(Sender: TObject);
    procedure N6Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure N7Click(Sender: TObject);
    procedure N10Click(Sender: TObject);
    procedure N11Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
//    procedure StringGrid2SelectCell(Sender: TObject; ACol, ARow: Integer;
      //var CanSelect: Boolean);
    procedure StringGrid2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure Timer2Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  mainform: Tmainform;
  searchdata,showdata:boolean;

implementation
uses loginunit,unitworkerfr,unitbasicinfofr,unituserfr,unitls,unitcx,unitmodule,unitbeifen,unithuifu,unitrecord,unitsr,unittrain;

{$R *.dfm}

procedure Tmainform.N2Click(Sender: TObject);
begin
    application.Createform(tworkerfr,workerfr);
    workerfr.showmodal;
    workerfr.free;
end;

procedure Tmainform.N4Click(Sender: TObject);
begin
    application.Createform(tbasicinfofr,basicinfofr);
    basicinfofr.showmodal;
    basicinfofr.free;
end;

procedure Tmainform.N3Click(Sender: TObject);
begin
    application.Createform(tuserfr,userfr);
    userfr.showmodal;
    userfr.free;
end;

procedure Tmainform.N8Click(Sender: TObject);
begin
    application.Createform(tformls,formls);
    formls.showmodal;
    formls.free;
    formls:=nil;
end;

procedure Tmainform.N9Click(Sender: TObject);
begin
    application.Createform(tformcx,formcx);
    formcx.showmodal;
    formcx.free;
    formcx:=nil;
end;

procedure Tmainform.N6Click(Sender: TObject);
begin
      Application.Terminate;
end;


procedure Tmainform.FormCreate(Sender: TObject);
var
i,j,h:integer;
today:TDateTime;
yesterdaytime,time:string;
begin
    if degree='管理员' then
    mainform.MainMenu1.Items[0].visible:=false;
   with StringGrid2 do
   begin
    FixedCols:=0;//左边没有固定列
    Cells[0,0]:='机车号';//列标题
    Cells[1,0]:='机车信息';
    Cells[2,0]:='合格标志';
    Cells[3,0]:='工号';
    Cells[4,0]:='测试者姓名';
   // Cells[5,0]:='点灯时间';
    Cells[5,0]:='所属文件';
  end;
  statusbar1.Panels[4].Text:=czymc;
  with datamodule2.ADOQuery9 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select 工号 from 登录表 where (姓名= :a)');
    Parameters.ParamByName('a').Value := czymc;
    Open;
  end;
    if DataModule2.ADOQuery9.RecordCount >0 then
    statusbar1.Panels[2].Text:= DataModule2.ADOQuery2.FieldByName('工号').AsString;
    statusbar1.Panels[6].Text:=formatdatetime('yyyy年mm月dd日 hh:mm:ss',now);
    today:=now();
    yesterdaytime:= formatdatetime('mmddhhmm',today-1);    //文件名是按"月,日,小时,分"来命名的么
    label2.Caption:=formatdatetime('yyyy年mm月dd日',today-1)+'上传信号机数据';
    //edit1.Text:=yesterdaytime;
    time:=copy(yesterdaytime,1,4);
    with datamodule2.ADOQuery10 do
    begin
        close;
        sql.Clear;
        sql.Add('select Distinct(文件名),机车编号,机车信息,合格标志,工号,测试者姓名 from 表1 where 文件名 like :var1');
        Parameters.ParamByName('var1').Value:=time+'%';
        open;
    end;
    if datamodule2.ADOQuery10.FieldByName('文件名').Value<>null then
    with datamodule2.ADOQuery10 do
    begin
    Open;
    First;
    StringGrid2.ColCount:= FieldCount-1;    //StringGrid1.ColCount:= FieldCount-1;  是按照数据库中的表的列数来创建的,程序中不需要那么多
    StringGrid2.RowCount:= RecordCount+1;
    for i:=0 to RecordCount-1 do
    begin
        StringGrid2.Cells[0,i+1]:= Fields[1].AsString;
        StringGrid2.Cells[1,i+1]:= Fields[2].AsString;
        StringGrid2.Cells[2,i+1]:= Fields[3].AsString;
        StringGrid2.Cells[3,i+1]:= Fields[4].AsString;
        StringGrid2.Cells[4,i+1]:= Fields[5].AsString;
        StringGrid2.Cells[5,i+1]:= Fields[0].AsString;
      //for j:=0 to FieldCount-1 do
     // begin
     //   StringGrid1.Cells[j,i+1]:= Fields[j].AsString;
     // end;
      Next;
    end;
  end;

end;
{procedure Tmainform.FormCreate(Sender: TObject);
var
i,j,h:integer;
begin
    if degree='管理员' then
    mainform.MainMenu1.Items[0].visible:=false;
   with StringGrid1 do
   begin
    FixedCols:=0;//左边没有固定列
    Cells[0,0]:='机车号';//列标题
    Cells[1,0]:='发码类型';
    Cells[2,0]:='载频频率';
    Cells[3,0]:='低频频率';
    Cells[4,0]:='发码时间';
    Cells[5,0]:='闪灯';
    Cells[6,0]:='点灯时间';
    Cells[7,0]:='应变时间';
    Cells[8,0]:='测试者';
    Cells[9,0]:='工号';
  end;
  statusbar1.Panels[4].Text:=czymc;
  with datamodule2.ADOQuery9 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select 工号 from 登录表 where (姓名= :a)');
    Parameters.ParamByName('a').Value := czymc;
    Open;
  end;
    if DataModule2.ADOQuery9.RecordCount >0 then
    statusbar1.Panels[2].Text:= DataModule2.ADOQuery2.FieldByName('工号').AsString;
    statusbar1.Panels[6].Text:=formatdatetime('yyyy年mm月dd日 hh:mm:ss',now);
    with datamodule2.ADOQuery10 do
    begin
        close;
        sql.Clear;
        sql.Add('select * from 表1' );
        open;
    end;
    if datamodule2.ADOQuery10.FieldByName('发码时间').Value<>null then
    with datamodule2.ADOQuery10 do begin
    Open;
    First;
    StringGrid1.ColCount:= FieldCount-3;    //StringGrid1.ColCount:= FieldCount=1;  是按照数据库中的表的列数来创建的,程序中不需要那么多
    StringGrid1.RowCount:= RecordCount+1;
    for i:=0 to RecordCount-1 do
    begin
        StringGrid1.Cells[0,i+1]:= Fields[8].AsString;
        StringGrid1.Cells[1,i+1]:= Fields[5].AsString;
        StringGrid1.Cells[2,i+1]:= Fields[6].AsString;
        StringGrid1.Cells[3,i+1]:= Fields[7].AsString;
        StringGrid1.Cells[4,i+1]:= Fields[0].AsString;
        StringGrid1.Cells[5,i+1]:= Fields[2].AsString;
        StringGrid1.Cells[6,i+1]:= Fields[12].AsString;
        StringGrid1.Cells[7,i+1]:= Fields[4].AsString;
        StringGrid1.Cells[8,i+1]:= Fields[11].AsString;
        StringGrid1.Cells[9,i+1]:= Fields[10].AsString;
      //for j:=0 to FieldCount-1 do
     // begin
     //   StringGrid1.Cells[j,i+1]:= Fields[j].AsString;
     // end;
      Next;
    end;
  end;}

    {begin
       // while not DataModule2.ADOQuery10.Eof do
        begin
        for i:=1 to datamodule2.ADOQuery10.RecordCount do
        begin
            for h:=0 to 9 do
            begin
            StringGrid1.Cells[h,i]:=DataModule2.ADOQuery10.fields[h].AsString;
            end;
            datamodule2.ADOQuery10.Next;
        end;
          end;
    end;  }
        {Edit1.Text :=floattostr ( DataModule1.ADOQuery2.FieldByName('道岔号').Value);
        Edit2.Text := inttostr( DataModule1.ADOQuery2.FieldByName('道岔工号').Value);
        Edit3.Text :=  DataModule1.ADOQuery2.FieldByName('测量时间').Value;
        Edit4.Text := floattostr( DataModule1.ADOQuery2.FieldByName('测量数据').Value);
        Edit5.Text :=  DataModule1.ADOQuery2.FieldByName('道岔工姓名').Value;
        Edit6.Text :=  DataModule1.ADOQuery2.FieldByName('道岔名').Value; }
      
//end;


procedure Tmainform.FormShow(Sender: TObject);
var
i:integer;
begin
    with StringGrid1 do
   begin
    FixedCols:=0;//左边没有固定列
    Cells[0,0]:='机车号';//列标题
    Cells[1,0]:='发码类型';
    Cells[2,0]:='载频频率';
    Cells[3,0]:='低频频率';
    Cells[4,0]:='发码时间';
    Cells[5,0]:='闪灯';
    Cells[6,0]:='点灯时间';
    Cells[7,0]:='应变时间';
    Cells[8,0]:='测试者';
    Cells[9,0]:='工号';
  end;
  statusbar1.Panels[4].Text:=czymc;
    with datamodule2.ADOQuery10 do
    begin
        close;
        sql.Clear;
        sql.Add('select * from temp' );
        open;
    end;
    if datamodule2.ADOQuery10.FieldByName('发码时间').Value<>null then
    with datamodule2.ADOQuery10 do begin
    Open;
    First;
    StringGrid1.ColCount:= FieldCount-5;    //StringGrid1.ColCount:= FieldCount-1;  是按照数据库中的表的列数来创建的,程序中不需要那么多
    StringGrid1.RowCount:= RecordCount+1;
    for i:=0 to RecordCount-1 do
    begin
        StringGrid1.Cells[0,i+1]:= Fields[8].AsString;

⌨️ 快捷键说明

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