📄 main.pas
字号:
unit main;
interface
uses
Windows, Messages, SysUtils,StrUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, Mask, ComCtrls, ExtCtrls, Buttons;
type
TfrmMain = class(TForm)
xmlEntity: TXMLDocument;
btnSave: TButton;
btnReset: TButton;
btnExit: TButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Label1: TLabel;
Label2: TLabel;
txtSid: TEdit;
Label3: TLabel;
txtUserName: TEdit;
Label4: TLabel;
txtPassword: TEdit;
StatusBar1: TStatusBar;
Panel1: TPanel;
Label5: TLabel;
txtIp: TEdit;
Memo1: TMemo;
TabSheet3: TTabSheet;
btnUpgrade: TBitBtn;
procedure btnExitClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure btnUpgradeClick(Sender: TObject);
private
{ Private declarations }
procedure resetbasic(strEntityEngineFile:String);
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
uses
NormalCode,publicDefine;
var
strEntityEngineFile: String;
{$R *.dfm}
{----------------------------------------------------------------------------------------------------------------------------
函数功能:窗体初始化
}
procedure TfrmMain.FormCreate(Sender: TObject);
var
strDefaultEntityEngineFile : String;
begin
//判断当前的系统配置文件是否存在
strDefaultEntityEngineFile :=NormalCode.getCurrentDir() + 'commonapp\etc\' + ENTITY_ENGINE_FILE_NAME;
if(Not FileExists(strDefaultEntityEngineFile)) then begin
frmMain.StatusBar1.Panels[1].Text :='数据配置文件没有找到!';
strEntityEngineFile :='';
btnSave.Enabled := false;
btnReset.Enabled:= false
end else begin
strEntityEngineFile := strDefaultEntityEngineFile;
frmMain.StatusBar1.Panels[1].Text :='就绪:' + strEntityEngineFile;
end;
if(PageControl1.ActivePageIndex<>0) then
PageControl1.ActivePageIndex := 0;
//显示当前配置信息
if(strEntityEngineFile <> '') then begin
resetbasic(strEntityEngineFile);
end;
end;
procedure TfrmMain.PageControl1Change(Sender: TObject);
begin
if(strEntityEngineFile <> '') then begin
resetbasic(strEntityEngineFile);
end;
end;
{----------------------------------------------------------------------------------------------------------------------------
函数功能:保存当前的设置
}
procedure TfrmMain.btnSaveClick(Sender: TObject);
var
ret1,ret2,ret3: boolean;
jdbc_uri: String ;
begin
case PageControl1.ActivePageIndex of
0: //基础数据配置
begin
jdbc_uri := 'jdbc:oracle:thin:@' + txtIp.Text + ':1521:' + txtSid.Text;
ret1:= NormalCode.setXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc','jdbc-username',txtUserName.Text);
ret2:= NormalCode.setXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc','jdbc-password',txtPassword.Text);
ret3:= NormalCode.setXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc','jdbc-uri',jdbc_uri);
if(ret1 and ret2 and ret3) then
ShowMessage('恭喜,基础数据配置保存成功!')
else
ShowMessage('基础数据配置保存出错!');
end;
1://高级数据配置保存
begin
memo1.Lines.SaveToFile(strEntityEngineFile);
ShowMessage('恭喜,高级数据配置保存成功!');
end;
else ;
end;
end;
{----------------------------------------------------------------------------------------------------------------------------
函数功能:重置
}
procedure TfrmMain.btnResetClick(Sender: TObject);
begin
resetbasic(strEntityEngineFile);
end;
{----------------------------------------------------------------------------------------------------------------------------
函数功能:数据升级
}
procedure TfrmMain.btnUpgradeClick(Sender: TObject);
var
strUpgradePath: String;
pExec : PChar;
begin
strUpgradePath:=NormalCode.getCurrentDir() + 'upgrade\pack.bat';
if(FileExists(strUpgradePath)) then begin
pExec := PChar(strUpgradePath);
NormalCode.exec(handle,'open',pExec,nil,nil,SW_SHOWNORMAL);
end else begin
ShowMessage('升级文件:' + strUpgradePath + '不存在!');
end;
end;
{----------------------------------------------------------------------------------------------------------------------------
函数功能:退出当前配置工具程序
}
procedure TfrmMain.btnExitClick(Sender: TObject);
begin
Close();
end;
{----------------------------------------------------------------------------------------------------------------------------
函数功能:显示当前的文件配置
入口参数:strEntityEngineFile文件内容。
}
procedure TfrmMain.resetbasic(strEntityEngineFile:String);
var
jdbc_uri,username, password:String;
strIp : String;
begin
case PageControl1.ActivePageIndex of
0: //基础数据配置显示
begin
jdbc_uri:= NormalCode.getXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc', 'jdbc-uri');
username:= NormalCode.getXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc', 'jdbc-username');
password:= NormalCode.getXmlNodeValue(strEntityEngineFile,'entity-config.datasource.inline-jdbc', 'jdbc-password');
txtUserName.Text:=username;
txtPassword.Text:=password;
if(jdbc_uri <>'') then begin
strIp := NormalCode.getCountStr(jdbc_uri,4,':');
txtIp.Text := RightStr(strIp,Length(strIp)-1);
txtSid.Text:= NormalCode.getCountStr(jdbc_uri,6,':');
end;
end;
1: //全部数据文件显示
memo1.Lines.LoadFromFile(strEntityEngineFile);
else ;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -