utsyscs.pas
来自「是一个用delphi设计的考勤系统」· PAS 代码 · 共 214 行
PAS
214 行
unit UTSysCs;
interface
uses windows, forms, SysUtils, Controls, IniFiles, ADODB, URecord, Classes;
type
TSysCs = class
private
IniFile: TInifile;
public
sFkPort: string;
sWWRPort: string;
bRz: boolean;
bWWRRz: boolean;
bMRz: boolean;
RetVal: integer; //返回码
RetMsg: string; //返回信息
//数据库信息
RemoteConnStrFile: string;
LocaldConnStrFile: string;
RemoteConnectString: string;
LocaldConnectString: string;
IsSysKeyDown: boolean;
IsConnect: boolean;
//Ini文件信息
sIniPath: string; //Ini路径
sSysPath: string; //系统路径
sLogPath: string; //日志路径
sImagePath: string; //图片路径
sZbDw: string; //制表单位
iFkPort: integer; //发卡器串口号
iWWRPort: integer; //以太网机串口号
sCjjh: string; //采集网点号
bFhk: boolean; //是否复合卡
sHelpFileName: string; //帮助文件名
//系统信息
OperateSys: string; //操作系统
lSysBh: longWord; //系统编号
sSysmc: string; //系统名称
sSydw: string; //使用单位
sAzrq: string; //安装日期
sSyssn: string; //系统序列号
sYyrjbbh: string; //应用软件版本号
iYhbhlx: integer; //用户编号类型
iYhsl: integer; //用户使用许可数量
constructor Create;
function ConnectDataBase: boolean;
function CloseDataBase: boolean;
function IniDevice(): boolean;
function LoadConnStr(): string;
procedure SaveConnStr(strConn: string);
function SaveSysCs: boolean;
end;
implementation
uses DM_DataModal, UGeneralFunc;
{ TSaveLoadCzjl }
function TSysCs.CloseDataBase: boolean;
begin
try
windData.AdoConn.Close;
windData.AdoConn.Connected := False;
except
end;
end;
function TSysCs.ConnectDataBase: boolean;
begin
result := False;
retval := -1;
try
if not WindData.OpenLocalDb then
begin
retmsg := '本地数据库连接失败';
exit;
end;
if not WindData.OpenDatabase then
begin
retmsg := '远程数据库连接失败';
exit;
end;
retval := 0;
retmsg := '数据库连结成功';
result := True;
except
retmsg := '数据库连结失败';
retval := -1;
end;
end;
constructor TSysCs.Create;
begin
sSysPath := GetCurrentDir;
sIniPath := sSysPath + '\Ini';
if not FileExists(sIniPath + '\SysIni.ini') then
begin
RetVal := 1;
RetMsg := '配置文件(SysIni.ini)丢失';
exit;
end;
IniFile := TIniFile.Create(sIniPath + '\SysIni.ini');
RemoteConnStrFile := sSysPath + IniFile.ReadString('Data', 'RemoteConnStrFile', sIniPath + '\data');
LocaldConnStrFile := sSysPath + IniFile.ReadString('Data', 'LocaldConnStrFile', sIniPath + '\data');
sLogPath := sSysPath + IniFile.ReadString('System', 'LogPath', '\log');
sImagePath := sSysPath + IniFile.ReadString('System', 'ImagePath', '\Image');
sZbDw := IniFile.ReadString('System', 'ZbDw', '');
sHelpFileName := IniFile.ReadString('System', 'HelpFileName', 'Help.chm');
iFkPort := IniFile.ReadInteger('Device', 'FkPort', 0);
iWWRPort := IniFile.ReadInteger('Device', 'WWrPort', 0);
sCjjh := IniFile.ReadString('Device', 'Cjjh', '');
bFhk := IniFile.ReadBool('Card', 'Fhk', True);
IniFile.Free;
RemoteConnectString := LoadConnStr;
end;
function TSysCs.SaveSysCs: boolean;
begin
result := False;
IniFile := TIniFile.Create(sIniPath + '\SysIni.ini');
try
IniFile.WriteString('System', 'LogPath', sLogPath);
IniFile.WriteString('System', 'ZbDw', sZbdw);
IniFile.WriteString('System', 'HelpFileNmae', sHelpFileName);
IniFile.WriteInteger('Device', 'FkPort', iFkPort);
IniFile.WriteInteger('Device', 'WWRPort', iWWRPort);
IniFile.WriteString('Device', 'Cjwdh', sCjjh);
IniFile.WriteBool('Card', 'Fhk', True);
result := True;
finally
// RetVal := 1;
// RetMsg := '保存系统文件出错';
IniFile.Free;
end;
end;
function TSyscs.LoadConnStr(): string;
var
sltConn: TStringlist;
i: integer;
begin
sltConn := TStringList.Create();
if FileExists(RemoteConnStrFile) then
begin
sltConn.LoadFromFile(RemoteConnStrFile);
Result := Decode(sltConn.Text, 13);
result[length(result)] := ' ';
result[length(result) - 1] := ' ';
end
else
Result := '';
sltConn.Free();
end;
procedure TSyscs.SaveConnStr(strConn: string);
var
sltConn: TStringlist;
begin
sltConn := TStringList.Create();
sltConn.Text := Encode(trim(strConn), 13);
sltConn.SaveToFile(RemoteConnStrFile);
sltConn.Free();
RemoteConnectString := strConn;
end;
function TSysCs.IniDevice: boolean;
var
mSysbh: integer;
mSector: integer;
mMSysCardPWD: string;
mSysPassWord: string;
bSta: byte;
begin
result := True;
IsSysKeyDown := False;
try
with WindData.PublicQuery do
begin
close;
sql.Clear;
sql.Add('select * from zx_s_syscs');
open;
if not eof then
begin
sSysmc := fieldbyname('sysmc').asstring; //系统名称
sSydw := fieldbyname('sydw').asstring; //使用单位
sAzrq := fieldbyname('Azrq').asstring; //安装日期
sSyssn := decode(fieldbyname('syssn').asstring, 13); //系统序列号
iYhsl := strtointdef(fieldbyname('hzr').AsString,0);
sYyrjbbh := fieldbyname('Yyrjbbh').asstring; //应用软件版本号
iYhbhlx := fieldbyname('Yhbhlx').asinteger; //用户编号类型
IsSysKeyDown := True;
end
else
begin
sSysmc := '未注册';
exit;
end;
end;
except
IsSysKeyDown := False;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?