📄 uconfigmgr.pas
字号:
unit uConfigMgr;
interface
uses IniFiles, Forms, SysUtils, CommonFunc;
type
TConfigMgr = class
public
constructor Create;
destructor Destroy;override;
private
FIniFile: TIniFile;
FCompanyName: string;
FCompanyLeader: string;
FCompanyTel: string;
FCompanyAddress: string;
FCompanyLogo: string;
FDBBackupFileName: string;
FServerName: string;
FDataBase: string;
function GetCompanyName: string;
function GetCompanyLeader: string;
function GetCompanyTel: string;
function GetCompanyAddress: string;
function GetCompanyLogo: string;
function GetDBBackupFileName: string;
function GetServerName: string;
function GetDataBase: string;
procedure SetCompanyName(AValue: string);
procedure SetCompanyLeader(AValue: string);
procedure SetCompanyTel(AValue: string);
procedure SetCompanyAddress(AValue: string);
procedure SetCompanyLogo(AValue: string);
procedure SetDBBackupFileName(AValue: string);
procedure SetServerName(AValue: string);
procedure SetDataBase(AValue: string);
published
property CompanyName: string read GetCompanyName write SetCompanyName;
property CompanyLeader: string read GetCompanyLeader write SetCompanyLeader;
property CompanyTel: string read GetCompanyTel write SetCompanyTel;
property CompanyAddress: string read GetCompanyAddress write SetCompanyAddress;
property CompanyLogo: string read GetCompanyLogo write SetCompanyLogo;
property DBBackupFileName: string read GetDBBackupFileName write SetDBBackupFileName;
property ServerName: string read GetServerName write SetServerName;
property DataBase: string read GetDataBase write SetDataBase;
end;
implementation
constructor TConfigMgr.Create;
const
LINI = 'config.ini';
var
LFilePath : string;
begin
LFilePath := ExcludeTrailingPathDelimiter(
ExtractFilePath(Application.ExeName));
FIniFile := TIniFile.Create(LFilePath + '\' + LINI);
end;
destructor TConfigMgr.Destroy;
begin
FreeAndNil(FIniFile);
end;
function TConfigMgr.GetCompanyName: string;
begin
if FCompanyName <> '' then
result := CompanyName
else
result := FIniFile.ReadString('Company', 'CompanyName','');
end;
procedure TConfigMgr.SetCompanyName(AValue: string);
begin
if FCompanyName <> AValue then
begin
FIniFile.WriteString('Company', 'CompanyName', AValue);
FCompanyName := AValue;
end;
end;
function TConfigMgr.GetCompanyLeader: string;
begin
if FCompanyLeader <> '' then
result := CompanyLeader
else
result := FIniFile.ReadString('Company', 'CompanyLeader','');
end;
procedure TConfigMgr.SetCompanyLeader(AValue: string);
begin
if FCompanyLeader <> AValue then
begin
FIniFile.WriteString('Company', 'CompanyLeader', AValue);
FCompanyLeader := AValue;
end;
end;
function TConfigMgr.GetCompanyTel: string;
begin
if FCompanyTel <> '' then
result := CompanyTel
else
result := FIniFile.ReadString('Company', 'CompanyTel','');
end;
procedure TConfigMgr.SetCompanyTel(AValue: string);
begin
if FCompanyTel <> AValue then
begin
FIniFile.WriteString('Company', 'CompanyTel', AValue);
FCompanyTel := AValue;
end;
end;
function TConfigMgr.GetCompanyAddress: string;
begin
if FCompanyAddress <> '' then
result := CompanyAddress
else
result := FIniFile.ReadString('Company', 'CompanyAddress','');
end;
procedure TConfigMgr.SetCompanyAddress(AValue: string);
begin
if FCompanyAddress <> AValue then
begin
FIniFile.WriteString('Company', 'CompanyAddress', AValue);
FCompanyAddress := AValue;
end;
end;
function TConfigMgr.GetCompanyLogo: string;
begin
if FCompanyLogo <> '' then
result := CompanyLogo
else
result := FIniFile.ReadString('Company', 'CompanyLogo','');
end;
procedure TConfigMgr.SetCompanyLogo(AValue: string);
begin
if FCompanyLogo <> AValue then
begin
FIniFile.WriteString('Company', 'CompanyLogo', AValue);
FCompanyLogo := AValue;
end;
end;
procedure TConfigMgr.SetDBBackupFileName(AValue: string);
begin
if FDBBackupFileName <> AValue then
begin
FIniFile.WriteString('DBBackup', 'DBFileName', AValue);
FDBBackupFileName := AValue;
end;
end;
function TConfigMgr.GetDBBackupFileName: string;
begin
if FDBBackupFileName <> '' then
result := FDBBackupFileName
else
result := FIniFile.ReadString('DBBackup', 'DBFileName',
GetApplicationPath + 'DBBackup.mdf');
end;
procedure TConfigMgr.SetServerName(AValue: string);
begin
if FServerName <> AValue then
begin
FIniFile.WriteString('Connect', 'ServerName', AValue);
FServerName := AValue;
end;
end;
function TConfigMgr.GetServerName: string;
begin
if FServerName <> '' then
result := FServerName
else
result := FIniFile.ReadString('Connect', 'ServerName',
'127.0.0.1');
end;
procedure TConfigMgr.SetDataBase(AValue: string);
begin
if FDataBase <> AValue then
begin
FIniFile.WriteString('Connect', 'DataBase', AValue);
FDataBase := AValue;
end;
end;
function TConfigMgr.GetDataBase: string;
begin
if FDataBase <> '' then
result := FDataBase
else
result := FIniFile.ReadString('Connect', 'DataBase',
'SuperMarketManage');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -