tvplanit: Fix Firebird datastore missing commit after updating contacts table structure to current version.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5181 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-09-18 20:24:52 +00:00
parent 0662015dbe
commit 27bb5c51fe
2 changed files with 65 additions and 72 deletions

View File

@ -19,9 +19,9 @@ object ContactEditForm: TContactEditForm
Height = 592
Top = 0
Width = 575
ActivePage = tabAddresses
ActivePage = tabBaseData
Align = alClient
TabIndex = 1
TabIndex = 0
TabOrder = 0
OnChange = PageControlChange
object tabBaseData: TTabSheet
@ -1095,7 +1095,7 @@ object ContactEditForm: TContactEditForm
BorderSpacing.Left = 4
BorderSpacing.Right = 8
ParentFont = False
TabOrder = 2
TabOrder = 1
end
object edWebsite2: TEdit
AnchorSideLeft.Control = cbWebsite2
@ -1142,7 +1142,7 @@ object ContactEditForm: TContactEditForm
ItemHeight = 15
MaxLength = 65535
ParentFont = False
TabOrder = 1
TabOrder = 2
end
end
end

View File

@ -417,6 +417,8 @@ begin
list := TStringList.Create;
try
FConnection.GetFieldNames(ContactsTableName, list);
try
// Fields renamed in 1.05
if list.IndexOf('Address') > -1 then
RenameField(ContactsTableName, 'Address', 'Address1');
@ -466,6 +468,12 @@ begin
AddField(ContactsTableName, 'WebsiteType1', ftInteger);
if list.IndexOf('WebsiteType2') = -1 then
AddField(ContactsTableName, 'WebsiteType2', ftInteger);
FConnection.Transaction.Commit;
except
FConnection.Transaction.Rollback;
raise Exception.Create('Failure to update table structure to current VisualPlanIt version');
end;
finally
list.Free;
end;
@ -519,32 +527,16 @@ end;
Firebird will complain about this field not being specified when posting. }
procedure TVpFirebirdDatastore.OpenTables;
begin
{
if FContactsTable.Transaction = nil then
FContactsTable.Transaction := FConnection.Transaction;
}
FixContactsTable;
FContactsTable.Open;
FContactsTable.Fields[0].Required := false;
{
if FEventsTable.Transaction = nil then
FEventsTable.Transaction := FConnection.Transaction;
}
FEventsTable.Open;
FEventsTable.Fields[0].Required := false;
{
if FResourceTable.Transaction = nil then
FResourceTable.Transaction := FConnection.Transaction;
}
FResourceTable.Open;
FResourceTable.Fields[0].Required := false;
{
if FTasksTable.Transaction = nil then
FTasksTable.Transaction := FConnection.Transaction;
}
FTasksTable.Open;
FTasksTable.Fields[0].Required := false;
end;
@ -553,7 +545,7 @@ procedure TVpFirebirdDatastore.PostContacts;
begin
inherited;
FContactsTable.ApplyUpdates;
FConnection.Transaction.CommitRetaining;
//FConnection.Transaction.CommitRetaining;
FContactsTable.Refresh;
end;
@ -561,7 +553,7 @@ procedure TVpFirebirdDatastore.PostEvents;
begin
inherited;
FEventsTable.ApplyUpdates;
FConnection.Transaction.CommitRetaining;
//FConnection.Transaction.CommitRetaining;
FEventsTable.Refresh;
end;
@ -569,7 +561,8 @@ procedure TVpFirebirdDatastore.PostResources;
begin
inherited;
FResourceTable.ApplyUpdates;
FConnection.Transaction.CommitRetaining;
//FConnection.Transaction.CommitRetaining;
// Refresh needed in order to get the resource id for the other tables.
// Without it the other datasets would not be stored after adding a resource.
// Seems to be pecularity of Firebird.
@ -580,7 +573,7 @@ procedure TVpFirebirdDatastore.PostTasks;
begin
inherited;
FTasksTable.ApplyUpdates;
FConnection.Transaction.CommitRetaining;
//FConnection.Transaction.CommitRetaining;
FTasksTable.Refresh;
end;