-
Notifications
You must be signed in to change notification settings - Fork 1
/
uBaseList.pas
137 lines (120 loc) · 3.37 KB
/
uBaseList.pas
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
{
Oracle Deploy System ver.1.0 (ORDESY)
by Volodymyr Sedler aka scribe
2016
Desc: wrap/deploy/save objects of oracle database.
No warranty of using this program.
Just Free.
With bugs, suggestions please write to [email protected]
On Github: github.com/justscribe/ORDESY
Dialog to edit the list of bases in ProjectList.
}
unit uBaseList;
interface
uses
// ORDESY Modules
uORDESY, uErrorHandle,
// Delphi Modules
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TfmBaseList = class(TForm)
lbxList: TListBox;
pnlControl: TPanel;
btnAdd: TButton;
btnDelete: TButton;
btnEdit: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure UpdateList(aProjectList: TORDESYProjectList);
procedure btnDeleteClick(Sender: TObject);
procedure btnAddClick(Sender: TObject);
procedure btnEditClick(Sender: TObject);
private
ProjectList: TORDESYProjectList;
end;
function ShowBaseListDialog(aProjectList: TORDESYProjectList): boolean;
implementation
{$R *.dfm}
uses
uMain;
function ShowBaseListDialog(aProjectList: TORDESYProjectList): boolean;
begin
with TfmBaseList.Create(Application) do
try
try
Result:= false;
ProjectList:= aProjectList;
UpdateList(ProjectList);
ShowModal;
Result:= true;
except
on E: Exception do
HandleError([ClassName, 'ShowBaseListDialog', E.Message]);
end;
finally
Free;
end;
end;
procedure TfmBaseList.btnAddClick(Sender: TObject);
begin
try
fmMain.AddBase(Self);
UpdateList(ProjectList);
except
on E: Exception do
HandleError([ClassName, 'btnAddClick', E.Message]);
end;
end;
procedure TfmBaseList.btnDeleteClick(Sender: TObject);
var
reply: word;
begin
try
if (lbxList.Count > 0) and (lbxList.ItemIndex >= 0) and (lbxList.Items.Objects[lbxList.ItemIndex] is TOraBase) then
begin
reply:= MessageBox(Handle, PChar('Delete base: ' + TOraBase(lbxList.Items.Objects[lbxList.ItemIndex]).Name + '?' + #13#10), PChar('Confirm'), 36);
if reply = IDYES then
if ProjectList.RemoveBaseById(TOraBase(lbxList.Items.Objects[lbxList.ItemIndex]).Id) then
UpdateList(ProjectList);
end;
except
on E: Exception do
HandleError([ClassName, 'btnDeleteClick', E.Message]);
end;
end;
procedure TfmBaseList.btnEditClick(Sender: TObject);
begin
try
if (lbxList.Count > 0) and (lbxList.ItemIndex >= 0) and (lbxList.Items.Objects[lbxList.ItemIndex] is TOraBase) then
if fmMain.EditBase(TOraBase(lbxList.Items.Objects[lbxList.ItemIndex])) then
UpdateList(ProjectList);
except
on E: Exception do
HandleError([ClassName, 'btnEditClick', E.Message]);
end;
end;
procedure TfmBaseList.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:= caFree;
end;
procedure TfmBaseList.UpdateList(aProjectList: TORDESYProjectList);
var
i: integer;
iBase: TOraBase;
begin
try
lbxList.Items.BeginUpdate;
lbxList.Clear;
for i := 0 to aProjectList.OraBaseCount - 1 do
begin
iBase:= aProjectList.GetOraBaseByIndex(i);
if Assigned(iBase) then
lbxList.AddItem(inttostr(iBase.Id) + ':|' + iBase.Name, iBase);
end;
lbxList.Items.EndUpdate;
except
on E: Exception do
HandleError([ClassName, 'UpdateList', E.Message]);
end;
end;
end.