1 |
tony |
33 |
{************************************************************************} |
2 |
|
|
{ } |
3 |
|
|
{ Borland Delphi Visual Component Library } |
4 |
|
|
{ InterBase Express core components } |
5 |
|
|
{ } |
6 |
|
|
{ Copyright (c) 1998-2000 Inprise Corporation } |
7 |
|
|
{ } |
8 |
|
|
{ InterBase Express is based in part on the product } |
9 |
|
|
{ Free IB Components, written by Gregory H. Deatz for } |
10 |
|
|
{ Hoagland, Longo, Moran, Dunst & Doukas Company. } |
11 |
|
|
{ Free IB Components is used under license. } |
12 |
|
|
{ } |
13 |
|
|
{ The contents of this file are subject to the InterBase } |
14 |
|
|
{ Public License Version 1.0 (the "License"); you may not } |
15 |
|
|
{ use this file except in compliance with the License. You } |
16 |
|
|
{ may obtain a copy of the License at http://www.Inprise.com/IPL.html } |
17 |
|
|
{ Software distributed under the License is distributed on } |
18 |
|
|
{ an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either } |
19 |
|
|
{ express or implied. See the License for the specific language } |
20 |
|
|
{ governing rights and limitations under the License. } |
21 |
|
|
{ The Original Code was created by InterBase Software Corporation } |
22 |
|
|
{ and its successors. } |
23 |
|
|
{ Portions created by Inprise Corporation are Copyright (C) Inprise } |
24 |
|
|
{ Corporation. All Rights Reserved. } |
25 |
|
|
{ Contributor(s): Jeff Overcash } |
26 |
|
|
{ } |
27 |
|
|
{************************************************************************} |
28 |
|
|
|
29 |
|
|
unit IBTransactionEdit; |
30 |
|
|
|
31 |
|
|
{$MODE Delphi} |
32 |
|
|
|
33 |
|
|
interface |
34 |
|
|
|
35 |
|
|
uses |
36 |
tony |
45 |
{Windows,} SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
37 |
|
|
StdCtrls, IBDataBase, IB, ExtCtrls, LResources; |
38 |
tony |
33 |
|
39 |
|
|
type |
40 |
|
|
|
41 |
|
|
{ TIBTransactionEditForm } |
42 |
|
|
|
43 |
|
|
TIBTransactionEditForm = class(TForm) |
44 |
|
|
GroupBox1: TGroupBox; |
45 |
|
|
Cancelbtn: TButton; |
46 |
|
|
OKBtn: TButton; |
47 |
|
|
rbOtherButton: TRadioButton; |
48 |
|
|
rbSnapShot: TRadioButton; |
49 |
|
|
rbReadCommitted: TRadioButton; |
50 |
|
|
rbReadOnlyTableStability: TRadioButton; |
51 |
|
|
rbReadWriteTableStability: TRadioButton; |
52 |
|
|
TransactionParams: TMemo; |
53 |
|
|
Panel1: TPanel; |
54 |
|
|
Label1: TLabel; |
55 |
|
|
procedure OKBtnClick(Sender: TObject); |
56 |
|
|
procedure rbSnapShotClick(Sender: TObject); |
57 |
|
|
procedure rbReadCommittedClick(Sender: TObject); |
58 |
|
|
procedure rbReadOnlyTableStabilityClick(Sender: TObject); |
59 |
|
|
procedure rbReadWriteTableStabilityClick(Sender: TObject); |
60 |
|
|
procedure FormCreate(Sender: TObject); |
61 |
|
|
procedure HelpBtnClick(Sender: TObject); |
62 |
|
|
procedure TransactionParamsClick(Sender: TObject); |
63 |
|
|
procedure TransactionParamsExit(Sender: TObject); |
64 |
|
|
|
65 |
|
|
private |
66 |
|
|
{ Private declarations } |
67 |
|
|
Transaction: TIBTransaction; |
68 |
|
|
function Edit: Boolean; |
69 |
|
|
procedure ParseParams; |
70 |
|
|
procedure ClearParamSelection; |
71 |
|
|
|
72 |
|
|
public |
73 |
|
|
{ Public declarations } |
74 |
|
|
end; |
75 |
|
|
|
76 |
|
|
var |
77 |
|
|
IBTransactionEditForm: TIBTransactionEditForm; |
78 |
|
|
|
79 |
|
|
function EditIBtransaction(Atransaction: TIBtransaction): Boolean; |
80 |
|
|
|
81 |
|
|
implementation |
82 |
|
|
|
83 |
tony |
45 |
uses FBMessages; |
84 |
|
|
|
85 |
tony |
33 |
{$R *.lfm} |
86 |
|
|
|
87 |
|
|
function EditIBtransaction(ATransaction: TIBtransaction): Boolean; |
88 |
|
|
begin |
89 |
|
|
with TIBtransactionEditForm.Create(Application) do |
90 |
|
|
try |
91 |
|
|
Transaction := ATransaction; |
92 |
|
|
Result := Edit; |
93 |
|
|
finally |
94 |
|
|
Free; |
95 |
|
|
end; |
96 |
|
|
end; |
97 |
|
|
|
98 |
|
|
function TIBtransactionEditForm.Edit: Boolean; |
99 |
|
|
begin |
100 |
|
|
TransactionParams.Lines := Transaction.Params; |
101 |
|
|
ParseParams; |
102 |
|
|
Result := False; |
103 |
|
|
if ShowModal = mrOk then |
104 |
|
|
begin |
105 |
|
|
Transaction.Params := TransactionParams.Lines; |
106 |
|
|
Result := True; |
107 |
|
|
end; |
108 |
|
|
end; |
109 |
|
|
|
110 |
|
|
type |
111 |
|
|
TTransactionParam = (concurrency, read_committed, rec_version, nowait, |
112 |
|
|
consistency, read, write); |
113 |
|
|
TTransactionParams = set of TTransactionParam; |
114 |
|
|
|
115 |
|
|
procedure TIBTransactionEditForm.ParseParams; |
116 |
|
|
var |
117 |
|
|
I: Integer; |
118 |
|
|
st: string; |
119 |
|
|
Value: TTransactionParams; |
120 |
|
|
|
121 |
|
|
begin |
122 |
|
|
Value := []; |
123 |
|
|
for I := 0 to TransactionParams.Lines.Count - 1 do |
124 |
|
|
begin |
125 |
|
|
st := LowerCase(Trim(TransactionParams.Lines[I])); |
126 |
|
|
if st = '' then |
127 |
|
|
continue; |
128 |
|
|
if st = 'concurrency' then |
129 |
|
|
Include(Value, concurrency) |
130 |
|
|
else if st = 'read_committed' then |
131 |
|
|
Include(Value, read_committed) |
132 |
|
|
else if st = 'rec_version' then |
133 |
|
|
Include(Value, rec_version) |
134 |
|
|
else if st = 'nowait' then |
135 |
|
|
Include(Value, nowait) |
136 |
|
|
else if st = 'read' then |
137 |
|
|
Include(Value, read) |
138 |
|
|
else if st = 'write' then |
139 |
|
|
Include(Value, write) |
140 |
|
|
else if st = 'consistency' then |
141 |
|
|
Include(Value, consistency) |
142 |
|
|
else begin |
143 |
|
|
Value := []; |
144 |
|
|
break; |
145 |
|
|
end; |
146 |
|
|
end; |
147 |
|
|
ClearParamSelection; |
148 |
|
|
if Value = [concurrency, nowait] then |
149 |
|
|
rbSnapShot.Checked := True |
150 |
|
|
else if Value = [read_committed, rec_version, nowait] then |
151 |
|
|
rbReadCommitted.Checked := True |
152 |
|
|
else if Value = [read, consistency] then |
153 |
|
|
rbReadOnlyTableStability.Checked := True |
154 |
|
|
else if Value = [write, consistency] then |
155 |
|
|
rbReadWriteTableStability.Checked := True |
156 |
|
|
else |
157 |
|
|
rbOtherButton.Checked := true |
158 |
|
|
end; |
159 |
|
|
|
160 |
|
|
procedure TIBTransactionEditForm.ClearParamSelection; |
161 |
|
|
begin |
162 |
|
|
rbSnapShot.Checked := False; |
163 |
|
|
rbReadCommitted.Checked := False; |
164 |
|
|
rbReadOnlyTableStability.Checked := False; |
165 |
|
|
rbReadWriteTableStability.Checked := False; |
166 |
|
|
end; |
167 |
|
|
|
168 |
|
|
procedure TIBTransactionEditForm.OKBtnClick(Sender: TObject); |
169 |
|
|
begin |
170 |
|
|
ModalResult := mrNone; |
171 |
|
|
if Transaction.Active then |
172 |
|
|
begin |
173 |
|
|
if MessageDlg(SCommitTransaction, mtConfirmation, |
174 |
|
|
mbOkCancel, 0) <> mrOk then Exit; |
175 |
|
|
Transaction.Rollback; |
176 |
|
|
end; |
177 |
|
|
ModalResult := mrOk; |
178 |
|
|
end; |
179 |
|
|
|
180 |
|
|
procedure TIBTransactionEditForm.FormCreate(Sender: TObject); |
181 |
|
|
begin |
182 |
|
|
// HelpContext := hcDIBTransactionEdit; |
183 |
|
|
end; |
184 |
|
|
|
185 |
|
|
procedure TIBTransactionEditForm.HelpBtnClick(Sender: TObject); |
186 |
|
|
begin |
187 |
|
|
Application.HelpContext(HelpContext); |
188 |
|
|
end; |
189 |
|
|
|
190 |
|
|
procedure TIBTransactionEditForm.rbSnapShotClick(Sender: TObject); |
191 |
|
|
begin |
192 |
|
|
TransactionParams.clear; |
193 |
|
|
TransactionParams.Lines.Add('concurrency'); { do not localize } |
194 |
|
|
TransactionParams.Lines.Add('nowait'); { do not localize } |
195 |
|
|
end; |
196 |
|
|
|
197 |
|
|
procedure TIBTransactionEditForm.rbReadCommittedClick(Sender: TObject); |
198 |
|
|
begin |
199 |
|
|
TransactionParams.clear; |
200 |
|
|
TransactionParams.Lines.Add('read_committed'); { do not localize } |
201 |
|
|
TransactionParams.Lines.Add('rec_version'); { do not localize } |
202 |
|
|
TransactionParams.Lines.Add('nowait'); { do not localize } |
203 |
|
|
end; |
204 |
|
|
|
205 |
|
|
procedure TIBTransactionEditForm.rbReadOnlyTableStabilityClick(Sender: TObject); |
206 |
|
|
begin |
207 |
|
|
TransactionParams.clear; |
208 |
|
|
TransactionParams.Lines.Add('read'); { do not localize } |
209 |
|
|
TransactionParams.Lines.Add('consistency'); { do not localize } |
210 |
|
|
end; |
211 |
|
|
|
212 |
|
|
procedure TIBTransactionEditForm.rbReadWriteTableStabilityClick(Sender: TObject); |
213 |
|
|
begin |
214 |
|
|
TransactionParams.clear; |
215 |
|
|
TransactionParams.Lines.Add('write'); { do not localize } |
216 |
|
|
TransactionParams.Lines.Add('consistency'); { do not localize } |
217 |
|
|
end; |
218 |
|
|
|
219 |
|
|
procedure TIBTransactionEditForm.TransactionParamsClick(Sender: TObject); |
220 |
|
|
begin |
221 |
|
|
ClearParamSelection; |
222 |
|
|
end; |
223 |
|
|
|
224 |
|
|
procedure TIBTransactionEditForm.TransactionParamsExit(Sender: TObject); |
225 |
|
|
begin |
226 |
|
|
ParseParams; |
227 |
|
|
end; |
228 |
|
|
|
229 |
|
|
|
230 |
tony |
45 |
end. |