-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuMainForm.pas
More file actions
157 lines (134 loc) · 4.75 KB
/
uMainForm.pas
File metadata and controls
157 lines (134 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
unit uMainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxClasses, dxReport, cxGraphics,
cxLookAndFeels, cxLookAndFeelPainters, Vcl.Menus, cxButtons,
cxControls, cxStyles, cxCustomData, cxFilter, cxData,
cxDataStorage, cxEdit, cxNavigator, dxScrollbarAnnotations,
Data.DB, cxDBData, cxGridLevel, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid,
Vcl.StdCtrls, dxmdaset, dxLayoutControlAdapters, dxLayoutContainer, dxLayoutControl,
dxBackend.Utils.WebBrowserForm, dxDashboard.Control, cxTextEdit, cxMaskEdit;
type
TMainForm = class(TForm)
btnNewDashboard: TcxButton;
btnDesign: TcxButton;
btnDelete: TcxButton;
gvLayouts: TcxGridDBTableView;
cxGrid2Level1: TcxGridLevel;
cxGrid2: TcxGrid;
gvLayoutsRecId: TcxGridDBColumn;
gvLayoutsLayout: TcxGridDBColumn;
gvLayoutsName: TcxGridDBColumn;
dxLayoutControl1Group_Root: TdxLayoutGroup;
dxLayoutControl1: TdxLayoutControl;
dxDashboardControl1: TdxDashboardControl;
lgButtons: TdxLayoutGroup;
liBtnNew: TdxLayoutItem;
liBtnShowDesigner: TdxLayoutItem;
liBtnDelete: TdxLayoutItem;
liGrid: TdxLayoutItem;
liDashboardControl: TdxLayoutItem;
gvLayoutsColumn1: TcxGridDBColumn;
procedure btnNewDashboardClick(Sender: TObject);
procedure btnDesignClick(Sender: TObject);
procedure btnDeleteClick(Sender: TObject);
procedure dxDashboardControl1LayoutChanged(ASender: TdxCustomDashboardControl);
procedure dxDashboardControl1StateChanged(ASender: TdxCustomDashboardControl);
procedure gvLayoutsFocusedRecordChanged(Sender: TcxCustomGridTableView;
APrevFocusedRecord, AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
procedure FormCreate(Sender: TObject);
procedure gvLayoutsEditValueChanged(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem);
procedure gvLayoutsNamePropertiesValidate(Sender: TObject;
var DisplayValue: TcxEditValue; var ErrorText: TCaption;
var Error: Boolean);
private
{ Private declarations }
procedure LoadLayoutAndState;
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
uses uData;
procedure TMainForm.FormCreate(Sender: TObject);
begin
LoadLayoutAndState;
end;
procedure TMainForm.LoadLayoutAndState;
begin
if (DataModule1.mdLayouts.RecordCount = 0) and (DataModule1.mdLayouts.State <> dsInsert) then
begin
dxDashboardControl1.Clear;
Exit;
end;
dxDashboardControl1.DashboardName := DataModule1.mdLayoutsName.AsString;
dxDashboardControl1.Layout.Assign(DataModule1.mdLayoutsLayout);
if not DataModule1.mdLayoutsState.IsNull then
dxDashboardControl1.State.Assign(DataModule1.mdLayoutsState);
dxDashboardControl1.Active := True;
end;
procedure TMainForm.btnDeleteClick(Sender: TObject);
begin
DataModule1.mdLayouts.Delete;
end;
procedure TMainForm.btnDesignClick(Sender: TObject);
begin
dxDashboardControl1.ShowDesigner;
end;
procedure TMainForm.btnNewDashboardClick(Sender: TObject);
begin
dxDashboardControl1.Clear;
dxDashboardControl1.ShowDesigner;
end;
procedure TMainForm.gvLayoutsNamePropertiesValidate(Sender: TObject;
var DisplayValue: TcxEditValue; var ErrorText: TCaption; var Error: Boolean);
begin
if DisplayValue = '' then
begin
Error := True;
ErrorText := 'Dashboard name cannot be blank.'
end;
end;
procedure TMainForm.gvLayoutsEditValueChanged(Sender: TcxCustomGridTableView;
AItem: TcxCustomGridTableItem);
begin
if AItem = gvLayoutsName then
dxDashboardControl1.DashboardName := AItem.EditValue;
end;
procedure TMainForm.gvLayoutsFocusedRecordChanged(
Sender: TcxCustomGridTableView; APrevFocusedRecord,
AFocusedRecord: TcxCustomGridRecord; ANewItemRecordFocusingChanged: Boolean);
begin
if AFocusedRecord = nil then
dxDashboardControl1.Clear;
if (AFocusedRecord <> APrevFocusedRecord) and (DataModule1.mdLayouts.State <> dsInsert) then
LoadLayoutAndState;
end;
procedure TMainForm.dxDashboardControl1LayoutChanged(
ASender: TdxCustomDashboardControl);
begin
dxDashboardControl1.Active := True;
if DataModule1.mdLayoutsName.AsString <> dxDashboardControl1.DashboardName then
begin
DataModule1.mdLayouts.Append;
DataModule1.mdLayoutsName.AsString := dxDashboardControl1.DashboardName;
end
else
DataModule1.mdLayouts.Edit;
DataModule1.mdLayoutsLayout.Assign(dxDashboardControl1.Layout);
DataModule1.mdLayouts.Post;
end;
procedure TMainForm.dxDashboardControl1StateChanged(
ASender: TdxCustomDashboardControl);
begin
DataModule1.mdLayouts.Edit;
DataModule1.mdLayoutsState.Assign(dxDashboardControl1.State);
DataModule1.mdLayouts.Post;
end;
end.