-
Notifications
You must be signed in to change notification settings - Fork 2
/
FBCustomDataSetAutoUpdateOptionsEditorD.pas
111 lines (99 loc) · 3.95 KB
/
FBCustomDataSetAutoUpdateOptionsEditorD.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
(********************************************************************************)
(* FB/IB Data set (FBDataSet) *)
(* *)
(* The contents of this file are subject to the GNU LIBRARY GENERAL PUBLIC *)
(* LICENSE 2 (the "License"); you may not use this file except in compliance *)
(* with the License. You may obtain a copy of the License at *)
(* http://www.gnu.org/copyleft/lesser.html *)
(* *)
(* Software distributed under the License is distributed on an "AS IS" basis, *)
(* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for *)
(* the specific language governing rights and limitations under the License. *)
(* *)
(* Unit owner : Lagunov Aleksey <alexs75@hotbox.ru> *)
(* *)
(********************************************************************************)
unit FBCustomDataSetAutoUpdateOptionsEditorD;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, FBCustomDataSet, ExtCtrls, DB, uib;
type
TFBCustomDataSetAutoUpdateOptionsEditorForm = class(TForm)
Label1: TLabel;
ComboBox1: TComboBox;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
ComboBox2: TComboBox;
Button1: TButton;
Button2: TButton;
JvUIBQuery1: TUIBQuery;
RadioGroup1: TRadioGroup;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
function ShowEditor(DS: TFBDataSet):boolean;
end;
var
FBCustomDataSetAutoUpdateOptionsEditorForm: TFBCustomDataSetAutoUpdateOptionsEditorForm;
implementation
uses FBMisc;
{$R *.dfm}
procedure TFBCustomDataSetAutoUpdateOptionsEditorForm.FormCreate(
Sender: TObject);
begin
Button1.Caption:=slcOk;
Button2.Caption:=slcCancel;
Label1.Caption:=slcUpdatedField;
Label2.Caption:=slcGeneratorName;
Label3.Caption:=slcIncrementBy;
end;
function TFBCustomDataSetAutoUpdateOptionsEditorForm.ShowEditor(
DS: TFBDataSet):boolean;
var
i:integer;
OldDataBaseConnected:boolean;
begin
Result:=false;
JvUIBQuery1.DataBase:=DS.DataBase;
JvUIBQuery1.Transaction:=DS.Transaction;
if not Assigned(JvUIBQuery1.DataBase) then FBError(fbeDatabaseNotAssigned, [DS.Name]);
if not Assigned(JvUIBQuery1.Transaction) then FBError(fbeTransactionNotAssigned, [DS.Name]);
OldDataBaseConnected:=JvUIBQuery1.DataBase.Connected;
//Fill generator list
JvUIBQuery1.Execute;
ComboBox2.Items.Clear;
try
while not JvUIBQuery1.Eof do
begin
ComboBox2.Items.Add(Trim(JvUIBQuery1.Fields.AsString[0]));
JvUIBQuery1.Next
end;
finally
JvUIBQuery1.Close;
JvUIBQuery1.DataBase.Connected:=OldDataBaseConnected;
end;
if ComboBox2.Items.IndexOf(DS.AutoUpdateOptions.GeneratorName)<>-1 then
ComboBox2.ItemIndex:=ComboBox2.Items.IndexOf(DS.AutoUpdateOptions.GeneratorName);
//Fill field list
ComboBox1.Items.Clear;
DS.FieldDefs.Update;
for i:=0 to DS.FieldDefs.Count-1 do
if DS.FieldDefs[i].DataType in [ftSmallint, ftInteger, ftWord, ftFloat,
ftCurrency, ftBCD, ftAutoInc, ftLargeint] then
ComboBox1.Items.Add(DS.FieldDefs[i].Name);
ComboBox1.Text:=DS.AutoUpdateOptions.KeyField;
Edit1.Text:=IntToStr(DS.AutoUpdateOptions.IncrementBy);
RadioGroup1.ItemIndex:=ord(DS.AutoUpdateOptions.WhenGetGenID);
if ShowModal = mrOK then
begin
DS.AutoUpdateOptions.IncrementBy:=StrToIntDef(Edit1.Text, 0);
DS.AutoUpdateOptions.WhenGetGenID:=TWhenGetGenID(RadioGroup1.ItemIndex);
DS.AutoUpdateOptions.KeyField:=ComboBox1.Text;
DS.AutoUpdateOptions.GeneratorName:=ComboBox2.Items[ComboBox2.ItemIndex];
Result:=true;
end;
end;
end.