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

📄 kxiancommon.~pas

📁 该系统将温度数据以类似股票K线显示方式进行分析
💻 ~PAS
字号:
unit kxiancommon;

interface

uses
  Windows, SysUtils, Registry, DB, DBGrids , ADODB, IniFiles,Dialogs,DateUtils,graphics;

type tMinData = record //定义分钟数据,数据文件.dat按此记录保存,从此记录通过readdata 生成画图的基础数据
     sActorId :string[6];
     sBatchNo :string[20];
     tDts     : tdatetime;//8
     sActorName : string[20];
     sGroupName : string[20];
     AvgT :      INTEGER; //4
     iFlag :   integer;//4
     banci :  string[4];
end;
type tActors = record  //定义控制点的基本信息
     sActorId :string[6];
     sActorName : string[20];
     sGroupId: string[6];
     sGroupName : string[20];
     ActX:integer;  //x
     ActY:integer;  //y
     ActW:integer;  //width
     ActH:integer;  //Height
     MinT:INTEGER;
     MaxT:INTEGER;
     CurTmp:Integer;
     sTmp : string[5];
     bOpen:boolean;
     bordercolor:tcolor;
     BackColor: tcolor;
     DetailColor:tcolor;
     FontColor:tcolor;
     ActiveColor:tcolor;
end;

type tData = record  //定义各一个格子的数据
     sActorId :string[6];
     sActorName : string[20];
     sGroupId: string[6];
     sGroupName : string[20];
     sBatchNo :string[20];
     iOpenT :INTEGER ;//OPEN  daydatd[1][i]
     iCloseT :INTEGER ;//CLOSE   DayData[4][I]
     iMaxT  :INTEGER ;// High DayData[2][I]
     iMinT  :INTEGER ;// Low  DayData[3][I]
     iAvgT  :INTEGER ;  // Avgt DayData[7][I]
     dtDateTime : tDateTime; //  DayData[5][I]日期  + DayData[0][I]
     dtBeginTime :tDatetime;
     iFlag: integer;
     MaxTemp : INTEGER;
     MinTemp : INTEGER;
     banci : string[4];
     end;
type
  TOperateType = (optAdd, optEdit, optBrowse);
  TVerType = (vtFile, vtProduct, vtBuild);

var
  EXEPath: string;  //主程序路径
  iUserID: STRING;
  sUserName: string;
  sTrueName :string;

  PrintRight: integer;
  ADOCwdkz: TADOConnection;
  l_iniFile: TIniFile;
  l_HostName, l_DataBase, L_USER, L_PASS: string;

  Actors :array of tActors;
  ConPos: integer;
  CurConID: integer; //表示活动的控制点
  ActorCount: integer; //反应釜数
  GroupCount:integer; //分组数
  sMessageFile:String;
  fMessageFile:textFile;
  PageNo, ActorsInPage :integer;

  batchs : array of string;
  batID: integer; //表示当前的批号编号
  batcount :integer;// 表示全部批号的数量
  //{$R *.RES}
const
  conConnectStr = 'Provider=SQLOLEDB.1;Password=%S;Persist Security Info=True;'+
    'User ID=%S;Initial Catalog=%S;Data Source=%S;'+
    'Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;'+
    'Workstation ID=%S;Use Encryption for Data=False;'+
    'Tag with column collation when possible=False' ;

   conConToMDB ='Provider=MSDASQL.1;Password=351265;Persist Security Info=True;User ID=ADMIN;Data Source=GTLWK';



function GetExePath: string;
function do_connect: boolean;
Function ConFind(mx, my :integer):Integer; //查找鼠标点下对应的控制点
Function ConFindStr(Id:string):Integer;
function Writemessage(sm:string):integer;
function GetmyVersion(AFileName: string; AVerType: TVerType = vtFile): string;
implementation

Function WriteMessage(Sm:string):integer;
Begin
    append(fMessageFile);
    Writeln(fMessageFile,sm);
    flush(fMessageFile);
    WriteMessage :=1;
END;

function GetmyVersion(AFileName: string; AVerType: TVerType): string;
var
  InfoSize :DWORD;
  Wnd: DWORD ;
  VerBuf: Pointer;
  FI: PVSFixedFileInfo;
  VerSize: DWORD;
