Skip to content

Commit 4edd1dc

Browse files
Initial commit
0 parents  commit 4edd1dc

15 files changed

Lines changed: 9991 additions & 0 deletions

CPB/ReportTemplate.cbproj

Lines changed: 1301 additions & 0 deletions
Large diffs are not rendered by default.

CPB/ReportTemplate.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//---------------------------------------------------------------------------
2+
3+
#include <vcl.h>
4+
#pragma hdrstop
5+
#include <tchar.h>
6+
//---------------------------------------------------------------------------
7+
USEFORM("uMainForm.cpp", MainForm);
8+
USEFORM("uData.cpp", DataModule1); /* TDataModule: File Type */
9+
//---------------------------------------------------------------------------
10+
int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
11+
{
12+
try
13+
{
14+
Application->Initialize();
15+
Application->MainFormOnTaskBar = true;
16+
Application->CreateForm(__classid(TMainForm), &MainForm);
17+
Application->CreateForm(__classid(TDataModule1), &DataModule1);
18+
Application->Run();
19+
}
20+
catch (Exception &exception)
21+
{
22+
Application->ShowException(&exception);
23+
}
24+
catch (...)
25+
{
26+
try
27+
{
28+
throw Exception("");
29+
}
30+
catch (Exception &exception)
31+
{
32+
Application->ShowException(&exception);
33+
}
34+
}
35+
return 0;
36+
}
37+
//---------------------------------------------------------------------------

CPB/ReportTemplatePCH1.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <vcl.h>
2+
#include <tchar.h>
3+

CPB/uData.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//---------------------------------------------------------------------------
2+
3+
4+
#pragma hdrstop
5+
6+
#include "uData.h"
7+
//---------------------------------------------------------------------------
8+
#pragma package(smart_init)
9+
#pragma classgroup "Vcl.Controls.TControl"
10+
#pragma link "dxmdaset"
11+
#pragma resource "*.dfm"
12+
TDataModule1 *DataModule1;
13+
//---------------------------------------------------------------------------
14+
const String DataFileName = "..\\..\\data.dat";
15+
16+
17+
__fastcall TDataModule1::TDataModule1(TComponent* Owner)
18+
: TDataModule(Owner)
19+
{
20+
}
21+
//---------------------------------------------------------------------------
22+
void __fastcall TDataModule1::DataModuleCreate(TObject *Sender)
23+
{
24+
if (FileExists(DataFileName))
25+
mdLayouts->LoadFromBinaryFile(DataFileName);
26+
}
27+
//---------------------------------------------------------------------------
28+
29+
void __fastcall TDataModule1::DataModuleDestroy(TObject *Sender)
30+
{
31+
if (mdLayouts->RecordCount > 0)
32+
mdLayouts->SaveToBinaryFile(DataFileName);
33+
}
34+
//---------------------------------------------------------------------------
35+

CPB/uData.dfm

Lines changed: 3336 additions & 0 deletions
Large diffs are not rendered by default.

