-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubMain.pas
232 lines (202 loc) · 6.03 KB
/
SubMain.pas
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
unit SubMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Data.DB,
Vcl.Grids, Vcl.DBGrids, Vcl.ComCtrls, Vcl.Imaging.pngimage;
type
TSubMainForm = class(TForm)
StatusBar1: TStatusBar;
LeftPanel: TPanel;
RightPanel: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
EmpLeftPanel: TPanel;
DBGridEmpList: TDBGrid;
HouseLeftPanel: TPanel;
HouseRightPanel: TPanel;
DBGridStores: TDBGrid;
Image1: TImage;
Button1: TButton;
Button2: TButton;
Button3: TButton;
TabSheet3: TTabSheet;
LPanel: TPanel;
RPanel: TPanel;
DBGridOffers: TDBGrid;
OffersPanel: TPanel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure LoadImage;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure DBGridEmpListDrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGridEmpListDrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure ChangeStorePicture;
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure SetDBGridsWidth;
procedure PageControl1Change(Sender: TObject);
procedure StatusBarUpdate;
private
{ Private declarations }
public
{ Public declarations }
end;
var
SubMainForm: TSubMainForm;
implementation
{$R *.dfm}
uses DM, EditEmp, EditStore, EditPromo;
procedure TSubMainForm.Button1Click(Sender: TObject);
var
Panel1: TPanel;
begin
if PageControl1.ActivePageIndex = 0 then
begin
EditEmpForm.ShowModal;
end;
if PageControl1.ActivePageIndex = 1 then
begin
FormEditStore.ShowModal;
end;
if PageControl1.ActivePageIndex = 2 then
begin
FormEditPromotion.ShowModal;
end;
end;
procedure TSubMainForm.Button2Click(Sender: TObject);
begin
if Application.MessageBox('Óäàëèòü?','',MB_YESNO)=IDYES then
begin
if PageControl1.ActivePageIndex = 0 then
begin
DMl.ADOStoredProcGetEmpList.Delete;
end;
if PageControl1.ActivePageIndex = 1 then
begin
DMl.ADOQueryStore.Delete;
end;
if PageControl1.ActivePageIndex = 2 then
begin
DMl.ADOQueryGetPromo.Delete;
end;
end;
end;
procedure TSubMainForm.ChangeStorePicture;
begin
try
image1.Picture.LoadFromFile(GetCurrentDir+'/Images/'+DMl.ADOQueryStore.FieldByName('Image').Text);
except
image1.Picture.LoadFromFile(GetCurrentDir+ '\Images\no-image-large.jpg');
end;
end;
procedure TSubMainForm.Button3Click(Sender: TObject);
begin
if Application.MessageBox('Äîáàâèòü?','',MB_YESNO)=IDYES then
begin
if PageControl1.ActivePageIndex = 0 then
begin
EditEmpForm.ShowModal;
end;
if PageControl1.ActivePageIndex = 1 then
begin
FormEditStore.ShowModal;
end;
if PageControl1.ActivePageIndex = 2 then
begin
FormEditPromotion.ShowModal;
end;
end;
end;
procedure TSubMainForm.DBGridEmpListDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Assigned(Column) then
begin
DBGridEmpList.Canvas.FillRect(Rect);
DBGridEmpList.Canvas.TextRect(Rect, Rect.Left, Rect.Top, ' '+Column.Field.AsString);
end;
end;
procedure TSubMainForm.DBGridEmpListDrawDataCell(Sender: TObject;
const Rect: TRect; Field: TField; State: TGridDrawState);
var
Grid : TStringGrid;
Texto : String;
Rectangulo : TRect;
begin
Rectangulo:=Rect;
Grid := TStringGrid(Sender);
if Field.IsBlob then begin
Grid.Canvas.FillRect(Rect);
Texto := Field.AsString;
DrawText( Grid.Canvas.Handle,
PChar(Texto),
StrLen(PChar(Texto)),
Rectangulo,
DT_WORDBREAK);
end;
end;
procedure TSubMainForm.FormKeyPress(Sender: TObject; var Key: Char);
begin
if (Key = #27) then
Close;
end;
procedure TSubMainForm.FormShow(Sender: TObject); // Èçìåíåíèå øèðèíû
begin
LoadImage;
SetDBGridsWidth;
StatusBarUpdate;
end;
procedure TSubMainForm.LoadImage; // Çàãðóçêà èõîáðàæåíèé
begin
try
// Çàêîìåíòèðîâàíî ïî ïðè÷èíå îøèáêè
image1.Picture.LoadFromFile(GetCurrentDir+'/Images/'+DMl.ADOQueryStore.FieldByName('Image').Text);
except
image1.Picture.LoadFromFile(GetCurrentDir+ '/Images/no-image-large.jpg');
end;
end;
procedure TSubMainForm.PageControl1Change(Sender: TObject);
begin
SetDBGridsWidth;
StatusBarUpdate;
end;
procedure TSubMainForm.SetDBGridsWidth;
begin
DBGridEmpList.Columns[0].Visible := False;
DBGridEmpList.Columns[1].Width := 200;
DBGridEmpList.Columns[2].Width := 115;
DBGridEmpList.Columns[3].Width := 115;
DBGridEmpList.Columns[4].Width := 200;
DBGridStores.Columns[0].Visible := False;
DBGridStores.Columns[1].Width := 150;
DBGridStores.Columns[2].Width := 150;
DBGridStores.Columns[3].Width := 150;
DBGridStores.Columns[4].Visible := False;
DBGridOffers.Columns[0].Visible := False;
DBGridOffers.Columns[1].Width := 100;
DBGridOffers.Columns[1].Width := 200;
DBGridOffers.Columns[1].Width := 300;
end;
procedure TSubMainForm.StatusBarUpdate;
begin
if PageControl1.ActivePageIndex = 0 then
begin
StatusBar1.Panels.Items[0].Text := 'Íîìåð òåêóùåé çàïèñè: '+ IntToStr(DMl.ADOStoredProcGetEmpList.RecNo);
StatusBar1.Panels.Items[1].Text := 'Êîëè÷åñòâî çàïèñåé: '+ IntToStr(DMl.ADOStoredProcGetEmpList.RecordCount);
end;
if PageControl1.ActivePageIndex = 1 then
begin
StatusBar1.Panels.Items[0].Text := 'Íîìåð òåêóùåé çàïèñè: '+ IntToStr(DMl.ADOQueryStore.RecNo);
StatusBar1.Panels.Items[1].Text := 'Êîëè÷åñòâî çàïèñåé: '+ IntToStr(DMl.ADOQueryStore.RecordCount);
end;
if PageControl1.ActivePageIndex = 2 then
begin
StatusBar1.Panels.Items[0].Text := 'Íîìåð òåêóùåé çàïèñè: '+ IntToStr(DMl.ADOQueryGetPromo.RecNo);
StatusBar1.Panels.Items[1].Text := 'Êîëè÷åñòâî çàïèñåé: '+ IntToStr(DMl.ADOQueryGetPromo.RecordCount);
end;
end;
end.