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

View File

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