CPB/uData.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//---------------------------------------------------------------------------
2+
3+
#ifndef uDataH
4+
#define uDataH
5+
//---------------------------------------------------------------------------
6+
#include <System.Classes.hpp>
7+
#include "dxmdaset.hpp"
8+
#include <Data.DB.hpp>
9+
//---------------------------------------------------------------------------
10+
class TDataModule1 : public TDataModule
11+
{
12+
__published: // IDE-managed Components
13+
TDataSource *dsProducts;
14+
TDataSource *dsCategories;
15+
TdxMemData *mdCategories;
16+
TAutoIncField *mdCategoriesCategoryID;
17+
TWideStringField *mdCategoriesCategoryName;
18+
TWideMemoField *mdCategoriesDescription;
19+
TBlobField *mdCategoriesPicture;
20+
TdxMemData *mdProducts;
21+
TAutoIncField *mdProductsProductID;
22+
TWideStringField *mdProductsProductName;
23+
TIntegerField *mdProductsSupplierID;
24+
TIntegerField *mdProductsCategoryID;
25+
TWideStringField *mdProductsQuantityPerUnit;
26+
TCurrencyField *mdProductsUnitPrice;
27+
TSmallintField *mdProductsUnitsInStock;
28+
TSmallintField *mdProductsUnitsOnOrder;
29+
TSmallintField *mdProductsReorderLevel;
30+
TBooleanField *mdProductsDiscontinued;
31+
TWideStringField *mdProductsEAN13;
32+
TdxMemData *mdLayouts;
33+
TBlobField *mdLayoutsLayout;
34+
TWideStringField *mdLayoutsName;
35+
TDataSource *dsLayouts;
36+
void __fastcall DataModuleCreate(TObject *Sender);
37+
void __fastcall DataModuleDestroy(TObject *Sender);
38+
private: // User declarations
39+
public: // User declarations
40+
__fastcall TDataModule1(TComponent* Owner);
41+
};
42+
//---------------------------------------------------------------------------
43+
extern PACKAGE TDataModule1 *DataModule1;
44+
//---------------------------------------------------------------------------
45+
#endif

CPB/uMainForm.cpp

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//---------------------------------------------------------------------------
2+
3+
#include <vcl.h>
4+
#pragma hdrstop
5+
6+
#include "uMainForm.h"
7+
//---------------------------------------------------------------------------
8+
#pragma package(smart_init)
9+
#pragma link "cxButtons"
10+
#pragma link "cxClasses"
11+
#pragma link "cxControls"
12+
#pragma link "cxCustomData"
13+
#pragma link "cxData"
14+
#pragma link "cxDataStorage"
15+
#pragma link "cxDBData"
16+
#pragma link "cxEdit"
17+
#pragma link "cxFilter"
18+
#pragma link "cxGraphics"
19+
#pragma link "cxGrid"
20+
#pragma link "cxGridCustomTableView"
21+
#pragma link "cxGridCustomView"
22+
#pragma link "cxGridDBTableView"
23+
#pragma link "cxGridLevel"
24+
#pragma link "cxGridTableView"
25+
#pragma link "cxLookAndFeelPainters"
26+
#pragma link "cxLookAndFeels"
27+
#pragma link "cxNavigator"
28+
#pragma link "cxStyles"
29+
#pragma link "dxDateRanges"
30+
#pragma link "dxReport"
31+
#pragma link "dxReport.Backend"
32+
#pragma link "dxReport.ConnectionString.JSON"
33+
34+
#if defined(_WIN64)
35+
#pragma link "dxReport.ConnectionString.JSON.DB.O"
36+
#else
37+
#pragma link "dxReport.ConnectionString.JSON.DB.OBJ"
38+
#endif
39+
40+
41+
#pragma link "dxScrollbarAnnotations"
42+
#pragma link "dxmdaset"
43+
#pragma resource "*.dfm"
44+
TMainForm *MainForm;
45+
//---------------------------------------------------------------------------
46+
__fastcall TMainForm::TMainForm(TComponent* Owner)
47+
: TForm(Owner)
48+
{
49+
50+
}
51+
//---------------------------------------------------------------------------
52+
53+
//---------------------------------------------------------------------------
54+
void __fastcall TMainForm::btnNewClick(TObject *Sender)
55+
{
56+
DataModule1->mdLayouts->Append();
57+
}
58+
59+
void __fastcall TMainForm::btnShowDesignerClick(TObject *Sender)
60+
{
61+
if ((DataModule1->mdLayouts->RecordCount == 0) &&
62+
!(DataModule1->mdLayouts->State == dsInsert))
63+
{
64+
ShowMessage("The database is empty");
65+
return;
66+
}
67+
68+
dxReport1->ReportName = DataModule1->mdLayoutsName->AsString;
69+
dxReport1->Layout->Assign(DataModule1->mdLayoutsLayout);
70+
dxReport1->ShowDesigner();
71+
}
72+
73+
void __fastcall TMainForm::btnViewReportClick(TObject *Sender)
74+
{
75+
if (DataModule1->mdLayoutsName->AsString == "")
76+
{
77+
ShowMessage("The report is not specified");
78+
return;
79+
}
80+
81+
dxReport1->ReportName = DataModule1->mdLayoutsName->AsString;
82+
dxReport1->Layout->Assign(DataModule1->mdLayoutsLayout);
83+
dxReport1->ShowViewer();
84+
}
85+
86+
void __fastcall TMainForm::dxReport1LayoutChanged(TdxReport *ASender)
87+
{
88+
DataModule1->mdLayouts->Edit();
89+
DataModule1->mdLayoutsLayout->Assign(dxReport1->Layout);
90+
DataModule1->mdLayoutsName->AsString = dxReport1->ReportName;
91+
DataModule1->mdLayouts->Post();
92+
}
93+
//---------------------------------------------------------------------------
94+

