Skip to content

Commit f186d1d

Browse files
committed
readme: draft
1 parent eb23b42 commit f186d1d

File tree

10 files changed

+293
-29
lines changed

10 files changed

+293
-29
lines changed

Delphi/StoreReportInDB.res

-123 KB
Binary file not shown.

Delphi/example.dat

24.5 KB
Binary file not shown.

Delphi/uMainForm.dfm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ object MainForm: TMainForm
1111
Font.Height = -12
1212
Font.Name = 'Segoe UI'
1313
Font.Style = []
14+
OnCreate = FormCreate
1415
TextHeight = 15
1516
object dxLayoutControl1: TdxLayoutControl
1617
Left = 0
@@ -44,6 +45,8 @@ object MainForm: TMainForm
4445
Height = 133
4546
TabOrder = 3
4647
object gvLayouts: TcxGridDBTableView
48+
OnEditValueChanged = gvLayoutsEditValueChanged
49+
OnFocusedItemChanged = gvLayoutsFocusedItemChanged
4750
DataController.DataSource = DataModule1.dsLayouts
4851
OptionsData.CancelOnExit = False
4952
OptionsData.Deleting = False

Delphi/uMainForm.pas

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ interface
99
cxStyles, Data.DB, cxDBData, dxLayoutControlAdapters,
1010
dxLayoutContainer, dxReport, cxGridLevel, cxGridCustomTableView,
1111
cxGridTableView, cxGridDBTableView, cxClasses, cxGridCustomView, cxGrid,
12-
cxButtons, dxLayoutControl;
12+
cxButtons, dxLayoutControl, cxCustomData, cxFilter, cxData, cxDataStorage,
13+
cxEdit, cxNavigator, dxDateRanges, dxScrollbarAnnotations;
1314

1415
type
1516
TMainForm = class(TForm)
@@ -29,11 +30,18 @@ TMainForm = class(TForm)
2930
liShowDesigner: TdxLayoutItem;
3031
liViewReport: TdxLayoutItem;
3132
liGrid: TdxLayoutItem;
33+
procedure FormCreate(Sender: TObject);
3234
procedure btnDesignClick(Sender: TObject);
3335
procedure btnPreviewClick(Sender: TObject);
3436
procedure btnNewClick(Sender: TObject);
3537
procedure dxReport1LayoutChanged(ASender: TdxReport);
38+
procedure gvLayoutsEditValueChanged(Sender: TcxCustomGridTableView; AItem:
39+
TcxCustomGridTableItem);
40+
procedure gvLayoutsFocusedItemChanged(Sender: TcxCustomGridTableView;
41+
APrevFocusedItem, AFocusedItem: TcxCustomGridTableItem);
3642
private
43+
procedure LoadReportNameAndLayout;
44+
procedure SaveReportNameAndLayout;
3745
{ Private declarations }
3846
public
3947
{ Public declarations }
@@ -48,43 +56,85 @@ implementation
4856

4957
uses uData;
5058

59+
procedure TMainForm.LoadReportNameAndLayout();
60+
begin
61+
if (DataModule1.mdLayouts.RecordCount = 0) and not (DataModule1.mdLayouts.State = dsInsert) then
62+
begin
63+
ShowMessage('The database is empty');
64+
Exit;
65+
end;
66+
// Load the report name from the database
67+
dxReport1.ReportName := DataModule1.mdLayoutsName.AsString;
68+
// Load the report layout from the database
69+
dxReport1.Layout.Assign(DataModule1.mdLayoutsLayout);
70+
end;
71+
72+
procedure TMainForm.SaveReportNameAndLayout();
73+
begin
74+
// Start editing the active dataset record
75+
DataModule1.mdLayouts.Edit;
76+
// Save the report name
77+
DataModule1.mdLayoutsName.AsString := dxReport1.ReportName;
78+
// Save the report layout
79+
DataModule1.mdLayoutsLayout.Assign(dxReport1.Layout);
80+
// Finish editing and write a modified record
81+
DataModule1.mdLayouts.Post;
82+
end;
83+
84+
// Handle the OnFormCreate event called when the application starts
85+
procedure TMainForm.FormCreate(Sender: TObject);
86+
begin
87+
LoadReportNameAndLayout;
88+
end;
89+
90+
// Handle the OnLayoutChanged event called when a user saves a report layout in the Report Designer
91+
procedure TMainForm.dxReport1LayoutChanged(ASender: TdxReport);
92+
begin
93+
SaveReportNameAndLayout;
94+
end;
5195

96+
// Handle the OnFocusedItemChanged event called when a user selects a different row
97+
// in the Grid Table View
98+
procedure TMainForm.gvLayoutsFocusedItemChanged(Sender: TcxCustomGridTableView;
99+
APrevFocusedItem, AFocusedItem: TcxCustomGridTableItem);
100+
begin
101+
LoadReportNameAndLayout;
102+
end;
103+
104+
// Handle the OnEditValueChanged event called when a user edits the layout name
105+
// in the Grid Table View
106+
procedure TMainForm.gvLayoutsEditValueChanged(Sender: TcxCustomGridTableView;
107+
AItem: TcxCustomGridTableItem);
108+
begin
109+
LoadReportNameAndLayout;
110+
end;
111+
112+
// To create a new report layout, create a new dataset record
52113
procedure TMainForm.btnNewClick(Sender: TObject);
53114
begin
54115
DataModule1.mdLayouts.Append
55116
end;
56117

57118
procedure TMainForm.btnDesignClick(Sender: TObject);
58119
begin
59-
if (DataModule1.mdLayouts.RecordCount = 0) and not (DataModule1.mdLayouts.State = dsInsert) then
120+
if (dxReport1.ReportName = '') then
60121
begin
61-
ShowMessage('The database is empty');
122+
ShowMessage('The report is not specified');
62123
Exit;
63124
end;
64-
dxReport1.ReportName := DataModule1.mdLayoutsName.AsString;
65-
dxReport1.Layout.Assign(DataModule1.mdLayoutsLayout);
66125
dxReport1.ShowDesigner;
67126
end;
68127

69128
procedure TMainForm.btnPreviewClick(Sender: TObject);
70129
begin
71-
if (DataModule1.mdLayoutsName.AsString = '') then
130+
if (dxReport1.ReportName = '') then
72131
begin
73132
ShowMessage('The report is not specified');
74133
Exit;
75134
end;
76-
77-
dxReport1.ReportName := DataModule1.mdLayoutsName.AsString;
78-
dxReport1.Layout.Assign(DataModule1.mdLayoutsLayout);
79135
dxReport1.ShowViewer;
80136
end;
81137

82-
procedure TMainForm.dxReport1LayoutChanged(ASender: TdxReport);
83-
begin
84-
DataModule1.mdLayouts.Edit;
85-
DataModule1.mdLayoutsLayout.Assign(dxReport1.Layout);
86-
DataModule1.mdLayoutsName.AsString := dxReport1.ReportName;
87-
DataModule1.mdLayouts.Post;
88-
end;
138+
89139

90140
end.

0 commit comments

Comments
 (0)