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

📄 equipmentinfolistclass.~pas

📁 delphi基于工业控制的串口通讯
💻 ~PAS
字号:
unit EquipmentInfoListClass;

interface
uses
    Contnrs
    ,Windows,Dialogs,Classes,Graphics,Controls,
    EquipmentInfoClass,ADODB,inifiles,forms,SysUtils, Messages;
type
    //定义一个TObjectList的类
    TEquipmentInfoList = class(TObjectList) //
    private
        MyADOQuery: TADOQuery;
        AEquipment     : TEquipmentInfo;
        procedure InitInf;//初始化信息
    public
        constructor Create;
        destructor destroy;override;
    end;

implementation

uses UnitDataModule;
{
*****************************TEquipmentInfoList*********************************
}
constructor TEquipmentInfoList.Create;
begin
    inherited;
    MyADOQuery:=TADOQuery.Create(nil);
    InitInf; //读初始化信息
    //
end;
destructor TEquipmentInfoList.destroy;
begin
    if  MyADOQuery = nil then exit;
    MyADOQuery.Free;
    inherited;
end;
//初始化信息
procedure TEquipmentInfoList.InitInf;
var
    ConnectStr:string;
    t1,t2     :integer;
    f              : TIniFile;
    DBName         : String; //数据库名称
    Server         : String; //服务器名称
    ProName        : String; //存储过程名称
    UseName        : String; //用户名称
    UsePasd        : String; //拥护口令
    SqlStr         :String;
begin
    //ConnectStr:='Provider=SQLOLEDB.1;Password=';
    //f:=TIniFile.Create(ExtractFileDir(application.Exename)+'\systemset.ini');
    //DBName :=f.ReadString('DatabaseSetting','DadaName','');
    //ProName:=f.ReadString('DatabaseSetting','Procedure_Name','');
    //Server :=f.ReadString('DatabaseSetting','Server','');
    //UseName:=f.ReadString('DatabaseSetting','UserName','');
    //UsePasd:=f.ReadString('DatabaseSetting','Password','');
    //ConnectStr:=ConnectStr+UsePasd+';Persist Security Info=True;User ID=';
    //ConnectStr:=ConnectStr+UseName+';Initial Catalog='+DBName+';Data Source='+Server;
    //f.Free;
    SqlStr:='GroupNO,Light_NO,Light_Name,Light_Address,Cont,Terminal,Uport,Light_States,Light_Type';
    t1 := GetTickCount;
    MyADOQuery.Connection:=frm_DataModule.ADO_Connection;
    with MyADOQuery do
    begin
        Close;
        SQL.Clear;
        Sql.Add('Select  '+ SqlStr+'  from [Equipment] order by GroupNO');
        try
            Open;
            while not Eof do
            begin
                AEquipment             := TEquipmentInfo.Create;                //在读数据时候把TEquipmentInfo创建
                AEquipment.Group_NO    := FieldByName('GroupNO').AsString;      //设备组号
                AEquipment.LightNO     := FieldByName('Light_NO').AsString;     //设备编号
                AEquipment.LightName   := FieldByName('Light_Name').AsString;   //设备名称
                AEquipment.LightAddress:= FieldByName('Light_Address').AsString;//设备地址
                AEquipment.ContNO      := FieldByName('Cont').AsInteger;        //集中器号
                AEquipment.TerminalNO  := FieldByName('Terminal').AsInteger;    //用户终端
                AEquipment.UportNO     := FieldByName('Uport').AsInteger;       //用户端口
                AEquipment.LightStates := FieldByName('Light_States').AsString; //端口状态
                AEquipment.LightType   := FieldByName('Light_Type').AsString;   //设备类型
                Next;
            end;
            t2 := GetTickCount;
            //showmessage('计时:'+ FloatToStr((t2-t1)/1000) + ' 秒');
        finally
            MyADOQuery.Active:=False;
        end;
    end;
end;
end.

⌨️ 快捷键说明

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