CPB/uMainForm.dfm

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
object MainForm: TMainForm
2+
Left = 0
3+
Top = 0
4+
Caption = 'MainForm'
5+
ClientHeight = 835
6+
ClientWidth = 1040
7+
Color = clBtnFace
8+
Font.Charset = DEFAULT_CHARSET
9+
Font.Color = clWindowText
10+
Font.Height = -12
11+
Font.Name = 'Segoe UI'
12+
Font.Style = []
13+
TextHeight = 15
14+
object btnShowDesigner: TcxButton
15+
Left = 24
16+
Top = 32
17+
Width = 145
18+
Height = 25
19+
Caption = 'Show Designer'
20+
SpeedButtonOptions.CanBeFocused = False
21+
TabOrder = 0
22+
OnClick = btnShowDesignerClick
23+
end
24+
object btnViewReport: TcxButton
25+
Left = 192
26+
Top = 32
27+
Width = 193
28+
Height = 25
29+
Caption = 'View Report'
30+
TabOrder = 1
31+
OnClick = btnViewReportClick
32+
end
33+
object cxGrid1: TcxGrid
34+
Left = 272
35+
Top = 496
36+
Width = 521
37+
Height = 265
38+
TabOrder = 2
39+
object gvCategories: TcxGridDBTableView
40+
Navigator.Buttons.CustomButtons = <>
41+
ScrollbarAnnotations.CustomAnnotations = <>
42+
DataController.DataSource = DataModule1.dsCategories
43+
DataController.KeyFieldNames = 'CategoryID'
44+
DataController.Summary.DefaultGroupSummaryItems = <>
45+
DataController.Summary.FooterSummaryItems = <>
46+
DataController.Summary.SummaryGroups = <>
47+
object gvCategoriesCategoryID: TcxGridDBColumn
48+
DataBinding.FieldName = 'CategoryID'
49+
end
50+
object gvCategoriesCategoryName: TcxGridDBColumn
51+
DataBinding.FieldName = 'CategoryName'
52+
end
53+
object gvCategoriesDescription: TcxGridDBColumn
54+
DataBinding.FieldName = 'Description'
55+
end
56+
end
57+
object gvProducts: TcxGridDBTableView
58+
Navigator.Buttons.CustomButtons = <>
59+
ScrollbarAnnotations.CustomAnnotations = <>
60+
DataController.DataSource = DataModule1.dsProducts
61+
DataController.DetailKeyFieldNames = 'CategoryID'
62+
DataController.KeyFieldNames = 'ProductID'
63+
DataController.MasterKeyFieldNames = 'CategoryID'
64+
DataController.Summary.DefaultGroupSummaryItems = <>
65+
DataController.Summary.FooterSummaryItems = <>
66+
DataController.Summary.SummaryGroups = <>
67+
object gvProductsProductID: TcxGridDBColumn
68+
DataBinding.FieldName = 'ProductID'
69+
end
70+
object gvProductsProductName: TcxGridDBColumn
71+
DataBinding.FieldName = 'ProductName'
72+
Width = 244
73+
end
74+
object gvProductsSupplierID: TcxGridDBColumn
75+
DataBinding.FieldName = 'SupplierID'
76+
end
77+
object gvProductsCategoryID: TcxGridDBColumn
78+
DataBinding.FieldName = 'CategoryID'
79+
end
80+
object gvProductsQuantityPerUnit: TcxGridDBColumn
81+
DataBinding.FieldName = 'QuantityPerUnit'
82+
Width = 124
83+
end
84+
object gvProductsUnitPrice: TcxGridDBColumn
85+
DataBinding.FieldName = 'UnitPrice'
86+
end
87+
object gvProductsUnitsInStock: TcxGridDBColumn
88+
DataBinding.FieldName = 'UnitsInStock'
89+
end
90+
object gvProductsUnitsOnOrder: TcxGridDBColumn
91+
DataBinding.FieldName = 'UnitsOnOrder'
92+
end
93+
object gvProductsReorderLevel: TcxGridDBColumn
94+
DataBinding.FieldName = 'ReorderLevel'
95+
end
96+
object gvProductsDiscontinued: TcxGridDBColumn
97+
DataBinding.FieldName = 'Discontinued'
98+
Width = 34
99+
end
100+
object gvProductsEAN13: TcxGridDBColumn
101+
DataBinding.FieldName = 'EAN13'
102+
Width = 76
103+
end
104+
end
105+
object cxGrid1Level1: TcxGridLevel
106+
GridView = gvCategories
107+
object cxGrid1Level2: TcxGridLevel
108+
GridView = gvProducts
109+
end
110+
end
111+
end
112+
object cxGrid2: TcxGrid
113+
Left = 48
114+
Top = 192
115+
Width = 377
116+
Height = 249
117+
TabOrder = 3
118+
object gvLayouts: TcxGridDBTableView
119+
Navigator.Buttons.CustomButtons = <>
120+
ScrollbarAnnotations.CustomAnnotations = <>
121+
DataController.DataSource = DataModule1.dsLayouts
122+
DataController.Summary.DefaultGroupSummaryItems = <>
123+
DataController.Summary.FooterSummaryItems = <>
124+
DataController.Summary.SummaryGroups = <>
125+
OptionsData.CancelOnExit = False
126+
OptionsData.Deleting = False
127+
OptionsData.DeletingConfirmation = False
128+
OptionsData.Editing = False
129+
OptionsData.Inserting = False
130+
OptionsView.Indicator = True
131+
object gvLayoutsRecId: TcxGridDBColumn
132+
DataBinding.FieldName = 'RecId'
133+
Visible = False
134+
end
135+
object gvLayoutsLayout: TcxGridDBColumn
136+
DataBinding.FieldName = 'Layout'
137+
end
138+
object gvLayoutsName: TcxGridDBColumn
139+
DataBinding.FieldName = 'Name'
140+
end
141+
end
142+
object cxGrid2Level1: TcxGridLevel
143+
GridView = gvLayouts
144+
end
145+
end
146+
object btnNew: TcxButton
147+
Left = 24
148+
Top = 72
149+
Width = 145
150+
Height = 25
151+
Caption = 'New Report'
152+
TabOrder = 4
153+
OnClick = btnNewClick
154+
end
155+
object dxReport1: TdxReport
156+
OnLayoutChanged = dxReport1LayoutChanged
157+
Left = 48
158+
Top = 88
159+
end
160+
object dxReportDataConnectionManager1: TdxReportDataConnectionManager
161+
Left = 112
162+
Top = 88
163+
object dxReportDataConnectionManager1dxReportDataSetJSONConnection1: TdxReportDataSetJSONConnection
164+
DisplayName = 'DataSetConnection'
165+
object itmProducts: TdxReportDataSetCollectionItem
166+
DataSet = DataModule1.mdProducts
167+
DataSetAlias = 'mdProducts'
168+
end
169+
object itmCategories: TdxReportDataSetCollectionItem
170+
DataSet = DataModule1.mdCategories
171+
DataSetAlias = 'mdCategories'
172+
end
173+
end
174+
end
175+
end

0 commit comments

Comments
 (0)