forked from treejames/OneSQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunHistory.pas
More file actions
172 lines (152 loc) · 4.78 KB
/
unHistory.pas
File metadata and controls
172 lines (152 loc) · 4.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
unit unHistory;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
cxLookAndFeelPainters, cxStyles, cxCustomData, cxFilter, cxData,
cxDataStorage, cxEdit, cxNavigator, Data.DB, cxDBData, MemDS, DBAccess,
cxGridLevel, cxClasses, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, SynEdit, SynDBEdit,
SynEditHighlighter, SynHighlighterSQL, Vcl.Menus, Vcl.StdCtrls, cxButtons,
Vcl.ExtCtrls, cxContainer, cxTextEdit, System.UITypes, FireDAC.Stan.Intf,
FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,
FireDAC.Comp.DataSet, FireDAC.Comp.Client;
type
Thistory = class(TForm)
dsHistory: TDataSource;
syntax: TSynSQLSyn;
Panel1: TPanel;
Panel2: TPanel;
grHistory: TcxGrid;
tvHistory: TcxGridDBTableView;
tvHistoryts: TcxGridDBColumn;
lvHistory: TcxGridLevel;
Panel3: TPanel;
dbseStatement: TDBSynEdit;
buClose: TcxButton;
edHistorySearch: TcxTextEdit;
tiExecuteHistory: TTimer;
qHistory: TFDQuery;
qHistoryid: TFDAutoIncField;
qHistorysess: TMemoField;
qHistorystatement: TMemoField;
qHistoryts: TDateTimeField;
Label1: TLabel;
edLimit: TEdit;
Label2: TLabel;
procedure FormCreate(Sender: TObject);
procedure buCloseClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure edHistorySearchExit(Sender: TObject);
procedure edHistorySearchEnter(Sender: TObject);
procedure edHistorySearchPropertiesChange(Sender: TObject);
procedure tiExecuteHistoryTimer(Sender: TObject);
procedure tvHistoryCellDblClick(Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
procedure qHistoryAfterDelete(DataSet: TDataSet);
procedure edLimitChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
iLookupId: Int64;
procedure ExecuteHistory(vSearch: Variant);
end;
var
history: Thistory;
implementation
{$R *.dfm}
uses unMain, unDm;
procedure Thistory.buCloseClick(Sender: TObject);
begin
CloseModal;
end;
procedure Thistory.tvHistoryCellDblClick(
Sender: TcxCustomGridTableView; ACellViewInfo: TcxGridTableDataCellViewInfo;
AButton: TMouseButton; AShift: TShiftState; var AHandled: Boolean);
begin
history.ModalResult := mrOK;
CloseModal;
end;
procedure Thistory.edHistorySearchEnter(Sender: TObject);
begin
if TcxTextEdit(Sender).Tag = 0 then
begin
TcxTextEdit(Sender).Text := '';
TcxTextEdit(Sender).Style.TextColor := clBlack;
TcxTextEdit(Sender).Style.TextStyle := TcxTextEdit(Sender).Style.TextStyle - [ fsItalic ];
TcxTextEdit(Sender).Tag := 1;
end;
end;
procedure Thistory.edHistorySearchExit(Sender: TObject);
begin
if TcxTextEdit(Sender).Text = '' then
begin
TcxTextEdit(Sender).Tag := 0;
TcxTextEdit(Sender).Text := 'Search History...';
TcxTextEdit(Sender).Style.TextColor := clGrayText;
TcxTextEdit(Sender).Style.TextStyle := TcxTextEdit(Sender).Style.TextStyle + [ fsItalic ];
end;
end;
procedure Thistory.edHistorySearchPropertiesChange(Sender: TObject);
begin
if TcxTextEdit(Sender).Tag = 1 then
begin
tiExecuteHistory.Enabled := False;
tiExecuteHistory.Enabled := True;
end;
end;
procedure Thistory.edLimitChange(Sender: TObject);
begin
try
if (TEdit(Sender).Text <> '') then
StrToInt(TEdit(Sender).Text);
except
On E : Exception do
begin
TEdit(Sender).Text := '';
ShowMessage(E.Message);
end;
end;
if StrToIntDef(TEdit(Sender).Text, 1000) <> qHistory.ParamByName('P_LIMIT').AsInteger then
with qHistory do
begin
Close;
ParamByName('P_LIMIT').Value := StrToIntDef(TEdit(Sender).Text, 1000);
Open;
end;
end;
procedure Thistory.ExecuteHistory(vSearch: Variant);
begin
with qHistory do
begin
Close;
ParamByName('P_SEARCH').Value := vSearch;
ParamByName('P_LIMIT').Value := StrToIntDef(edLimit.Text, 1000);
Open;
end;
end;
procedure Thistory.FormCreate(Sender: TObject);
begin
dm.Style(syntax);
end;
procedure Thistory.FormShow(Sender: TObject);
begin
ExecuteHistory('');
if iLookupId <> 0 then
if not qHistory.Locate('id', iLookupId, []) then
MessageDlg('Query statement not found in history log! All logs will be displayed.', mtWarning, [mbOK], 0);
iLookupId := 0;
end;
procedure Thistory.qHistoryAfterDelete(DataSet: TDataSet);
begin
Dataset.Refresh;
end;
procedure Thistory.tiExecuteHistoryTimer(Sender: TObject);
begin
tiExecuteHistory.Enabled := False;
ExecuteHistory(edHistorySearch.Text);
end;
end.