📄 umain.pas
字号:
end;
begin
dropSource := Source;
dropX := x;
dropY := y;
Point.x := x;
Point.y := y;
Point := memScript.ClientToScreen(Point);
if Source is TListView then begin
if TListView(Source).name = 'lvDetails' then begin
PopDADLayout.Popup(Point.x, Point.y);
end else begin
iLastPos := memScript.perform(EM_LINEFROMCHAR, -1, 0);
if iLastPos = 0 then iLastPos := -1;
for lcv := 2 to TListView(Source).ItemFocused.Subitems.Count - 1 do begin
inc(iLastPos);
InsertMemoText(TListView(Source).Itemfocused.SubItems[lcv]);
end;
end;
end else if Source is TTreeView then begin
PopObjectLayout.Popup(Point.x, Point.y);
end;
end;
{
Save the results based on the page that you are on.
}
procedure TfrmMain.btnSaveScriptClick(Sender: TObject);
begin
case pgcResults.Activepage.PageIndex of
0: begin
if memScript.SelLength > 0 then
bo_SQL.SaveMemoToFile(memScript.SelText)
else
bo_SQL.SaveMemoToFile(memScript.text)
end;
1: begin
if memResults.SelLength > 0 then
bo_SQL.SaveMemoToFile(memResults.SelText)
else
bo_SQL.SaveMemoToFile(memResults.text)
end;
2: begin
if memObjText.SelLength > 0 then
bo_SQL.SaveMemoToFile(memObjText.SelText)
else
bo_SQL.SaveMemoToFile(memObjText.text)
end;
end;
end;
{
Clear the results based on the page that you are on.
}
procedure TfrmMain.btnClearClick(Sender: TObject);
begin
case pgcResults.Activepage.PageIndex of
0: begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to clear the script?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
memScript.Lines.Clear;
end;
end;
end;
1: begin
if memResults.Lines.Count > 0 then begin
if messagedlg('Do you want to clear the results?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
if messagedlg('Do you want to save the results first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memResults.text);
end;
memResults.Lines.Clear;
end;
end;
end;
2: begin
if memObjText.Lines.Count > 0 then begin
if messagedlg('Do you want to clear the object text?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
if messagedlg('Do you want to save the object text first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memObjText.text);
end;
memObjText.Lines.Clear;
end;
end;
end;
end;
end;
{
Method to clear the script and optionally save off the text before starting again.
}
procedure TfrmMain.btnNewClick(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want create a new script?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
memScript.Lines.Clear;
memResults.Lines.Clear;
end;
end;
end;
{
Method to load an existing SQL script.
}
procedure TfrmMain.btnLoadClick(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to clear the script?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
memScript.Lines.clear;
end;
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
end;
bo_SQL.LoadMemoFromFile(memScript);
end;
{
Execute the script.
}
procedure TfrmMain.btnExecuteClick(Sender: TObject);
var
lHasResults : boolean;
sDelimiter : string;
begin
case rgDelimiter.ItemIndex of
0: sDelimiter := ',';
1: sDelimiter := ' ';
2: sDelimiter := '|';
3: sDelimiter := #$9;
4: sDelimiter := txtDelimiter.text;
end;
if rdbExecute.checked then begin
// Execute the script.
lHasResults := bo_SQL.Execute(memScript, memResults, tvObjects, chkClearResults.checked, sDelimiter, true);
// If results were returned, then show them.
if lHasResults then pgcResults.Activepage := tabResults;
end else if rdbParse.checked then begin
// Parse the script. No results returned.
bo_SQL.Execute(memScript, memResults, tvObjects, chkClearResults.checked, sDelimiter, false);
end;
// Refresh the list.
//if tvObjects.Selected.Level >= 2 then RefreshAliases1Click(nil);
end;
{
OnChange load the macros for the first time for the macros page.
}
procedure TfrmMain.pgcScriptChange(Sender: TObject);
begin
if (pgcScript.ActivePage.pageindex = 1) and
(lvmacros.items.count = 0) then begin
bo_SQL.LoadMacros(lvMacros);
end;
end;
procedure TfrmMain.CreateGetProcedure1Click(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
end;
bo_SQL.BuildFromTemplate(tvObjects.selected, memScript.lines, dad_SP_Alias_Get);
pgcResults.ActivePage := tabScript;
end;
procedure TfrmMain.CreateUpdProcedure1Click(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
end;
bo_SQL.BuildFromTemplate(tvObjects.selected, memScript.lines, dad_SP_Alias_Upd);
pgcResults.ActivePage := tabScript;
end;
procedure TfrmMain.CreateInsProcedure1Click(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
end;
bo_SQL.BuildFromTemplate(tvObjects.selected, memScript.lines, dad_SP_Alias_Ins);
pgcResults.ActivePage := tabScript;
end;
procedure TfrmMain.CreateDelProcedure1Click(Sender: TObject);
begin
if memScript.Lines.Count > 0 then begin
if messagedlg('Do you want to save this script first?', mtWarning,
[mbyes, mbno], 0) = mrYes then begin
bo_SQL.SaveMemoToFile(memScript.text);
end;
end;
bo_SQL.BuildFromTemplate(tvObjects.selected, memScript.lines, dad_SP_Alias_Del);
pgcResults.ActivePage := tabScript;
end;
{
When closing, save off the form settings.
}
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if chkSaveDesktop.checked then SaveFormSettings;
end;
{
Save the object attributes on a form.
}
procedure TfrmMain.SaveFormSettings;
var
MyIni : TIniFile;
sPath : string;
begin
sPath := ExtractFilePath(paramstr(0));
MyIni := TIniFile.Create(spath + 'desktop.ini');
try
MyIni.WriteString(self.name, 'SQLPath', bo_SQL.SQLPath);
MyIni.WriteInteger(self.Name, self.Name + '.height', self.height);
MyIni.WriteInteger(self.Name, self.Name + '.width', self.width);
MyIni.WriteInteger(self.Name, self.Name + '.top', self.top);
MyIni.WriteInteger(self.Name, self.Name + '.left', self.left);
MyIni.WriteInteger(self.Name, 'pnlDetails.height', pnlDetails.height);
MyIni.WriteInteger(self.Name, 'pnlObjects.Width', pnlObjects.Width);
MyIni.WriteInteger(self.Name, 'grdData.height', grdData.height);
MyIni.WriteBool(self.name, 'chkShowData.checked', chkShowData.checked);
MyIni.WriteBool(self.name, 'chkSaveDesktop.checked', chkSaveDesktop.checked);
MyIni.WriteBool(self.name, 'chkClearResults.checked', chkClearResults.checked);
MyIni.WriteInteger(self.name, 'rgDelimiter.itemindex', rgDelimiter.ItemIndex);
MyIni.WriteString(self.name, 'txtDelimiter.text', txtDelimiter.text);
MyIni.WriteBool(self.name, 'rdbExecute.checked', rdbExecute.checked);
MyIni.WriteBool(self.name, 'rdbParse.checked', rdbParse.checked);
finally
MyIni.free;
end;
end;
{
Reset the object attributes of the form.
}
procedure TfrmMain.LoadFormSettings;
var
MyIni : TIniFile;
sPath : string;
begin
sPath := ExtractFilePath(paramstr(0));
MyIni := TIniFile.Create(spath + 'desktop.ini');
try
bo_SQL.SQLPath := MyIni.ReadString(self.name, 'SQLPath', 'c:\temp\');
self.height := MyIni.ReadInteger(self.Name, self.Name + '.height', self.height);
self.width := MyIni.ReadInteger(self.Name, self.Name + '.width', self.width);
self.top := MyIni.ReadInteger(self.Name, self.Name + '.top', self.top);
self.left := MyIni.ReadInteger(self.Name, self.Name + '.left', self.left);
pnlDetails.height := MyIni.ReadInteger(self.Name, 'pnlDetails.height', pnlDetails.height);
pnlObjects.width := MyIni.ReadInteger(self.Name, 'pnlObjects.width', pnlObjects.width);
grdData.height := MyIni.ReadInteger(self.Name, 'grdData.height', grdData.height);
chkShowData.checked := MyIni.ReadBool(self.Name, 'chkShowData.checked', chkShowData.checked);
chkSaveDesktop.checked := MyIni.ReadBool(self.Name, 'chkSaveDesktop.checked', chkSaveDesktop.checked);
chkClearResults.checked := MyIni.ReadBool(self.Name, 'chkClearResults.checked', chkClearResults.checked);
rgDelimiter.ItemIndex := MyIni.ReadInteger(self.name, 'rgDelimiter.itemindex', rgDelimiter.ItemIndex);
rdbExecute.checked := MyIni.ReadBool(self.name, 'rdbExecute.checked', rdbExecute.checked);
rdbParse.checked := MyIni.ReadBool(self.name, 'rdbParse.checked', rdbParse.checked);
finally
MyIni.free;
end;
end;
{
Load the user saved form settings.
}
procedure TfrmMain.FormShow(Sender: TObject);
begin
LoadFormSettings;
end;
{
Keep stuff lined up.
}
procedure TfrmMain.FormResize(Sender: TObject);
begin
chkShowData.left := self.width - chkShowdata.Width - 50;
chkSaveDesktop.left := chkShowData.left;
chkClearResults.left := chkShowData.left - chkClearResults.width - 10;
end;
{
If the page has changed to the object text page, load the SQLScriptText
for the selected node.
}
procedure TfrmMain.pgcResultsChange(Sender: TObject);
begin
if (tvObjects.selected <> nil) and
(pgcResults.ActivePage.pageindex = 2) and
(tvObjects.selected.Level = 3) then begin
bo_SQL.GetSQLScriptText(memObjText, tvObjects.selected);
end;
end;
{
Refresh the macro list.
}
procedure TfrmMain.RefreshMacroList1Click(Sender: TObject);
begin
bo_SQL.LoadMacros(lvMacros);
end;
procedure TfrmMain.popObjectsPopup(Sender: TObject);
begin
DoPopMenuGUI;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -