You've already forked lazarus-ccr
tvplanit: Fix "Apply to planner" button in FlexDatastore demo for Access.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5193 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -10,9 +10,6 @@
|
|||||||
<ResourceType Value="res"/>
|
<ResourceType Value="res"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
|
||||||
<StringTable ProductVersion=""/>
|
|
||||||
</VersionInfo>
|
|
||||||
<BuildModes Count="1">
|
<BuildModes Count="1">
|
||||||
<Item1 Name="Default" Default="True"/>
|
<Item1 Name="Default" Default="True"/>
|
||||||
</BuildModes>
|
</BuildModes>
|
||||||
|
@ -3,7 +3,7 @@ object Form1: TForm1
|
|||||||
Height = 686
|
Height = 686
|
||||||
Top = 169
|
Top = 169
|
||||||
Width = 980
|
Width = 980
|
||||||
Caption = 'Form1'
|
Caption = 'VpFlexDatastore demo (MS Access via ODBC)'
|
||||||
ClientHeight = 686
|
ClientHeight = 686
|
||||||
ClientWidth = 980
|
ClientWidth = 980
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
@ -193,7 +193,7 @@ object Form1: TForm1
|
|||||||
DisplayOptions.CheckStyle = csCheck
|
DisplayOptions.CheckStyle = csCheck
|
||||||
DisplayOptions.DueDateFormat = 'dd.MM.yyyy'
|
DisplayOptions.DueDateFormat = 'dd.MM.yyyy'
|
||||||
DisplayOptions.ShowCompletedTasks = False
|
DisplayOptions.ShowCompletedTasks = False
|
||||||
DisplayOptions.ShowAll = False
|
DisplayOptions.ShowAll = True
|
||||||
DisplayOptions.ShowDueDate = True
|
DisplayOptions.ShowDueDate = True
|
||||||
DisplayOptions.OverdueColor = clRed
|
DisplayOptions.OverdueColor = clRed
|
||||||
DisplayOptions.NormalColor = clBlack
|
DisplayOptions.NormalColor = clBlack
|
||||||
@ -279,6 +279,7 @@ object Form1: TForm1
|
|||||||
Color = clWindow
|
Color = clWindow
|
||||||
Columns = <>
|
Columns = <>
|
||||||
DataSource = DsResources
|
DataSource = DsResources
|
||||||
|
Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgThumbTracking]
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -299,13 +300,13 @@ object Form1: TForm1
|
|||||||
Options = []
|
Options = []
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object Button1: TButton
|
object BtnApplyToPlanner: TButton
|
||||||
Left = 264
|
Left = 264
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 120
|
Width = 120
|
||||||
Caption = 'Apply to planner'
|
Caption = 'Apply to planner'
|
||||||
OnClick = Button1Click
|
OnClick = BtnApplyToPlannerClick
|
||||||
TabOrder = 2
|
TabOrder = 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -325,7 +326,7 @@ object Form1: TForm1
|
|||||||
top = 168
|
top = 168
|
||||||
end
|
end
|
||||||
object VpResourceEditDialog1: TVpResourceEditDialog
|
object VpResourceEditDialog1: TVpResourceEditDialog
|
||||||
Version = 'v1.04'
|
Version = 'v1.05'
|
||||||
DataStore = VpFlexDataStore1
|
DataStore = VpFlexDataStore1
|
||||||
Options = []
|
Options = []
|
||||||
Placement.Position = mpCenter
|
Placement.Position = mpCenter
|
||||||
@ -1270,6 +1271,9 @@ object Form1: TForm1
|
|||||||
Precision = -1
|
Precision = -1
|
||||||
Size = 100
|
Size = 100
|
||||||
end>
|
end>
|
||||||
|
AfterEdit = QryGridAfterEdit
|
||||||
|
AfterInsert = QryGridAfterInsert
|
||||||
|
AfterPost = QryGridAfterPost
|
||||||
Database = ODBCConnection1
|
Database = ODBCConnection1
|
||||||
Transaction = SQLTransaction1
|
Transaction = SQLTransaction1
|
||||||
SQL.Strings = (
|
SQL.Strings = (
|
||||||
@ -1277,6 +1281,7 @@ object Form1: TForm1
|
|||||||
)
|
)
|
||||||
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
||||||
Params = <>
|
Params = <>
|
||||||
|
UpdateMode = upWhereAll
|
||||||
UsePrimaryKeyAsKey = False
|
UsePrimaryKeyAsKey = False
|
||||||
left = 531
|
left = 531
|
||||||
top = 171
|
top = 171
|
||||||
@ -1461,6 +1466,9 @@ object Form1: TForm1
|
|||||||
Precision = -1
|
Precision = -1
|
||||||
Size = 100
|
Size = 100
|
||||||
end>
|
end>
|
||||||
|
AfterEdit = QryGridAfterEdit
|
||||||
|
AfterInsert = QryGridAfterInsert
|
||||||
|
AfterPost = QryGridAfterPost
|
||||||
Database = ODBCConnection1
|
Database = ODBCConnection1
|
||||||
Transaction = SQLTransaction1
|
Transaction = SQLTransaction1
|
||||||
SQL.Strings = (
|
SQL.Strings = (
|
||||||
@ -1468,6 +1476,7 @@ object Form1: TForm1
|
|||||||
)
|
)
|
||||||
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
||||||
Params = <>
|
Params = <>
|
||||||
|
UpdateMode = upWhereAll
|
||||||
UsePrimaryKeyAsKey = False
|
UsePrimaryKeyAsKey = False
|
||||||
left = 531
|
left = 531
|
||||||
top = 225
|
top = 225
|
||||||
@ -1475,6 +1484,9 @@ object Form1: TForm1
|
|||||||
object QryAllEvents: TSQLQuery
|
object QryAllEvents: TSQLQuery
|
||||||
PacketRecords = -1
|
PacketRecords = -1
|
||||||
FieldDefs = <>
|
FieldDefs = <>
|
||||||
|
AfterEdit = QryGridAfterEdit
|
||||||
|
AfterInsert = QryGridAfterInsert
|
||||||
|
AfterPost = QryGridAfterPost
|
||||||
Database = ODBCConnection1
|
Database = ODBCConnection1
|
||||||
Transaction = SQLTransaction1
|
Transaction = SQLTransaction1
|
||||||
SQL.Strings = (
|
SQL.Strings = (
|
||||||
@ -1482,6 +1494,7 @@ object Form1: TForm1
|
|||||||
)
|
)
|
||||||
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
||||||
Params = <>
|
Params = <>
|
||||||
|
UpdateMode = upWhereAll
|
||||||
UsePrimaryKeyAsKey = False
|
UsePrimaryKeyAsKey = False
|
||||||
left = 531
|
left = 531
|
||||||
top = 285
|
top = 285
|
||||||
@ -1489,6 +1502,9 @@ object Form1: TForm1
|
|||||||
object QryAllTasks: TSQLQuery
|
object QryAllTasks: TSQLQuery
|
||||||
PacketRecords = -1
|
PacketRecords = -1
|
||||||
FieldDefs = <>
|
FieldDefs = <>
|
||||||
|
AfterEdit = QryGridAfterEdit
|
||||||
|
AfterInsert = QryGridAfterInsert
|
||||||
|
AfterPost = QryGridAfterPost
|
||||||
Database = ODBCConnection1
|
Database = ODBCConnection1
|
||||||
Transaction = SQLTransaction1
|
Transaction = SQLTransaction1
|
||||||
SQL.Strings = (
|
SQL.Strings = (
|
||||||
@ -1496,6 +1512,7 @@ object Form1: TForm1
|
|||||||
)
|
)
|
||||||
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
Options = [sqoKeepOpenOnCommit, sqoAutoCommit]
|
||||||
Params = <>
|
Params = <>
|
||||||
|
UpdateMode = upWhereAll
|
||||||
UsePrimaryKeyAsKey = False
|
UsePrimaryKeyAsKey = False
|
||||||
left = 531
|
left = 531
|
||||||
top = 352
|
top = 352
|
||||||
|
@ -17,7 +17,7 @@ type
|
|||||||
TForm1 = class(TForm)
|
TForm1 = class(TForm)
|
||||||
BtnNewRes: TButton;
|
BtnNewRes: TButton;
|
||||||
BtnEditRes: TButton;
|
BtnEditRes: TButton;
|
||||||
Button1: TButton;
|
BtnApplyToPlanner: TButton;
|
||||||
DsAllResources: TDataSource;
|
DsAllResources: TDataSource;
|
||||||
DsAllContacts: TDataSource;
|
DsAllContacts: TDataSource;
|
||||||
DsAllEvents: TDataSource;
|
DsAllEvents: TDataSource;
|
||||||
@ -60,10 +60,13 @@ type
|
|||||||
VpWeekView1: TVpWeekView;
|
VpWeekView1: TVpWeekView;
|
||||||
procedure BtnNewResClick(Sender: TObject);
|
procedure BtnNewResClick(Sender: TObject);
|
||||||
procedure BtnEditResClick(Sender: TObject);
|
procedure BtnEditResClick(Sender: TObject);
|
||||||
procedure Button1Click(Sender: TObject);
|
procedure BtnApplyToPlannerClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure PageControl1Change(Sender: TObject);
|
procedure PageControl1Change(Sender: TObject);
|
||||||
|
procedure QryGridAfterPost(DataSet: TDataSet);
|
||||||
|
procedure QryGridAfterInsert(DataSet: TDataSet);
|
||||||
|
procedure QryGridAfterEdit(DataSet: TDataSet);
|
||||||
procedure TabControl1Change(Sender: TObject);
|
procedure TabControl1Change(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
@ -97,9 +100,29 @@ begin
|
|||||||
VpResourceEditDialog1.Execute;
|
VpResourceEditDialog1.Execute;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.Button1Click(Sender: TObject);
|
procedure TForm1.BtnApplyToPlannerClick(Sender: TObject);
|
||||||
|
var
|
||||||
|
resID: Integer;
|
||||||
begin
|
begin
|
||||||
|
// Remember id of currently selected resource
|
||||||
|
resID := VpFlexDatastore1.ResourceID;
|
||||||
|
|
||||||
|
// Since the datastore does not know about the changes made in the grid
|
||||||
|
// we have to force the datastore to re-read everything.
|
||||||
|
// Maybe there's better way...
|
||||||
|
VpFlexDatastore1.Connected := false;
|
||||||
|
VpFlexDatastore1.Connected := true;
|
||||||
|
|
||||||
|
// Return to previous resource
|
||||||
|
VpFlexDatastore1.Resources.ClearResources;
|
||||||
VpFlexDatastore1.Load;
|
VpFlexDatastore1.Load;
|
||||||
|
VpFlexDatastore1.ResourceID := resID;
|
||||||
|
|
||||||
|
// Don't forget to re-activate the grid's datasources
|
||||||
|
QryAllResources.Open;
|
||||||
|
QryAllEvents.Open;
|
||||||
|
QryAllContacts.Open;
|
||||||
|
QryAllTasks.Open;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Setting up the database connection and the datastore. Preselect a resource
|
// Setting up the database connection and the datastore. Preselect a resource
|
||||||
@ -159,10 +182,38 @@ begin
|
|||||||
if PageControl1.PageIndex = 2 then TabControl1Change(nil);
|
if PageControl1.PageIndex = 2 then TabControl1Change(nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.QryGridAfterEdit(DataSet: TDataSet);
|
||||||
|
begin
|
||||||
|
BtnApplyToPlanner.Enabled := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.QryGridAfterInsert(DataSet: TDataSet);
|
||||||
|
begin
|
||||||
|
BtnApplyToPlanner.Enabled := false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TForm1.QryGridAfterPost(DataSet: TDataSet);
|
||||||
|
begin
|
||||||
|
// Note: UpdateMode must be upWhereAll! Otherwise there's an error "No update
|
||||||
|
// query specified and failed to generate one. (No fields for inclusion in
|
||||||
|
// where statement found)".
|
||||||
|
// http://wiki.freepascal.org/SqlDBHowto#How_does_SqlDB_send_the_changes_to_the_database_server.3F
|
||||||
|
|
||||||
|
TSQLQuery(Dataset).ApplyUpdates;
|
||||||
|
SQLTransaction1.CommitRetaining;
|
||||||
|
|
||||||
|
BtnApplyToPlanner.Enabled := true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.TabControl1Change(Sender: TObject);
|
procedure TForm1.TabControl1Change(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
DsAllResources.Dataset.Close;
|
||||||
|
DsAllContacts.Dataset.Close;
|
||||||
|
DsAllEvents.Dataset.Close;
|
||||||
|
DsAllTasks.Dataset.Close;
|
||||||
|
|
||||||
case TabControl1.TabIndex of
|
case TabControl1.TabIndex of
|
||||||
0: Grid.Datasource := DsAllResources;
|
0: Grid.Datasource := DsAllResources;
|
||||||
1: Grid.Datasource := DsAllContacts;
|
1: Grid.Datasource := DsAllContacts;
|
||||||
@ -170,6 +221,7 @@ begin
|
|||||||
3: Grid.Datasource := DsAllTasks;
|
3: Grid.Datasource := DsAllTasks;
|
||||||
end;
|
end;
|
||||||
DBNavigator.Datasource := Grid.Datasource;
|
DBNavigator.Datasource := Grid.Datasource;
|
||||||
|
Grid.Datasource.Dataset.Open;
|
||||||
for i:=0 to Grid.Columns.Count-1 do
|
for i:=0 to Grid.Columns.Count-1 do
|
||||||
Grid.Columns[i].Width := 100;;
|
Grid.Columns[i].Width := 100;;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user