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