1 |
{************************************************************************} |
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 |
{Windows,} Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, |
37 |
StdCtrls, IBDataBase, IB, ExtCtrls, IBXConst, LResources; |
38 |
|
39 |
type |
40 |
TIBTransactionEditForm = class(TForm) |
41 |
GroupBox1: TGroupBox; |
42 |
HelpBtn: TButton; |
43 |
Cancelbtn: TButton; |
44 |
OKBtn: TButton; |
45 |
rbSnapShot: TRadioButton; |
46 |
rbReadCommitted: TRadioButton; |
47 |
rbReadOnlyTableStability: TRadioButton; |
48 |
rbReadWriteTableStability: TRadioButton; |
49 |
TransactionParams: TMemo; |
50 |
Panel1: TPanel; |
51 |
Label1: TLabel; |
52 |
procedure OKBtnClick(Sender: TObject); |
53 |
procedure rbSnapShotClick(Sender: TObject); |
54 |
procedure rbReadCommittedClick(Sender: TObject); |
55 |
procedure rbReadOnlyTableStabilityClick(Sender: TObject); |
56 |
procedure rbReadWriteTableStabilityClick(Sender: TObject); |
57 |
procedure FormCreate(Sender: TObject); |
58 |
procedure HelpBtnClick(Sender: TObject); |
59 |
procedure TransactionParamsClick(Sender: TObject); |
60 |
procedure TransactionParamsExit(Sender: TObject); |
61 |
|
62 |
private |
63 |
{ Private declarations } |
64 |
Transaction: TIBTransaction; |
65 |
function Edit: Boolean; |
66 |
procedure ParseParams; |
67 |
procedure ClearParamSelection; |
68 |
|
69 |
public |
70 |
{ Public declarations } |
71 |
end; |
72 |
|
73 |
var |
74 |
IBTransactionEditForm: TIBTransactionEditForm; |
75 |
|
76 |
function EditIBtransaction(Atransaction: TIBtransaction): Boolean; |
77 |
|
78 |
implementation |
79 |
|
80 |
|
81 |
{uses |
82 |
LibHelp;} |
83 |
|
84 |
function EditIBtransaction(ATransaction: TIBtransaction): Boolean; |
85 |
begin |
86 |
with TIBtransactionEditForm.Create(Application) do |
87 |
try |
88 |
Transaction := ATransaction; |
89 |
Result := Edit; |
90 |
finally |
91 |
Free; |
92 |
end; |
93 |
end; |
94 |
|
95 |
function TIBtransactionEditForm.Edit: Boolean; |
96 |
begin |
97 |
TransactionParams.Lines := Transaction.Params; |
98 |
ParseParams; |
99 |
Result := False; |
100 |
if ShowModal = mrOk then |
101 |
begin |
102 |
Transaction.Params := TransactionParams.Lines; |
103 |
Result := True; |
104 |
end; |
105 |
end; |
106 |
|
107 |
type |
108 |
TTransactionParam = (concurrency, read_committed, rec_version, nowait, |
109 |
consistency, read, write); |
110 |
TTransactionParams = set of TTransactionParam; |
111 |
|
112 |
procedure TIBTransactionEditForm.ParseParams; |
113 |
var |
114 |
I: Integer; |
115 |
st: string; |
116 |
Value: TTransactionParams; |
117 |
|
118 |
begin |
119 |
Value := []; |
120 |
for I := 0 to TransactionParams.Lines.Count - 1 do |
121 |
begin |
122 |
st := LowerCase(Trim(TransactionParams.Lines[I])); |
123 |
if st = '' then |
124 |
continue; |
125 |
if st = 'concurrency' then |
126 |
Include(Value, concurrency) |
127 |
else if st = 'read_committed' then |
128 |
Include(Value, read_committed) |
129 |
else if st = 'rec_version' then |
130 |
Include(Value, rec_version) |
131 |
else if st = 'nowait' then |
132 |
Include(Value, nowait) |
133 |
else if st = 'read' then |
134 |
Include(Value, read) |
135 |
else if st = 'write' then |
136 |
Include(Value, write) |
137 |
else if st = 'consistency' then |
138 |
Include(Value, consistency) |
139 |
else begin |
140 |
Value := []; |
141 |
break; |
142 |
end; |
143 |
end; |
144 |
ClearParamSelection; |
145 |
if Value = [concurrency, nowait] then |
146 |
rbSnapShot.Checked := True |
147 |
else if Value = [read_committed, rec_version, nowait] then |
148 |
rbReadCommitted.Checked := True |
149 |
else if Value = [read, consistency] then |
150 |
rbReadOnlyTableStability.Checked := True |
151 |
else if Value = [write, consistency] then |
152 |
rbReadWriteTableStability.Checked := True; |
153 |
end; |
154 |
|
155 |
procedure TIBTransactionEditForm.ClearParamSelection; |
156 |
begin |
157 |
rbSnapShot.Checked := False; |
158 |
rbReadCommitted.Checked := False; |
159 |
rbReadOnlyTableStability.Checked := False; |
160 |
rbReadWriteTableStability.Checked := False; |
161 |
end; |
162 |
|
163 |
procedure TIBTransactionEditForm.OKBtnClick(Sender: TObject); |
164 |
begin |
165 |
ModalResult := mrNone; |
166 |
if Transaction.Active then |
167 |
begin |
168 |
if MessageDlg(SCommitTransaction, mtConfirmation, |
169 |
mbOkCancel, 0) <> mrOk then Exit; |
170 |
Transaction.Rollback; |
171 |
end; |
172 |
ModalResult := mrOk; |
173 |
end; |
174 |
|
175 |
procedure TIBTransactionEditForm.FormCreate(Sender: TObject); |
176 |
begin |
177 |
// HelpContext := hcDIBTransactionEdit; |
178 |
end; |
179 |
|
180 |
procedure TIBTransactionEditForm.HelpBtnClick(Sender: TObject); |
181 |
begin |
182 |
Application.HelpContext(HelpContext); |
183 |
end; |
184 |
|
185 |
procedure TIBTransactionEditForm.rbSnapShotClick(Sender: TObject); |
186 |
begin |
187 |
TransactionParams.clear; |
188 |
TransactionParams.Lines.Add('concurrency'); { do not localize } |
189 |
TransactionParams.Lines.Add('nowait'); { do not localize } |
190 |
end; |
191 |
|
192 |
procedure TIBTransactionEditForm.rbReadCommittedClick(Sender: TObject); |
193 |
begin |
194 |
TransactionParams.clear; |
195 |
TransactionParams.Lines.Add('read_committed'); { do not localize } |
196 |
TransactionParams.Lines.Add('rec_version'); { do not localize } |
197 |
TransactionParams.Lines.Add('nowait'); { do not localize } |
198 |
end; |
199 |
|
200 |
procedure TIBTransactionEditForm.rbReadOnlyTableStabilityClick(Sender: TObject); |
201 |
begin |
202 |
TransactionParams.clear; |
203 |
TransactionParams.Lines.Add('read'); { do not localize } |
204 |
TransactionParams.Lines.Add('consistency'); { do not localize } |
205 |
end; |
206 |
|
207 |
procedure TIBTransactionEditForm.rbReadWriteTableStabilityClick(Sender: TObject); |
208 |
begin |
209 |
TransactionParams.clear; |
210 |
TransactionParams.Lines.Add('write'); { do not localize } |
211 |
TransactionParams.Lines.Add('consistency'); { do not localize } |
212 |
end; |
213 |
|
214 |
procedure TIBTransactionEditForm.TransactionParamsClick(Sender: TObject); |
215 |
begin |
216 |
ClearParamSelection; |
217 |
end; |
218 |
|
219 |
procedure TIBTransactionEditForm.TransactionParamsExit(Sender: TObject); |
220 |
begin |
221 |
ParseParams; |
222 |
end; |
223 |
|
224 |
initialization |
225 |
{$i IBTransactionEdit.lrs} |
226 |
|
227 |
end. |