-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuProjectDialogs.pas
161 lines (144 loc) · 4.37 KB
/
uProjectDialogs.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
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 justscribe@yahoo.com
On Github: github.com/justscribe/ORDESY
Dialog to create/edit projects/modules.
}
unit uProjectDialogs;
interface
uses
uORDESY,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons;
type
TfmProjectCreate = class(TForm)
pnlMain: TPanel;
gbxProjectName: TGroupBox;
edtProjectName: TEdit;
gbxDescription: TGroupBox;
mmDescription: TMemo;
lblCreatorHead: TLabel;
lblCreator: TLabel;
btnCreate: TBitBtn;
btnCancel: TBitBtn;
lblDateCreate: TLabel;
lblDate: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure UpdateCurrentDateTime(Sender: TObject);
procedure btnCreateClick(Sender: TObject);
end;
function ShowProjectCreateDialog(const aCreator: string; aProjectList: TORDESYProjectList): boolean;
function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
function ShowModuleCreateDialog(aProject: TORDESYProject): boolean;
function ShowModuleEditDialog(aModule: TORDESYModule): boolean;
implementation
{$R *.dfm}
function ShowProjectCreateDialog(const aCreator: string; aProjectList: TORDESYProjectList): boolean;
var
dTimer: TTimer;
begin
with TfmProjectCreate.Create(Application) do
try
Result:= false;
lblCreator.Caption:= aCreator;
dTimer:= TTimer.Create(Parent);
dTimer.Interval:= 1000;
dTimer.OnTimer:= UpdateCurrentDateTime;
if ShowModal = mrOk then
begin
aProjectList.AddProject(TORDESYProject.Create(aProjectList, aProjectList.GetFreeProjectId, edtProjectName.Text, mmDescription.Text, lblCreator.Caption));
Result:= true;
end;
finally
dTimer.Free;
Free;
end;
end;
function ShowProjectEditDialog(aProject: TORDESYProject): boolean;
begin
with TfmProjectCreate.Create(Application) do
try
Result:= false;
Caption:= 'Edit project';
edtProjectName.Text:= aProject.Name;
mmDescription.Text:= aProject.Description;
lblCreator.Caption:= aProject.Creator;
lblDateCreate.Caption:= FormatDateTime('c', aProject.DateCreate);
lblDateCreate.Visible:= true;
btnCreate.Caption:= 'Save';
if ShowModal = mrOk then
begin
aProject.Name:= edtProjectName.Text;
aProject.Description:= mmDescription.Text;
aProject.Creator:= lblCreator.Caption;
Result:= true;
end;
finally
Free;
end;
end;
function ShowModuleCreateDialog(aProject: TORDESYProject): boolean;
begin
with TfmProjectCreate.Create(Application) do
try
Result:= false;
Caption:= 'Add module';
lblCreatorHead.Visible:= false;
lblDate.Visible:= false;
if ShowModal = mrOk then
begin
aProject.AddModule(TORDESYModule.Create(aProject, aProject.GetFreeModuleId, edtProjectName.Text, mmDescription.Text));
Result:= true;
end;
finally
Free;
end;
end;
function ShowModuleEditDialog(aModule: TORDESYModule): boolean;
begin
with TfmProjectCreate.Create(Application) do
try
Result:= false;
Caption:= 'Edit module';
edtProjectName.Text:= aModule.Name;
mmDescription.Text:= aModule.Description;
lblCreatorHead.Visible:= false;
lblDate.Visible:= false;
btnCreate.Caption:= 'Save';
if ShowModal = mrOk then
begin
aModule.Name:= edtProjectName.Text;
aModule.Description:= mmDescription.Text;
Result:= true;
end;
finally
Free;
end;
end;
procedure TfmProjectCreate.btnCreateClick(Sender: TObject);
begin
if (edtProjectName.Text = '') or (length(edtProjectName.Text) > 255) then
begin
ModalResult:= mrNone;
raise Exception.Create('Incorrect project name, empty or more than 255 characters!');
end;
if (length(mmDescription.Text) > 1000) then
begin
ModalResult:= mrNone;
raise Exception.Create('Incorrect project description, more than 1000 characters!');
end;
end;
procedure TfmProjectCreate.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:= caFree;
end;
procedure TfmProjectCreate.UpdateCurrentDateTime(Sender: TObject);
begin
lblDateCreate.Caption:= FormatDateTime('c', Date + Time);
end;
end.