begin
  Result := '';
  InfoSize := GetFileVersionInfoSize(PChar(AFileName), Wnd);
  if InfoSize <> 0 then
  begin
    GetMem(VerBuf, InfoSize);
    try
      if GetFileVersionInfo(PChar(AFileName), Wnd, InfoSize, VerBuf) then
        if VerQueryValue(VerBuf, '\', Pointer(FI), VerSize) then
          case AVerType of
            vtFile:
              Result := Format('%d.%d.%d.%d', [HIWORD(FI.dwFileVersionMS),
                LOWORD(FI.dwFileVersionMS), HIWORD(FI.dwFileVersionLS),
                  LOWORD(FI.dwFileVersionLS)]);
            vtProduct:
              Result := Format('%d.%d', [HIWORD(FI.dwProductVersionMS),
                LOWORD(FI.dwProductVersionMS)]);
            vtBuild:
              Result := Format('%d', [LOWORD(FI.dwFileVersionLS)]);
          end;
    finally
      FreeMem(VerBuf);
    end;
  end;
end;

Function ConFind(mx, my :integer):Integer; //查找鼠标点下对应的控制点
Var ai, ai_begin, ai_end:Integer;
var li_count:integer;
begin
        ai_begin :=(PageNo-1)*ActorsInPage ;
        ai_end :=PageNo*ActorsInPage ;
        li_count := Length(Actors);
        if ai_end >li_count then ai_end := li_count;
        ai:=ai_begin;
        while (ai < ai_end)  do
        Begin
                if( (mx > Actors[ai].ActX) and (mx < (Actors[ai].ActX + Actors[ai].ActW)) and (my > Actors[ai].ActY) and (my < (Actors[ai].ActY + Actors[ai].ActH))) then
                begin
                        conFind := ai;
                        exit ;
                end
                else
                ai := ai +1;

        End;
        Confind := -1;
End;
Function ConFindStr(Id :string):Integer; //查找鼠标点下对应的控制点
Var ai:Integer;
begin
        ai :=0 ;
        while (ai < length(Actors))  do
        Begin
                if UpperCase(Trim(Actors[ai].sActorId)) = UpperCase(Trim(id))  then
                begin
                        conFindStr := ai;
                        exit ;
                end
                else
                ai := ai +1;

        End;
        ConfindStr := -1;
End;
function GetExePath: string;
begin
  Result := ExtractFilePath(ParamStr(0));
end;

function do_connect: boolean;
//var ls_file : string;
var  ADOQMdb: TADOQuery;
begin
{  ls_file := getexepath +'\'+'CONFIG.ini';
  l_iniFile := TIniFile.Create(ls_file);
  with l_iniFile do
  try
    l_HostName := ReadString('CONNECTION', 'HostName', '1LENOVO-50F8A530');
    l_DataBase := ReadString('CONNECTION', 'DataBase', 'GTLWK');
    L_USER := ReadString('CONNECTION', 'USER', 'SA');
    L_PASS := ReadString('CONNECTION', 'PASS', '351261');

    ADOCwdkz.ConnectionString := Format(conConnectStr, [L_PASS,L_USER,l_DataBase, l_HostName,l_HostName]);
    ADOCwdkz.LoginPrompt := False;
    ADOCwdkz.Connected := True;
    ADOCwdkz.Open;
    result := true;
  finally
    free;
  end;
 }

  ADOCwdkz := TADOConnection.Create(nil);

  adoqMdb := TAdoquery.Create(nil);
  adoqMdb.ConnectionString := conConToMDB;
  adoqMdb.SQL.Text :='Select * From Loginfo WHERE ENABLED = TRUE';
  AdoqMdb.open;
  with adoqMdb do
  begin
    l_HostName := Fields.Fields[0].Asstring;
    l_DataBase := Fields.Fields[1].Asstring;
    L_USER := Fields.Fields[2].Asstring;
    L_PASS := Fields.Fields[3].Asstring;

    ADOCwdkz.ConnectionString := Format(conConnectStr, [L_PASS,L_USER,l_DataBase, l_HostName,l_HostName]);
    ADOCwdkz.LoginPrompt := False;
    ADOCwdkz.Connected := True;
    ADOCwdkz.Open;
    result := true;
    adoqMdb.Close;
  end;
end;

end.

⌨️ 快捷键说明

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