root / UnitIngredientDetail.pas @ 1
Historique | Voir | Annoter | Télécharger (34,036 ko)
1 |
unit UnitIngredientDetail;
|
---|---|
2 |
|
3 |
{$WARN SYMBOL_PLATFORM OFF}
|
4 |
|
5 |
interface
|
6 |
|
7 |
uses
|
8 |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, |
9 |
Dialogs, gnugettext, StdCtrls, ComCtrls, ExtCtrls, Mask, DB, DBCtrls, |
10 |
ActnList, ImgList, ToolWin, JvExStdCtrls, JvEdit, JvValidateEdit, RpBase, |
11 |
RpSystem, RpRender, RpRenderPDF, RpRave, RpDefine, RpCon, RpConDS, JvCsvData, |
12 |
RvClass, RvCsStd, RvCsData, JvButton, JvCtrls, XMLIntf, XMLDoc, RpDevice; |
13 |
|
14 |
type
|
15 |
TFormIngredientDetail = class(TForm)
|
16 |
RvDataSetConnectionIngredients: TRvDataSetConnection; |
17 |
RvProjectReport: TRvProject; |
18 |
RvSystemReport: TRvSystem; |
19 |
SaveDialogExport: TSaveDialog; |
20 |
ActionListButtons: TActionList; |
21 |
ActionHelp: TAction; |
22 |
ActionClose: TAction; |
23 |
ImageListIcons: TImageList; |
24 |
ActionModify: TAction; |
25 |
ActionDelete: TAction; |
26 |
ActionPrint: TAction; |
27 |
ActionXML: TAction; |
28 |
PanelButtons: TPanel; |
29 |
PanelMain: TPanel; |
30 |
LabelClass: TLabel; |
31 |
LabelDefinition: TLabel; |
32 |
LabelMS: TLabel; |
33 |
LabelName: TLabel; |
34 |
LabelSource: TLabel; |
35 |
DBEditClass: TDBEdit; |
36 |
DBEditMS: TDBEdit; |
37 |
DBEditName: TDBEdit; |
38 |
DBEditSource: TDBEdit; |
39 |
DBMemoDefinition: TDBMemo; |
40 |
GroupBoxAA: TGroupBox; |
41 |
LabelAADig: TLabel; |
42 |
LabelAATot: TLabel; |
43 |
LabelLys: TLabel; |
44 |
LabelTyr: TLabel; |
45 |
LabelThr: TLabel; |
46 |
LabelPheTyr: TLabel; |
47 |
LabelMet: TLabel; |
48 |
LabelHis: TLabel; |
49 |
LabelCys: TLabel; |
50 |
LabelArg: TLabel; |
51 |
LabelMetCys: TLabel; |
52 |
LabelAla: TLabel; |
53 |
LabelTrp: TLabel; |
54 |
LabelAsp: TLabel; |
55 |
LabelIle: TLabel; |
56 |
LabelGlu: TLabel; |
57 |
LabelVal: TLabel; |
58 |
LabelGly: TLabel; |
59 |
LabelLeu: TLabel; |
60 |
LabelSer: TLabel; |
61 |
LabelPhe: TLabel; |
62 |
LabelPro: TLabel; |
63 |
LabeldAA: TLabel; |
64 |
DBEditLys: TDBEdit; |
65 |
DBEditLysd: TDBEdit; |
66 |
DBEditTyr: TDBEdit; |
67 |
DBEditTyrd: TDBEdit; |
68 |
DBEditThr: TDBEdit; |
69 |
DBEditThrd: TDBEdit; |
70 |
DBEditPheTyr: TDBEdit; |
71 |
DBEditPheTyrd: TDBEdit; |
72 |
DBEditMet: TDBEdit; |
73 |
DBEditMetd: TDBEdit; |
74 |
DBEditHis: TDBEdit; |
75 |
DBEditHisd: TDBEdit; |
76 |
DBEditCys: TDBEdit; |
77 |
DBEditCysd: TDBEdit; |
78 |
DBEditArg: TDBEdit; |
79 |
DBEditArgd: TDBEdit; |
80 |
DBEditMetCys: TDBEdit; |
81 |
DBEditMetCysd: TDBEdit; |
82 |
DBEditAla: TDBEdit; |
83 |
DBEditAlad: TDBEdit; |
84 |
DBEditTrp: TDBEdit; |
85 |
DBEditTrpd: TDBEdit; |
86 |
DBEditAsp: TDBEdit; |
87 |
DBEditAspd: TDBEdit; |
88 |
DBEditIle: TDBEdit; |
89 |
DBEditIled: TDBEdit; |
90 |
DBEditGlu: TDBEdit; |
91 |
DBEditGlud: TDBEdit; |
92 |
DBEditVal: TDBEdit; |
93 |
DBEditVald: TDBEdit; |
94 |
DBEditGly: TDBEdit; |
95 |
DBEditGlyd: TDBEdit; |
96 |
DBEditLeu: TDBEdit; |
97 |
DBEditLeud: TDBEdit; |
98 |
DBEditSer: TDBEdit; |
99 |
DBEditSerd: TDBEdit; |
100 |
DBEditPhe: TDBEdit; |
101 |
DBEditPhed: TDBEdit; |
102 |
DBEditPro: TDBEdit; |
103 |
DBEditProd: TDBEdit; |
104 |
DEditdLys: TDBEdit; |
105 |
DBEditdTyr: TDBEdit; |
106 |
DBEditdThr: TDBEdit; |
107 |
DBEditdPheTyr: TDBEdit; |
108 |
DBEditdMet: TDBEdit; |
109 |
DBEditdHis: TDBEdit; |
110 |
DBEditdCys: TDBEdit; |
111 |
DBEditdArg: TDBEdit; |
112 |
DBEditdMetCys: TDBEdit; |
113 |
DBEditdAla: TDBEdit; |
114 |
DBEditdTrp: TDBEdit; |
115 |
DBEditdAsp: TDBEdit; |
116 |
DBEditdIle: TDBEdit; |
117 |
DBEditdGlu: TDBEdit; |
118 |
DBEditdVal: TDBEdit; |
119 |
DBEditdGly: TDBEdit; |
120 |
DBEditdLeu: TDBEdit; |
121 |
DBEditdSer: TDBEdit; |
122 |
DBEditdPhe: TDBEdit; |
123 |
DBEditdPro: TDBEdit; |
124 |
GroupBoxAzote: TGroupBox; |
125 |
LabelCrois3: TLabel; |
126 |
LabelTruie3: TLabel; |
127 |
LabeldN: TLabel; |
128 |
DBEditdNc: TDBEdit; |
129 |
DBEditdNt: TDBEdit; |
130 |
GroupBoxEnergy: TGroupBox; |
131 |
LabelEB: TLabel; |
132 |
LabelED: TLabel; |
133 |
LabelEM: TLabel; |
134 |
LabelEN: TLabel; |
135 |
LabelCrois1: TLabel; |
136 |
LabelTruie1: TLabel; |
137 |
LabelRatio: TLabel; |
138 |
DBEditEBc: TDBEdit; |
139 |
DBEditEBt: TDBEdit; |
140 |
DBEditEDc: TDBEdit; |
141 |
DBEditEDt: TDBEdit; |
142 |
DBEditEMc: TDBEdit; |
143 |
DBEditEMt: TDBEdit; |
144 |
DBEditENc: TDBEdit; |
145 |
DBEditENt: TDBEdit; |
146 |
DBEditEDt_EDc: TDBEdit; |
147 |
DBEditEMt_EMc: TDBEdit; |
148 |
DBEditENt_ENc: TDBEdit; |
149 |
ValidateEditEBt_EBc: TJvValidateEdit; |
150 |
GroupBoxEnergyUtilization: TGroupBox; |
151 |
LabeldE: TLabel; |
152 |
LabelEM_ED: TLabel; |
153 |
LabelEN_EM: TLabel; |
154 |
LabelCrois2: TLabel; |
155 |
LabelTruie2: TLabel; |
156 |
LabelBonus: TLabel; |
157 |
LabelLysd_EN: TLabel; |
158 |
DBEditdEc: TDBEdit; |
159 |
DBEditdEt: TDBEdit; |
160 |
DBEditEMc_EDc: TDBEdit; |
161 |
DBEditEMt_EDt: TDBEdit; |
162 |
DBEditENc_EMc: TDBEdit; |
163 |
DBEditENt_EMt: TDBEdit; |
164 |
DBEditBonus: TDBEdit; |
165 |
DBEditLysd_ENc: TDBEdit; |
166 |
DBEditLysd_ENt: TDBEdit; |
167 |
GroupBoxMinerals: TGroupBox; |
168 |
LabelCa: TLabel; |
169 |
LabelP: TLabel; |
170 |
LabelDigP: TLabel; |
171 |
LabelFarine: TLabel; |
172 |
LabelGranule: TLabel; |
173 |
LabeldP: TLabel; |
174 |
DBEditCa: TDBEdit; |
175 |
DBEditP: TDBEdit; |
176 |
DBEditdPphy: TDBEdit; |
177 |
DBEditdP: TDBEdit; |
178 |
GroupBoxProximal: TGroupBox; |
179 |
LabelMAT: TLabel; |
180 |
LabelCB: TLabel; |
181 |
LabelMG: TLabel; |
182 |
LabelMM: TLabel; |
183 |
LabelNDF: TLabel; |
184 |
LabelADF: TLabel; |
185 |
LabelADL: TLabel; |
186 |
LabelAmidon: TLabel; |
187 |
LabelSucres: TLabel; |
188 |
DBEditMAT: TDBEdit; |
189 |
DBEditCB: TDBEdit; |
190 |
DBEditMG: TDBEdit; |
191 |
DBEditMM: TDBEdit; |
192 |
DBEditNDF: TDBEdit; |
193 |
DBEditADF: TDBEdit; |
194 |
DBEditADL: TDBEdit; |
195 |
DBEditAmidon: TDBEdit; |
196 |
DBEditSucres: TDBEdit; |
197 |
JvImgBtnModify: TJvImgBtn; |
198 |
JvImgBtnDelete: TJvImgBtn; |
199 |
JvImgBtnPrint: TJvImgBtn; |
200 |
JvImgBtnXML: TJvImgBtn; |
201 |
JvImgBtnHelp: TJvImgBtn; |
202 |
JvImgBtnClose: TJvImgBtn; |
203 |
PanelHead: TPanel; |
204 |
procedure FormCreate(Sender: TObject);
|
205 |
procedure FormShow(Sender: TObject);
|
206 |
procedure ActionModifyExecute(Sender: TObject);
|
207 |
procedure ActionDeleteExecute(Sender: TObject);
|
208 |
procedure ActionPrintExecute(Sender: TObject);
|
209 |
procedure ActionXMLExecute(Sender: TObject);
|
210 |
procedure ActionHelpExecute(Sender: TObject);
|
211 |
procedure ActionCloseExecute(Sender: TObject);
|
212 |
private
|
213 |
{ D?clarations priv?es }
|
214 |
procedure BuildReport;
|
215 |
procedure EditEmpty(Edit: TJvValidateEdit);
|
216 |
procedure EditShadow(Edit: TDBEdit);
|
217 |
public
|
218 |
{ D?clarations publiques }
|
219 |
end;
|
220 |
|
221 |
var
|
222 |
FormIngredientDetail: TFormIngredientDetail; |
223 |
|
224 |
implementation
|
225 |
|
226 |
{$R *.dfm}
|
227 |
|
228 |
uses
|
229 |
UnitDeclaration, UnitOptions, UnitIngredientEditionCopy, UnitIngredientEditionOriginal; |
230 |
|
231 |
procedure TFormIngredientDetail.ActionCloseExecute(Sender: TObject);
|
232 |
begin
|
233 |
ModalResult := mrClose; |
234 |
end;
|
235 |
|
236 |
procedure TFormIngredientDetail.ActionXMLExecute(Sender: TObject);
|
237 |
var
|
238 |
i: Integer; |
239 |
USFormatSettings: TFormatSettings; |
240 |
XMLDoc: IXMLDocument; |
241 |
Workbook, Worksheet, Table, Row: IXMLNode; |
242 |
|
243 |
procedure CellData(Row: IXMLNode; Value, Format: string); |
244 |
var
|
245 |
Cell, Data: IXMLNode; |
246 |
begin
|
247 |
Cell := Row.AddChild('Cell');
|
248 |
Data := Cell.AddChild('Data');
|
249 |
Data.Attributes['ss:Type'] := Format;
|
250 |
Data.Text := Value; |
251 |
end;
|
252 |
|
253 |
begin
|
254 |
if SaveDialogExport.Execute
|
255 |
then
|
256 |
begin
|
257 |
GetLocaleFormatSettings(1033, USFormatSettings);
|
258 |
XMLDoc := TXMLDocument.Create(nil);
|
259 |
try
|
260 |
XMLDoc.XML.Clear; |
261 |
XMLDoc.XML.Add('<?xml version="1.0" encoding="UTF-8"?>');
|
262 |
XMLDoc.XML.Add('<?mso-application progid="Excel.Sheet"?>');
|
263 |
XMLDoc.XML.Add('<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet">');
|
264 |
XMLDoc.XML.Add('</Workbook>');
|
265 |
XMLDoc.Active := True; |
266 |
Workbook := XMLDoc.DocumentElement; |
267 |
Workbook.DeclareNamespace('o', 'urn:schemas-microsoft-com:office:office'); |
268 |
Workbook.DeclareNamespace('x', 'urn:schemas-microsoft-com:office:excel'); |
269 |
Workbook.DeclareNamespace('ss', 'urn:schemas-microsoft-com:office:spreadsheet'); |
270 |
Workbook.DeclareNamespace('html', 'http://www.w3.org/TR/REC-html40'); |
271 |
Worksheet := Workbook.AddChild('Worksheet');
|
272 |
Worksheet.SetAttributeNS('ss:Name', Workbook.FindNamespaceURI('ss'), Caption); |
273 |
Table := Worksheet.AddChild('Table');
|
274 |
// Titre
|
275 |
Row := Table.AddChild('Row');
|
276 |
CellData(Row, _('Label'), 'String'); |
277 |
CellData(Row, _('Value'), 'String'); |
278 |
CellData(Row, _('Unit'), 'String'); |
279 |
// Donn?es
|
280 |
with DataModuleDeclaration do |
281 |
for i := 0 to ClientDataSetIngredients.FieldCount - 1 do |
282 |
if not (i in [0, 2, 3, 5, 6, 9, 58..77, 78..97]) |
283 |
then // Champs export?s |
284 |
begin
|
285 |
Row := Table.AddChild('Row');
|
286 |
// Label
|
287 |
CellData(Row, _(ClientDataSetIngredients.Fields[i].DisplayLabel), 'String');
|
288 |
// Value
|
289 |
case i of |
290 |
1, 4, 7: |
291 |
CellData(Row, ClientDataSetIngredients.Fields[i].AsWideString, 'String');
|
292 |
8, 10..18: |
293 |
if not ClientDataSetIngredients.Fields[i].IsNull |
294 |
then
|
295 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, FormOptions.ProximalDecimals, USFormatSettings), 'Number') |
296 |
else
|
297 |
CellData(Row, '', 'String'); |
298 |
19, 22, 24, 26, 28, 30, 32: |
299 |
if not ClientDataSetIngredients.Fields[i].IsNull |
300 |
then
|
301 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, FormOptions.EnergyDecimals, USFormatSettings), 'Number') |
302 |
else
|
303 |
CellData(Row, '', 'String'); |
304 |
20, 21, 23, 25, 27, 29, 31, 33..37, 122..123: |
305 |
if not ClientDataSetIngredients.Fields[i].IsNull |
306 |
then
|
307 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, 1, USFormatSettings), 'Number') |
308 |
else
|
309 |
CellData(Row, '', 'String'); |
310 |
38..57, 98..117: |
311 |
if not ClientDataSetIngredients.Fields[i].IsNull |
312 |
then
|
313 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, FormOptions.AADecimals, USFormatSettings), 'Number') |
314 |
else
|
315 |
CellData(Row, '', 'String'); |
316 |
118..119: |
317 |
if not ClientDataSetIngredients.Fields[i].IsNull |
318 |
then
|
319 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, 2, USFormatSettings), 'Number') |
320 |
else
|
321 |
CellData(Row, '', 'String'); |
322 |
120..121: |
323 |
if not ClientDataSetIngredients.Fields[i].IsNull |
324 |
then
|
325 |
CellData(Row, FloatToStrF(ClientDataSetIngredients.Fields[i].AsFloat, ffFixed, 15, FormOptions.MineralsDecimals, USFormatSettings), 'Number') |
326 |
else
|
327 |
CellData(Row, '', 'String'); |
328 |
end;
|
329 |
// Unit
|
330 |
case i of |
331 |
8: // MS |
332 |
CellData(Row, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], 'String');
|
333 |
10..18: // Analyse proximale |
334 |
if FormOptions.Expression = 0 |
335 |
then // sur frais |
336 |
CellData(Row, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], 'String')
|
337 |
else // sur mati?re s?che |
338 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]), 'String'); |
339 |
19, 22, 24, 26, 28, 30, 32: // Energie |
340 |
if FormOptions.Expression = 0 |
341 |
then // sur frais |
342 |
CellData(Row, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], 'String')
|
343 |
else // sur mati?re s?che |
344 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]), 'String'); |
345 |
20, 21, 23, 25, 27, 29, 31, 33..37, 122..123: // % |
346 |
CellData(Row, '%', 'String'); |
347 |
38..57, 98..117: // AA |
348 |
if FormOptions.Expression = 0 |
349 |
then // sur frais |
350 |
CellData(Row, FormOptions.ComboBoxAA.Items[FormOptions.AA], 'String')
|
351 |
else // sur mati?re s?che |
352 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]), 'String'); |
353 |
118..119: // Lysd/EN |
354 |
if FormOptions.Energy = 0 |
355 |
then // MJ |
356 |
CellData(Row, _('g/MJ'), 'String') |
357 |
else // kcal |
358 |
CellData(Row, _('g/1000kcal'), 'String'); |
359 |
120..121: // Min?raux |
360 |
if FormOptions.Expression = 0 |
361 |
then // sur frais |
362 |
CellData(Row, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], 'String')
|
363 |
else // sur mati?re s?che |
364 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]), 'String'); |
365 |
end;
|
366 |
end;
|
367 |
XMLDoc.SaveToFile(SaveDialogExport.FileName); |
368 |
XmlDoc.Active := False; |
369 |
finally
|
370 |
XMLDoc := nil;
|
371 |
end;
|
372 |
end;
|
373 |
end;
|
374 |
|
375 |
procedure TFormIngredientDetail.ActionDeleteExecute(Sender: TObject);
|
376 |
var
|
377 |
UserName: String;
|
378 |
begin
|
379 |
with DataModuleDeclaration do |
380 |
begin
|
381 |
ClientDataSetComposition.Filter := Format('Ingredient = %d and User', [ClientDataSetIngredientsId.Value]);
|
382 |
ClientDataSetComposition.Filtered := True; |
383 |
try
|
384 |
if ClientDataSetComposition.RecordCount > 0 |
385 |
then
|
386 |
MessageDlg(_('This ingredient is used in a diet.') + sLineBreak + _('You cannot delete it.'), mtError, [mbOK], 0) |
387 |
else
|
388 |
if MessageDlg(_('Are sure you want to delete this record?') + sLineBreak + _('This action could not be canceled.'), mtConfirmation, [mbYes, mbNo], 0) = mrYes |
389 |
then
|
390 |
begin
|
391 |
ClientDataSetIngredients.DisableControls; |
392 |
try
|
393 |
UserName := ClientDataSetIngredientsName.Value; |
394 |
// Suprimer la mati?re premi?re
|
395 |
DBUser.BeginTransaction; |
396 |
try
|
397 |
DBUser.ExecSQL('DELETE FROM Ingredients '
|
398 |
+ Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
|
399 |
DBUser.Commit; |
400 |
except
|
401 |
DBUser.RollBack; |
402 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitIngredientDetail', 'ActionDeleteExecute', 'DBUser (DELETE FROM Ingredients)']), mtError, [mbOK], 0); |
403 |
Exit; |
404 |
end;
|
405 |
// Suprimer de ClientDataSetIngredients
|
406 |
ClientDataSetIngredients.Delete; |
407 |
// Suprimer le nom de la liste des mati?res premi?res utilisateur
|
408 |
UserList.Delete(UserList.IndexOf(UserName)); |
409 |
// Fermer la fen?tre
|
410 |
Close; |
411 |
finally
|
412 |
ClientDataSetIngredients.EnableControls; |
413 |
end;
|
414 |
end;
|
415 |
finally
|
416 |
ClientDataSetComposition.Filtered := False; |
417 |
ClientDataSetComposition.Filter := '';
|
418 |
end;
|
419 |
end;
|
420 |
end;
|
421 |
|
422 |
procedure TFormIngredientDetail.ActionHelpExecute(Sender: TObject);
|
423 |
begin
|
424 |
Application.HelpContext(HelpContext); |
425 |
end;
|
426 |
|
427 |
procedure TFormIngredientDetail.ActionModifyExecute(Sender: TObject);
|
428 |
begin
|
429 |
if DataModuleDeclaration.ClientDataSetIngredientsModel.IsNull
|
430 |
then // Cr?ation originale |
431 |
begin
|
432 |
FormIngredientEditionOriginal := TFormIngredientEditionOriginal.Create(nil);
|
433 |
try
|
434 |
FormIngredientEditionOriginal.ShowModal; |
435 |
finally
|
436 |
FormIngredientEditionOriginal.Release; |
437 |
end;
|
438 |
end
|
439 |
else // Copie des tables de r?f?rence |
440 |
begin
|
441 |
FormIngredientEditionCopy := TFormIngredientEditionCopy.Create(nil);
|
442 |
try
|
443 |
FormIngredientEditionCopy.ShowModal; |
444 |
finally
|
445 |
FormIngredientEditionCopy.Release; |
446 |
end;
|
447 |
end;
|
448 |
// with DataModuleDeclaration do
|
449 |
// Hint := ClientDataSetIngredientsDefinition.Value;
|
450 |
end;
|
451 |
|
452 |
procedure TFormIngredientDetail.ActionPrintExecute(Sender: TObject);
|
453 |
begin
|
454 |
if RpDev.PrinterSetupDialog
|
455 |
then
|
456 |
begin
|
457 |
RvSystemReport.DoNativeOutput := False; |
458 |
RvSystemReport.DefaultDest := rdPrinter; |
459 |
RvSystemReport.RenderObject := nil;
|
460 |
RvSystemReport.OutputFileName := '';
|
461 |
RvProjectReport.Open; |
462 |
BuildReport; |
463 |
with DataModuleDeclaration do |
464 |
if ClientDataSetIngredientsUser.Value
|
465 |
then // User |
466 |
TableIngredients.Free; |
467 |
RvProjectReport.Execute; |
468 |
Application.ProcessMessages; |
469 |
RvProjectReport.Close; |
470 |
end;
|
471 |
end;
|
472 |
|
473 |
procedure TFormIngredientDetail.BuildReport;
|
474 |
var
|
475 |
i: Integer; |
476 |
Page: TRavePage; |
477 |
begin
|
478 |
with DataModuleDeclaration do |
479 |
if ClientDataSetIngredientsUser.Value
|
480 |
then // User |
481 |
TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
|
482 |
+ Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
|
483 |
with DataModuleDeclaration do |
484 |
if ClientDataSetIngredients.Eof
|
485 |
then // Bug : seconde page blanche |
486 |
if ClientDataSetIngredients.RecordCount > 1 |
487 |
then
|
488 |
begin
|
489 |
ClientDataSetIngredients.Prior; |
490 |
ClientDataSetIngredients.Next; |
491 |
end
|
492 |
else
|
493 |
ClientDataSetIngredients.First; |
494 |
Page := RvProjectReport.ProjMan.FindRaveComponent('ReportIngredient.PageIngredient1', nil) as TRavePage; |
495 |
for i := 0 to Page.ComponentCount - 1 do |
496 |
begin
|
497 |
if Page.Components[i].ClassNameIs('TRaveText') |
498 |
then // Traduire |
499 |
begin
|
500 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
501 |
then
|
502 |
(Page.Components[i] as TRaveText).Font.Name := 'Arial Unicode MS'; |
503 |
TranslateComponent(Page.Components[i]); |
504 |
if (Page.Components[i] as TRaveText).Name = 'TextMS' |
505 |
then
|
506 |
with FormOptions do |
507 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, ComboBoxProximal.Items[Proximal]]); |
508 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitProximal' |
509 |
then
|
510 |
with FormOptions do |
511 |
if Expression = 0 |
512 |
then // sur frais |
513 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxProximal.Items[Proximal]]) |
514 |
else // sur mati?re s?che |
515 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxProximal.Items[Proximal], _('DM')]); |
516 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyC' |
517 |
then
|
518 |
with FormOptions do |
519 |
if Expression = 0 |
520 |
then // sur frais |
521 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxEnergy.Items[Energy]]) |
522 |
else // sur mati?re s?che |
523 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxEnergy.Items[Energy], _('DM')]); |
524 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyT' |
525 |
then
|
526 |
with FormOptions do |
527 |
if Expression = 0 |
528 |
then // sur frais |
529 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxEnergy.Items[Energy]]) |
530 |
else // sur mati?re s?che |
531 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxEnergy.Items[Energy], _('DM')]); |
532 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyRatio' |
533 |
then
|
534 |
(Page.Components[i] as TRaveText).Text := '(%)'; |
535 |
if (Page.Components[i] as TRaveText).Name = 'TextEBt_EBc' |
536 |
then
|
537 |
(Page.Components[i] as TRaveText).Text := ValidateEditEBt_EBc.Text;
|
538 |
if (Page.Components[i] as TRaveText).Name = 'TextdE' |
539 |
then
|
540 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
541 |
if (Page.Components[i] as TRaveText).Name = 'TextME_DE' |
542 |
then
|
543 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
544 |
if (Page.Components[i] as TRaveText).Name = 'TextNE_ME' |
545 |
then
|
546 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
547 |
end;
|
548 |
if Page.Components[i].ClassNameIs('TRaveDataMemo') and (Screen.Fonts.IndexOf('Arial Unicode MS') <> -1) |
549 |
then
|
550 |
(Page.Components[i] as TRaveDataMemo).Font.Name := 'Arial Unicode MS'; |
551 |
if Page.Components[i].ClassNameIs('TRaveDataText') |
552 |
then
|
553 |
begin
|
554 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
555 |
then
|
556 |
(Page.Components[i] as TRaveDataText).Font.Name := 'Arial Unicode MS'; |
557 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextMM' |
558 |
then
|
559 |
with DataModuleDeclaration do |
560 |
if ClientDataSetIngredientsUser.Value
|
561 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MM']) |
562 |
then // Valeur h?rit?e du mod?le |
563 |
begin
|
564 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
565 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
566 |
end;
|
567 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextMAT' |
568 |
then
|
569 |
with DataModuleDeclaration do |
570 |
if ClientDataSetIngredientsUser.Value
|
571 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MAT']) |
572 |
then // Valeur h?rit?e du mod?le |
573 |
begin
|
574 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
575 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
576 |
end;
|
577 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextMG' |
578 |
then
|
579 |
with DataModuleDeclaration do |
580 |
if ClientDataSetIngredientsUser.Value
|
581 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MG']) |
582 |
then // Valeur h?rit?e du mod?le |
583 |
begin
|
584 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
585 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
586 |
end;
|
587 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextCB' |
588 |
then
|
589 |
with DataModuleDeclaration do |
590 |
if ClientDataSetIngredientsUser.Value
|
591 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['CB']) |
592 |
then // Valeur h?rit?e du mod?le |
593 |
begin
|
594 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
595 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
596 |
end;
|
597 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextNDF' |
598 |
then
|
599 |
with DataModuleDeclaration do |
600 |
if ClientDataSetIngredientsUser.Value
|
601 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['NDF']) |
602 |
then // Valeur h?rit?e du mod?le |
603 |
begin
|
604 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
605 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
606 |
end;
|
607 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextADF' |
608 |
then
|
609 |
with DataModuleDeclaration do |
610 |
if ClientDataSetIngredientsUser.Value
|
611 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADF']) |
612 |
then // Valeur h?rit?e du mod?le |
613 |
begin
|
614 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
615 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
616 |
end;
|
617 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextADL' |
618 |
then
|
619 |
with DataModuleDeclaration do |
620 |
if ClientDataSetIngredientsUser.Value
|
621 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADL']) |
622 |
then // Valeur h?rit?e du mod?le |
623 |
begin
|
624 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
625 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
626 |
end;
|
627 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextAmidon' |
628 |
then
|
629 |
with DataModuleDeclaration do |
630 |
if ClientDataSetIngredientsUser.Value
|
631 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Amidon']) |
632 |
then // Valeur h?rit?e du mod?le |
633 |
begin
|
634 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
635 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
636 |
end;
|
637 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextSucres' |
638 |
then
|
639 |
with DataModuleDeclaration do |
640 |
if ClientDataSetIngredientsUser.Value
|
641 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Sucres']) |
642 |
then // Valeur h?rit?e du mod?le |
643 |
begin
|
644 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
645 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
646 |
end;
|
647 |
end;
|
648 |
end;
|
649 |
Page := RvProjectReport.ProjMan.FindRaveComponent('ReportIngredient.PageIngredient2', nil) as TRavePage; |
650 |
for i := 0 to Page.ComponentCount - 1 do |
651 |
begin
|
652 |
if Page.Components[i].ClassNameIs('TRaveText') |
653 |
then // Traduire |
654 |
begin
|
655 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
656 |
then
|
657 |
(Page.Components[i] as TRaveText).Font.Name := 'Arial Unicode MS'; |
658 |
TranslateComponent(Page.Components[i]); |
659 |
if (Page.Components[i] as TRaveText).Name = 'TextdN' |
660 |
then
|
661 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
662 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitAATot' |
663 |
then
|
664 |
with FormOptions do |
665 |
if Expression = 0 |
666 |
then // sur frais |
667 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxAA.Items[AA]]) |
668 |
else // sur mati?re s?che |
669 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxAA.Items[AA], _('DM')]); |
670 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitAADig' |
671 |
then
|
672 |
with FormOptions do |
673 |
if Expression = 0 |
674 |
then // sur frais |
675 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxAA.Items[AA]]) |
676 |
else // sur mati?re s?che |
677 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxAA.Items[AA], _('DM')]); |
678 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitLysd_EN' |
679 |
then
|
680 |
if FormOptions.Energy = 0 |
681 |
then // MJ |
682 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/MJ')]) |
683 |
else // kcal |
684 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/1000kcal')]); |
685 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitMinerals' |
686 |
then
|
687 |
with FormOptions do |
688 |
if Expression = 0 |
689 |
then // sur frais |
690 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxMinerals.Items[Minerals]]) |
691 |
else // sur mati?re s?che |
692 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxMinerals.Items[Minerals], _('DM')]); |
693 |
if (Page.Components[i] as TRaveText).Name = 'TextdP' |
694 |
then
|
695 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
696 |
end;
|
697 |
if Page.Components[i].ClassNameIs('TRaveDataText') |
698 |
then
|
699 |
begin
|
700 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
701 |
then
|
702 |
(Page.Components[i] as TRaveDataText).Font.Name := 'Arial Unicode MS'; |
703 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextCa' |
704 |
then
|
705 |
with DataModuleDeclaration do |
706 |
if ClientDataSetIngredientsUser.Value
|
707 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ca']) |
708 |
then // Valeur h?rit?e du mod?le |
709 |
begin
|
710 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
711 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
712 |
end;
|
713 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextP' |
714 |
then
|
715 |
with DataModuleDeclaration do |
716 |
if ClientDataSetIngredientsUser.Value
|
717 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['P']) |
718 |
then // Valeur h?rit?e du mod?le |
719 |
begin
|
720 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
721 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
722 |
end;
|
723 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextdP' |
724 |
then
|
725 |
with DataModuleDeclaration do |
726 |
if ClientDataSetIngredientsUser.Value
|
727 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dP']) |
728 |
then // Valeur h?rit?e du mod?le |
729 |
begin
|
730 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
731 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
732 |
end;
|
733 |
if (Page.Components[i] as TRaveDataText).Name = 'DataTextdPphy' |
734 |
then
|
735 |
with DataModuleDeclaration do |
736 |
if ClientDataSetIngredientsUser.Value
|
737 |
and TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPphy']) |
738 |
then // Valeur h?rit?e du mod?le |
739 |
begin
|
740 |
(Page.Components[i] as TRaveDataText).Font.Style := (Page.Components[i] as TRaveDataText).Font.Style + [fsItalic]; |
741 |
(Page.Components[i] as TRaveDataText).Font.Color := clGray;
|
742 |
end;
|
743 |
end;
|
744 |
end;
|
745 |
end;
|
746 |
|
747 |
procedure TFormIngredientDetail.EditEmpty(Edit: TJvValidateEdit);
|
748 |
begin
|
749 |
Edit.DisplayFormat := dfNone; |
750 |
Edit.Value := '';
|
751 |
end;
|
752 |
|
753 |
procedure TFormIngredientDetail.EditShadow(Edit: TDBEdit);
|
754 |
begin
|
755 |
Edit.Font.Style := Edit.Font.Style + [fsItalic]; |
756 |
Edit.Font.Color := cl3DDkShadow; |
757 |
end;
|
758 |
|
759 |
procedure TFormIngredientDetail.FormCreate(Sender: TObject);
|
760 |
var
|
761 |
ProximalUnit, EnergyUnit, AAUnit, MineralsUnit: String;
|
762 |
begin
|
763 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
764 |
then
|
765 |
Font.Name := 'Arial Unicode MS';
|
766 |
// PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
|
767 |
PanelButtons.Font.Style := [fsBold]; |
768 |
LabelName.Font.Style := [fsBold]; |
769 |
DBEditName.Font.Style := [fsBold]; |
770 |
TranslateComponent(Self); |
771 |
with FormOptions do |
772 |
if Expression = 0 |
773 |
then // sur frais |
774 |
begin
|
775 |
ProximalUnit := ComboBoxProximal.Items[Proximal]; |
776 |
EnergyUnit := ComboBoxEnergy.Items[Energy]; |
777 |
AAUnit := ComboBoxAA.Items[AA]; |
778 |
MineralsUnit := ComboBoxMinerals.Items[Minerals]; |
779 |
end
|
780 |
else // sur mati?re s?che |
781 |
begin
|
782 |
ProximalUnit := Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]); |
783 |
EnergyUnit := Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]); |
784 |
AAUnit := Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]); |
785 |
MineralsUnit := Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]); |
786 |
end;
|
787 |
with FormOptions do |
788 |
LabelMS.Caption := Format('%s (%s)', [LabelMS.Caption, ComboBoxProximal.Items[Proximal]]);
|
789 |
GroupBoxProximal.Caption := Format('%s (%s)', [GroupBoxProximal.Caption, ProximalUnit]);
|
790 |
GroupBoxEnergy.Caption := Format('%s (%s)', [GroupBoxEnergy.Caption, EnergyUnit]);
|
791 |
LabelRatio.Caption := Format('%s (%%)', [LabelRatio.Caption]);
|
792 |
GroupBoxEnergyUtilization.Caption := Format('%s (%%)', [GroupBoxEnergyUtilization.Caption]);
|
793 |
GroupBoxAzote.Caption := Format('%s (%%)', [GroupBoxAzote.Caption]);
|
794 |
if FormOptions.Energy = 0 |
795 |
then // MJ |
796 |
LabelLysd_EN.Caption := Format('%s (%s)', [LabelLysd_EN.Caption, _('g/MJ')]) |
797 |
else // kcal |
798 |
LabelLysd_EN.Caption := Format('%s (%s)', [LabelLysd_EN.Caption, _('g/1000kcal')]); |
799 |
GroupBoxAA.Caption := Format('%s (%s)', [GroupBoxAA.Caption, AAUnit]);
|
800 |
LabeldAA.Caption := Format('%s (%%)', [LabeldAA.Caption]);
|
801 |
GroupBoxMinerals.Caption := Format('%s (%s)', [GroupBoxMinerals.Caption, MineralsUnit]);
|
802 |
LabelDigP.Caption := Format('%s (%%)', [LabelDigP.Caption]);
|
803 |
end;
|
804 |
|
805 |
procedure TFormIngredientDetail.FormShow(Sender: TObject);
|
806 |
begin
|
807 |
with DataModuleDeclaration do |
808 |
begin
|
809 |
if ClientDataSetIngredientsEB.IsNull
|
810 |
then
|
811 |
EditEmpty(ValidateEditEBt_EBc) |
812 |
else
|
813 |
ValidateEditEBt_EBc.Value := 100;
|
814 |
if ClientDataSetIngredientsUser.Value
|
815 |
then // Mati?re premi?re utilisateur |
816 |
begin
|
817 |
TableIngredients := DBUser.GetTable('SELECT * FROM Ingredients '
|
818 |
+ Format('WHERE Id = %d', [ClientDataSetIngredientsId.Value]));
|
819 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MM']) |
820 |
then // Valeur h?rit?e du mod?le |
821 |
EditShadow(DBEditMM); |
822 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MAT']) |
823 |
then // Valeur h?rit?e du mod?le |
824 |
EditShadow(DBEditMAT); |
825 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['MG']) |
826 |
then // Valeur h?rit?e du mod?le |
827 |
EditShadow(DBEditMG); |
828 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['CB']) |
829 |
then // Valeur h?rit?e du mod?le |
830 |
EditShadow(DBEditCB); |
831 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['NDF']) |
832 |
then // Valeur h?rit?e du mod?le |
833 |
EditShadow(DBEditNDF); |
834 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADF']) |
835 |
then // Valeur h?rit?e du mod?le |
836 |
EditShadow(DBEditADF); |
837 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['ADL']) |
838 |
then // Valeur h?rit?e du mod?le |
839 |
EditShadow(DBEditADL); |
840 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Amidon']) |
841 |
then // Valeur h?rit?e du mod?le |
842 |
EditShadow(DBEditAmidon); |
843 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Sucres']) |
844 |
then // Valeur h?rit?e du mod?le |
845 |
EditShadow(DBEditSucres); |
846 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['Ca']) |
847 |
then // Valeur h?rit?e du mod?le |
848 |
EditShadow(DBEditCa); |
849 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['P']) |
850 |
then // Valeur h?rit?e du mod?le |
851 |
EditShadow(DBEditP); |
852 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dPphy']) |
853 |
then // Valeur h?rit?e du mod?le |
854 |
EditShadow(DBEditdPphy); |
855 |
if TableIngredients.FieldIsNull(TableIngredients.FieldIndex['dP']) |
856 |
then // Valeur h?rit?e du mod?le |
857 |
EditShadow(DBEditdP); |
858 |
TableIngredients.Free; |
859 |
end
|
860 |
else // Mati?re premi?re de r?f?rence |
861 |
begin
|
862 |
JvImgBtnModify.Enabled := False; |
863 |
JvImgBtnDelete.Enabled := False; |
864 |
end;
|
865 |
end;
|
866 |
end;
|
867 |
|
868 |
end.
|