root / UnitIngredientsList.pas @ 5
Historique | Voir | Annoter | Télécharger (22,295 ko)
1 |
unit UnitIngredientsList;
|
---|---|
2 |
|
3 |
interface
|
4 |
|
5 |
uses
|
6 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
7 |
Dialogs, StdCtrls, ComCtrls, ExtCtrls, DB, DBGrids, Grids, ActnList, ImgList, |
8 |
ToolWin, Buttons, JvDBUltimGrid, JvExDBGrids, JvDBGrid, gnugettext, |
9 |
JvExStdCtrls, JvButton, JvCtrls; |
10 |
|
11 |
type
|
12 |
TFormIngredientsList = class(TForm)
|
13 |
PageControlLists: TPageControl; |
14 |
TabSheetProximal: TTabSheet; |
15 |
TabSheetEnergy: TTabSheet; |
16 |
TabSheetAATot: TTabSheet; |
17 |
TabSheetAADig: TTabSheet; |
18 |
DBGridProximal: TDBGrid; |
19 |
DBGridEnergy: TDBGrid; |
20 |
DBGridAATot: TDBGrid; |
21 |
DBGridAADig: TDBGrid; |
22 |
TabSheetEnergyUtilization: TTabSheet; |
23 |
DBGridRatios: TDBGrid; |
24 |
TabSheetMinerals: TTabSheet; |
25 |
DBGridMinerals: TDBGrid; |
26 |
TabSheetAA_MAT: TTabSheet; |
27 |
TabSheetdAA: TTabSheet; |
28 |
DBGridAA_MAT: TDBGrid; |
29 |
DBGriddAA: TDBGrid; |
30 |
TabSheetMS: TTabSheet; |
31 |
DBGridMS: TDBGrid; |
32 |
TabSheetdP: TTabSheet; |
33 |
DBGriddP: TDBGrid; |
34 |
SplitterList: TSplitter; |
35 |
ImageListIcons: TImageList; |
36 |
ActionListButtons: TActionList; |
37 |
ActionView: TAction; |
38 |
ActionCreate: TAction; |
39 |
ActionHelp: TAction; |
40 |
ActionClose: TAction; |
41 |
LabelWarning: TLabel; |
42 |
GroupBoxFilters: TGroupBox; |
43 |
LabelFilteredClass: TLabel; |
44 |
LabelFilteredDatabase: TLabel; |
45 |
LabelFilteredName: TLabel; |
46 |
ComboBoxClass: TComboBox; |
47 |
ComboBoxDatabase: TComboBox; |
48 |
EditName: TEdit; |
49 |
CheckBoxClass: TCheckBox; |
50 |
CheckBoxDatabase: TCheckBox; |
51 |
CheckBoxName: TCheckBox; |
52 |
PanelButtons: TPanel; |
53 |
PanelName: TPanel; |
54 |
DBGridName: TDBGrid; |
55 |
JvImgBtnView: TJvImgBtn; |
56 |
JvImgBtnCreate: TJvImgBtn; |
57 |
JvImgBtnHelp: TJvImgBtn; |
58 |
JvImgBtnClose: TJvImgBtn; |
59 |
procedure FormCreate(Sender: TObject);
|
60 |
procedure ComboBoxClassChange(Sender: TObject);
|
61 |
procedure DBGridTitleClick(Column: TColumn);
|
62 |
procedure DBGridDrawColumnCell(Sender: TObject; const Rect: TRect; |
63 |
DataCol: Integer; Column: TColumn; State: TGridDrawState); |
64 |
procedure EditNameChange(Sender: TObject);
|
65 |
procedure CheckBoxFilterClick(Sender: TObject);
|
66 |
procedure PageControlListsChange(Sender: TObject);
|
67 |
procedure FormDestroy(Sender: TObject);
|
68 |
procedure DBGridDblClick(Sender: TObject);
|
69 |
procedure FormShow(Sender: TObject);
|
70 |
procedure ComboBoxDatabaseChange(Sender: TObject);
|
71 |
procedure SplitterListMoved(Sender: TObject);
|
72 |
procedure FormResize(Sender: TObject);
|
73 |
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; |
74 |
procedure ActionViewExecute(Sender: TObject);
|
75 |
procedure ActionCreateExecute(Sender: TObject);
|
76 |
procedure ActionHelpExecute(Sender: TObject);
|
77 |
procedure ActionCloseExecute(Sender: TObject);
|
78 |
private
|
79 |
{ D?clarations priv?es }
|
80 |
DBGridNameOldWindowProc: TWndMethod; |
81 |
DBGridMSOldWindowProc: TWndMethod; |
82 |
DBGridProximalOldWindowProc: TWndMethod; |
83 |
DBGridRatiosOldWindowProc: TWndMethod; |
84 |
DBGridEnergyOldWindowProc: TWndMethod; |
85 |
DBGridAATotOldWindowProc: TWndMethod; |
86 |
DBGridAA_MATOldWindowProc: TWndMethod; |
87 |
DBGriddAAOldWindowProc: TWndMethod; |
88 |
DBGridAADigOldWindowProc: TWndMethod; |
89 |
DBGridMineralsOldWindowProc: TWndMethod; |
90 |
DBGriddPOldWindowProc: TWndMethod; |
91 |
Procedure DBGridNameNewWindowProc(var Msg: TMessage); |
92 |
Procedure DBGridMSNewWindowProc(var Msg: TMessage); |
93 |
Procedure DBGridProximalNewWindowProc(var Msg: TMessage); |
94 |
Procedure DBGridRatiosNewWindowProc(var Msg: TMessage); |
95 |
Procedure DBGridEnergyNewWindowProc(var Msg: TMessage); |
96 |
Procedure DBGridAATotNewWindowProc(var Msg: TMessage); |
97 |
Procedure DBGridAA_MATNewWindowProc(var Msg: TMessage); |
98 |
Procedure DBGriddAANewWindowProc(var Msg: TMessage); |
99 |
Procedure DBGridAADigNewWindowProc(var Msg: TMessage); |
100 |
Procedure DBGridMineralsNewWindowProc(var Msg: TMessage); |
101 |
Procedure DBGriddPNewWindowProc(var Msg: TMessage); |
102 |
public
|
103 |
{ D?clarations publiques }
|
104 |
end;
|
105 |
|
106 |
var
|
107 |
FormIngredientsList: TFormIngredientsList; |
108 |
|
109 |
implementation
|
110 |
|
111 |
{$R *.dfm}
|
112 |
|
113 |
uses
|
114 |
UnitDeclaration, UnitOptions, UnitIngredientCreation, UnitIngredientDetail; |
115 |
|
116 |
procedure TFormIngredientsList.ActionCloseExecute(Sender: TObject);
|
117 |
begin
|
118 |
ModalResult := mrClose; |
119 |
end;
|
120 |
|
121 |
procedure TFormIngredientsList.ActionCreateExecute(Sender: TObject);
|
122 |
begin
|
123 |
FormIngredientCreation := TFormIngredientCreation.Create(nil);
|
124 |
try
|
125 |
// D?sactiver les filtres
|
126 |
CheckBoxClass.Checked := False; |
127 |
CheckBoxDatabase.Checked := False; |
128 |
CheckBoxName.Checked := False; |
129 |
if FormIngredientCreation.ShowModal = mrOk
|
130 |
then
|
131 |
begin
|
132 |
FormIngredientDetail := TFormIngredientDetail.Create(nil);
|
133 |
try
|
134 |
// Modifier le nouvel enregistrement
|
135 |
FormIngredientDetail.ActionModifyExecute(Sender); |
136 |
FormIngredientDetail.ShowModal; |
137 |
finally
|
138 |
FormIngredientDetail.Release; |
139 |
end;
|
140 |
end;
|
141 |
finally
|
142 |
FormIngredientCreation.Release; |
143 |
end;
|
144 |
end;
|
145 |
|
146 |
procedure TFormIngredientsList.ActionHelpExecute(Sender: TObject);
|
147 |
begin
|
148 |
Application.HelpContext(HelpContext); |
149 |
end;
|
150 |
|
151 |
procedure TFormIngredientsList.ActionViewExecute(Sender: TObject);
|
152 |
begin
|
153 |
if DataModuleDeclaration.ClientDataSetIngredients.RecordCount = 0 |
154 |
then // Aucun enregistrement affich? (filtres) |
155 |
Exit; |
156 |
FormIngredientDetail := TFormIngredientDetail.Create(nil);
|
157 |
try
|
158 |
FormIngredientDetail.ShowModal; |
159 |
finally
|
160 |
FormIngredientDetail.Release; |
161 |
end;
|
162 |
end;
|
163 |
|
164 |
procedure TFormIngredientsList.CheckBoxFilterClick(Sender: TObject);
|
165 |
var
|
166 |
Id, User: Integer; |
167 |
begin
|
168 |
if CheckBoxClass.Checked
|
169 |
then
|
170 |
begin
|
171 |
LabelFilteredClass.Caption := _('Enabled');
|
172 |
LabelFilteredClass.Font.Color := clGreen; |
173 |
end
|
174 |
else
|
175 |
begin
|
176 |
LabelFilteredClass.Caption := _('Disabled');
|
177 |
LabelFilteredClass.Font.Color := clRed; |
178 |
end;
|
179 |
ComboBoxClass.Enabled := CheckBoxClass.Checked; |
180 |
if CheckBoxDatabase.Checked
|
181 |
then
|
182 |
begin
|
183 |
LabelFilteredDatabase.Caption := _('Enabled');
|
184 |
LabelFilteredDatabase.Font.Color := clGreen; |
185 |
end
|
186 |
else
|
187 |
begin
|
188 |
LabelFilteredDatabase.Caption := _('Disabled');
|
189 |
LabelFilteredDatabase.Font.Color := clRed; |
190 |
end;
|
191 |
ComboBoxDatabase.Enabled := CheckBoxDatabase.Checked; |
192 |
if CheckBoxName.Checked
|
193 |
then
|
194 |
begin
|
195 |
LabelFilteredName.Caption := _('Enabled');
|
196 |
LabelFilteredName.Font.Color := clGreen; |
197 |
end
|
198 |
else
|
199 |
begin
|
200 |
LabelFilteredName.Caption := _('Disabled');
|
201 |
LabelFilteredName.Font.Color := clRed; |
202 |
end;
|
203 |
EditName.Enabled := CheckBoxName.Checked; |
204 |
with DataModuleDeclaration do |
205 |
begin
|
206 |
Id := ClientDataSetIngredientsId.Value; |
207 |
if ClientDataSetIngredientsUser.Value
|
208 |
then
|
209 |
User := 1
|
210 |
else
|
211 |
User := 0;
|
212 |
ClientDataSetIngredients.Filtered := False; |
213 |
FilterOnClass := CheckBoxClass.Checked; |
214 |
FilteredClass := ComboBoxClass.ItemIndex + 1;
|
215 |
FilterOnDatabase := CheckBoxDatabase.Checked; |
216 |
FilteredDatabase := ComboBoxDatabase.ItemIndex + 1;
|
217 |
FilterOnName := CheckBoxName.Checked; |
218 |
FilteredName := Trim(EditName.Text); |
219 |
if (FilterOnClass and (FilteredClass <> 0)) |
220 |
or (FilterOnDatabase and (FilteredDatabase <> 0)) |
221 |
or (FilterOnName and (FilteredName <> '')) |
222 |
then
|
223 |
ClientDataSetIngredients.Filtered := True; |
224 |
ClientDataSetIngredients.Locate('Id;User', VarArrayOf([Id, User]), [])
|
225 |
end;
|
226 |
end;
|
227 |
|
228 |
procedure TFormIngredientsList.ComboBoxClassChange(Sender: TObject);
|
229 |
begin
|
230 |
if CheckBoxClass.Checked
|
231 |
then
|
232 |
CheckBoxFilterClick(nil);
|
233 |
end;
|
234 |
|
235 |
procedure TFormIngredientsList.ComboBoxDatabaseChange(Sender: TObject);
|
236 |
begin
|
237 |
if CheckBoxDatabase.Checked
|
238 |
then
|
239 |
CheckBoxFilterClick(nil);
|
240 |
end;
|
241 |
|
242 |
procedure TFormIngredientsList.DBGridDblClick(Sender: TObject);
|
243 |
begin
|
244 |
// ButtonViewClick(nil);
|
245 |
ActionViewExecute(nil);
|
246 |
end;
|
247 |
|
248 |
procedure TFormIngredientsList.DBGridDrawColumnCell(Sender: TObject;
|
249 |
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
250 |
begin
|
251 |
with Sender as TDBGrid do |
252 |
begin
|
253 |
if Column.FieldName = DataModuleDeclaration.ClientDataSetIngredients.IndexFieldNames
|
254 |
then // Colonne tri?e |
255 |
Canvas.Font.Style := Canvas.Font.Style + [fsBold]; |
256 |
if Column.FieldName = 'Name' |
257 |
then // Couleur particuli?re pour indiquer la base d'origine |
258 |
if gdSelected in State |
259 |
then // Cellule courante |
260 |
begin
|
261 |
if DataModuleDeclaration.ClientDataSetIngredientsUser.Value
|
262 |
then // User |
263 |
Canvas.Font.Color := clWebPaleTurquoise |
264 |
else // InraAfz |
265 |
Canvas.Font.Color := clWebLightPink; |
266 |
Canvas.Brush.Color := clWebGray; |
267 |
end
|
268 |
else // Cellule normale |
269 |
begin
|
270 |
Canvas.Font.Color := clWebBlack; |
271 |
if DataModuleDeclaration.ClientDataSetIngredientsUser.Value
|
272 |
then // User |
273 |
Canvas.Brush.Color := clWebPaleTurquoise |
274 |
else // InraAfz |
275 |
Canvas.Brush.Color := clWebLightPink; |
276 |
end
|
277 |
else // Valeurs |
278 |
begin
|
279 |
if gdSelected in State |
280 |
then // Cellule courante |
281 |
begin
|
282 |
Canvas.Font.Color := clWebWhite; |
283 |
Canvas.Brush.Color := clWebGray; |
284 |
end
|
285 |
else
|
286 |
begin
|
287 |
Canvas.Font.Color := clWebBlack; |
288 |
Canvas.Brush.Color := clWebLightGrey; |
289 |
end;
|
290 |
if ((Sender = DBGridProximal) and (Column.FieldName <> 'MS2')) |
291 |
or (Sender = DBGridMinerals)
|
292 |
then
|
293 |
with DataModuleDeclaration do |
294 |
if ClientDataSetIngredientsUser.Value
|
295 |
then // User |
296 |
begin
|
297 |
TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
|
298 |
+ Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
|
299 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex[Column.FieldName])
|
300 |
then // Valeur h?rit?e du mod?le |
301 |
begin
|
302 |
Canvas.Font.Style := Canvas.Font.Style + [fsItalic]; |
303 |
if gdSelected in State |
304 |
then // Cellule courante |
305 |
Canvas.Font.Color := clWebSilver |
306 |
else
|
307 |
Canvas.Font.Color := clWebDimGray; |
308 |
end;
|
309 |
TableIngredients.Free; |
310 |
end;
|
311 |
end;
|
312 |
DefaultDrawColumnCell(Rect, DataCol, Column, State); |
313 |
end;
|
314 |
end;
|
315 |
|
316 |
procedure TFormIngredientsList.DBGridNameNewWindowProc(var Msg: TMessage); |
317 |
begin
|
318 |
if Msg.Msg = WM_MOUSEWHEEL
|
319 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
320 |
if SmallInt(Msg.WParamHi) < 0 |
321 |
then
|
322 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
323 |
else
|
324 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
325 |
else // Traitement des autres messages |
326 |
begin
|
327 |
if Msg.Msg = WM_NCCALCSIZE
|
328 |
then // Forcer l'affichage des ascenseurs |
329 |
ShowScrollBar(DBGridName.Handle, SB_BOTH, True); |
330 |
DBGridNameOldWindowProc(Msg); |
331 |
end;
|
332 |
end;
|
333 |
|
334 |
procedure TFormIngredientsList.DBGridMSNewWindowProc(var Msg: TMessage); |
335 |
begin
|
336 |
if Msg.Msg = WM_MOUSEWHEEL
|
337 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
338 |
if SmallInt(Msg.WParamHi) < 0 |
339 |
then
|
340 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
341 |
else
|
342 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
343 |
else // Traitement des autres messages |
344 |
begin
|
345 |
if Msg.Msg = WM_NCCALCSIZE
|
346 |
then // Forcer l'affichage des ascenseurs |
347 |
ShowScrollBar(DBGridMS.Handle, SB_BOTH, True); |
348 |
DBGridMSOldWindowProc(Msg); |
349 |
end;
|
350 |
end;
|
351 |
|
352 |
procedure TFormIngredientsList.DBGridProximalNewWindowProc(var Msg: TMessage); |
353 |
begin
|
354 |
if Msg.Msg = WM_MOUSEWHEEL
|
355 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
356 |
if SmallInt(Msg.WParamHi) < 0 |
357 |
then
|
358 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
359 |
else
|
360 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
361 |
else // Traitement des autres messages |
362 |
begin
|
363 |
if Msg.Msg = WM_NCCALCSIZE
|
364 |
then // Forcer l'affichage des ascenseurs |
365 |
ShowScrollBar(DBGridProximal.Handle, SB_BOTH, True); |
366 |
DBGridProximalOldWindowProc(Msg); |
367 |
end;
|
368 |
end;
|
369 |
|
370 |
procedure TFormIngredientsList.DBGridRatiosNewWindowProc(var Msg: TMessage); |
371 |
begin
|
372 |
if Msg.Msg = WM_MOUSEWHEEL
|
373 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
374 |
if SmallInt(Msg.WParamHi) < 0 |
375 |
then
|
376 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
377 |
else
|
378 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
379 |
else // Traitement des autres messages |
380 |
begin
|
381 |
if Msg.Msg = WM_NCCALCSIZE
|
382 |
then // Forcer l'affichage des ascenseurs |
383 |
ShowScrollBar(DBGridRatios.Handle, SB_BOTH, True); |
384 |
DBGridRatiosOldWindowProc(Msg); |
385 |
end;
|
386 |
end;
|
387 |
|
388 |
procedure TFormIngredientsList.DBGridEnergyNewWindowProc(var Msg: TMessage); |
389 |
begin
|
390 |
if Msg.Msg = WM_MOUSEWHEEL
|
391 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
392 |
if SmallInt(Msg.WParamHi) < 0 |
393 |
then
|
394 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
395 |
else
|
396 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
397 |
else // Traitement des autres messages |
398 |
begin
|
399 |
if Msg.Msg = WM_NCCALCSIZE
|
400 |
then // Forcer l'affichage des ascenseurs |
401 |
ShowScrollBar(DBGridEnergy.Handle, SB_BOTH, True); |
402 |
DBGridEnergyOldWindowProc(Msg); |
403 |
end;
|
404 |
end;
|
405 |
|
406 |
procedure TFormIngredientsList.DBGridAATotNewWindowProc(var Msg: TMessage); |
407 |
begin
|
408 |
if Msg.Msg = WM_MOUSEWHEEL
|
409 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
410 |
if SmallInt(Msg.WParamHi) < 0 |
411 |
then
|
412 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
413 |
else
|
414 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
415 |
else // Traitement des autres messages |
416 |
begin
|
417 |
if Msg.Msg = WM_NCCALCSIZE
|
418 |
then // Forcer l'affichage des ascenseurs |
419 |
ShowScrollBar(DBGridAATot.Handle, SB_BOTH, True); |
420 |
DBGridAATotOldWindowProc(Msg); |
421 |
end;
|
422 |
end;
|
423 |
|
424 |
procedure TFormIngredientsList.DBGridAA_MATNewWindowProc(var Msg: TMessage); |
425 |
begin
|
426 |
if Msg.Msg = WM_MOUSEWHEEL
|
427 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
428 |
if SmallInt(Msg.WParamHi) < 0 |
429 |
then
|
430 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
431 |
else
|
432 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
433 |
else // Traitement des autres messages |
434 |
begin
|
435 |
if Msg.Msg = WM_NCCALCSIZE
|
436 |
then // Forcer l'affichage des ascenseurs |
437 |
ShowScrollBar(DBGridAA_MAT.Handle, SB_BOTH, True); |
438 |
DBGridAA_MATOldWindowProc(Msg); |
439 |
end;
|
440 |
end;
|
441 |
|
442 |
procedure TFormIngredientsList.DBGriddAANewWindowProc(var Msg: TMessage); |
443 |
begin
|
444 |
if Msg.Msg = WM_MOUSEWHEEL
|
445 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
446 |
if SmallInt(Msg.WParamHi) < 0 |
447 |
then
|
448 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
449 |
else
|
450 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
451 |
else // Traitement des autres messages |
452 |
begin
|
453 |
if Msg.Msg = WM_NCCALCSIZE
|
454 |
then // Forcer l'affichage des ascenseurs |
455 |
ShowScrollBar(DBGriddAA.Handle, SB_BOTH, True); |
456 |
DBGriddAAOldWindowProc(Msg); |
457 |
end;
|
458 |
end;
|
459 |
|
460 |
procedure TFormIngredientsList.DBGridAADigNewWindowProc(var Msg: TMessage); |
461 |
begin
|
462 |
if Msg.Msg = WM_MOUSEWHEEL
|
463 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
464 |
if SmallInt(Msg.WParamHi) < 0 |
465 |
then
|
466 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
467 |
else
|
468 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
469 |
else // Traitement des autres messages |
470 |
begin
|
471 |
if Msg.Msg = WM_NCCALCSIZE
|
472 |
then // Forcer l'affichage des ascenseurs |
473 |
ShowScrollBar(DBGridAADig.Handle, SB_BOTH, True); |
474 |
DBGridAADigOldWindowProc(Msg); |
475 |
end;
|
476 |
end;
|
477 |
|
478 |
procedure TFormIngredientsList.DBGridMineralsNewWindowProc(var Msg: TMessage); |
479 |
begin
|
480 |
if Msg.Msg = WM_MOUSEWHEEL
|
481 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
482 |
if SmallInt(Msg.WParamHi) < 0 |
483 |
then
|
484 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
485 |
else
|
486 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
487 |
else // Traitement des autres messages |
488 |
begin
|
489 |
if Msg.Msg = WM_NCCALCSIZE
|
490 |
then // Forcer l'affichage des ascenseurs |
491 |
ShowScrollBar(DBGridMinerals.Handle, SB_BOTH, True); |
492 |
DBGridMineralsOldWindowProc(Msg); |
493 |
end;
|
494 |
end;
|
495 |
|
496 |
procedure TFormIngredientsList.DBGriddPNewWindowProc(var Msg: TMessage); |
497 |
begin
|
498 |
if Msg.Msg = WM_MOUSEWHEEL
|
499 |
then // Interception de l'?v?nement WM_MOUSEWHEEL |
500 |
if SmallInt(Msg.WParamHi) < 0 |
501 |
then
|
502 |
DataModuleDeclaration.ClientDataSetIngredients.Next |
503 |
else
|
504 |
DataModuleDeclaration.ClientDataSetIngredients.Prior |
505 |
else // Traitement des autres messages |
506 |
begin
|
507 |
if Msg.Msg = WM_NCCALCSIZE
|
508 |
then // Forcer l'affichage des ascenseurs |
509 |
ShowScrollBar(DBGriddP.Handle, SB_BOTH, True); |
510 |
DBGriddPOldWindowProc(Msg); |
511 |
end;
|
512 |
end;
|
513 |
|
514 |
procedure TFormIngredientsList.DBGridTitleClick(Column: TColumn);
|
515 |
begin
|
516 |
with DataModuleDeclaration.ClientDataSetIngredients do |
517 |
if IndexFieldNames = Column.FieldName
|
518 |
then // C'est d?j? l'index => tri selon le nom |
519 |
IndexFieldNames := 'Name'
|
520 |
else
|
521 |
IndexFieldNames := Column.FieldName; |
522 |
end;
|
523 |
|
524 |
procedure TFormIngredientsList.EditNameChange(Sender: TObject);
|
525 |
begin
|
526 |
if CheckBoxName.Checked
|
527 |
then
|
528 |
CheckBoxFilterClick(nil);
|
529 |
end;
|
530 |
|
531 |
procedure TFormIngredientsList.FormCreate(Sender: TObject);
|
532 |
var
|
533 |
ProximalUnit, EnergyUnit, AAUnit, MineralsUnit: String;
|
534 |
begin
|
535 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
536 |
then
|
537 |
Font.Name := 'Arial Unicode MS';
|
538 |
// PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
|
539 |
PanelButtons.Font.Style := [fsBold]; |
540 |
LabelWarning.Font.Style := [fsItalic]; |
541 |
LabelFilteredClass.Font.Color := clRed; |
542 |
LabelFilteredDatabase.Font.Color := clRed; |
543 |
LabelFilteredName.Font.Color := clRed; |
544 |
TranslateComponent(Self); |
545 |
with FormOptions do |
546 |
if Expression = 0 |
547 |
then // sur frais |
548 |
begin
|
549 |
ProximalUnit := ComboBoxProximal.Items[Proximal]; |
550 |
EnergyUnit := ComboBoxEnergy.Items[Energy]; |
551 |
AAUnit := ComboBoxAA.Items[AA]; |
552 |
MineralsUnit := ComboBoxMinerals.Items[Minerals]; |
553 |
end
|
554 |
else // sur mati?re s?che |
555 |
begin
|
556 |
ProximalUnit := Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]); |
557 |
EnergyUnit := Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]); |
558 |
AAUnit := Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]); |
559 |
MineralsUnit := Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]); |
560 |
end;
|
561 |
with FormOptions do |
562 |
TabSheetMS.Caption := Format('%s (%s)', [TabSheetMS.Caption, ComboBoxProximal.Items[Proximal]]);
|
563 |
TabSheetProximal.Caption := Format('%s (%s)', [TabSheetProximal.Caption, ProximalUnit]);
|
564 |
TabSheetEnergy.Caption := Format('%s (%s)', [TabSheetEnergy.Caption, EnergyUnit]);
|
565 |
TabSheetEnergyUtilization.Caption := Format('%s (%%)', [TabSheetEnergyUtilization.Caption]);
|
566 |
TabSheetAATot.Caption := Format('%s (%s)', [TabSheetAATot.Caption, AAUnit]);
|
567 |
TabSheetAA_MAT.Caption := Format('%s (%%)', [TabSheetAA_MAT.Caption]);
|
568 |
TabSheetdAA.Caption := Format('%s (%%)', [TabSheetdAA.Caption]);
|
569 |
TabSheetAADig.Caption := Format('%s (%s)', [TabSheetAADig.Caption, AAUnit]);
|
570 |
TabSheetMinerals.Caption := Format('%s (%s)', [TabSheetMinerals.Caption, MineralsUnit]);
|
571 |
TabSheetdP.Caption := Format('%s (%%)', [TabSheetdP.Caption]);
|
572 |
with DataModuleDeclaration do |
573 |
begin
|
574 |
// Classes
|
575 |
ClientDataSetClasses.First; |
576 |
while not ClientDataSetClasses.Eof do |
577 |
begin
|
578 |
ComboBoxClass.Items.Add(ClientDataSetClassesName.Value); |
579 |
ClientDataSetClasses.Next; |
580 |
end;
|
581 |
end;
|
582 |
// Sauvegarder la WndProc actuelle du DBGrid
|
583 |
DBGridNameOldWindowProc := DBGridName.WindowProc; |
584 |
DBGridMSOldWindowProc := DBGridMS.WindowProc; |
585 |
DBGridProximalOldWindowProc := DBGridProximal.WindowProc; |
586 |
DBGridRatiosOldWindowProc := DBGridRatios.WindowProc; |
587 |
DBGridEnergyOldWindowProc := DBGridEnergy.WindowProc; |
588 |
DBGridAATotOldWindowProc := DBGridAATot.WindowProc; |
589 |
DBGridAA_MATOldWindowProc := DBGridAA_MAT.WindowProc; |
590 |
DBGriddAAOldWindowProc := DBGriddAA.WindowProc; |
591 |
DBGridAADigOldWindowProc := DBGridAADig.WindowProc; |
592 |
DBGridMineralsOldWindowProc := DBGridMinerals.WindowProc; |
593 |
DBGriddPOldWindowProc := DBGriddP.WindowProc; |
594 |
// Affecter une nouvelle proc?dure de fen?tre
|
595 |
DBGridName.WindowProc := DBGridNameNewWindowProc; |
596 |
DBGridMS.WindowProc := DBGridMSNewWindowProc; |
597 |
DBGridProximal.WindowProc := DBGridProximalNewWindowProc; |
598 |
DBGridRatios.WindowProc := DBGridRatiosNewWindowProc; |
599 |
DBGridEnergy.WindowProc := DBGridEnergyNewWindowProc; |
600 |
DBGridAATot.WindowProc := DBGridAATotNewWindowProc; |
601 |
DBGridAA_MAT.WindowProc := DBGridAA_MATNewWindowProc; |
602 |
DBGriddAA.WindowProc := DBGriddAANewWindowProc; |
603 |
DBGridAADig.WindowProc := DBGridAADigNewWindowProc; |
604 |
DBGridMinerals.WindowProc := DBGridMineralsNewWindowProc; |
605 |
DBGriddP.WindowProc := DBGriddPNewWindowProc; |
606 |
end;
|
607 |
|
608 |
procedure TFormIngredientsList.FormDestroy(Sender: TObject);
|
609 |
begin
|
610 |
with DataModuleDeclaration do |
611 |
begin
|
612 |
ClientDataSetIngredients.Filtered := False; |
613 |
FilterOnClass := False; |
614 |
FilterOnDatabase := False; |
615 |
FilterOnName := False; |
616 |
end;
|
617 |
end;
|
618 |
|
619 |
procedure TFormIngredientsList.FormResize(Sender: TObject);
|
620 |
begin
|
621 |
// Adaptater la position et la taille de la liste des noms
|
622 |
DBGridName.Top := TabSheetMS.Top; |
623 |
case PageControlLists.ActivePageIndex of |
624 |
0: DBGridName.Height := DBGridMS.Height;
|
625 |
1: DBGridName.Height := DBGridProximal.Height;
|
626 |
2: DBGridName.Height := DBGridRatios.Height;
|
627 |
3: DBGridName.Height := DBGridEnergy.Height;
|
628 |
4: DBGridName.Height := DBGridAATot.Height;
|
629 |
5: DBGridName.Height := DBGridAA_MAT.Height;
|
630 |
6: DBGridName.Height := DBGriddAA.Height;
|
631 |
7: DBGridName.Height := DBGridAADig.Height;
|
632 |
8: DBGridName.Height := DBGridMinerals.Height;
|
633 |
9: DBGridName.Height := DBGriddP.Height;
|
634 |
end;
|
635 |
end;
|
636 |
|
637 |
procedure TFormIngredientsList.FormShow(Sender: TObject);
|
638 |
begin
|
639 |
with DataModuleDeclaration do |
640 |
ClientDataSetIngredients.First; |
641 |
PageControlLists.ActivePageIndex := 0;
|
642 |
PageControlListsChange(nil);
|
643 |
end;
|
644 |
|
645 |
procedure TFormIngredientsList.PageControlListsChange(Sender: TObject);
|
646 |
begin
|
647 |
// Activer la liste de l'onglet s?lectionn?
|
648 |
case PageControlLists.ActivePageIndex of |
649 |
0: ActiveControl := DBGridMS;
|
650 |
1: ActiveControl := DBGridProximal;
|
651 |
2: ActiveControl := DBGridRatios;
|
652 |
3: ActiveControl := DBGridEnergy;
|
653 |
4: ActiveControl := DBGridAATot;
|
654 |
5: ActiveControl := DBGridAA_MAT;
|
655 |
6: ActiveControl := DBGriddAA;
|
656 |
7: ActiveControl := DBGridAADig;
|
657 |
8: ActiveControl := DBGridMinerals;
|
658 |
9: ActiveControl := DBGriddP;
|
659 |
end;
|
660 |
FormResize(nil);
|
661 |
end;
|
662 |
|
663 |
procedure TFormIngredientsList.SplitterListMoved(Sender: TObject);
|
664 |
begin
|
665 |
FormResize(nil);
|
666 |
end;
|
667 |
|
668 |
procedure TFormIngredientsList.WMSysCommand(var Message: TWMSysCommand); |
669 |
begin
|
670 |
if Message.CmdType = SC_MINIMIZE
|
671 |
then
|
672 |
Application.Minimize |
673 |
else
|
674 |
inherited;
|
675 |
end;
|
676 |
|
677 |
end.
|