root / UnitFeedDetail.pas @ 3
Historique | Voir | Annoter | Télécharger (31,284 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 |
procedure FormCreate(Sender: TObject);
|
215 |
procedure FormShow(Sender: TObject);
|
216 |
procedure ActionModifyExecute(Sender: TObject);
|
217 |
procedure ActionDeleteExecute(Sender: TObject);
|
218 |
procedure ActionGraphsExecute(Sender: TObject);
|
219 |
procedure ActionPrintExecute(Sender: TObject);
|
220 |
procedure ActionXMLExecute(Sender: TObject);
|
221 |
procedure ActionHelpExecute(Sender: TObject);
|
222 |
procedure ActionCloseExecute(Sender: TObject);
|
223 |
private
|
224 |
{ D?clarations priv?es }
|
225 |
procedure BuildReport;
|
226 |
procedure EditEmpty(Edit: TJvValidateEdit);
|
227 |
public
|
228 |
{ D?clarations publiques }
|
229 |
end;
|
230 |
|
231 |
var
|
232 |
FormFeedDetail: TFormFeedDetail; |
233 |
|
234 |
implementation
|
235 |
|
236 |
uses
|
237 |
UnitDeclaration, UnitOptions, UnitFeedEdition, UnitFeedCharts; |
238 |
|
239 |
{$R *.dfm}
|
240 |
|
241 |
procedure TFormFeedDetail.ActionCloseExecute(Sender: TObject);
|
242 |
begin
|
243 |
ModalResult := mrClose; |
244 |
end;
|
245 |
|
246 |
procedure TFormFeedDetail.ActionXMLExecute(Sender: TObject);
|
247 |
var
|
248 |
i: Integer; |
249 |
USFormatSettings: TFormatSettings; |
250 |
XMLDoc: IXMLDocument; |
251 |
Workbook, Worksheet, Table, Row: IXMLNode; |
252 |
|
253 |
procedure CellData(Row: IXMLNode; Value, Format: string); |
254 |
var
|
255 |
Cell, Data: IXMLNode; |
256 |
begin
|
257 |
Cell := Row.AddChild('Cell');
|
258 |
Data := Cell.AddChild('Data');
|
259 |
Data.Attributes['ss:Type'] := Format;
|
260 |
Data.Text := Value; |
261 |
end;
|
262 |
|
263 |
begin
|
264 |
if SaveDialogExport.Execute
|
265 |
then
|
266 |
begin
|
267 |
GetLocaleFormatSettings(1033, USFormatSettings);
|
268 |
XMLDoc := TXMLDocument.Create(nil);
|
269 |
try
|
270 |
XMLDoc.XML.Clear; |
271 |
XMLDoc.XML.Add('<?xml version="1.0" encoding="UTF-8" ?>');
|
272 |
XMLDoc.XML.Add('<?mso-application progid="Excel.Sheet"?>');
|
273 |
XMLDoc.XML.Add('<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet">');
|
274 |
XMLDoc.XML.Add('</Workbook>');
|
275 |
XMLDoc.Active := True; |
276 |
Workbook := XMLDoc.DocumentElement; |
277 |
Workbook.DeclareNamespace('o', 'urn:schemas-microsoft-com:office:office'); |
278 |
Workbook.DeclareNamespace('x', 'urn:schemas-microsoft-com:office:excel'); |
279 |
Workbook.DeclareNamespace('ss', 'urn:schemas-microsoft-com:office:spreadsheet'); |
280 |
Workbook.DeclareNamespace('html', 'http://www.w3.org/TR/REC-html40'); |
281 |
Worksheet := Workbook.AddChild('Worksheet');
|
282 |
Worksheet.SetAttributeNS('ss:Name', Workbook.FindNamespaceURI('ss'), Caption); |
283 |
Table := Worksheet.AddChild('Table');
|
284 |
// Titre
|
285 |
Row := Table.AddChild('Row');
|
286 |
CellData(Row, _('Label'), 'String'); |
287 |
CellData(Row, _('Value'), 'String'); |
288 |
CellData(Row, _('Unit'), 'String'); |
289 |
// Donn?es
|
290 |
with DataModuleDeclaration do |
291 |
for i := 0 to ClientDataSetFeeds.FieldCount - 1 do |
292 |
if not (i in [0, 2, 7, 102..104, 106..109]) |
293 |
then // Champs export?s |
294 |
begin
|
295 |
Row := Table.AddChild('Row');
|
296 |
// Label
|
297 |
CellData(Row, _(ClientDataSetFeeds.Fields[i].DisplayLabel), 'String');
|
298 |
// Value
|
299 |
case i of |
300 |
1:
|
301 |
CellData(Row, ClientDataSetFeeds.Fields[i].AsWideString, 'String');
|
302 |
3: // Pr?sentation |
303 |
if ClientDataSetFeedsPresentation.Value = 0 |
304 |
then
|
305 |
CellData(Row, _('Mash'), 'String') |
306 |
else
|
307 |
CellData(Row, _('Pellet'), 'String'); |
308 |
6, 8..16: |
309 |
if not ClientDataSetFeeds.Fields[i].IsNull |
310 |
then
|
311 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, FormOptions.ProximalDecimals, USFormatSettings), 'Number') |
312 |
else
|
313 |
CellData(Row, '', 'String'); |
314 |
17, 19, 21, 23, 25, 27, 29: |
315 |
if not ClientDataSetFeeds.Fields[i].IsNull |
316 |
then
|
317 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, FormOptions.EnergyDecimals, USFormatSettings), 'Number') |
318 |
else
|
319 |
CellData(Row, '', 'String'); |
320 |
4, 5, 18, 20, 22, 24, 26, 28, 30..34, 99: |
321 |
if not ClientDataSetFeeds.Fields[i].IsNull |
322 |
then
|
323 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, 1, USFormatSettings), 'Number') |
324 |
else
|
325 |
CellData(Row, '', 'String'); |
326 |
35..54, 55..74: |
327 |
if not ClientDataSetFeeds.Fields[i].IsNull |
328 |
then
|
329 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, FormOptions.AADecimals, USFormatSettings), 'Number') |
330 |
else
|
331 |
CellData(Row, '', 'String'); |
332 |
75..76, 100..101: |
333 |
if not ClientDataSetFeeds.Fields[i].IsNull |
334 |
then
|
335 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, 2, USFormatSettings), 'Number') |
336 |
else
|
337 |
CellData(Row, '', 'String'); |
338 |
77..95, 105: |
339 |
if not ClientDataSetFeeds.Fields[i].IsNull |
340 |
then
|
341 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, 0, USFormatSettings), 'Number') |
342 |
else
|
343 |
CellData(Row, '', 'String'); |
344 |
96..98: |
345 |
if not ClientDataSetFeeds.Fields[i].IsNull |
346 |
then
|
347 |
CellData(Row, FloatToStrF(ClientDataSetFeeds.Fields[i].AsFloat, ffFixed, 15, FormOptions.MineralsDecimals, USFormatSettings), 'Number') |
348 |
else
|
349 |
CellData(Row, '', 'String'); |
350 |
end;
|
351 |
// Unit
|
352 |
case i of |
353 |
6: // MS |
354 |
CellData(Row, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], 'String');
|
355 |
8..16: // Analyse proximale |
356 |
if FormOptions.Expression = 0 |
357 |
then // sur frais |
358 |
CellData(Row, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], 'String')
|
359 |
else // sur mati?re s?che |
360 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], _('DM')]), 'String'); |
361 |
17, 19, 21, 23, 25, 27, 29: // Energie |
362 |
if FormOptions.Expression = 0 |
363 |
then // sur frais |
364 |
CellData(Row, FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], 'String')
|
365 |
else // sur mati?re s?che |
366 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxEnergy.Items[FormOptions.Energy], _('DM')]), 'String'); |
367 |
4..5, 18, 20, 22, 24, 26, 28, 30..34, 77..95: // % |
368 |
CellData(Row, '%', 'String'); |
369 |
35..54, 55..74: // AA |
370 |
if FormOptions.Expression = 0 |
371 |
then // sur frais |
372 |
CellData(Row, FormOptions.ComboBoxAA.Items[FormOptions.AA], 'String')
|
373 |
else // sur mati?re s?che |
374 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxAA.Items[FormOptions.AA], _('DM')]), 'String'); |
375 |
75..76, 100..101: // Lysd/EN ou Pd/EN |
376 |
if FormOptions.Energy = 0 |
377 |
then // MJ |
378 |
CellData(Row, _('g/MJ'), 'String') |
379 |
else // kcal |
380 |
CellData(Row, _('g/1000kcal'), 'String'); |
381 |
96..98: // Min?raux |
382 |
if FormOptions.Expression = 0 |
383 |
then // sur frais |
384 |
CellData(Row, FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], 'String')
|
385 |
else // sur mati?re s?che |
386 |
CellData(Row, Format('%s %s', [FormOptions.ComboBoxMinerals.Items[FormOptions.Minerals], _('DM')]), 'String'); |
387 |
105:
|
388 |
CellData(Row, _('IU/kg'), 'String'); |
389 |
end;
|
390 |
end;
|
391 |
Worksheet := Workbook.AddChild('Worksheet');
|
392 |
Worksheet.SetAttributeNS('ss:Name', Workbook.FindNamespaceURI('ss'), _('Ingredients')); |
393 |
Table := Worksheet.AddChild('Table');
|
394 |
with DataModuleDeclaration do |
395 |
begin
|
396 |
// Titres
|
397 |
Row := Table.AddChild('Row');
|
398 |
CellData(Row, _('Diet'), 'String'); |
399 |
CellData(Row, ClientDataSetFeedsName.Value, 'String');
|
400 |
Row := Table.AddChild('Row');
|
401 |
Row := Table.AddChild('Row');
|
402 |
CellData(Row, _('Ingredient'), 'String'); |
403 |
CellData(Row, _('Dry matter'), 'String'); |
404 |
CellData(Row, _('Incorporation level'), 'String'); |
405 |
Row := Table.AddChild('Row');
|
406 |
CellData(Row, '', 'String'); |
407 |
CellData(Row, FormOptions.ComboBoxProximal.Items[FormOptions.Proximal], 'String');
|
408 |
CellData(Row, FormOptions.ComboBoxIncorporation.Items[FormOptions.Incorporation], 'String');
|
409 |
// Donn?es
|
410 |
ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
|
411 |
ClientDataSetComposition.Filtered := True; |
412 |
ClientDataSetComposition.First; |
413 |
while not ClientDataSetComposition.Eof do |
414 |
begin
|
415 |
Row := Table.AddChild('Row');
|
416 |
CellData(Row, ClientDataSetCompositionIngredientName.Value, 'String');
|
417 |
CellData(Row, FloatToStrF(ClientDataSetCompositionMS.AsFloat, ffFixed, 15, FormOptions.ProximalDecimals, USFormatSettings), 'Number'); |
418 |
CellData(Row, FloatToStrF(ClientDataSetCompositionLevel.AsFloat, ffFixed, 15, FormOptions.IncorporationDecimals, USFormatSettings), 'Number'); |
419 |
ClientDataSetComposition.Next; |
420 |
end;
|
421 |
ClientDataSetComposition.Filtered := False; |
422 |
ClientDataSetComposition.Filter := '';
|
423 |
if not ClientDataSetFeedsPhytaseId.IsNull |
424 |
then // Phytase |
425 |
begin
|
426 |
Row := Table.AddChild('Row');
|
427 |
CellData(Row, Format('%s %1.2f', [_('Phytase'), ClientDataSetFeedsPhytaseType.Value]), 'String'); |
428 |
CellData(Row, '', 'String'); |
429 |
CellData(Row, FloatToStrF(ClientDataSetFeedsPhytaseLevel.AsFloat, ffFixed, 15, FormOptions.IncorporationDecimals, USFormatSettings), 'Number'); |
430 |
end;
|
431 |
end;
|
432 |
XMLDoc.SaveToFile(SaveDialogExport.FileName); |
433 |
XmlDoc.Active := False; |
434 |
finally
|
435 |
XMLDoc := nil;
|
436 |
end;
|
437 |
end;
|
438 |
end;
|
439 |
|
440 |
procedure TFormFeedDetail.ActionDeleteExecute(Sender: TObject);
|
441 |
var
|
442 |
FeedName: String;
|
443 |
begin
|
444 |
with DataModuleDeclaration do |
445 |
if MessageDlg(_('Are sure you want to delete this record?') + sLineBreak + _('This action could not be canceled.'), mtConfirmation, [mbYes, mbNo], 0) = mrYes |
446 |
then
|
447 |
begin
|
448 |
ClientDataSetFeeds.DisableControls; |
449 |
try
|
450 |
FeedName := ClientDataSetFeedsName.Value; |
451 |
// Supprimer la composition du r?gime
|
452 |
DBUser.BeginTransaction; |
453 |
try
|
454 |
DBUser.ExecSQL('DELETE FROM Composition '
|
455 |
+ Format('WHERE Feed = %d', [ClientDataSetFeedsId.Value]));
|
456 |
DBUser.Commit; |
457 |
except
|
458 |
DBUser.RollBack; |
459 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitFeedDetail', 'ActionDeleteExecute', 'DBUser (DELETE FROM Composition)']), mtError, [mbOK], 0); |
460 |
Exit; |
461 |
end;
|
462 |
// Suprimer de ClientDataSetComposition
|
463 |
ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
|
464 |
ClientDataSetComposition.Filtered := True; |
465 |
ClientDataSetComposition.First; |
466 |
while not ClientDataSetComposition.Eof do |
467 |
ClientDataSetComposition.Delete; |
468 |
ClientDataSetComposition.Filtered := False; |
469 |
ClientDataSetComposition.Filter := '';
|
470 |
// Suprimer l'aliment
|
471 |
DBUser.BeginTransaction; |
472 |
try
|
473 |
DBUser.ExecSQL('DELETE FROM Feeds '
|
474 |
+ Format('WHERE Id = %d', [ClientDataSetFeedsId.Value]));
|
475 |
DBUser.Commit; |
476 |
except
|
477 |
DBUser.RollBack; |
478 |
MessageDlg(Format(_('Unknown error: %s %s %s'), ['UnitFeedDetail', 'ActionDeleteExecute', 'DBUser (DELETE FROM Feeds)']), mtError, [mbOK], 0); |
479 |
Exit; |
480 |
end;
|
481 |
// Suprimer de ClientDataSetFeeds
|
482 |
ClientDataSetFeeds.Delete; |
483 |
// Suprimer le nom de la liste des r?gimes
|
484 |
FeedList.Delete(FeedList.IndexOf(FeedName)); |
485 |
// Fermer la fen?tre
|
486 |
Close; |
487 |
finally
|
488 |
ClientDataSetFeeds.EnableControls; |
489 |
end;
|
490 |
end;
|
491 |
end;
|
492 |
|
493 |
procedure TFormFeedDetail.ActionGraphsExecute(Sender: TObject);
|
494 |
begin
|
495 |
FormFeedCharts := TFormFeedCharts.Create(nil);
|
496 |
try
|
497 |
FormFeedCharts.ShowModal; |
498 |
finally
|
499 |
FormFeedCharts.Release; |
500 |
end;
|
501 |
end;
|
502 |
|
503 |
procedure TFormFeedDetail.ActionHelpExecute(Sender: TObject);
|
504 |
begin
|
505 |
Application.HelpContext(HelpContext); |
506 |
end;
|
507 |
|
508 |
procedure TFormFeedDetail.ActionModifyExecute(Sender: TObject);
|
509 |
begin
|
510 |
FormFeedEdition := TFormFeedEdition.Create(nil);
|
511 |
try
|
512 |
FormFeedEdition.ShowModal; |
513 |
finally
|
514 |
FormFeedEdition.Release; |
515 |
end;
|
516 |
// with DataModuleDeclaration do
|
517 |
// Hint := ClientDataSetFeedsDescription.Value;
|
518 |
end;
|
519 |
|
520 |
procedure TFormFeedDetail.ActionPrintExecute(Sender: TObject);
|
521 |
begin
|
522 |
if RpDev.PrinterSetupDialog
|
523 |
then
|
524 |
begin
|
525 |
RvSystemReport.DoNativeOutput := false; |
526 |
RvSystemReport.DefaultDest := rdPrinter; |
527 |
RvSystemReport.RenderObject := nil;
|
528 |
RvSystemReport.OutputFileName := '';
|
529 |
RvProjectReport.Open; |
530 |
BuildReport; |
531 |
RvProjectReport.Execute; |
532 |
RvProjectReport.Close; |
533 |
with DataModuleDeclaration do |
534 |
begin
|
535 |
ClientDataSetComposition.Filtered := False; |
536 |
ClientDataSetComposition.Filter := '';
|
537 |
end;
|
538 |
end;
|
539 |
end;
|
540 |
|
541 |
procedure TFormFeedDetail.BuildReport;
|
542 |
var
|
543 |
i: Integer; |
544 |
Page: TRavePage; |
545 |
begin
|
546 |
with DataModuleDeclaration do |
547 |
begin
|
548 |
if ClientDataSetFeeds.Eof
|
549 |
then // Bug : seconde page blanche |
550 |
if ClientDataSetIngredients.RecordCount > 1 |
551 |
then
|
552 |
begin
|
553 |
ClientDataSetIngredients.Prior; |
554 |
ClientDataSetIngredients.Next; |
555 |
end
|
556 |
else
|
557 |
ClientDataSetIngredients.First; |
558 |
ClientDataSetComposition.Filter := Format('Feed = %d', [ClientDataSetFeedsId.Value]);
|
559 |
ClientDataSetComposition.Filtered := True; |
560 |
// Taux d'incorporation total
|
561 |
ClientDataSetFeeds.Edit; |
562 |
if ClientDataSetComposition.Aggregates[0].Value = Null |
563 |
then
|
564 |
ClientDataSetFeedsLevelSum.Clear |
565 |
else
|
566 |
ClientDataSetFeedsLevelSum.Value := ClientDataSetComposition.Aggregates[0].Value;
|
567 |
ClientDataSetFeeds.Post; |
568 |
end;
|
569 |
Page := RvProjectReport.ProjMan.FindRaveComponent('ReportFeed.PageFeed1', nil) as TRavePage; |
570 |
for i := 0 to Page.ComponentCount - 1 do |
571 |
begin
|
572 |
if Page.Components[i].ClassNameIs('TRaveText') |
573 |
then // Traduire |
574 |
begin
|
575 |
if (Page.Components[i] as TRaveText).Name = 'TextPresentation2' |
576 |
then
|
577 |
if DataModuleDeclaration.ClientDataSetFeedsPresentation.Value = 0 |
578 |
then
|
579 |
(Page.Components[i] as TRaveText).Text := 'Mash' |
580 |
else
|
581 |
(Page.Components[i] as TRaveText).Text := 'Pellet'; |
582 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
583 |
then
|
584 |
(Page.Components[i] as TRaveText).Font.Name := 'Arial Unicode MS'; |
585 |
TranslateComponent(Page.Components[i]); |
586 |
if (Page.Components[i] as TRaveText).Name = 'TextMS' |
587 |
then
|
588 |
with FormOptions do |
589 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, ComboBoxProximal.Items[Proximal]]); |
590 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitProximal' |
591 |
then
|
592 |
with FormOptions do |
593 |
if Expression = 0 |
594 |
then // sur frais |
595 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxProximal.Items[Proximal]]) |
596 |
else // sur mati?re s?che |
597 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxProximal.Items[Proximal], _('DM')]); |
598 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyC' |
599 |
then
|
600 |
with FormOptions do |
601 |
if Expression = 0 |
602 |
then // sur frais |
603 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxEnergy.Items[Energy]]) |
604 |
else // sur mati?re s?che |
605 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxEnergy.Items[Energy], _('DM')]); |
606 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyT' |
607 |
then
|
608 |
with FormOptions do |
609 |
if Expression = 0 |
610 |
then // sur frais |
611 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxEnergy.Items[Energy]]) |
612 |
else // sur mati?re s?che |
613 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxEnergy.Items[Energy], _('DM')]); |
614 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitEnergyRatio' |
615 |
then
|
616 |
(Page.Components[i] as TRaveText).Text := '(%)'; |
617 |
if (Page.Components[i] as TRaveText).Name = 'TextEBt_EBc' |
618 |
then
|
619 |
(Page.Components[i] as TRaveText).Text := ValidateEditEBt_EBc.Text;
|
620 |
if (Page.Components[i] as TRaveText).Name = 'TextBonus' |
621 |
then
|
622 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
623 |
if (Page.Components[i] as TRaveText).Name = 'TextdE' |
624 |
then
|
625 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
626 |
if (Page.Components[i] as TRaveText).Name = 'TextEM_ED' |
627 |
then
|
628 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
629 |
if (Page.Components[i] as TRaveText).Name = 'TextEN_EM' |
630 |
then
|
631 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
632 |
end;
|
633 |
if Page.Components[i].ClassNameIs('TRaveDataMemo') and (Screen.Fonts.IndexOf('Arial Unicode MS') <> -1) |
634 |
then
|
635 |
(Page.Components[i] as TRaveDataMemo).Font.Name := 'Arial Unicode MS'; |
636 |
if Page.Components[i].ClassNameIs('TRaveDataText') and (Screen.Fonts.IndexOf('Arial Unicode MS') <> -1) |
637 |
then
|
638 |
(Page.Components[i] as TRaveDataText).Font.Name := 'Arial Unicode MS'; |
639 |
end;
|
640 |
Page := RvProjectReport.ProjMan.FindRaveComponent('ReportFeed.PageFeed2', nil) as TRavePage; |
641 |
for i := 0 to Page.ComponentCount - 1 do |
642 |
begin
|
643 |
if Page.Components[i].ClassNameIs('TRaveText') |
644 |
then // Traduire |
645 |
begin
|
646 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
647 |
then
|
648 |
(Page.Components[i] as TRaveText).Font.Name := 'Arial Unicode MS'; |
649 |
TranslateComponent(Page.Components[i]); |
650 |
if (Page.Components[i] as TRaveText).Name = 'TextdN' |
651 |
then
|
652 |
(Page.Components[i] as TRaveText).Text := Format('%s (%%)', [(Page.Components[i] as TRaveText).Text]); |
653 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitAATot' |
654 |
then
|
655 |
with FormOptions do |
656 |
if Expression = 0 |
657 |
then // sur frais |
658 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxAA.Items[AA]]) |
659 |
else // sur mati?re s?che |
660 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxAA.Items[AA], _('DM')]); |
661 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitAADig' |
662 |
then
|
663 |
with FormOptions do |
664 |
if Expression = 0 |
665 |
then // sur frais |
666 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxAA.Items[AA]]) |
667 |
else // sur mati?re s?che |
668 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxAA.Items[AA], _('DM')]); |
669 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitAAProtId' |
670 |
then
|
671 |
(Page.Components[i] as TRaveText).Text := '(%)'; |
672 |
if (Page.Components[i] as TRaveText).Name = 'TextLysd_Lysd' |
673 |
then
|
674 |
(Page.Components[i] as TRaveText).Text := ValidateEditLysd_Lysd.Text;
|
675 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitLysd_EN' |
676 |
then
|
677 |
if FormOptions.Energy = 0 |
678 |
then // MJ |
679 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/MJ')]) |
680 |
else // kcal |
681 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/1000kcal')]); |
682 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitMinerals' |
683 |
then
|
684 |
with FormOptions do |
685 |
if Expression = 0 |
686 |
then // sur frais |
687 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxMinerals.Items[Minerals]]) |
688 |
else // sur mati?re s?che |
689 |
(Page.Components[i] as TRaveText).Text := Format('(%s %s)', [ComboBoxMinerals.Items[Minerals], _('DM')]); |
690 |
if (Page.Components[i] as TRaveText).Name = 'TextUnitPd_EN' |
691 |
then
|
692 |
if FormOptions.Energy = 0 |
693 |
then // MJ |
694 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/MJ')]) |
695 |
else // kcal |
696 |
(Page.Components[i] as TRaveText).Text := Format('%s (%s)', [(Page.Components[i] as TRaveText).Text, _('g/1000kcal')]); |
697 |
end;
|
698 |
if Page.Components[i].ClassNameIs('TRaveDataText') and (Screen.Fonts.IndexOf('Arial Unicode MS') <> -1) |
699 |
then
|
700 |
(Page.Components[i] as TRaveDataText).Font.Name := 'Arial Unicode MS'; |
701 |
end;
|
702 |
Page := RvProjectReport.ProjMan.FindRaveComponent('ReportFeed.PageComposition', nil) as TRavePage; |
703 |
for i := 0 to Page.ComponentCount - 1 do |
704 |
begin
|
705 |
if Page.Components[i].ClassNameIs('TRaveText') |
706 |
then // Traduire |
707 |
begin
|
708 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
709 |
then
|
710 |
(Page.Components[i] as TRaveText).Font.Name := 'Arial Unicode MS'; |
711 |
TranslateComponent(Page.Components[i]); |
712 |
if (Page.Components[i] as TRaveText).Name = 'TextMSUnit' |
713 |
then
|
714 |
with FormOptions do |
715 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxProximal.Items[Proximal]]); |
716 |
if (Page.Components[i] as TRaveText).Name = 'TextLevelUnit' |
717 |
then
|
718 |
with FormOptions do |
719 |
(Page.Components[i] as TRaveText).Text := Format('(%s)', [ComboBoxIncorporation.Items[Incorporation]]); |
720 |
if (Page.Components[i] as TRaveText).Name = 'TextPhytase' |
721 |
then
|
722 |
with DataModuleDeclaration do |
723 |
if ClientDataSetFeedsPhytaseId.IsNull
|
724 |
then
|
725 |
(Page.Components[i] as TRaveText).Text := '' |
726 |
else
|
727 |
(Page.Components[i] as TRaveText).Text := Format('%s %1.2f', [(Page.Components[i] as TRaveText).Text, ClientDataSetFeedsPhytaseType.Value]); |
728 |
end;
|
729 |
if Page.Components[i].ClassNameIs('TRaveDataText') and (Screen.Fonts.IndexOf('Arial Unicode MS') <> -1) |
730 |
then
|
731 |
(Page.Components[i] as TRaveDataText).Font.Name := 'Arial Unicode MS'; |
732 |
end;
|
733 |
end;
|
734 |
|
735 |
procedure TFormFeedDetail.EditEmpty(Edit: TJvValidateEdit);
|
736 |
begin
|
737 |
Edit.DisplayFormat := dfNone; |
738 |
Edit.Value := '';
|
739 |
end;
|
740 |
|
741 |
procedure TFormFeedDetail.FormCreate(Sender: TObject);
|
742 |
var
|
743 |
ProximalUnit, EnergyUnit, AAUnit, MineralsUnit: String;
|
744 |
begin
|
745 |
if Screen.Fonts.IndexOf('Arial Unicode MS') <> -1 |
746 |
then
|
747 |
Font.Name := 'Arial Unicode MS';
|
748 |
// PanelButtons.Font.Size := PanelButtons.Font.Size + 2;
|
749 |
PanelButtons.Font.Style := [fsBold]; |
750 |
LabelName.Font.Style := [fsBold]; |
751 |
DBEditName.Font.Style := [fsBold]; |
752 |
TranslateComponent(Self); |
753 |
with FormOptions do |
754 |
if Expression = 0 |
755 |
then // sur frais |
756 |
begin
|
757 |
ProximalUnit := ComboBoxProximal.Items[Proximal]; |
758 |
EnergyUnit := ComboBoxEnergy.Items[Energy]; |
759 |
AAUnit := ComboBoxAA.Items[AA]; |
760 |
MineralsUnit := ComboBoxMinerals.Items[Minerals]; |
761 |
end
|
762 |
else // sur mati?re s?che |
763 |
begin
|
764 |
ProximalUnit := Format('%s %s', [ComboBoxProximal.Items[Proximal], _('DM')]); |
765 |
EnergyUnit := Format('%s %s', [ComboBoxEnergy.Items[Energy], _('DM')]); |
766 |
AAUnit := Format('%s %s', [ComboBoxAA.Items[AA], _('DM')]); |
767 |
MineralsUnit := Format('%s %s', [ComboBoxMinerals.Items[Minerals], _('DM')]); |
768 |
end;
|
769 |
with FormOptions do |
770 |
LabelMS.Caption := Format('%s (%s)', [LabelMS.Caption, ComboBoxProximal.Items[Proximal]]);
|
771 |
GroupBoxProximal.Caption := Format('%s (%s)', [GroupBoxProximal.Caption, ProximalUnit]);
|
772 |
GroupBoxEnergy.Caption := Format('%s (%s)', [GroupBoxEnergy.Caption, EnergyUnit]);
|
773 |
LabelRatio.Caption := Format('%s (%%)', [LabelRatio.Caption]);
|
774 |
GroupBoxEnergyUtilization.Caption := Format('%s (%%)', [GroupBoxEnergyUtilization.Caption]);
|
775 |
GroupBoxMinerals.Caption := Format('%s (%s)', [GroupBoxMinerals.Caption, MineralsUnit]);
|
776 |
// LabelCa_Pd.Caption := Format('%s (%%)', [LabelCa_Pd.Caption]);
|
777 |
if FormOptions.Expression = 0 |
778 |
then // sur frais |
779 |
LabelBE.Caption := Format('%s (%s)', [LabelBE.Caption, _('mEq/kg')]) |
780 |
else // sur mati?re s?che |
781 |
LabelBE.Caption := Format('%s (%s %s)', [LabelBE.Caption, _('mEq/kg'), _('DM')]); |
782 |
// GroupBoxAzote.Caption := Format('%s (%%)', [GroupBoxAzote.Caption]);
|
783 |
LabeldN.Caption := Format('%s (%%)', [LabeldN.Caption]);
|
784 |
if FormOptions.Energy = 0 |
785 |
then // MJ |
786 |
LabelLysd_EN.Caption := Format('%s (%s)', [LabelLysd_EN.Caption, _('g/MJ')]) |
787 |
else // kcal |
788 |
LabelLysd_EN.Caption := Format('%s (%s)', [LabelLysd_EN.Caption, _('g/1000kcal')]); |
789 |
if FormOptions.Energy = 0 |
790 |
then // MJ |
791 |
LabelPd_EN.Caption := Format('%s (%s)', [LabelPd_EN.Caption, _('g/MJ')]) |
792 |
else // kcal |
793 |
LabelPd_EN.Caption := Format('%s (%s)', [LabelPd_EN.Caption, _('g/1000kcal')]); |
794 |
GroupBoxAA.Caption := Format('%s (%s)', [GroupBoxAA.Caption, AAUnit]);
|
795 |
LabelIdealProtein.Caption := Format('%s (%%)', [LabelIdealProtein.Caption]);
|
796 |
end;
|
797 |
|
798 |
procedure TFormFeedDetail.FormShow(Sender: TObject);
|
799 |
begin
|
800 |
with DataModuleDeclaration do |
801 |
begin
|
802 |
if ClientDataSetFeedsPresentation.Value = 0 |
803 |
then
|
804 |
EditPresentation.Text := _('Mash')
|
805 |
else
|
806 |
EditPresentation.Text := _('Pellet');
|
807 |
if ClientDataSetFeedsEB.IsNull
|
808 |
then
|
809 |
EditEmpty(ValidateEditEBt_EBc) |
810 |
else
|
811 |
ValidateEditEBt_EBc.Value := 100;
|
812 |
if ClientDataSetFeedsLysd.IsNull
|
813 |
then
|
814 |
EditEmpty(ValidateEditLysd_Lysd) |
815 |
else
|
816 |
ValidateEditLysd_Lysd.Value := 100;
|
817 |
end;
|
818 |
end;
|
819 |
|
820 |
end.
|