Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit MasterForm;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Buttons, ExtCtrls, RumenGut,Microbes, StdCtrls,Math,Utils,
- Global,DateUtils,Printers, Mask, DBCtrls, ComCtrls,strutils, Menus,Save,
- IniFiles, IDGlobal, ShellApi, PDF_In_The_BoxCtl_TLB,System.UITypes, FireDAC.Stan.Intf,
- FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf,
- FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys,
- {FireDAC.Phys.DB2,} FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf,
- FireDAC.DApt, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, FireDAC.Phys.ODBCBase,
- FireDAC.Comp.Client, FireDAC.Comp.DataSet, Data.DB, FireDAC.Stan.ExprFuncs,Variants,
- {FireDAC.Phys.DB2Def, }Vcl.OleCtrls, FireDAC.Phys.MySQLDef, FireDAC.Phys.MySQL,
- FireDAC.VCLUI.Login,lpsolve;
- type
- TNonChecked=array[1..16] of Integer;
- type
- TCategory = record
- Category,FName: array[1..18] of String;
- FAmount,FPrice: array[1..18] of Single;
- end;
- type
- TFeedName=record
- ForageID: Integer;
- FeedNameString: String;
- end;
- type
- TWC=record
- WC_Country,WC_Currency,WC_Abbrev,WC_ISO,WC_Cent: array[1..225] of UnicodeString;
- WC_Fraction: array[1..225] of Integer;
- end;
- type
- TMain = class(TForm)
- Panel1: TPanel;
- SpeedButton3: TSpeedButton;
- btnRun: TSpeedButton;
- SpeedButton1: TSpeedButton;
- SpeedButton5: TSpeedButton;
- SpeedButton6: TSpeedButton;
- SpeedButton7: TSpeedButton;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Maintenance1: TMenuItem;
- Quit1: TMenuItem;
- SaveDialog1: TSaveDialog;
- Help1: TMenuItem;
- SpeedButton4: TSpeedButton;
- PrinterSetup1: TMenuItem;
- PrinterSetupDialog1: TPrinterSetupDialog;
- SpeedButton8: TSpeedButton;
- PrintDialog1: TPrintDialog;
- SpeedButton10: TSpeedButton;
- Open1: TMenuItem;
- SaveAs1: TMenuItem;
- L1: TMenuItem;
- Feeds1: TMenuItem;
- ViewProtein1: TMenuItem;
- ViewEnergy1: TMenuItem;
- ModelOptions1: TMenuItem;
- StatusBar1: TStatusBar;
- NewFarmer1: TMenuItem;
- PreMixes1: TMenuItem;
- About1: TMenuItem;
- SpeedButton11: TSpeedButton;
- ShowAddFeedIngredients1: TMenuItem;
- DeleteaFeed1: TMenuItem;
- DeleteaPreMix1: TMenuItem;
- SetIngPrice: TMenuItem;
- AutoCreatePreMix1: TMenuItem;
- ViewMGP1: TMenuItem;
- Analysebcp1: TMenuItem;
- Optimize1: TMenuItem;
- ModifyRates1: TMenuItem;
- FDConnection1: TFDConnection;
- FDQuery1: TFDQuery;
- FDTable1: TFDTable;
- FDGUIxWaitCursor1: TFDGUIxWaitCursor;
- WhatIf1: TMenuItem;
- WhatIf2: TMenuItem;
- Admin1: TMenuItem;
- Update1: TMenuItem;
- FromDatabase1: TMenuItem;
- pH6Help11: TMenuItem;
- ForagesfromDatabase1: TMenuItem;
- AdjustfNDF1: TMenuItem;
- AddForage1: TMenuItem;
- RestrictDB1: TMenuItem;
- PdfBox1: TPdfBox;
- Label1: TLabel;
- Enlarge1: TMenuItem;
- ShowGraphs1: TMenuItem;
- ShowDiet1: TMenuItem;
- ShowMilk1: TMenuItem;
- ShowNutrients1: TMenuItem;
- ShowRumenFunctions1: TMenuItem;
- ShowMinerals1: TMenuItem;
- FDPhysMySQLDriverLink1: TFDPhysMySQLDriverLink;
- Currency1: TMenuItem;
- Memo1: TMemo;
- procedure SpeedButton3Click(Sender: TObject);
- procedure btnRunClick(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure SpeedButton1Click(Sender: TObject);
- procedure SpeedButton6Click(Sender: TObject);
- procedure SpeedButton7Click(Sender: TObject);
- procedure SpeedButton8Click(Sender: TObject);
- procedure Quit1Click(Sender: TObject);
- procedure SpeedButton4Click(Sender: TObject);
- procedure PrinterSetup1Click(Sender: TObject);
- // procedure SpeedButton9Click(Sender: TObject);
- procedure SpeedButton10Click(Sender: TObject);
- procedure Open1Click(Sender: TObject);
- procedure Save1Click(Sender: TObject);
- procedure SaveAs1Click(Sender: TObject);
- procedure L1Click(Sender: TObject);
- procedure ReadLanguage;
- procedure ViewProtein1Click(Sender: TObject);
- procedure ViewEnergy1Click(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure ModelOptions1Click(Sender: TObject);
- procedure NewFarmer1Click(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure PreMixes1Click(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure SpeedButton11Click(Sender: TObject);
- procedure ShowAddFeedIngredients1Click(Sender: TObject);
- procedure DeleteaFeed1Click(Sender: TObject);
- procedure DeleteaPreMix1Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure SetIngPriceClick(Sender: TObject);
- procedure AutoCreatePreMix1Click(Sender: TObject);
- procedure ViewMGP1Click(Sender: TObject);
- procedure Analysebcp1Click(Sender: TObject);
- procedure Optimize1Click(Sender: TObject);
- procedure ModifyRates1Click(Sender: TObject);
- procedure WhatIf2Click(Sender: TObject);
- procedure Admin1Click(Sender: TObject);
- procedure FromDatabase1Click(Sender: TObject);
- procedure pH6Help11Click(Sender: TObject);
- procedure ForagesfromDatabase1Click(Sender: TObject);
- procedure AdjustfNDF1Click(Sender: TObject);
- procedure AddForage1Click(Sender: TObject);
- procedure RestrictDB1Click(Sender: TObject);
- procedure TrackBar1EndDrag(Sender, Target: TObject; X, Y: Integer);
- procedure Enlarge1Click(Sender: TObject);
- procedure ShowGraphs1Click(Sender: TObject);
- procedure ShowDiet1Click(Sender: TObject);
- procedure ShowMilk1Click(Sender: TObject);
- procedure ShowNutrients1Click(Sender: TObject);
- procedure ShowRumenFunctions1Click(Sender: TObject);
- procedure ShowMinerals1Click(Sender: TObject);
- procedure Currency1Click(Sender: TObject);
- private
- procedure MoveIngredient(FromIng,ToIng: Integer);
- procedure SetUpDBFeedLabels;
- procedure SetUpDBFeedPrices;
- procedure AddPreMix(n,ID: Integer;PreM: TCategory;Total: Single);
- procedure SetUpQuery(n: Integer);
- procedure ReadDBClient(n: Integer);
- procedure SetUpQueryPM(n: Integer);
- procedure ReadDBPreMix(n: Integer);
- procedure WriteIniFile;
- procedure GetMinerals;
- public
- function CopyDir(const fromDir, toDir: string): Boolean;
- function MoveDir(const fromDir, toDir: string): Boolean;
- function HH(Command: Word; Data: Integer;
- var CallHelp: Boolean): Boolean;
- procedure SetRunButtonEnabledStatus(Enabled: boolean);
- procedure GetFeedOrder(Category,Name,AmountDiet1,AmountDiet2,
- AmountDiet3,AmountDiet4,AmountDiet5: String;FeedNo: Integer;
- var p: Integer);
- procedure IfDietTrue(WeekOfLactation: Integer;{var ProteinLoss,BodyProteinGain,
- LostProtein,BodyProteinLoss: Single;} Lignin,MatProtein: Single);
- procedure EnDecryptFile(Path: String);
- procedure DisableToolbarOutputButtons;
- procedure ReadFileMinerals;
- procedure ReadFeedPrice;
- // procedure AddFileToDatabase(AName: String);
- function GetDocuments: string;
- function GetProgramFiles: string;
- function GetProfile: string;
- procedure AreTheyChecked(var NotChecked: TNonChecked);
- procedure SeeWhatChecked(var n,m: Integer);
- procedure SeeWhatCheckedPreMix(var n: Integer);
- // procedure AddToClient(Category,Name: String;FeedNo,TMRorPreMix: Integer);
- // procedure AddToPreMix(Name: String;NewPreMixbcp: MakePreMix;TotalPreMixAmount: Single);
- procedure InitializeDBandTables;
- procedure SetUpDBMasterFeeds;
- procedure SetUpDBClientFeeds;
- procedure SetUpDBPreMixes;
- procedure SetUpDBFormulation;
- procedure SetUpDBFarmer;
- procedure SetUpDBResults;
- procedure DateToRestrictCDB;
- function EncryptStr(const S :WideString; Key: Word): String;
- function IsHex(S: String): Boolean;
- function DecryptStr(const S: String; Key: Word): String;
- end;
- var
- Main: TMain;
- ptrFeedInfo: PFeedsRecord;
- ptrAnimal: PAnimal;
- WCurr: TWC;
- implementation
- uses
- SingleForm, ResultsForm, {Cowform,} Outform, {NewFeed,}{ FILicenceInt,} TMR_Conc,
- ChLanguage, AddFood, Protein, Energy, OptionsUsed, Intro, PrintWhat,
- PDFForm, PDFReports,{ MonthlyLicence,} Blend, AboutUnit, FeedDelete,{ConsultantsReport,}
- shlobj, PreMixDelete, NewClient, ForageCalculator,SetPMName,
- ActiveFibreWarning,MGPcode, Analyse_BCP, ChangeRatesPpn,SetUpDB,Vcl.OleAuto,
- SavingfilestoDB, System.Generics.Collections, System.Generics.Defaults, WhatIf,
- Adminstrator, FeedMill2Solver, Adjust_fNDF, pH6plusFC, RestrictDB, CurrencySelector;
- {$R *.DFM}
- const
- HH_DISPLAY_TOPIC = $0000;
- HH_DISPLAY_TOC = $0001;
- HH_CLOSE_ALL = $0012;
- var
- fsysGrazing,{BackUp,}UpdateYesNo,DifferentHD,RunpH6,SavingData: Boolean;
- moptSingle,moptOptim,NewClients,NewFarmers,NewMaster,NewMineral,NewBlends: Boolean;
- ProteinLoss,BodyProteinGain,LostProtein,BodyProteinLoss,BdyWt,DMIDiet1,AccessServer: Single;
- BeefOrCow: String;
- HardDriveNo: Int64;
- DBMasterFeedsHigh,DBClientFeedsHigh,DBPreMixFeedsHigh,DBFormulationHigh,
- DBFarmerHigh,DBResultsHigh: Integer;
- procedure TMain.FormCreate(Sender: TObject);
- var
- t,n,LowFormulation,LowFormNo,IndexPosn,DaysToGo,i: Integer;
- IniFile: TIniFile;
- //ProgressBarStyle: Integer;
- ex: Boolean;
- Year,Day,Month,YearDS,MonthDS,DayDS: Word;
- RDB: String;
- EDDateStarted: TDateTime;
- Header,NewLine: String;
- SupS: TextFile;
- begin
- //put this in to force '.' rather than ','!
- FormatSettings.DecimalSeparator:='.';
- FormatSettings.DateSeparator:='/';
- Main.Top:=1;
- //ScaleControls((Screen.Width*100)DIV 1260,100);
- FullServerDB:=True; DBConnected:=False; RunpH6:=True;
- Beef:=False;
- ex:=False; OneDrive:=True;
- //Beef:=True;
- //MyDocumentsPath is a string that is set by GetDocuments function + ...
- MyDocumentsPath:=GetDocuments+'\pH6+ Models';
- if Beef then
- begin
- BeefOrCow:='pH6+ Beef';
- DatabaseDirectory:=MyDocumentsPath+'\pH6+ Beef\Database';
- ClientDirectory:=MyDocumentsPath+'\pH6+ Beef\Client';
- end
- else
- begin
- BeefOrCow:='pH6+ Milk';
- DatabaseDirectory:=MyDocumentsPath+'\pH6+ Milk\Database';
- ClientDirectory:=MyDocumentsPath+'\pH6+ Milk\Client';
- BatchModePath:=MyDocumentsPath+'\pH6+ Milk\Batch Data Input';
- end;
- //See if FirstChoice.txt exists which must mean that this is first time
- //Check to see if FirstChoice.txt is in GetDocuments directory because if so, it has been loaded already.
- if FileExists(DatabaseDirectory+'\FirstChoice.txt') then
- begin
- if FileExists(GetDocuments+'\log_pH6+.ph6') then
- begin
- FirstChoice:=False;
- if FileExists(GetDocuments+'\reg_pH6+.ph6') then
- CopyFile(PWideChar(GetDocuments+'\reg_pH6+.ph6'),PWideChar(DatabaseDirectory+'\pH6+ Milk CD.ini'),False);
- end
- else
- FirstChoice:=True;
- end
- else
- begin
- FirstChoice:=False;
- end;
- //FirstChoice:=True;
- {if OneDrive then
- begin
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBFarmer.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFarmer.ph6'),PWideChar(DatabaseDirectory+'\DBFarmer.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBFormulation.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFormulation.ph6'),PWideChar(DatabaseDirectory+'\DBFormulation.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBMasterFeeds.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBMasterFeeds.ph6'),PWideChar(DatabaseDirectory+'\DBMasterFeeds.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBPreMixes.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBPreMixes.ph6'),PWideChar(DatabaseDirectory+'\DBPreMixes.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBClientFeeds.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBClientFeeds.ph6'),PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBResults.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBResults.ph6'),PWideChar(DatabaseDirectory+'\DBResults.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\DBFeedPrices.ph6') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFeedPrices.ph6'),PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),False);
- if FileExists(GetProfile+'\OneDrive\pH6+\Database\'+BeefOrCow+' CD.ini') then
- CopyFile(PWideChar(GetProfile+'\OneDrive\pH6+\Database\'+BeefOrCow+' CD.ini'),PWideChar(DatabaseDirectory+'\'+BeefOrCow+' CD.ini'),False);
- end; }
- //have an ini file to remember certain things
- EnDeCryptFile(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');
- IniFile := TIniFile.Create(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');
- LangID:=IniFile.ReadInteger('Language','LangID',1);
- kgToOther:=IniFile.ReadFloat('Language','kgToOther',1);
- MJToOther:=IniFile.ReadFloat('Language','MJToOther',1);
- BatchMode:=IniFile.ReadBool('Maintenance','Batch',BatchMode);
- //Beef:=IniFile.ReadBool('Maintenance','Beef',Beef);
- //Sheep:=IniFile.ReadBool('Maintenance','Sheep',Sheep);
- ShowAFFile:=IniFile.ReadBool('Maintenance','ShowAFFile',True);
- MasterFeedsHigh:=IniFile.ReadInteger('Maintenance','MasterFeedsHigh',132);
- ClientFeedsHigh:=IniFile.ReadInteger('Maintenance','ClientFeedsHigh',0);
- PreMixFeedsHigh:=IniFile.ReadInteger('Maintenance','PreMixFeedsHigh',0);
- FarmerHigh:=IniFile.ReadInteger('Maintenance','FarmerHigh',0);
- FormulationHigh:=IniFile.ReadInteger('Maintenance','FormulationHigh',0);
- ResultsHigh:=IniFile.ReadInteger('Maintenance','ResultsHigh',0);
- DBResultsChange:=IniFile.ReadBool('Maintenance','DBResultsChange',False);
- DBNotConnected:=IniFile.ReadInteger('Maintenance','DBNotConnected',0);
- DateLastUsed:=IniFile.ReadFloat('Maintenance','DateLastUsed',0);
- User:=IniFile.ReadString('Maintenance','User','-1');
- Password:=IniFile.ReadString('Maintenance','Password','-1');
- User_Name:=IniFile.ReadString('Maintenance','UserName','-1');
- PW:=IniFile.ReadString('Maintenance','PW','-1');
- ProgramCrashed:=IniFile.ReadBool('Maintenance','ProgramCrashed',False);
- IniFile.WriteBool('Maintenance','ProgramCrashed',True);
- OldClientFeedsHigh:=IniFile.ReadInteger('Maintenance','OldClientFeedsHigh',-1);
- OldMasterFeedsHigh:=IniFile.ReadInteger('Maintenance','OldMasterFeedsHigh',-1);
- OldPreMixFeedsHigh:=IniFile.ReadInteger('Maintenance','OldPreMixFeedsHigh',-1);
- OldFormulationHigh:=IniFile.ReadInteger('Maintenance','OldFormulationHigh',-1);
- OldResultsHigh:=IniFile.ReadInteger('Maintenance','OldResultsHigh',-1);
- OldFarmerHigh:=IniFile.ReadInteger('Maintenance','OldFarmerHigh',-1);
- ForagefNDFfactor:=IniFile.ReadFloat('Maintenance','ForagefNDFfactor',1);
- MineralsHigh:=IniFile.ReadInteger('Maintenance','MineralsHigh',6);
- DateStarted:=IniFile.ReadString('Maintenance','DateStarted','20-3-2011');
- DateChosenToRestrictDB:=IniFile.ReadString('Maintenance','DateChosenToRestrictDB','20-3-2011');
- DifferentHDNo:=IniFile.ReadInteger('Maintenance','DifferentHDNo',1);
- HighFormulationPos:=IniFile.ReadInteger('Maintenance','HighFormulationPos',0);
- HighFormulationNeg:=IniFile.ReadInteger('Maintenance','HighFormulationNeg',-5);
- HighResultsPos:=IniFile.ReadInteger('Maintenance','HighResultsPos',0);
- HighResultsNeg:=IniFile.ReadInteger('Maintenance','HighResultsNeg',-5);
- HighClientNeg:=IniFile.ReadInteger('Maintenance','HighClientNeg',-10);
- DateChosenToRestrictDBPM:=IniFile.ReadString('Maintenance','DateChosenToRestrictDBPM','20-3-2011');
- HighPreMixesPos:=IniFile.ReadInteger('Maintenance','HighPreMixesPos',0);
- HighPreMixesNeg:=IniFile.ReadInteger('Maintenance','HighPreMixesNeg',-10);
- YearChosenToRestrictDBFarmer:=IniFile.ReadInteger('Maintenance','YearChosenToRestrictDBFarmer',2011);
- AccessServer:=IniFile.ReadFloat('Maintenance','AccessServer',Now);
- WCCountry:=IniFile.ReadString('Maintenance','WCCountry','United Kingdom');
- WCCurrency:=IniFile.ReadString('Maintenance','WCCurrency','British pound');
- WCAbbrev:=IniFile.ReadString('Maintenance','WCAbbrev','£');
- WCISO:=IniFile.ReadString('Maintenance','WCISO','GBP');
- WCCent:=IniFile.ReadString('Maintenance','WCCent','Penny');
- WCFraction:=IniFile.ReadInteger('Maintenance','WCFraction',100);
- IniFile.Free;
- EnDeCryptFile(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');
- //UserName:='db2admin';//'ph6user';//'db2admin';//'ph6user1';
- //PW:='pHs1xplus';//'pHs1xuseR';//'pHs1xplus';//'pHs1xuseR1';
- if (LangID<1) or (LangID>3) then LangID:=1;
- if kgToOther=0 then kgToOther:=1;
- if MJToOther=0 then MJToOther:=1;
- //User:='neil@ph6plus.com';
- //Password:='barbie45';
- //if User='-1' then FullServerDB:=False;
- if MineralsHigh<7 then MineralsHigh:=6;
- if FarmerHigh=0 then FarmerHigh:=1;
- if AccessServer<Now-30 then
- begin
- if AccessServer<Now-60 then
- begin
- ShowMessage('pH6+ Dairy will close down.'+#13#10+
- 'You haven''t accessed the server for 60 days.'+#13#10+
- 'Please contact info@ph6plus.com for more information');
- Application.Terminate;
- end
- else
- begin
- DaysToGo:=60-Round(Now-AccessServer);
- ShowMessage('You must access the server to check on certain things.'+#13#10+ #13#10+
- 'pH6+ Dairy will not run after 60 days of non-access.' +#13#10+ #13#10+
- 'You have '+IntToStr(DaysToGo)+' days to go!'+#13#10+ #13#10+
- 'Please contact info@ph6plus.com for more information');
- end;
- end;
- if Beef then
- Main.Caption:='pH6+ Beef by pH6+ Ltd'
- else if Sheep then
- Main.Caption:='pH6+ Sheep by pH6+ Ltd'
- else
- Main.Caption:='pH6+ Milk by pH6+ Ltd';
- SFV:=False;
- //SFV:=True;
- SUL:=False;
- //SUL:=True;
- MUL:=True; SingleAutoSolve:=False;
- //MUL:=False; SingleAutoSolve:=False;
- BatchMode:=False;
- WLtoSR:=False;
- Analysebcp1.Visible:=False;
- Zaoying:=False;
- Quit1.Visible:=False;
- Optimize1.Visible:=False;
- if User_Name='db2admin' then
- begin
- Admin1.Visible:=True;
- end
- else
- begin
- Admin1.Visible:=False;
- end;
- Administrator:=False; DietTrue:=False;
- ForageCalc:=False; ResultsSingleCow:=False; NewForageName:=''; UpdateYesNo:=False;
- NotAlkapHer:=True; {Bicarbonate7_74:=True;} AutoSolveName:=False;
- BeefCorrection:=True; LagTimeParlour:=false; ChopLength:=True; LongForage:=False;
- rFeedInfo.SwardLength:=5;
- rFeedInfo.MilkPrice:=28;
- rFeedInfo.RC1:=SolubleRate;//0.325;//0.45;
- SugarHighRate:=True;
- EncryptDatabase:=True;
- pH6:=False;
- OpenIt:=False;
- OpenIt1:=False;
- BeenOpen:=False;
- version1_8:=True;
- PreMixParlourNo:=1;
- RoboticHour[1]:=[3,11,15];
- rFeedInfo.ParlourFeed:=nil;
- PMParlourNameOfTable:=nil;
- PMParlourFeedName:=nil;
- PMParlourAmount:=nil;
- SetLength(rFeedInfo.ParlourFeed,PreMixParlourNo);
- SetLength(PMParlourNameOfTable,PreMixParlourNo);
- SetLength(PMParlourFeedName,PreMixParlourNo);
- SetLength(PMParlourAmount,PreMixParlourNo);
- PMParlourAmount[0]:=100;
- TMRStarted:=False;
- MicrobesAcidosis:=True;
- OpenPath:=DatabaseDirectory;
- ConsultantPhoneNo:=''; ConsultantName:='';
- NewClients:=False; NewFarmers:=False;
- if not FirstChoice then
- begin
- try
- InitializeDBandTables;
- except
- on E: EFDDBEngineException do
- begin
- if E.Kind=ekServerGone then
- begin
- DBConnected:=False;
- FDConnection1.Connected:=False;
- SetUpDBMasterFeeds;
- SetUpDBClientFeeds;
- SetUpDBPreMixes;
- SetUpDBFarmer;
- SetUpDBFormulation;
- SetUpDBResults;
- SetUpDBFeedPrices;
- end;
- end;
- end;
- end;
- FDConnection1.Connected:=False;
- if (DateStarted='20-3-2011') and (DBConnected) then
- begin
- LowFormulation:=DBFormulation[0].ID;
- LowFormNo:=0;
- for n := 1 to Length(DBFormulation)-1 do
- begin
- if DBFormulation[n].ID<LowFormulation then
- begin
- LowFormNo:=n;
- end;
- end;
- SysUtils.DecodeDate(DBFormulation[LowFormNo].DietInfo,Year,Month,Day);
- DateStarted:=IntToStr(Day)+'-'+IntToStr(Month)+'-'+IntToStr(Year);
- DateChosenToRestrictDB:=DateStarted;
- end;
- RDB:=DateStarted;
- IndexPosn:=LastDelimiter('-',RDB);
- YearDS:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- IndexPosn:=LastDelimiter('-',RDB);
- MonthDS:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- DayDS:=StrToInt(RDB);
- EDDateStarted:=EncodeDate(YearDS,MonthDS,DayDS);
- if EDDateStarted>Now-547 then
- RestrictDB1.Enabled:=False;
- SetUpDBFeedLabels;
- if DBConnected then
- StatusBar1.SimpleText:='Connected'
- else
- begin
- StatusBar1.SimpleText:='NOT Connected';
- FromDatabase1.Enabled:=False;
- end;
- if DBConnected then
- FDConnection1.Connected:=False;
- EnDeCryptFile(DatabaseDirectory+'\Stored\DBWC.ph6');
- Memo1.Lines.LoadFromFile(DatabaseDirectory+'\Stored\DBWC.ph6');
- EnDeCryptFile(DatabaseDirectory+'\Stored\DBWC.ph6');
- for i := 0 to Memo1.Lines.Count-1 do
- begin
- NewLine := Memo1.Lines.Strings[i]; // or Line := Memo1.Lines[i];
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_Fraction[i+1]:=StrToInt(Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn));
- Delete(NewLine,IndexPosn,Length(NewLine)-IndexPosn+1);
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_Cent[i+1]:=Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn);
- Delete(NewLine,IndexPosn,Length(NewLine)-IndexPosn+1);
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_ISO[i+1]:=Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn);
- Delete(NewLine,IndexPosn,Length(NewLine)-IndexPosn+1);
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_Abbrev[i+1] :=(Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn));
- Delete(NewLine,IndexPosn,Length(NewLine)-IndexPosn+1);
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_Currency[i+1]:=Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn);
- Delete(NewLine,IndexPosn,Length(NewLine)-IndexPosn+1);
- IndexPosn:=LastDelimiter(',',NewLine);
- WCurr.WC_Country[i+1]:=Copy(NewLine,IndexPosn+1,Length(NewLine)-IndexPosn);
- end;
- for i := 1 to 225 do
- begin
- if WCurr.WC_Country[i]=WCCountry then
- begin
- WCCurrency:=WCurr.WC_Currency[i];
- WCAbbrev:=WCurr.WC_Abbrev[i];
- WCISO:=WCurr.WC_ISO[i];
- WCCent:=WCurr.WC_Cent[i];
- WCFraction:=WCurr.WC_Fraction[i];
- end;
- end;
- SolverExists:=False;
- SpeedButton8.Enabled:=False;
- SpeedButton10.Enabled:=False;
- for n:=1 to 5 do
- begin
- GrazingHour[n]:=[];
- FSParlour[n]:=False;
- ParlourHour[n]:=[5,15];
- end;
- if Beef then
- begin
- SpeedButton5.Visible:=False;
- end;
- JerseyOpt:=1.0;
- for t:=1 to 3 do ParlourFeeds[t]:=2;
- for t:=1 to 4 do Fixed_MilkConcentrate[t]:=True;
- ActiveFibreonProtein:=True;
- NoOfMeals:=11;
- rFeedInfo.LPBRwithRumination:=True;
- rFeedInfo.RatioLongtoTotal:=0.2;
- SingleRun:=True; Virgilio:=False;
- fsysGrazing:=True; TMRRobotic12:=False;
- moptSingle:=True; OldDiet:=False;
- moptOptim:=False;
- SolverText:='Favorites_Init.txt';
- SpeedButton1.Down:=True;
- if Sheep then
- begin
- Animal.Weight:=50;
- Animal.PotMilk:=1;
- Animal.Sex:=2;
- Animal.Species:=2;
- Animal.Maturing:=1;
- Animal.MatureWeight:=75;
- InitialiseAnimal('Sheep');
- LactationDay1:=0.7;
- DigitsOut:=2;
- end
- else
- begin
- Animal.Weight:=600;
- Animal.PotMilk:=20;
- Animal.Sex:=2;
- Animal.Species:=1;
- Animal.Maturing:=1;
- Animal.MatureWeight:=750;
- InitialiseAnimal('cow');
- LactationDay1:=20;
- DigitsOut:=1;
- end;
- if Beef then Animal.Lactating:=False else Animal.Lactating:=True;
- SRMilkYield:=30;
- SRWeek:=12;
- SRMatureWt:=650;
- SRCS:=2.5;
- SRButter:=3.5;
- SRMilkProtein:=3.3;
- Animal.Activity:=0;
- LactationLength:=301;
- Animal.CloseTo:=3;
- Animal.FarOff:=Round((282-LactationLength+70)/7)-Animal.CloseTo;
- DayNo[4]:=LactationLength+Round((282+70-LactationLength-21)*0.67);
- DayNo[5]:=LactationLength+Animal.FarOff*7+14;
- WeekToShow:=6;
- SpeedButton5.Enabled:=False;
- SpeedButton6.Enabled:=False;
- SpeedButton7.Enabled:=False;
- File1.Caption:=rTranslate.no2;
- Open1.Caption:=rTranslate.no10;
- SaveAs1.Caption:=rTranslate.no11;
- PrinterSetup1.Caption:=rTranslate.no16;
- Quit1.Caption:=rTranslate.no15;
- Maintenance1.Caption:=rTranslate.no3;
- Help1.Caption:=rTranslate.no5;
- SpeedButton1.Caption:=rTranslate.no8;
- SpeedButton4.Caption:=rTranslate.no7;
- if Beef then
- btnRun.Caption:=rTranslate.no9+' pH6+ Beef'
- else
- btnRun.Caption:=rTranslate.no9+' pH6+ Milk';
- SpeedButton7.Hint:=rTranslate.no11;
- SpeedButton5.Caption:=rTranslate.no12;
- SpeedButton6.Caption:=rTranslate.no13;
- SpeedButton8.Hint:=rTranslate.no14;
- SpeedButton3.Caption:=rTranslate.no15;
- rFeedInfo.DietToFed[1]:=True;
- rFeedInfo.DietToFed[2]:=False;
- rFeedInfo.DietToFed[3]:=False;
- rFeedInfo.DietToFed[4]:=False;
- rFeedInfo.DietToFed[5]:=False;
- rFeedInfo.DynamicWater:=True;
- rFeedInfo.AddFeed:=False;
- rFeedInfo.LagTime:=True;
- rFeedInfo.Long:=True;
- rFeedInfo.Pectins:=True;
- DMAmount[1]:='';
- for n:=1 to 5 do
- FSGrazingAll[n]:=False;
- rFeedInfo.MY305d1[1,1]:=0.76842;
- rFeedInfo.MY305d1[2,1]:=0.76842;//1;
- rFeedInfo.MY305d1[1,2]:=0.9399;//1.2232;
- rFeedInfo.MY305d1[2,2]:=0.9399;//1.2232;
- rFeedInfo.MY305d1[1,3]:=1;//1.3014;
- rFeedInfo.MY305d1[2,3]:=1;//1.3014;
- rFeedInfo.MY305d[3]:=8000;
- rFeedInfo.MY305d[1]:=Round(rFeedInfo.MY305d[3]*{/}rFeedInfo.MY305d1[1,1{3}]);
- rFeedInfo.MY305d[2]:=Round(rFeedInfo.MY305d[3]*rFeedInfo.MY305d1[1,2]);
- ReadFileMinerals;
- StartFS:=True;
- NewType:=False;
- rFeedInfo.ACHOintoWSCsNDF:=True;
- rFeedInfo.iParlour:=0;
- rFeedInfo.iGrazing:=0;
- rFeedInfo.iRobotic:=0;
- rFeedInfo.iLiquid:=0;
- rFeedInfo.PreMix:=0;
- rFeedInfo.iNonPMFeeds:=0;
- ParlourNDF:=0;
- ParlourOil:=0;
- IMustSave:=False;
- Yeast:=False;
- LargeBull:=1100; LargeSteer:=990; LargeHeifer:=900; LargeHS:=945;
- MediumBull:=950; MediumSteer:=880; MediumHeifer:=800; MediumHS:=840;
- SmallBull:=780; SmallSteer:=715; SmallHeifer:=655; SmallHS:=680;
- PBNa[1]:=2.5;PBNa[2]:=3;PBNa[3]:=7; //3.5
- PBK[1]:=12.5;PBK[2]:=17.5;PBK[3]:=25;
- PBP[1]:=3.8;PBP[2]:=4.2;PBP[3]:=4.6;
- PBCa[1]:=PBP[1]*1.75;PBCa[2]:=PBP[2]*1.75;PBCa[3]:=PBP[3]*2;
- PBCl[1]:=6;PBCl[2]:=6.5;PBCl[3]:=9;
- PBS[1]:=2;PBS[2]:=25;PBS[3]:=30;
- PBMg[1]:=PBK[1]*0.2;PBMg[2]:=PBK[2]*0.2;PBMg[3]:=PBK[3]*0.25;
- PBCu[1]:=12;PBCu[2]:=20;PBCu[3]:=40;
- PBSe[1]:=0.3;PBSe[2]:=0.4;PBSe[3]:=0.5;
- PBZn[1]:=60;PBZn[2]:=100;PBZn[3]:=150;
- PBFe[1]:=150;PBFe[2]:=450;PBFe[3]:=750;
- PBMo[1]:=0;PBMo[2]:=1.5;PBMo[3]:=2.5;
- AutoCreatePreMix:=True; ParlourPreMix:=False;
- ModifyRates1.Visible:=False;
- NotRunYet:=False;
- RestSalivaPpn:=1.25; ParticlePassagePpn:=1; LargeParticleBR:=1; MaxRuminationFactor:=1;
- LargeParticleIntakePpn:=1;
- TCM:=False; version1_01_16:=True;
- PreMixesDelDB:=False; SavingResults:=False; SavingData:=False;
- ClientDelDB:=False; AdjustfNDFClientFeed:=0;
- {AssignFile(SupS,'Minerals.mrq');
- Rewrite(SupS);
- Writeln(SupS,'Na ReqL ReqNL TolL TolNL');
- Header:='2.5'+','+'0.8'+','+'15.7'+','+'35.4'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'K');
- Header:='10'+','+'6.5'+','+'30'+','+'30'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Ca');
- Header:='7'+','+'5'+','+'20'+','+'20'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Mg');
- Header:='2.4'+','+'1.8'+','+'5'+','+'5'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Cl');
- Header:='3.25'+','+'2'+','+'24.3'+','+'54.6'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'P');
- Header:='3.75'+','+'2'+','+'10'+','+'10'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'S');
- Header:='2'+','+'1.5'+','+'3.5'+','+'3.5'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Cu');
- Header:='15'+','+'10'+','+'100'+','+'100'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Se');
- Header:='0.3'+','+'0.15'+','+'2'+','+'2'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Zn');
- Header:='60'+','+'40'+','+'500'+','+'500'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Mn');
- Header:='80'+','+'80'+','+'1000'+','+'1000'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- Writeln(SupS,'Mo');
- Header:='1.75'+','+'1.75'+','+'10'+','+'10'+',';
- Write(SupS,Header);
- Writeln(SupS,'');
- CloseFile(SupS); }
- end;
- procedure TMain.SetUpDBFarmer;
- var
- n: Integer;
- DecryptTelephone: Bool;
- //Value: Bool;
- begin
- //DBNotConnected:=0;
- if (DBConnected) and (DBNotConnected=0) then
- begin
- if (FileExists(DatabaseDirectory+'\DBFarmer.ph6')) and (not DifferentHD) and
- {((n=FarmerHigh) or }(NewFarmers=False) and (Administrator=False) and (UpdateYesNo=False) then
- begin
- n:=FarmerHigh;
- DBFarmer:=nil;
- SetLength(DBFarmer,n);
- EnDeCryptFile(DatabaseDirectory+'\DBFarmer.ph6');
- OpenFarmer(n);
- EnDeCryptFile(DatabaseDirectory+'\DBFarmer.ph6');
- end
- else
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM MasterTable ');
- SQL.Add('WHERE Consultant =:apptype');
- SQL.Add('AND YearStarted >= :apptype1');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- Params[1].DataType:=ftInteger;
- Params[1].Value:=YearChosenToRestrictDBFarmer;
- Open;
- EnableControls;
- end;
- FarmerHigh:=FDQuery1.RecordCount;
- DBFarmer:=nil;
- SetLength(DBFarmer,FarmerHigh);
- FDQuery1.First;
- n:=0;
- while not FDQuery1.Eof do
- begin
- DecryptTelephone:=False;
- DBFarmer[n].Code:=FDQuery1.FieldByName('FarmerDetails').AsString;
- DBFarmer[n].DietID:=FDQuery1.FieldByName('ID').AsInteger;
- if (IsHex(FDQuery1.FieldByName('Name').AsString)) and (FDQuery1.FieldByName('Name').AsString<>'') then
- begin
- DBFarmer[n].Name:=DecryptStr(FDQuery1.FieldByName('Name').AsString,223);
- DecryptTelephone:=True;
- end
- else
- DBFarmer[n].Name:=FDQuery1.FieldByName('Name').AsString;
- if (IsHex(FDQuery1.FieldByName('Address1').AsString)) and (FDQuery1.FieldByName('Address1').AsString<>'') then
- DBFarmer[n].Add1:=DecryptStr(FDQuery1.FieldByName('Address1').AsString,223)
- else
- DBFarmer[n].Add1:=FDQuery1.FieldByName('Address1').AsString;
- if (IsHex(FDQuery1.FieldByName('Address2').AsString)) and (FDQuery1.FieldByName('Address2').AsString<>'') then
- DBFarmer[n].Add2:=DecryptStr(FDQuery1.FieldByName('Address2').AsString,223)
- else
- DBFarmer[n].Add2:=FDQuery1.FieldByName('Address2').AsString;
- if (IsHex(FDQuery1.FieldByName('Address3').AsString)) and (FDQuery1.FieldByName('Address3').AsString<>'') then
- DBFarmer[n].Add3:=DecryptStr(FDQuery1.FieldByName('Address3').AsString,223)
- else
- DBFarmer[n].Add3:=FDQuery1.FieldByName('Address3').AsString;
- if (IsHex(FDQuery1.FieldByName('Postcode').AsString)) and (FDQuery1.FieldByName('Postcode').AsString<>'') then
- DBFarmer[n].PC:=DecryptStr(FDQuery1.FieldByName('Postcode').AsString,223)
- else
- DBFarmer[n].PC:=FDQuery1.FieldByName('Postcode').AsString;
- if (DecryptTelephone) and (FDQuery1.FieldByName('Telephone').AsString<>'') then
- DBFarmer[n].Tel:=DecryptStr(FDQuery1.FieldByName('Telephone').AsString,223)
- else
- DBFarmer[n].Tel:=FDQuery1.FieldByName('Telephone').AsString;
- if (IsHex(FDQuery1.FieldByName('Email').AsString)) and (FDQuery1.FieldByName('Email').AsString<>'') then
- DBFarmer[n].Email:=DecryptStr(FDQuery1.FieldByName('Email').AsString,223)
- else
- DBFarmer[n].Email:=FDQuery1.FieldByName('Email').AsString;
- {Value:=IsHex(FDQuery1.FieldByName('Name').AsString);
- if FDQuery1.FieldByName('Name').AsString='' then Value:=False;
- if Value then
- begin
- DBFarmer[n].Name:=DecryptStr(FDQuery1.FieldByName('Name').AsString,223);
- DBFarmer[n].Add1:=DecryptStr(FDQuery1.FieldByName('Address1').AsString,223);
- DBFarmer[n].Add2:=DecryptStr(FDQuery1.FieldByName('Address2').AsString,223);
- DBFarmer[n].Add3:=DecryptStr(FDQuery1.FieldByName('Address3').AsString,223);
- DBFarmer[n].PC:=DecryptStr(FDQuery1.FieldByName('Postcode').AsString,223);
- DBFarmer[n].Tel:=DecryptStr(FDQuery1.FieldByName('Telephone').AsString,223);
- DBFarmer[n].Email:=DecryptStr(FDQuery1.FieldByName('Email').AsString,223);
- end
- else
- begin
- DBFarmer[n].Name:=FDQuery1.FieldByName('Name').AsString;
- DBFarmer[n].Add1:=FDQuery1.FieldByName('Address1').AsString;
- DBFarmer[n].Add2:=FDQuery1.FieldByName('Address2').AsString;
- DBFarmer[n].Add3:=FDQuery1.FieldByName('Address3').AsString;
- DBFarmer[n].PC:=FDQuery1.FieldByName('Postcode').AsString;
- DBFarmer[n].Tel:=FDQuery1.FieldByName('Telephone').AsString;
- DBFarmer[n].Email:=FDQuery1.FieldByName('Email').AsString;
- end;}
- DBFarmer[n].New:=0;
- inc(n);
- FDQuery1.Next;
- end;
- FDQuery1.Close;
- end;
- end
- else
- begin
- DBFarmer:=nil;
- SetLength(DBFarmer,FarmerHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBFarmer.ph6');
- OpenFarmer(FarmerHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBFarmer.ph6');
- end;
- if FirstChoice then Welcome.FormCreate(Self);
- FirstChoice:=False;
- end;
- procedure TMain.SpeedButton6Click(Sender: TObject);
- const
- DivideBy=1.1;
- var
- TimePoint,MultiplyBy: Integer;
- DontShow: Boolean;
- SupS: TextFile;
- Header: String;
- MyRgn: HRGN;
- begin
- DontShow:=False;
- if SingleRun then
- begin
- // EnlargeOutput:=True;
- if EnlargeOutput then MultiplyBy:=2 else MultiplyBy:=1;
- Results.PageControl1.Visible:=False;
- Results.VertScrollBar.Position:=0;
- Results.HorzScrollBar.Position:=0;
- Results.Panel4.Visible:=True;
- Results.Panel4.Top:=10;
- Results.Panel4.Left:=10;
- Results.Panel4.Width:=Round(MultiplyBy*210/25.4*Results.PixelsPerInch/DivideBy);
- Results.Panel4.Height:=Round(MultiplyBy*297/25.4*Results.PixelsPerInch/DivideBy);
- if EnlargeOutput then
- begin
- if EnlargeGraphs then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.32);
- Results.HorzScrollBar.Position:=Round(Results.Panel4.Width*0.75);
- end;
- if EnlargeDiet then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.21);
- Results.HorzScrollBar.Position:=0;
- end;
- if EnlargeNutrients then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.535);
- Results.HorzScrollBar.Position:=0;
- end;
- if EnlargeMilk then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.19);
- Results.HorzScrollBar.Position:=Round(Results.Panel4.Width*0.75);
- end;
- if EnlargeRumen then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.66);
- Results.HorzScrollBar.Position:=0;
- end;
- if EnlargeMinerals then
- begin
- Results.VertScrollBar.Position:=Round(Results.Panel4.Height*0.65);
- Results.HorzScrollBar.Position:=Round(Results.Panel4.Width*0.75);
- end;
- end
- else
- begin
- Results.VertScrollBar.Position:=Round(205*Results.PixelsPerInch/96);
- end;
- if Beef then TimePoint:=1
- else
- begin
- if LeftStr(Instant.Edit66.Text,1)='-' then
- TimePoint:=Round(LactationLength/DaysInWeek)+7
- +StrToInt(Instant.Edit66.Text)
- else
- TimePoint:=StrToInt(Instant.Edit66.Text);
- end;
- if rNutrientsAbsorbed.DMI[SRLactNo,TimePoint-1]=0 then
- begin
- ShowMessage('The rumen pH is too low!'+#10#13+'Try reducing starch and/or increases NDF in the diet.'+#10#13+
- 'If CP is too low, try increasing CP');
- DontShow:=True;
- end
- else if (rNutrientsAbsorbed.ParlourDMI[SRLactNo,TimePoint-1]>=
- rNutrientsAbsorbed.DMI[SRLactNo,TimePoint-1]) then
- begin
- ShowMessage('You have put in too much Parlour Feed!'+#10#13+
- 'Please reduce the amount fed.'+#10#13+
- 'Parlour: '+FloatToStr(rNutrientsAbsorbed.ParlourDMI[SRLactNo,TimePoint-1])+#10#13+
- 'DMI: '+FloatToStr(rNutrientsAbsorbed.DMI[SRLactNo,TimePoint-1])+#10#13+
- 'SRLactNo: '+IntToStr(SRLactNo)+#10#13+
- 'TimePoint: '+IntToStr(TimePoint)+#10#13+
- 'Days completed:= '+IntToStr(WhyWontItWork)+#10#13+
- 'Intake= '+FloatToStr(WWIW)) ;
- DontShow:=True;
- end
- else
- SingleRunOutput(Results.Image4.Canvas,@Feeding,Results.Panel4.Width,
- Results.Panel4.Height,TimePoint,DivideBy);
- { if FileExists('NeilNDF.txt') then
- begin
- if not DirectoryExists(ClientDirectory+'\ForageNDF') then
- ForceDirectories(ClientDirectory+'\ForageNDF');
- AssignFile(SupS,ClientDirectory+'\ForageNDF\'+Farmer.FD+'-ForageNDF.csv');
- ReWrite(SupS);
- Header:='Forage NDF'+',';
- for TimePoint := 1 to 24 do
- Header:=Header+IntToStr(TimePoint)+',';
- WriteLn(SupS,Header);
- Header:='Total Large Particle Forage NDF'+',';
- for TimePoint := 1 to 24 do
- Header:=Header+FloatToStr(TLongNDFForage[TimePoint])+',';
- WriteLn(SupS,Header);
- Header:='Unfermentable Large Particle Forage NDF'+',';
- for TimePoint := 1 to 24 do
- Header:=Header+FloatToStr(ULongNDFForage[TimePoint])+',';
- WriteLn(SupS,Header);
- Header:='Total Forage NDF'+',';
- for TimePoint := 1 to 24 do
- Header:=Header+FloatToStr(TNDFForage[TimePoint])+',';
- WriteLn(SupS,Header);
- Header:='Unfermentable Forage NDF'+',';
- for TimePoint := 1 to 24 do
- Header:=Header+FloatToStr(UNDFForage[TimePoint])+',';
- WriteLn(SupS,Header);
- CloseFile(SupS);
- end; }
- end;
- if not DontShow then Results.Show;
- end;
- function TMain.GetDocuments: string;
- var
- r: Bool;
- path: array[0..Max_Path] of Char;
- text: String;
- begin
- r := ShGetSpecialFolderPath(0, path, CSIDL_PERSONAL , False) ;
- if LangID=2 then
- text:='Dossier ''mes documents'' introuve'
- else
- text:='Could not find MyDocuments folder location.';
- if not r then raise Exception.Create(text) ;
- Result := Path;
- end;
- function TMain.GetProgramFiles: string;
- var
- r: Bool;
- path: array[0..Max_Path] of Char;
- text: String;
- begin
- r := ShGetSpecialFolderPath(0, path, CSIDL_PROGRAM_FILES , False) ;
- text:='Could not find Program Files folder location.';
- if not r then raise Exception.Create(text) ;
- Result := Path;
- end;
- function TMain.GetProfile: string;
- var
- r: Bool;
- path: array[0..Max_Path] of Char;
- text: String;
- begin
- r := ShGetSpecialFolderPath(0, path, CSIDL_PROFILE , False) ;
- text:='Could not find Profile folder location.';
- if not r then raise Exception.Create(text) ;
- Result := Path;
- end;
- function HtmlHelp(hwndCaller: HWND;
- pszFile: PChar; uCommand: UINT;
- dwData: DWORD): HWND; stdcall;
- external 'HHCTRL.OCX' name 'HtmlHelpW';
- procedure TMain.SetRunButtonEnabledStatus(Enabled: boolean);
- var
- ToolbarRunButton: TControl;
- begin
- ToolbarRunButton := Main.btnRun;
- if version1_8 then ToolbarRunButton.Enabled := Enabled;
- end;
- procedure TMain.DisableToolbarOutputButtons;
- // Disables the toolbar output buttons (Graph & Table) - these are re-enabled
- // once the toolbar Run button is clicked.
- // The Graph button is TMain.SpeedButton5
- // The Table button is TMain.SpeedButton6
- var
- ToolbarGraphButton: TSpeedButton;
- ToolbarTableButton: TSpeedButton;
- begin
- ToolbarGraphButton := Self.SpeedButton5;
- ToolbarTableButton := Self.SpeedButton6;
- if version1_8 then
- begin
- ToolbarGraphButton.Enabled := False;
- ToolbarGraphButton.Down := False;
- ToolbarTableButton.Enabled := False;
- ToolbarTableButton.Down := False;
- end;
- end;
- procedure TMain.EnDecryptFile(Path: String);
- var
- InMS, OutMS: TMemoryStream;
- cnt: Integer;
- C: byte;
- begin
- InMS := TMemoryStream.Create;
- OutMS := TMemoryStream.Create;
- try
- InMS.LoadFromFile(Path);
- InMS.Position := 0;
- for cnt := 0 to InMS.Size - 1 DO
- begin
- InMS.Read(C, 1);
- C := (C xor not (ord(5981 shr cnt)));
- OutMS.Write(C, 1);
- end;
- OutMS.SaveToFile(Path);
- finally
- InMS.Free;
- OutMS.Free;
- end;
- end;
- procedure TMain.Enlarge1Click(Sender: TObject);
- begin
- //if EnlargeOutput and (EnlargeGraphs or EnlargeDiet
- // or EnlargeMilk or EnlargeNutrients or EnlargeNutrients
- // or EnlargeMinerals) then EnlargeOutput:=False else EnlargeOutput:=True;
- end;
- function TMain.EncryptStr(const S :WideString; Key: Word): String;
- var i :Integer;
- RStr :RawByteString;
- RStrB :TBytes Absolute RStr;
- begin
- Result:= '';
- RStr:= UTF8Encode(S);
- for i := 0 to Length(RStr)-1 do begin
- RStrB[i] := RStrB[i] xor (Key shr 8);
- Key := (RStrB[i] + Key) * CKEY1 + CKEY2;
- end;
- for i := 0 to Length(RStr)-1 do begin
- Result:= Result + IntToHex(RStrB[i], 2);
- end;
- end;
- function TMain.IsHex(S: String): Boolean;
- var
- n: Integer;
- begin
- Result:=True;
- for n := 1 to length(s) do
- if not (char(s[n]) in ['0'..'9']) and not (char(s[n]) in ['A'..'F']) then
- begin
- Result:=False;
- exit;
- end;
- end;
- function TMain.DecryptStr(const S: String; Key: Word): String;
- var i, tmpKey :Integer;
- RStr :RawByteString;
- RStrB :TBytes Absolute RStr;
- tmpStr :string;
- begin
- tmpStr:= UpperCase(S);
- SetLength(RStr, Length(tmpStr) div 2);
- i:= 1;
- try
- while (i < Length(tmpStr)) do begin
- RStrB[i div 2]:= StrToInt('$' + tmpStr[i] + tmpStr[i+1]);
- Inc(i, 2);
- end;
- except
- Result:= '';
- Exit;
- end;
- for i := 0 to Length(RStr)-1 do begin
- tmpKey:= RStrB[i];
- RStrB[i] := RStrB[i] xor (Key shr 8);
- Key := (tmpKey + Key) * CKEY1 + CKEY2;
- end;
- Result:= UTF8ToString(RStr);
- end;
- procedure TMain.SetUpQueryPM(n: Integer);
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Blends '); //localhost
- SQL.Add('WHERE Consultant =:apptype');
- // if n=1 then
- SQL.Add('AND DateAdded > :DateLastUsed');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- // if n=1 then
- // begin
- Params[1].DataType:=ftInteger;
- Params[1].Value:=DateIntegerPM;
- // end;
- Open;
- EnableControls;
- end;
- FDQuery1.First;
- end;
- procedure TMain.SetUpQuery(n: Integer);
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Client ');
- SQL.Add('WHERE ( Consultant =:apptype)');
- SQL.Add('AND ( DateAdded >:apptype1');
- SQL.Add('OR ID <0)');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- Params[1].DataType:=ftInteger;
- Params[1].Value:=DateInteger-60;
- Open;
- EnableControls;
- end;
- FDQuery1.First;
- end;
- procedure TMain.SetUpDBFormulation;
- var
- n: Integer;
- begin
- //DBNotConnected:=0;
- if (DBConnected) and (DBNotConnected=0) then
- begin
- if (FileExists(DatabaseDirectory+'\DBFormulation.ph6')) {and (n=FormulationHigh) }
- and (Administrator=False) and (UpdateYesNo=False) and (not DifferentHD) then
- begin
- n:=FormulationHigh;
- DBFormulation:=nil;
- SetLength(DBFormulation,n);
- EnDeCryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- OpenFormulation(n);
- EnDeCryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- end
- else
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Formulation ');
- SQL.Add('WHERE Consultant =:apptype');
- SQL.Add('AND Started >:apptype1');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- Params[1].DataType:=ftInteger;
- Params[1].Value:=DateInteger;
- Open;
- EnableControls;
- end;
- FDQuery1.First;
- FormulationHigh:=FDQuery1.RecordCount;
- DBFormulation:=nil;
- SetLength(DBFormulation,FormulationHigh);
- n:=0;
- while not FDQuery1.Eof do
- begin
- DBFormulation[n].ID:=FDQuery1.FieldByName('ID').AsInteger;
- DBFormulation[n].FarmerDetails:=FDQuery1.FieldByName('FarmerDetails').AsString;
- DBFormulation[n].FormDate:=FDQuery1.FieldByName('FormDate').AsString;
- DBFormulation[n].StartDate:=FDQuery1.FieldByName('StartDate').AsString;
- DBFormulation[n].FinishDate:=FDQuery1.FieldByName('FinishDate').AsString;
- DBFormulation[n].Nutritionist:=FDQuery1.FieldByName('Nutritionist').AsString;
- DBFormulation[n].DietInfo:=FDQuery1.FieldByName('Started').AsInteger;
- DBFormulation[n].NowInt:=Round(DateTimeToModifiedJulianDate(DBFormulation[n].DietInfo)*Thousand);
- DBFormulation[n].New:=0;
- inc(n);
- FDQuery1.Next;
- end;
- end;
- FDQuery1.Close;
- end
- else
- begin
- DBFormulation:=nil;
- SetLength(DBFormulation,FormulationHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- OpenFormulation(FormulationHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- end;
- TArray.Sort<TFormulation>(DBFormulation, TDelegatedComparer<TFormulation>.Construct
- (function(const Left, Right: TFormulation): Integer
- begin
- Result:=TComparer<Integer>.Default.Compare(Left.NowInt,Right.NowInt);
- end));
- end;
- procedure TMain.SetUpDBResults;
- var
- n: Integer;
- begin
- //DBNotConnected:=0;
- if (DBConnected) and (DBNotConnected=0) then
- begin
- if (FileExists(DatabaseDirectory+'\DBResults.ph6')) {and (n=ResultsHigh)} and (not DifferentHD)
- and (not DBResultsChange) and (Administrator=False) and (UpdateYesNo=False) then
- begin
- n:=ResultsHigh;
- DBResults:=nil;
- SetLength(DBResults,n);
- // EnDeCryptFile(DatabaseDirectory+'\DBResults.ph6');
- OpenResults(n);
- // EnDeCryptFile(DatabaseDirectory+'\DBResults.ph6');
- end
- else
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Results ');
- SQL.Add('WHERE Consultant =:apptype');
- SQL.Add('AND Diet IN (Select ID FROM Formulation WHERE Consultant =:apptype AND Started >:apptype1)');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- Params[1].DataType:=ftInteger;
- Params[1].Value:=DateInteger;
- Open;
- EnableControls;
- end;
- FDQuery1.First;
- ResultsHigh:=FDQuery1.RecordCount;
- DBResults:=nil;
- SetLength(DBResults,ResultsHigh);
- DBResultsChange:=False;
- n:=0;
- while not FDQuery1.Eof do
- begin
- DBResults[n].New:=0;
- DBResults[n].ID:=FDQuery1.FieldByName('ID').AsInteger;
- DBResults[n].Client:=FDQuery1.FieldByName('Client').AsInteger;
- DBResults[n].Diet:=FDQuery1.FieldByName('Diet').AsInteger;
- DBResults[n].TMR1:=FDQuery1.FieldByName('TMR 1').AsInteger;
- DBResults[n].TMR2:=FDQuery1.FieldByName('TMR 2').AsInteger;
- DBResults[n].TMR3:=FDQuery1.FieldByName('TMR 3').AsInteger;
- DBResults[n].TMR4:=FDQuery1.FieldByName('TMR 4').AsInteger;
- DBResults[n].TMR5:=FDQuery1.FieldByName('TMR 5').AsInteger;
- DBResults[n].TMR6:=FDQuery1.FieldByName('TMR 6').AsInteger;
- DBResults[n].TMR7:=FDQuery1.FieldByName('TMR 7').AsInteger;
- DBResults[n].TMR8:=FDQuery1.FieldByName('TMR 8').AsInteger;
- DBResults[n].TMR9:=FDQuery1.FieldByName('TMR 9').AsInteger;
- DBResults[n].TMR10:=FDQuery1.FieldByName('TMR 10').AsInteger;
- DBResults[n].TMR11:=FDQuery1.FieldByName('TMR 11').AsInteger;
- DBResults[n].TMR12:=FDQuery1.FieldByName('TMR 12').AsInteger;
- DBResults[n].TMR13:=FDQuery1.FieldByName('TMR 13').AsInteger;
- DBResults[n].TMR14:=FDQuery1.FieldByName('TMR 14').AsInteger;
- DBResults[n].TMR15:=FDQuery1.FieldByName('TMR 15').AsInteger;
- DBResults[n].TMR16:=FDQuery1.FieldByName('TMR 16').AsInteger;
- DBResults[n].Parlour1:=FDQuery1.FieldByName('Parlour 1').AsInteger;
- DBResults[n].Parlour2:=FDQuery1.FieldByName('Parlour 2').AsInteger;
- DBResults[n].Parlour3:=FDQuery1.FieldByName('Parlour 3').AsInteger;
- DBResults[n].Grazing:=FDQuery1.FieldByName('Grazing').AsInteger;
- DBResults[n].ResultsID:=FDQuery1.FieldByName('ResultsID').AsInteger;
- DBResults[n].MatureBW:=FDQuery1.FieldByName('MatureBW').AsInteger;
- DBResults[n].WeekOfLactation:=FDQuery1.FieldByName('WeekOfLactation').AsInteger;
- DBResults[n].PotentialYield:=FDQuery1.FieldByName('PotentialYield').AsInteger;
- DBResults[n].Heifer3:=FDQuery1.FieldByName('Heifer-3+').AsInteger;
- DBResults[n].NoOfCows:=FDQuery1.FieldByName('NoOfCows').AsInteger;
- DBResults[n].FeedingStrategyPlan:=FDQuery1.FieldByName('FeedingStrategyPlan').AsInteger;
- DBResults[n].MilkingFrequency:=FDQuery1.FieldByName('MilkingFrequency').AsInteger;
- DBResults[n].GrazingTimeAfterMilking:=FDQuery1.FieldByName('GrazingTimeAfterMilking').AsInteger;
- DBResults[n].ParlourType:=FDQuery1.FieldByName('Parlour Type').AsInteger;
- DBResults[n].GrazingSwardLength:=FDQuery1.FieldByName('GrazingSwardLength').AsInteger;
- DBResults[n].LactorGrowth:=FDQuery1.FieldByName('LactorGrowth').AsInteger;
- DBResults[n].SizeOfAnimal:=FDQuery1.FieldByName('SizeOfAnimal').AsInteger;
- DBResults[n].JerseyBreed:=FDQuery1.FieldByName('JerseyBreed').AsInteger;
- DBResults[n].GrazingStartAfterMilking:=FDQuery1.FieldByName('GrazingStartaftermilking').AsInteger;
- DBResults[n].TMR1Type:=FDQuery1.FieldByName('TMR 1 Type').AsString;
- DBResults[n].TMR2Type:=FDQuery1.FieldByName('TMR 2 Type').AsString;
- DBResults[n].TMR3Type:=FDQuery1.FieldByName('TMR 3 Type').AsString;
- DBResults[n].TMR4Type:=FDQuery1.FieldByName('TMR 4 Type').AsString;
- DBResults[n].TMR5Type:=FDQuery1.FieldByName('TMR 5 Type').AsString;
- DBResults[n].TMR6Type:=FDQuery1.FieldByName('TMR 6 Type').AsString;
- DBResults[n].TMR7Type:=FDQuery1.FieldByName('TMR 7 Type').AsString;
- DBResults[n].TMR8Type:=FDQuery1.FieldByName('TMR 8 Type').AsString;
- DBResults[n].TMR9Type:=FDQuery1.FieldByName('TMR 9 Type').AsString;
- DBResults[n].TMR10Type:=FDQuery1.FieldByName('TMR 10 Type').AsString;
- DBResults[n].TMR11Type:=FDQuery1.FieldByName('TMR 11 Type').AsString;
- DBResults[n].TMR12Type:=FDQuery1.FieldByName('TMR 12 Type').AsString;
- DBResults[n].TMR13Type:=FDQuery1.FieldByName('TMR 13 Type').AsString;
- DBResults[n].TMR14Type:=FDQuery1.FieldByName('TMR 14 Type').AsString;
- DBResults[n].TMR15Type:=FDQuery1.FieldByName('TMR 15 Type').AsString;
- DBResults[n].TMR16Type:=FDQuery1.FieldByName('TMR 16 Type').AsString;
- DBResults[n].Parlour1Type:=FDQuery1.FieldByName('Parlour 1 Type').AsString;
- DBResults[n].Parlour2Type:=FDQuery1.FieldByName('Parlour 2 Type').AsString;
- DBResults[n].Parlour3Type:=FDQuery1.FieldByName('Parlour 3 Type').AsString;
- DBResults[n].TMR1Amount:=FDQuery1.FieldByName('TMR 1 Amount').AsString;
- DBResults[n].TMR2Amount:=FDQuery1.FieldByName('TMR 2 Amount').AsString;
- DBResults[n].TMR3Amount:=FDQuery1.FieldByName('TMR 3 Amount').AsString;
- DBResults[n].TMR4Amount:=FDQuery1.FieldByName('TMR 4 Amount').AsString;
- DBResults[n].TMR5Amount:=FDQuery1.FieldByName('TMR 5 Amount').AsString;
- DBResults[n].TMR6Amount:=FDQuery1.FieldByName('TMR 6 Amount').AsString;
- DBResults[n].TMR7Amount:=FDQuery1.FieldByName('TMR 7 Amount').AsString;
- DBResults[n].TMR8Amount:=FDQuery1.FieldByName('TMR 8 Amount').AsString;
- DBResults[n].TMR9Amount:=FDQuery1.FieldByName('TMR 9 Amount').AsString;
- DBResults[n].TMR10Amount:=FDQuery1.FieldByName('TMR 10 Amount').AsString;
- DBResults[n].TMR11Amount:=FDQuery1.FieldByName('TMR 11 Amount').AsString;
- DBResults[n].TMR12Amount:=FDQuery1.FieldByName('TMR 12 Amount').AsString;
- DBResults[n].TMR13Amount:=FDQuery1.FieldByName('TMR 13 Amount').AsString;
- DBResults[n].TMR14Amount:=FDQuery1.FieldByName('TMR 14 Amount').AsString;
- DBResults[n].TMR15Amount:=FDQuery1.FieldByName('TMR 15 Amount').AsString;
- DBResults[n].TMR16Amount:=FDQuery1.FieldByName('TMR 16 Amount').AsString;
- DBResults[n].Parlour1Amount:=FDQuery1.FieldByName('Parlour Amount 1').AsString;
- DBResults[n].Parlour2Amount:=FDQuery1.FieldByName('Parlour Amount 2').AsString;
- DBResults[n].Parlour3Amount:=FDQuery1.FieldByName('Parlour Amount 3').AsString;
- DBResults[n].Parlour4Amount:=FDQuery1.FieldByName('Parlour Amount 4').AsString;
- DBResults[n].GrazingType:=FDQuery1.FieldByName('Grazing Type').AsString;
- DBResults[n].Priceperlitre:=FDQuery1.FieldByName('Priceperlitre').AsFloat;
- DBResults[n].ConditionScore:=FDQuery1.FieldByName('ConditionScore').AsFloat;
- DBResults[n].MilkFat:=FDQuery1.FieldByName('MilkFat').AsFloat;
- DBResults[n].MilkProtein:=FDQuery1.FieldByName('MilkProtein').AsFloat;
- DBResults[n].ph1:=FDQuery1.FieldByName('pH 1').AsFloat;
- DBResults[n].ph2:=FDQuery1.FieldByName('pH 2').AsFloat;
- DBResults[n].ph3:=FDQuery1.FieldByName('pH 3').AsFloat;
- DBResults[n].ph4:=FDQuery1.FieldByName('pH 4').AsFloat;
- DBResults[n].ph5:=FDQuery1.FieldByName('pH 5').AsFloat;
- DBResults[n].ph6:=FDQuery1.FieldByName('pH 6').AsFloat;
- DBResults[n].ph7:=FDQuery1.FieldByName('pH 7').AsFloat;
- DBResults[n].ph8:=FDQuery1.FieldByName('pH 8').AsFloat;
- DBResults[n].ph9:=FDQuery1.FieldByName('pH 9').AsFloat;
- DBResults[n].ph10:=FDQuery1.FieldByName('pH 10').AsFloat;
- DBResults[n].ph11:=FDQuery1.FieldByName('pH 11').AsFloat;
- DBResults[n].ph12:=FDQuery1.FieldByName('pH 12').AsFloat;
- DBResults[n].ph13:=FDQuery1.FieldByName('pH 13').AsFloat;
- DBResults[n].ph14:=FDQuery1.FieldByName('pH 14').AsFloat;
- DBResults[n].ph15:=FDQuery1.FieldByName('pH 15').AsFloat;
- DBResults[n].ph16:=FDQuery1.FieldByName('pH 16').AsFloat;
- DBResults[n].ph17:=FDQuery1.FieldByName('pH 17').AsFloat;
- DBResults[n].ph18:=FDQuery1.FieldByName('pH 18').AsFloat;
- DBResults[n].ph19:=FDQuery1.FieldByName('pH 19').AsFloat;
- DBResults[n].ph20:=FDQuery1.FieldByName('pH 20').AsFloat;
- DBResults[n].ph21:=FDQuery1.FieldByName('pH 21').AsFloat;
- DBResults[n].ph22:=FDQuery1.FieldByName('pH 22').AsFloat;
- DBResults[n].ph23:=FDQuery1.FieldByName('pH 23').AsFloat;
- DBResults[n].ph24:=FDQuery1.FieldByName('pH 24').AsFloat;
- DBResults[n].CH4:=FDQuery1.FieldByName('CH4').AsFloat;
- DBResults[n].ConcUse:=FDQuery1.FieldByName('ConcUse kgDM/litre').AsFloat;
- // DBResults[n].ConcFeed£hdd:=FDQuery1.FieldByName('ConcFeed £/hd/d').AsFloat;
- // DBResults[n].ConcFeedpl:=FDQuery1.FieldByName('ConcFeed p/litre').AsFloat;
- // DBResults[n].AllFeed£hdd:=FDQuery1.FieldByName('AllFeeds £/hd/d').AsFloat;
- // DBResults[n].AllFeedpl:=FDQuery1.FieldByName('AllFeeds p/litre').AsFloat;
- // DBResults[n].MarginOverFeed£hdd:=FDQuery1.FieldByName('Marginoverfeed £/hd/d').AsFloat;
- // DBResults[n].MarginOverFeedpl:=FDQuery1.FieldByName('Marginoverfeed p/litre').AsFloat;
- // DBResults[n].MilkYieldAchieved:=FDQuery1.FieldByName('MilkYieldAchieved').AsFloat;
- // DBResults[n].ParlourTMR:=FDQuery1.FieldByName('ParlourTMR').AsString;
- // DBResults[n].PredictedDMI:=FDQuery1.FieldByName('PredictedDMI').AsFloat;
- // DBResults[n].PredictedForagePC:=FDQuery1.FieldByName('PredictedForagePC').AsFloat;
- inc(n);
- FDQuery1.Next;
- end;
- FDQuery1.Close;
- end;
- end
- else
- begin
- DBResults:=nil;
- SetLength(DBResults,ResultsHigh);
- // EnDeCryptFile(DatabaseDirectory+'\DBResults.ph6');
- OpenResults(ResultsHigh);
- // EnDeCryptFile(DatabaseDirectory+'\DBResults.ph6');
- end;
- end;
- procedure TMain.InitializeDBandTables;
- var
- DateOfNow: Double;
- MaximumComponentLength, FileSystemFlags, VolumeSerialNumber: DWORD;
- StoredHardDriveNo: Int64;
- Header: String;
- SupS: TextFile;
- begin
- Consultant:=0; DifferentHD:=False; HardDriveNo:=0; DBMasterFeedsHigh:=0;
- DBClientFeedsHigh:=0; DBPreMixFeedsHigh:=0; DBFormulationHigh:=0;
- DBFarmerHigh:=0; DBResultsHigh:=0; ShutDownNow:=False;
- //FullServerDB:=False;DBConnected:=False;
- try
- if FullServerDB then
- begin
- if FDConnection1.Ping then
- begin
- DateToRestrictCDB;
- FDConnection1.Connected:=True;
- FDTable1.TableName:='Consultant';
- FDTable1.Open;
- DBConnected:=True;
- NewClients:=False;
- NewFarmers:=False;
- NewMaster:=False;
- NewMineral:=False;
- NewBlends:=False;
- NIRS4Farm:=False;
- // Consultant:=0;
- if FDTable1.Locate('User',User,[]) then
- begin
- if FDTable1.FieldByName('Password').AsString=Password then
- begin
- AccessServer:=Now;
- GetVolumeInformationA('C:\', nil, 0, @VolumeSerialNumber,
- MaximumComponentLength, FileSystemFlags, nil, 0);
- HardDriveNo:=VolumeSerialNumber;
- Consultant:=FDTable1.FieldByName('ID').AsInteger;
- ConsultantName:=FDTable1.FieldByName('NameOfConsultant').AsString;
- ConsultantPhoneNo:=FDTable1.FieldByName('Telephone').AsString;
- StoredHardDriveNo:=FDTable1.FieldByName('SHDN').AsLargeInt;
- if StoredHardDriveNo<>HardDriveNo then
- begin
- DifferentHD:=True;
- if FirstChoice then DifferentHD:=False;
- if StoredHardDriveNo<HardDriveNo then
- DifferentHDNo:=1
- else
- DifferentHDNo:=2;
- end;
- if FDTable1.FieldByName('Client').AsInteger=1 then
- NewClients:=True;
- if FDTable1.FieldByName('MasterTable').AsInteger=1 then
- NewFarmers:=True;
- if FDTable1.FieldByName('MasterFeeds').AsInteger=1 then
- NewMaster:=True;
- if FDTable1.FieldByName('Minerals').AsInteger=1 then
- NewMineral:=True;
- if FDTable1.FieldByName('Blends').AsInteger=1 then
- NewBlends:=True;
- if FDTable1.FieldByName('Addcsv').AsInteger=1 then
- NIRS4Farm:=True;
- if (NewClients) or (NewFarmers) or (NewMaster) or (DifferentHD)
- or (NewMineral) or (NewBlends) then
- begin
- FDTable1.Edit;
- FDTable1.FieldByName('Client').AsInteger:=0;
- FDTable1.FieldByName('MasterTable').AsInteger:=0;
- FDTable1.FieldByName('MasterFeeds').AsInteger:=0;
- FDTable1.FieldByName('SHDN').AsLargeInt:=HardDriveNo;
- FDTable1.FieldByName('Minerals').AsInteger:=0;
- FDTable1.FieldByName('Blends').AsInteger:=0;
- FDTable1.Post;
- end;
- DateOfNow:=Now;
- if DateOfNow>FDTable1.FieldByName('PaidUntil').AsFloat then
- begin
- if (DateOfNow-31)>FDTable1.FieldByName('PaidUntil').AsFloat then
- ShutDownNow:=True;
- DBConnected:=False;
- FDConnection1.Connected:=False;
- end;
- end;
- end
- else
- begin
- FirstChoice:=True;
- DBConnected:=False;
- end;
- FDTable1.Close;
- if DifferentHD then
- begin
- FDTable1.TableName:='INIFiles';
- FDTable1.Open;
- if FDTable1.Locate('Consultant',Consultant,[]) then
- begin
- DBMasterFeedsHigh:=FDTable1.FieldByName('MasterFeedsHigh').AsInteger;
- DBClientFeedsHigh:=FDTable1.FieldByName('ClientFeedsHigh').AsInteger;
- DBPreMixFeedsHigh:=FDTable1.FieldByName('PreMixFeedsHigh').AsInteger;
- DBFormulationHigh:=FDTable1.FieldByName('FormulationHigh').AsInteger;
- DBFarmerHigh:=FDTable1.FieldByName('FarmerHigh').AsInteger;
- if DBFarmerHigh=0 then DBFarmerHigh:=1;
- DBResultsHigh:=FDTable1.FieldByName('ResultsHigh').AsInteger;
- end;
- FDTable1.Close;
- end;
- if (Consultant>0) and DBConnected then
- begin
- FDTable1.TableName:='Useage';
- FDTable1.Open;
- FDTable1.Append;
- FDTable1.FieldByName('Consultant').AsInteger:=Consultant;
- FDTable1.FieldByName('LastUsed').AsDateTime:=StrToDateTime(DateTimeToStr(Now));
- FDTable1.FieldByName('Version').AsString:=VersionNo;
- FDTable1.Post;
- FDTable1.Close;
- end;
- end;
- end;
- //if not FirstChoice then
- // begin
- SetUpDBMasterFeeds;
- SetUpDBClientFeeds;
- SetUpDBPreMixes;
- SetUpDBFarmer;
- SetUpDBFormulation;
- SetUpDBResults;
- SetUpDBFeedPrices;
- if DBConnected then DateLastUsed:=Now;
- GetMinerals;
- // end;
- except
- end;
- end;
- procedure TMain.SpeedButton3Click(Sender: TObject);
- const
- PingTime=800;
- var
- n,m: Integer;
- SaveCursor: TCursor;
- text: String;
- ComboResults,DBPingTime,NotTicked: Boolean;
- Start,Stop,ElapsedTime: Integer;
- begin
- //if not DirectoryExists(GetProfile+'\OneDrive\pH6+\Database') then
- // ForceDirectories(GetProfile+'\OneDrive\pH6+\Database');
- if not Administrator then
- begin
- SaveCursor:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- DBNotConnected:=0; DBPingTime:=True;
- if DBConnected then
- begin
- if not SavingData then
- begin
- SaveToDB.Show;
- Application.ProcessMessages;
- end;
- FDConnection1.LoginPrompt:=False;
- if FDConnection1.Ping then
- begin
- FDConnection1.Connected:=True;
- end
- else
- begin
- DBConnected:=False;
- end;
- end;
- text:='';
- try
- SaveMaster;
- if MasterFeedsHigh>OldMasterFeedsHigh then OldMasterFeedsHigh:=MasterFeedsHigh;
- EnDecryptFile(DatabaseDirectory+'\DBMasterFeeds.ph6');
- if MasterFeedsHigh=OldMasterFeedsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBMasterFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBMasterFeeds.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBMasterFeeds.ph6'),False);
- end;
- // FileSizes(DatabaseDirectory+'\DBMasterFeeds.ph6',DatabaseDirectory+'\Stored\DBMasterFeeds.ph6');
- // CopyFile(PWideChar(DatabaseDirectory+'\DBMasterFeeds.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBMasterFeeds.ph6'),False);
- except
- text:=text+'MasterFeeds not saved ';
- end;
- try
- AreAmendClient;
- ElapsedTime:=0;
- if (ClientToDB) and (DBConnected) then
- begin
- Start:=GetTickCount;
- if (FDConnection1.Ping) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- if ElapsedTime>PingTime then DBPingTime:=False;
- DBPingTime:=True;
- if DBPingTime then
- begin
- FDTable1.TableName:='Client';
- FDTable1.Open;
- for n := 0 to Length(AmendClient)-1 do
- begin
- if AmendClient[n].New=-1 then //delete
- begin
- if FDTable1.Locate('Consultant;ID',VarArrayOf([Consultant,AmendClient[n].ID]),[]) then
- begin
- FDTable1.Delete;
- end;
- end
- else if AmendClient[n].New=1 then //insert
- begin
- for m := 0 to Length(DBClientFeeds)-1 do
- if AmendClient[n].ID=DBClientFeeds[m].ID then
- begin
- InsertClient(DBClientFeeds[m],1);
- DBClientFeeds[m].New:=0;
- end;
- end
- else if AmendClient[n].New=-2 then //append new cost or new DM
- begin
- for m := 0 to Length(DBClientFeeds)-1 do
- if AmendClient[n].ID=DBClientFeeds[m].ID then
- begin
- InsertClient(DBClientFeeds[m],-2);
- DBClientFeeds[m].New:=0;
- AmendClient[n].New:=0;
- end;
- end
- else if AmendClient[n].New=-3 then //append new GasA - multiplier for fNDF
- begin
- for m := 0 to Length(DBClientFeeds)-1 do
- if AmendClient[n].ID=DBClientFeeds[m].ID then
- begin
- InsertClient(DBClientFeeds[m],-3);
- DBClientFeeds[m].New:=0;
- AmendClient[n].New:=0;
- end;
- end;
- end;
- FDTable1.Close;
- if ClientDelDB then
- begin
- ClientDelDB:=False;
- end;
- ClientToDB:=False;
- end
- else //if DBPingTime is false
- begin
- DBNotConnected:=1;
- DBConnected:=False;
- // Stop:=GetTickCount;
- // ElapsedTime:=Stop-Start;
- end;
- end;
- end;
- SaveClient;
- if ClientFeedsHigh>OldClientFeedsHigh then OldClientFeedsHigh:=ClientFeedsHigh;
- EnDecryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- if ClientFeedsHigh=OldClientFeedsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBClientFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBClientFeeds.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBClientFeeds.ph6',DatabaseDirectory+'\Stored\DBClientFeeds.ph6');
- //CopyFile(PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBClientFeeds.ph6'),False);
- SaveToDB.CheckBox1.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label1.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- except
- DBNotConnected:=1;
- // ClientFeedsHigh:=Length(DBClientFeeds);
- SaveClient;
- if ClientFeedsHigh>OldClientFeedsHigh then OldClientFeedsHigh:=ClientFeedsHigh;
- EnDecryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- if ClientFeedsHigh=OldClientFeedsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBClientFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBClientFeeds.ph6'),False);
- end;
- // FileSizes(DatabaseDirectory+'\DBClientFeeds.ph6',DatabaseDirectory+'\Stored\DBClientFeeds.ph6');
- // CopyFile(PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBClientFeeds.ph6'),False);
- text:=text+'Client Feeds not saved to database. Try running pH6+ again and then close down. ';
- FDTable1.Close;
- end;
- try
- AreAmendPreMixes;
- ElapsedTime:=0;
- if (PreMixesToDB) and (DBConnected) then
- begin
- Start:=GetTickCount;
- if (FDConnection1.Ping) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- FDTable1.TableName:='Blends';
- FDTable1.Open;
- for n := 0 to Length(AmendPreMixes)-1 do
- begin
- if AmendPreMixes[n].New=-4 then
- begin
- if FDTable1.Locate('Consultant;ID',VarArrayOf([Consultant,AmendPreMixes[n].ID]),[]) then
- begin
- FDTable1.Delete;
- end;
- end;
- for m := 0 to Length(DBPreMixes)-1 do
- if AmendPreMixes[n].ID=DBPreMixes[m].ID then
- begin
- InsertPreMixes(DBPreMixes[m],AmendPreMixes[n].New);
- DBPreMixes[m].New:=0;
- end;
- end;
- FDTable1.Close;
- if PreMixesDelDB then
- begin
- PreMixesDelDB:=False;
- end;
- PreMixesToDB:=False;
- end
- else
- begin
- DBNotConnected:=1;
- DBConnected:=False;
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- end;
- end;
- SavePreMixes;
- PreMixFeedsHigh:=Length(DBPreMixes);
- if PreMixFeedsHigh>OldPreMixFeedsHigh then OldPreMixFeedsHigh:=PreMixFeedsHigh;
- EnDecryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- if PreMixFeedsHigh=OldPreMixFeedsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBPreMixes.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBPreMixes.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBPreMixes.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBPreMixes.ph6',DatabaseDirectory+'\Stored\DBPreMixes.ph6');
- //CopyFile(PWideChar(DatabaseDirectory+'\DBPreMixes.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBPreMixes.ph6'),False);
- SaveToDB.CheckBox2.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label2.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- except
- DBNotConnected:=1;
- PreMixFeedsHigh:=Length(DBPreMixes);
- SavePreMixes;
- if PreMixFeedsHigh>OldPreMixFeedsHigh then OldPreMixFeedsHigh:=PreMixFeedsHigh;
- EnDecryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- if PreMixFeedsHigh=OldPreMixFeedsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBPreMixFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBPreMixFeeds.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBPreMixFeeds.ph6'),False);
- end;
- // FileSizes(DatabaseDirectory+'\DBPreMixes.ph6',DatabaseDirectory+'\Stored\DBPreMixes.ph6');
- // CopyFile(PWideChar(DatabaseDirectory+'\DBPreMixes.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBPreMixes.ph6'),False);
- text:=text+'PreMixes not saved to database. Try running pH6+ again and then close down. ';
- FDTable1.Close;
- end;
- try
- SaveFarmer;
- FarmerHigh:=Length(DBFarmer);
- if FarmerHigh>OldFarmerHigh then OldFarmerHigh:=FarmerHigh;
- EnDecryptFile(DatabaseDirectory+'\DBFarmer.ph6');
- if FarmerHigh=OldFarmerHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBFarmer.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBFarmer.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBFarmer.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBFarmer.ph6',DatabaseDirectory+'\Stored\DBFarmer.ph6');
- //CopyFile(PWideChar(DatabaseDirectory+'\DBFarmer.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFarmer.ph6'),False);
- ElapsedTime:=0;
- if (FarmerToDB) and (DBConnected) then
- begin
- Start:=GetTickCount;
- if (FDConnection1.Ping) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- FDTable1.TableName:='MasterTable';
- FDTable1.Open;
- for n := 0 to Length(AmendFarmer)-1 do
- begin
- if AmendFarmer[n].New=-1 then //delete
- begin
- if FDTable1.Locate('Consultant;ID',VarArrayOf([Consultant,AmendFarmer[n].ID]),[]) then
- begin
- FDTable1.Delete;
- end;
- end
- else if AmendFarmer[n].New=1 then //insert
- begin
- for m := 0 to Length(DBFarmer)-1 do
- if AmendFarmer[n].ID=DBFarmer[m].DietID then
- begin
- InsertFarmer(DBFarmer[m],1);
- //get ID and alter results to this
- DBFarmer[m].DietID:=FDTable1.FieldByName('ID').AsInteger;
- DBFarmer[m].New:=0;
- AmendFarmer[n].New:=0;
- end;
- end
- else if AmendFarmer[n].New=-2 then
- begin
- for m := 0 to Length(DBFarmer)-1 do
- if AmendFarmer[n].ID=DBFarmer[m].DietID then
- begin
- InsertFarmer(DBFarmer[m],-2);
- DBFarmer[m].New:=0;
- AmendFarmer[n].New:=0;
- end;
- end;
- end;
- FDTable1.Close;
- if FarmerDelDB then
- begin
- FarmerDelDB:=False;
- end;
- FarmerToDB:=False;
- // Sleep(500);
- end
- else
- begin
- DBNotConnected:=1;
- DBConnected:=False;
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- end;
- end;
- SaveToDB.CheckBox3.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label3.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- except
- DBNotConnected:=1;
- FarmerHigh:=Length(DBFarmer);
- text:=text+'Farmer not saved to database ';
- FDTable1.Close;
- end;
- try
- AreAmendFormulation;
- ElapsedTime:=0;
- if (FormulationToDB) and (DBConnected) then
- begin
- Start:=GetTickCount;
- if (FDConnection1.Ping) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- FDTable1.TableName:='Formulation';
- FDTable1.Open;
- for n := 0 to Length(AmendFormulation)-1 do
- begin
- if AmendFormulation[n].New=-1 then //delete
- begin
- if FDTable1.Locate('Consultant;ID',VarArrayOf([Consultant,AmendFormulation[n].ID]),[]) then
- begin
- FDTable1.Delete;
- end;
- end
- else if AmendFormulation[n].New=1 then //insert
- begin
- for m := 0 to Length(DBFormulation)-1 do
- if AmendFormulation[n].ID=DBFormulation[m].ID then
- begin
- InsertFormulation(DBFormulation[m]);
- //get ID and alter results to this
- DBFormulation[m].New:=0;
- AmendFormulation[n].New:=0;
- end;
- end;
- end;
- FDTable1.Close;
- if FormulationDelDB then
- begin
- FormulationDelDB:=False;
- end;
- FormulationToDB:=False;
- // Sleep(250);
- end
- else
- begin
- DBNotConnected:=1;
- DBConnected:=False;
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- end;
- end;
- SaveFormulations;
- FormulationHigh:=Length(DBFormulation);
- if FormulationHigh>OldFormulationHigh then OldFormulationHigh:=FormulationHigh;
- EnDecryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- if FormulationHigh=OldFormulationHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBFormulation.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBFormulation.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBFormulation.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBFormulation.ph6',DatabaseDirectory+'\Stored\DBFormulation.ph6');
- //CopyFile(PWideChar(DatabaseDirectory+'\DBFormulation.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFormulation.ph6'),False);
- SaveToDB.CheckBox4.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label4.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- except
- DBNotConnected:=1;
- FormulationHigh:=Length(DBFormulation);
- SaveFormulations;
- if FormulationHigh>OldFormulationHigh then OldFormulationHigh:=FormulationHigh;
- EnDecryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- if FormulationHigh=OldFormulationHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBFormulation.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBFormulation.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBFormulation.ph6'),False);
- end;
- // FileSizes(DatabaseDirectory+'\DBFormulation.ph6',DatabaseDirectory+'\Stored\DBFormulation.ph6');
- // CopyFile(PWideChar(DatabaseDirectory+'\DBFormulation.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFormulation.ph6'),False);
- text:=text+'Formulation not saved to database. Try running pH6+ again and then close down. ';
- FDTable1.Close;
- end;
- try
- if not SavingData then Application.ProcessMessages;
- AreAmendResults;
- ElapsedTime:=0;
- ComboResults:=False;
- if (ResultsToDB) and (DBConnected) then
- begin
- NotTicked:=False;
- Start:=GetTickCount;
- if (FDConnection1.Ping) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- if ElapsedTime>PingTime then DBPingTime:=False;
- if DBPingTime then
- begin
- FDTable1.TableName:='Results';
- FDTable1.Open;
- for n := 0 to Length(AmendResults)-1 do
- begin
- if AmendResults[n].New=-4 then
- begin
- ComboResults:=True;
- if FDTable1.Locate('Consultant;Diet',VarArrayOf([Consultant,AmendResults[n].ID]),[]) then
- begin
- // text:=IntToStr(FDTable1.FieldByName('ID').AsInteger);
- // ShowMessage(text);
- { with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('DELETE FROM Results');
- SQL.Add('WHERE Consultant =:apptype');
- SQL.Add('AND Diet =:apptype1');
- Params[0].DataType:=ftInteger;
- Params[0].Value:=Consultant;
- Params[1].DataType:=ftInteger;
- Params[1].Value:=AmendResults[n].ID;
- Execute;
- EnableControls;
- end; }
- // FDQuery1.First;
- // delete from Results where Consultant={Consultant} and Diet={[n].ID}
- FDTable1.Delete;
- DBResultsChange:=True;
- end;
- end;
- for m:=0 to Length(DBResults)-1 do
- if AmendResults[n].ID=DBResults[m].Diet then //DBResults[m].ID
- begin
- InsertResult(DBResults[m],0);
- DBResults[m].New:=0;
- // DBResultsChange:=False;
- end;
- end;
- FDTable1.Close;
- if ComboResults then
- begin
- ResultsDelDB:=False;
- end;
- ResultsToDB:=False;
- end
- else
- begin
- DBNotConnected:=1;
- DBConnected:=False;
- NotTicked:=True;
- text:=text+'Internet connection lost! To complete saving results to central database,try running pH6+ again and then close down.';
- // Stop:=GetTickCount;
- // ElapsedTime:=Stop-Start;
- end;
- end;
- end;
- SaveResults;
- ResultsHigh:=Length(DBResults);
- if ResultsHigh>OldResultsHigh then OldResultsHigh:=ResultsHigh;
- if ResultsHigh=OldResultsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBResults.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBResults.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBResults.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBResults.ph6',DatabaseDirectory+'\Stored\DBResults.ph6');
- //CopyFile(PWideChar(DatabaseDirectory+'\DBResults.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBResults.ph6'),False);
- if not NotTicked then SaveToDB.CheckBox5.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label5.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- except
- DBNotConnected:=1;
- SaveResults;
- ResultsHigh:=Length(DBResults);
- if ResultsHigh>OldResultsHigh then OldResultsHigh:=ResultsHigh;
- if ResultsHigh=OldResultsHigh then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBResults.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBResults.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBResults.ph6'),False);
- end;
- // FileSizes(DatabaseDirectory+'\DBResults.ph6',DatabaseDirectory+'\Stored\DBResults.ph6');
- // CopyFile(PWideChar(DatabaseDirectory+'\DBResults.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBResults.ph6'),False);
- text:=text+'Results not saved to database. Try running pH6+ again and then close down.';
- FDTable1.Close;
- end;
- try
- ElapsedTime:=0;
- if FeedPrice[1]>0 then
- begin
- SaveFeedPrices;
- EnDecryptFile(DatabaseDirectory+'\DBFeedPrices.ph6');
- Start:=GetTickCount;
- if (FDConnection1.Ping) and (DBConnected) then
- begin
- Stop:=GetTickCount;
- ElapsedTime:=Stop-Start;
- FDTable1.TableName:='FeedPricesbyConsultant';
- FDTable1.Open;
- InsertPrices;
- FDTable1.Close;
- SaveToDB.CheckBox6.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label6.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- end;
- end
- else
- begin
- DeleteFile(DatabaseDirectory+'\DBFeedPrices.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\Daily\DBFeedPrices.ph6'),PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),False);
- SaveToDB.CheckBox6.Checked:=True;
- if (Consultant=1) or (Consultant=2) then
- SaveToDB.Label6.Caption:=IntToStr(ElapsedTime);
- if not SavingData then Application.ProcessMessages;
- end;
- except
- DeleteFile(DatabaseDirectory+'\DBFeedPrices.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\Daily\DBFeedPrices.ph6'),PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),False);
- // CopyFile(PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFeedPrices.ph6'),False);
- // text:=text+'Feed Prices not saved to database ';
- FDTable1.Close;
- end;
- //CopyFile(PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),PWideChar(GetProfile+'\OneDrive\pH6+\Database\DBFeedPrices.ph6'),False);
- try
- if DBConnected then
- if FDConnection1.Ping then
- begin
- FDTable1.TableName:='INIFiles';
- FDTable1.Open;
- AmendINI;
- FDTable1.Close;
- end;
- except
- text:=text+'INI Files not saved to database';
- FDTable1.Close;
- end;
- FDConnection1.Connected:=False;
- if rTranslate.no225<>'' then
- begin
- DeleteFile(DatabaseDirectory+'\Stored\DBFeedLabels.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBFeedLabels.ph6'),PWideChar(DatabaseDirectory+'\Stored\DBFeedLabels.ph6'),False);
- end;
- //FileSizes(DatabaseDirectory+'\DBFeedLabels.ph6',DatabaseDirectory+'\Stored\DBFeedLabels.ph6');
- if text<>'' then
- ShowMessage(text);
- Screen.Cursor:=SaveCursor;
- end;
- Application.Terminate;
- end;
- procedure TMain.GetFeedOrder(Category,Name,AmountDiet1,AmountDiet2,
- AmountDiet3,AmountDiet4,AmountDiet5: String;FeedNo: Integer;
- var p: Integer);
- var
- m: Integer;
- begin
- if FeedLength[FeedNo].Start>0 then
- for m:=FeedLength[FeedNo].Start-1 to FeedLength[FeedNo].Finish-1 do
- begin
- FeedOrder[m,1]:=Category;
- FeedOrder[m,2]:=Name;
- if FeedLength[FeedNo].Start=FeedLength[FeedNo].Finish then
- begin
- FeedOrder[m,3]:=AmountDiet1;
- FeedOrder[m,4]:=AmountDiet2;
- FeedOrder[m,5]:=AmountDiet3;
- FeedOrder[m,6]:=AmountDiet4;
- FeedOrder[m,7]:=AmountDiet5;
- FeedOrder[m,8]:=AmountDiet1;
- FeedOrder[m,9]:=AmountDiet2;
- FeedOrder[m,10]:=AmountDiet3;
- FeedOrder[m,11]:=AmountDiet4;
- FeedOrder[m,12]:=AmountDiet5;
- end
- else
- begin
- if AmountDiet1='' then FeedOrder[m,3]:='0' else
- FeedOrder[m,3]:=FloatToStr(StrToFloat(AmountDiet1)*PMAmount[p]/100);
- if AmountDiet2='' then FeedOrder[m,4]:='0' else
- FeedOrder[m,4]:=FloatToStr(StrToFloat(AmountDiet2)*PMAmount[p]/100);
- if AmountDiet3='' then FeedOrder[m,5]:='0' else
- FeedOrder[m,5]:=FloatToStr(StrToFloat(AmountDiet3)*PMAmount[p]/100);
- if AmountDiet4='' then FeedOrder[m,6]:='0' else
- FeedOrder[m,6]:=FloatToStr(StrToFloat(AmountDiet4)*PMAmount[p]/100);
- if AmountDiet5='' then FeedOrder[m,7]:='0' else
- FeedOrder[m,7]:=FloatToStr(StrToFloat(AmountDiet5)*PMAmount[p]/100);
- FeedOrder[m,8]:=FeedOrder[m,3];
- FeedOrder[m,9]:=FeedOrder[m,4];
- FeedOrder[m,10]:=FeedOrder[m,5];
- FeedOrder[m,11]:=FeedOrder[m,6];
- FeedOrder[m,12]:=FeedOrder[m,7];
- inc(p);
- end;
- if FeedOrder[m,3]='' then FeedOrder[m,3]:='0';
- if FeedOrder[m,4]='' then FeedOrder[m,4]:='0';
- if FeedOrder[m,5]='' then FeedOrder[m,5]:='0';
- if FeedOrder[m,6]='' then FeedOrder[m,6]:='0';
- if FeedOrder[m,7]='' then FeedOrder[m,7]:='0';
- if FeedOrder[m,8]='' then FeedOrder[m,8]:='0';
- if FeedOrder[m,9]='' then FeedOrder[m,9]:='0';
- if FeedOrder[m,10]='' then FeedOrder[m,10]:='0';
- if FeedOrder[m,11]='' then FeedOrder[m,11]:='0';
- if FeedOrder[m,12]='' then FeedOrder[m,12]:='0';
- end;
- end;
- procedure TMain.btnRunClick(Sender: TObject);
- const
- RoboticsYield=10; //15
- MaxParlourPerMeal=6;
- var
- MatProtein,ProteinWt,ProteinLoss,BodyProtein,LostProtein,BodyProteinLoss,BodyProteinGain: Single;
- MEGReq,MPGReq: array[0..4] of Single;
- {Start,Finish,}n,m,p,counter,counter2,Pass,PassUpper,WeekOfLactation,
- FinalCount,YearOfLactation,TimeToStart,TimeToFinish{,PBarCount,PBar}: Integer;
- CanRun: Boolean;
- DMImax,DMDiet1,DMDiet2,DMDiet3,DMDiet4,DMDiet5,Lignin,PF,
- MCS,TotalDM: Single;
- SaveCursor: TCursor;
- text: String;
- IngredientDMzero: array of Integer;
- begin
- IMustSave:=True; WhyWontItWork:=0;
- CanRun:=True;
- IngredientDMzero:=nil;
- SetLength(IngredientDMzero,rFeedInfo.iNoFeeds);
- for n := 0 to rFeedInfo.iNoFeeds-1 do
- begin
- if rFeedInfo.TMRFeed[n].DM=0 then
- begin
- CanRun:=False;
- IngredientDMzero[n]:=n+1;
- end;
- end;
- if CanRun = false then //not CanRun then
- begin
- text:='';
- for n := 0 to rFeedInfo.iNoFeeds-1 do
- if IngredientDMzero[n]>0 then
- text:=text+IntToStr(IngredientDMzero[n])+', ';
- ShowMessage('Some ingredients aren''t entered correctly. The Ingredient no is: '+text);
- end
- else
- begin
- try
- //Start:=GetTickCount;
- SaveCursor:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- //ProgressBar1.Position := 0;
- //ProgressBar1.Max := 100;
- //PBarCount:=0; {PBar:=0;}
- //FeedingStrategy.FormDeactivate must be run here in order that correct
- //Grazing is calculated from TMRRobotic and Milk Yield
- FeedingStrategy.FormActivate(FeedingStrategy);
- FeedingStrategy.FormDeactivate(FeedingStrategy);
- if TMRRobotic then
- begin
- // if FeedingStrategy.ComboBox5.Text<>'' then
- // FeedingStrategy.ComboBox5Change(FeedingStrategy);
- if FeedingStrategy.ComboBox6.Text<>'' then
- begin
- rFeedInfo.iLiquid:=1;
- end
- else
- rFeedInfo.iLiquid:=0;
- end;
- //Reset all TMR amounts
- Instant.FillEditType;
- Instant.AddFeeds(EditTypeStringArray,1);
- //Instant.ComboBox1Change(Instant);
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- rFeedInfo.DietToFed[1]:=True;
- DryCow:=True;
- end
- else
- begin
- DryCow:=False;
- end;
- for n:=0 to 2 do
- for m:=0 to UpperLimit do
- begin
- rNutrientsAbsorbed.DMI[n,m]:=0;
- rNutrientsAbsorbed.GrazingDMI[n,m]:=0;
- rNutrientsAbsorbed.ParlourDMI[n,m]:=0;
- rNutrientsAbsorbed.RoboticDMI[n,m]:=0;
- rNutrientsAbsorbed.LiquidDMI[n,m]:=0;
- end;
- pH6:=True; TMROnlyGS:=True;
- ptrFeedInfo:=@rFeedInfo;
- ptrNutAbsorbed:=@rNutrientsAbsorbed;
- ptrAnimal:=@Animal;
- AcidNeutralised:=1;
- if Instant.Label63.Caption='' then
- rFeedInfo.Fixed:=0
- else
- rFeedInfo.Fixed:=StrToFloat(Instant.Label63.Caption);
- //if SingleRun then
- // begin
- Animal.MatureWeight:=Round(StrToInt(Instant.Edit61.Text)/kgToOther);
- if Beef then
- Animal.MatureCS:=4.25
- else
- Animal.MatureCS:=StrToFloat(Instant.Edit62.Text);
- // end
- //else
- // begin
- // Animal.MatureWeight:=Round(StrToInt(CowF.Edit1.Text)/kgToOther);
- // Animal.MatureCS:=StrToFloat(CowF.Edit2.Text);
- // end;
- if Beef then
- begin
- if SingleRun then
- begin
- Animal.WeightArray[2,0]:=StrToInt(Instant.Edit66.Text)/kgToOther;
- Animal.CS[2,0]:=StrToFloat(Instant.Edit62.Text);
- end
- else
- begin
- // Animal.WeightArray[2,0]:=StrToInt(CowF.Edit12.Text)/kgToOther;
- // Animal.CS[2,0]:=StrToFloat(CowF.Edit13.Text);
- end;
- BodyComposition(ptrAnimal,1,0);
- Animal.DaysInMonth:=7;
- end;
- if SingleRun then
- begin
- Mature(Round(StrToInt(Instant.Edit61.Text)/kgToOther),
- Animal.MatureCS);
- // if LeftStr(Instant.Edit66.Text,1)<>'-' then
- for n:=2 to 5 do
- rFeedInfo.DietToFed[n]:=False;
- if Instant.RadioButton1.Checked then
- begin
- SRLactNo:=0;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- HerdProbsS[SRLactNo,0]:=0;
- HerdProbsS[1,0]:=0;
- HerdProbsS[2,0]:=0;
- HerdProbsS[SRLactNo,3]:=1;
- HerdProbsS[SRLactNo,4]:=1;
- end
- else
- begin
- HerdProbsS[SRLactNo,0]:=1;
- HerdProbsS[1,0]:=0;
- HerdProbsS[2,0]:=0;
- HerdProbsS[SRLactNo,3]:=0;
- HerdProbsS[SRLactNo,4]:=0;
- end;
- LactationNo[1]:=1;
- LactationNo[2]:=0;
- LactationNo[3]:=0;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- Animal.Weight:=Round(0.8*StrToInt(Instant.Edit61.Text));
- end
- else if Instant.RadioButton2.Checked then
- begin
- SRLactNo:=1;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- HerdProbsS[SRLactNo,0]:=0;
- HerdProbsS[0,0]:=0;
- HerdProbsS[2,0]:=0;
- HerdProbsS[SRLactNo,3]:=1;
- HerdProbsS[SRLactNo,4]:=1;
- end
- else
- begin
- HerdProbsS[SRLactNo,0]:=1;
- HerdProbsS[0,0]:=0;
- HerdProbsS[2,0]:=0;
- HerdProbsS[SRLactNo,3]:=0;
- HerdProbsS[SRLactNo,4]:=0;
- end;
- LactationNo[1]:=0;
- LactationNo[2]:=1;
- LactationNo[3]:=0;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- Animal.Weight:=Round(0.9*StrToInt(Instant.Edit61.Text));
- end
- else
- begin
- SRLactNo:=2;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- HerdProbsS[SRLactNo,0]:=0;
- HerdProbsS[0,0]:=0;
- HerdProbsS[1,0]:=0;
- HerdProbsS[SRLactNo,3]:=1;
- HerdProbsS[SRLactNo,4]:=1;
- end
- else
- begin
- HerdProbsS[SRLactNo,0]:=1;
- HerdProbsS[0,0]:=0;
- HerdProbsS[1,0]:=0;
- HerdProbsS[SRLactNo,3]:=0;
- HerdProbsS[SRLactNo,4]:=0;
- end;
- LactationNo[1]:=0;
- LactationNo[2]:=0;
- LactationNo[3]:=1;
- end;
- if Beef then
- begin
- SRLactNo:=2;
- HerdProbsS[SRLactNo,0]:=1;
- HerdProbsS[0,0]:=0;
- HerdProbsS[1,0]:=0;
- LactationNo[1]:=0;
- LactationNo[2]:=0;
- LactationNo[3]:=1;
- end;
- rFeedInfo.Diet:=1;
- rFeedInfo.WeekToEnd[1]:=Round(LactationLength/DaysInWeek);
- DayNo[1]:=StrToInt(Instant.Edit66.Text)*DaysInWeek-DaysInWeek;
- end;
- if Animal.Lactating then rFeedInfo.Lactating:=True else rFeedInfo.Lactating:=False;
- rFeedInfo.Dijkstra:=False;
- rFeedInfo.Mario:=False;
- rFeedInfo.TMR:=True;
- rFeedInfo.iDaysToRun:=20;//24
- for n:=0 to 2 do
- begin
- for m:=0 to UpperLimit do
- begin
- rNutrientsAbsorbed.PotentialMilk[n,m]:=0;
- rNutrientsAbsorbed.MilkFromE[n,m]:=0;
- rNutrientsAbsorbed.MilkFromP[n,m]:=0;
- rNutrientsAbsorbed.DMI[n,m]:=0;
- rNutrientsAbsorbed.ParlourDMI[n,m]:=0;
- rNutrientsAbsorbed.GrazingDMI[n,m]:=0;
- rNutrientsAbsorbed.DietME[n,m]:=0;
- rNutrientsAbsorbed.EReq[n,m]:=0;
- rNutrientsAbsorbed.MPReq[n,m]:=0;
- rNutrientsAbsorbed.pHLim[n,m]:=0;
- rNutrientsAbsorbed.BodyWeight[n,m]:=0;
- rNutrientsAbsorbed.BodyChange[n,m]:=0;
- end;
- end;
- for n:=0 to UpperLimit do
- rNutrientsAbsorbed.ProteinFromBody[n]:=0;
- if not BatchMode then
- begin
- FeedOrder:=nil;
- SetLength(FeedOrder,rFeedInfo.iNoFeeds);
- end;
- //get no of diets
- WhyWontItWork:=1;
- rFeedInfo.iNoDiets:=0;
- if rFeedInfo.DietToFed[1] then rFeedInfo.iNoDiets:=1;
- if rFeedInfo.DietToFed[2] then rFeedInfo.iNoDiets:=rFeedInfo.iNoDiets+1;
- if rFeedInfo.DietToFed[3] then rFeedInfo.iNoDiets:=rFeedInfo.iNoDiets+1;
- if rFeedInfo.DietToFed[4] then rFeedInfo.iNoDiets:=rFeedInfo.iNoDiets+1;
- if rFeedInfo.DietToFed[5] then rFeedInfo.iNoDiets:=rFeedInfo.iNoDiets+1;
- if FixedGrazing then PassUpper:=2 else PassUpper:=1;
- Pass:=1;
- p:=0;
- GetFeedOrder(Instant.ComboBox5.Text,Instant.ComboBox1.Text,Instant.Edit6.Text,
- '','','','',1,p);
- GetFeedOrder(Instant.ComboBox6.Text,Instant.ComboBox2.Text,Instant.Edit7.Text,
- '','','','',2,p);
- GetFeedOrder(Instant.ComboBox7.Text,Instant.ComboBox3.Text,Instant.Edit8.Text,
- '','','','',3,p);
- GetFeedOrder(Instant.ComboBox8.Text,Instant.ComboBox4.Text,Instant.Edit9.Text,
- '','','','',4,p);
- GetFeedOrder(Instant.ComboBox9.Text,Instant.ComboBox10.Text,Instant.Edit13.Text,
- '','','','',5,p);
- GetFeedOrder(Instant.ComboBox11.Text,Instant.ComboBox12.Text,Instant.Edit16.Text,
- '','','','',6,p);
- GetFeedOrder(Instant.ComboBox13.Text,Instant.ComboBox14.Text,Instant.Edit18.Text,
- '','','','',7,p);
- GetFeedOrder(Instant.ComboBox15.Text,Instant.ComboBox16.Text,Instant.Edit20.Text,
- '','','','',8,p);
- GetFeedOrder(Instant.ComboBox17.Text,Instant.ComboBox18.Text,Instant.Edit22.Text,
- '','','','',9,p);
- GetFeedOrder(Instant.ComboBox19.Text,Instant.ComboBox20.Text,Instant.Edit24.Text,
- '','','','',10,p);
- GetFeedOrder(Instant.ComboBox21.Text,Instant.ComboBox22.Text,Instant.Edit26.Text,
- '','','','',11,p);
- GetFeedOrder(Instant.ComboBox23.Text,Instant.ComboBox24.Text,Instant.Edit28.Text,
- '','','','',12,p);
- GetFeedOrder(Instant.ComboBox25.Text,Instant.ComboBox26.Text,Instant.Edit1.Text,
- '','','','',13,p);
- GetFeedOrder(Instant.ComboBox27.Text,Instant.ComboBox28.Text,Instant.Edit2.Text,
- '','','','',14,p);
- GetFeedOrder(Instant.ComboBox29.Text,Instant.ComboBox30.Text,Instant.Edit3.Text,
- '','','','',15,p);
- GetFeedOrder(Instant.ComboBox31.Text,Instant.ComboBox32.Text,Instant.Edit4.Text,
- '','','','',16,p);
- //convert fresh wts (kg per mix) of feed to dry weight (g/kg given)
- //convert fresh wt given to dry wt given & sum dry weights across diets
- DMDiet1:=0; DMDiet2:=0; DMDiet3:=0; DMDiet4:=0; DMDiet5:=0;
- for counter:=0 to rFeedInfo.iNoFeeds-1 do
- begin
- if rFeedInfo.DietToFed[1] then
- begin
- FeedOrder[counter,8]:=FloatToStr(StrToFloat(FeedOrder[counter,3])*rFeedInfo.TMRFeed[counter].DM/100);
- DMDiet1:=DMDiet1+StrToFloat(FeedOrder[counter,8]);
- DMIDiet1:=DMDiet1;
- end;
- if rFeedInfo.DietToFed[2] then
- begin
- FeedOrder[counter,9]:=FloatToStr(StrToFloat(FeedOrder[counter,4])*rFeedInfo.TMRFeed[counter].DM/100);
- DMDiet2:=DMDiet2+StrToFloat(FeedOrder[counter,9]);
- end;
- if rFeedInfo.DietToFed[3] then
- begin
- FeedOrder[counter,10]:=FloatToStr(StrToFloat(FeedOrder[counter,5])*rFeedInfo.TMRFeed[counter].DM/100);
- DMDiet3:=DMDiet3+StrToFloat(FeedOrder[counter,10]);
- end;
- if rFeedInfo.DietToFed[4] then
- begin
- FeedOrder[counter,11]:=FloatToStr(StrToFloat(FeedOrder[counter,6])*rFeedInfo.TMRFeed[counter].DM/100);
- DMDiet4:=DMDiet4+StrToFloat(FeedOrder[counter,11]);
- end;
- if rFeedInfo.DietToFed[5] then
- begin
- FeedOrder[counter,12]:=FloatToStr(StrToFloat(FeedOrder[counter,7])*rFeedInfo.TMRFeed[counter].DM/100);
- DMDiet5:=DMDiet5+StrToFloat(FeedOrder[counter,12]);
- end;
- end;
- //convert DM given to g/kg DM and calculate DM
- for counter := 1 to 5 do
- begin
- rFeedInfo.TMRDM[counter]:=0; rFeedInfo.TMRFM[counter]:=0;
- end;
- for counter:=0 to rFeedInfo.iNoFeeds-1 do
- begin
- if (rFeedInfo.DietToFed[1]) and not (CompleteFSGrazingAll) then //FSGrazingAll[1]
- begin
- FeedOrder[counter,8]:=FloatToStr(StrToFloat(FeedOrder[counter,8])/DMDiet1*Thousand);
- if rFeedInfo.TMRFeed[counter].pemNDF>3.5 then
- begin
- rFeedInfo.TMRDM[1]:=rFeedInfo.TMRDM[1]+StrToFloat(FeedOrder[counter,8])
- /Thousand;
- rFeedInfo.TMRFM[1]:=rFeedInfo.TMRFM[1]+StrToFloat(FeedOrder[counter,8])
- /Thousand/rFeedInfo.TMRFeed[counter].DM*100;
- if (rFeedInfo.TMRFeed[counter].FeedType=2) and (FeedOrder[counter,8]<>'0') then
- TMROnlyGS:=False;
- end;
- end;
- if (rFeedInfo.DietToFed[2]) and not (FSGrazingAll[2]) then
- begin
- FeedOrder[counter,9]:=FloatToStr(StrToFloat(FeedOrder[counter,9])/DMDiet2*Thousand);
- if rFeedInfo.TMRFeed[counter].pemNDF>3.5 then
- begin
- rFeedInfo.TMRDM[2]:=rFeedInfo.TMRDM[2]+StrToFloat(FeedOrder[counter,9])
- /Thousand;
- rFeedInfo.TMRFM[2]:=rFeedInfo.TMRFM[2]+StrToFloat(FeedOrder[counter,9])
- /Thousand/rFeedInfo.TMRFeed[counter].DM*100;
- end;
- end;
- if (rFeedInfo.DietToFed[3]) and not (FSGrazingAll[3]) then
- begin
- FeedOrder[counter,10]:=FloatToStr(StrToFloat(FeedOrder[counter,10])/DMDiet3*Thousand);
- if rFeedInfo.TMRFeed[counter].pemNDF>3.5 then
- begin
- rFeedInfo.TMRDM[3]:=rFeedInfo.TMRDM[3]+StrToFloat(FeedOrder[counter,10])
- /Thousand;
- rFeedInfo.TMRFM[3]:=rFeedInfo.TMRFM[3]+StrToFloat(FeedOrder[counter,10])
- /Thousand/rFeedInfo.TMRFeed[counter].DM*100;
- end;
- end;
- if (rFeedInfo.DietToFed[4]) and not (FSGrazingAll[4]) then
- begin
- FeedOrder[counter,11]:=FloatToStr(StrToFloat(FeedOrder[counter,11])/DMDiet4*Thousand);
- if rFeedInfo.TMRFeed[counter].pemNDF>3.5 then
- begin
- rFeedInfo.TMRDM[4]:=rFeedInfo.TMRDM[4]+StrToFloat(FeedOrder[counter,11])
- /Thousand;
- rFeedInfo.TMRFM[4]:=rFeedInfo.TMRFM[4]+StrToFloat(FeedOrder[counter,11])
- /Thousand/rFeedInfo.TMRFeed[counter].DM*100;
- end;
- end;
- if (rFeedInfo.DietToFed[5]) and not (FSGrazingAll[5]) then
- begin
- FeedOrder[counter,12]:=FloatToStr(StrToFloat(FeedOrder[counter,12])/DMDiet5*Thousand);
- if rFeedInfo.TMRFeed[counter].pemNDF>3.5 then
- begin
- rFeedInfo.TMRDM[5]:=rFeedInfo.TMRDM[5]+StrToFloat(FeedOrder[counter,12])
- /Thousand;
- rFeedInfo.TMRFM[5]:=rFeedInfo.TMRFM[5]+StrToFloat(FeedOrder[counter,12])
- /Thousand/rFeedInfo.TMRFeed[counter].DM*100;
- end;
- end;
- end;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- rFeedInfo.TMRDM[5]:=rFeedInfo.TMRDM[1];
- rFeedInfo.TMRDM[4]:=rFeedInfo.TMRDM[1];
- rFeedInfo.TMRFM[5]:=rFeedInfo.TMRFM[1];
- rFeedInfo.TMRFM[4]:=rFeedInfo.TMRFM[1];
- end;
- //recalculate pemNDF for use in analysis of bcp files
- pemNDF[1]:=0;
- TotalDM:=0;
- for counter := 0 to rFeedInfo.iNoFeeds-1 do
- begin
- pemNDF[1]:=pemNDF[1]+rFeedInfo.TMRFeed[counter].pemNDF*StrToFloat(FeedOrder[counter,8]);
- TotalDM:=TotalDM+StrToFloat(FeedOrder[counter,8]);
- end;
- if TotalDM>0 then pemNDF[1]:=pemNDF[1]/TotalDM else pemNDF[1]:=0;
- //prepare Feeding array
- Feeding:=nil;
- SetLength(Feeding,rFeedInfo.iNoFeeds*5);
- for counter2:=0 to rFeedInfo.iNoFeeds-1 do
- for n:=0 to 4 do
- Feeding[counter2+n*(rFeedInfo.iNoFeeds)]:=StrToFloat(FeedOrder[counter2,8+n])/Thousand;
- NotAlkapHer:=True;
- for counter := 0 to rFeedInfo.iNoFeeds-1 do
- begin
- if (FeedOrder[counter,2]='AlkabupHa') and (StrToFloat(FeedOrder[counter,3])>0)
- then
- begin
- NotAlkapHer:=False;
- AlkabupHaCounter:=counter;
- //AlkabupHa contains 93 moles NH3 per kg
- if TAcidEaten>0 then
- AcidNeutralised:=(TAcidEaten-StrToFloat(FeedOrder[counter,3])*93)/TAcidEaten;
- if AcidNeutralised<0 then AcidNeutralised:=0;
- end;
- end;
- TimeToFinish:=Round(LactationLength/DaysInWeek);
- if (rFeedInfo.DietToFed[4]) and (rFeedInfo.DietToFed[5]) then
- TimeToFinish:=Round(LactationLength/DaysInWeek)+Animal.FarOff+Animal.CloseTo
- else if (rFeedInfo.DietToFed[4]) then
- TimeToFinish:=Round(LactationLength/DaysInWeek)+Animal.FarOff
- else if (rFeedInfo.DietToFed[5]) then
- TimeToFinish:=Round(LactationLength/DaysInWeek)+Animal.CloseTo;
- if SingleRun then
- begin
- if Beef then
- begin
- TimeToStart:=1;
- TimeToFinish:=1;
- end
- else
- begin
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- TimeToStart:=Round(LactationLength/DaysInWeek)+7
- +StrToInt(Instant.Edit66.Text);
- TimeToFinish:=TimeToStart;
- end
- else
- begin
- TimeToStart:=StrToInt(Instant.Edit66.Text);
- TimeToFinish:=StrToInt(Instant.Edit66.Text);
- end;
- end;
- if TimeToStart>Round(LactationLength/DaysInWeek) then
- begin
- rFeedInfo.DietToFed[1]:=False;
- if Round(LactationLength/DaysInWeek)+Animal.FarOff>TimeToStart then
- rFeedInfo.DietToFed[4]:=True
- else
- rFeedInfo.DietToFed[5]:=True;
- end;
- end
- else
- TimeToStart:=1;
- WhyWontItWork:=2;
- for YearOfLactation:=1 to 3 do
- if LactationNo[YearOfLactation]>0 then
- begin
- CowParity:=YearOfLactation-1;
- if SingleRun then
- begin
- rFeedInfo.RumFillUpper:=0.9;
- if DryCow then
- rFeedInfo.RumFillUpper:=0.8;
- if Beef then
- rFeedInfo.Weight:=StrToFloat(Instant.Edit66.Text)/kgToOther
- else
- rFeedInfo.Weight:=StrToFloat(Instant.Edit61.Text)/kgToOther;
- if LeftStr(Instant.Edit66.Text,1)<>'-' then
- Animal.Weight:=Round(rFeedInfo.Weight);
- rFeedInfo.CS:=StrToFloat(Instant.Edit62.Text);
- // Mature(Round(StrtoInt(Instant.Edit61.Text)/kgToOther),StrtoFloat(Instant.Edit62.Text));
- CS:=StrToFloat(Instant.Edit62.Text);
- end
- else
- begin
- rFeedInfo.RumFillUpper:=0.7;
- // rFeedInfo.Weight:=StrToFloat(CowF.Edit1.Text)/kgToOther;
- // Animal.Weight:=Round(rFeedInfo.Weight);
- // rFeedInfo.CS:=StrToFloat(CowF.Edit2.Text);
- // Mature(Round(StrtoInt(CowF.Edit1.Text)/kgToOther),StrtoFloat(CowF.Edit2.Text));
- // CS:=rFeedInfo.CalvCS[YearOfLactation];
- end;
- ParityEffects(YearOfLactation,Round(rFeedInfo.MY305d[YearOfLactation]/kgToOther),
- StrtoFloat('4'),Strtofloat('3.3'));
- rFeedInfo.CalvWeight[YearOfLactation]:=Round(CalcLwtFromCSandP/kgToOther);
- AnimalLipid:=LipidParity;
- // if CowF.CheckBox1.Checked=True then
- CalcCSandGrowth(0,rFeedInfo.Mated[YearOfLactation]*7,YearOfLactation,CS,
- MatProtein,ProteinWt);
- // else
- // CalcCSandGrowth(0,360,YearOfLactation,CS,MatProtein,ProteinWt);
- //ProteinWt gives the weight of protein of animal. Transferred to BodyProtein
- BodyProtein:=ProteinWt;
- BodyProteinLoss:=0;
- if SingleRun then rFeedInfo.MaxMY:=StrToFloat(Instant.Edit63.Text)/kgToOther
- else
- if YearOfLactation=1 then
- rFeedInfo.MaxMY:=CalcMY(0.00465*rFeedInfo.MY305d[1],0.00218,45,0)
- else if YearOfLactation=2 then
- rFeedInfo.MaxMY:=CalcMY(0.005317*rFeedInfo.MY305d[2],0.00322,35,0)
- else
- rFeedInfo.MaxMY:=CalcMY(0.005877*rFeedInfo.MY305d[3],0.00393,35,0);
- for WeekOfLactation:=TimeToStart to TimeToFinish do
- begin
- //work out what diet to be fed
- {PBar:=PBar+1; }
- if Beef then BodyComposition(ptrAnimal,2,WeekOfLactation-1);
- rFeedInfo.Week:=WeekOfLactation-1;
- if WeekOfLactation-1<rFeedInfo.WeekToEnd[1] then rFeedInfo.Diet:=1
- else if WeekOfLactation-1<rFeedInfo.WeekToEnd[2] then rFeedInfo.Diet:=2
- else if WeekOfLactation-1<Round(LactationLength/7) then rFeedInfo.Diet:=3
- //but if no diet5, then rFeedInfo.Diet should = 4
- else if rFeedInfo.DietToFed[5] then
- begin
- if WeekOfLactation-1<TimeToFinish-3 then rFeedInfo.Diet:=4 else rFeedInfo.Diet:=5;
- end
- else rFeedInfo.Diet:=4;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- begin
- if Round(LactationLength/DaysInWeek)+Animal.FarOff>TimeToStart then
- begin
- rFeedInfo.Diet:=4;
- pemNDF[4]:=pemNDF[1];
- for counter2:=0 to rFeedInfo.iNoFeeds-1 do
- Feeding[counter2+(rFeedInfo.Diet-1)*(rFeedInfo.iNoFeeds)]:=
- StrToFloat(FeedOrder[counter2,8])/Thousand;
- for n:=1 to rFeedInfo.iNoFeeds do
- FeedOrder[n-1,7+rFeedInfo.Diet]:=FeedOrder[n-1,7+1];
- end
- else
- begin
- rFeedInfo.Diet:=5;
- pemNDF[5]:=pemNDF[1];
- for counter2:=0 to rFeedInfo.iNoFeeds-1 do
- Feeding[counter2+(rFeedInfo.Diet-1)*(rFeedInfo.iNoFeeds)]:=
- StrToFloat(FeedOrder[counter2,8])/Thousand;
- for n:=1 to rFeedInfo.iNoFeeds do
- FeedOrder[n-1,7+rFeedInfo.Diet]:=FeedOrder[n-1,7+1];
- end;
- end;
- if WeekOfLactation-1<=rFeedInfo.ParlourWeeks[1] then rFeedInfo.Parlour:=1
- else if WeekOfLactation-1<=rFeedInfo.ParlourWeeks[2] then rFeedInfo.Parlour:=2
- else if WeekOfLactation-1<=rFeedInfo.ParlourWeeks[3] then rFeedInfo.Parlour:=3
- else if WeekOfLactation-1<=rFeedInfo.ParlourWeeks[4] then rFeedInfo.Parlour:=4;
- //Eating Time
- AwakeTime:=[1..24];
- FSGrazingpemNDF:=False;
- if FSGrazingAll[rFeedInfo.Diet] then
- begin
- pemNDF[rFeedInfo.Diet]:=rFeedInfo.GrazingFeed.pemNDF;
- ActiveFibreTMR:=pemNDF[rFeedInfo.Diet];
- ActiveFibreGrazing:=ActiveFibreTMR;
- FSGrazingpemNDF:=True;
- end
- else if FSGrazing[rFeedInfo.Diet] then
- begin
- FSGrazingpemNDF:=True;
- ActiveFibreGrazing:=rFeedInfo.GrazingFeed.pemNDF;
- ActiveFibreTMR:=pemNDF[rFeedInfo.Diet];
- end
- else
- ActiveFibreTMR:=pemNDF[rFeedInfo.Diet];
- if pemNDF[rFeedInfo.Diet]<27.5 then
- RuminatingTime:=0.0054*pemNDF[rFeedInfo.Diet]+0.4531
- else
- RuminatingTime:=0.6;
- Available2Eat:=WakingTime*(1-RuminatingTime);
- // if Available2Eat<9.5 then EatingTime:=[4,7,9,12,15,18,21,24]
- // else if Available2Eat<10.5 then EatingTime:=[3,6,9,12,14,16,18,21,24]
- // else if Available2Eat<11.5 then EatingTime:=[2,4,6,9,12,14,16,18,21,23]
- // else EatingTime:=[2,4,6,8,10,12,14,16,18,21,23];
- //if TMRRobotic alter ParlourFeeds and ParlourHour
- if TMRRobotic then
- begin
- if (SingleRun) then
- begin
- // ParlourFeeds[rFeedInfo.Parlour]:=2;
- // ParlourHour[rFeedInfo.Parlour]:=[5,16];
- RoboticFeeds[rFeedInfo.Parlour]:=trunc(StrToFloat(Instant.Edit63.Text)/RoboticsYield*20);
- text:=FloatToStrF(RoboticFeeds[rFeedInfo.Parlour]/10,ffFixed,3,0);
- RoboticFeeds[rFeedInfo.Parlour]:=StrToFloat(text)/2;
- if RightStr(FloatToStr(RoboticFeeds[rFeedInfo.Parlour]),2)='.5' then
- begin
- HalfRobotic:=True;
- end
- else
- begin
- HalfRobotic:=False;
- end;
- if RoboticFeeds[rFeedInfo.Parlour]<2.4 then
- begin
- RoboticHour[rFeedInfo.Parlour]:=[1,12];
- if Instant.RadioButton4.Checked then EatingTime:=[3,8,11,14,17,19,23]
- else if Instant.RadioButton6.Checked then EatingTime:=[3,8,14,17,19,23]
- else if Instant.RadioButton7.Checked then EatingTime:=[3,8,14,23];
- end
- else if RoboticFeeds[rFeedInfo.Parlour]<3.4 then
- begin
- RoboticHour[rFeedInfo.Parlour]:=[1,8,16];
- if Instant.RadioButton4.Checked then EatingTime:=[3,5,9,11,14,17,19,23]
- else if Instant.RadioButton6.Checked then EatingTime:=[3,9,14,17,19,23]
- else if Instant.RadioButton7.Checked then EatingTime:=[3,9,14,23];
- end
- else if RoboticFeeds[rFeedInfo.Parlour]<4.4 then
- begin
- RoboticHour[rFeedInfo.Parlour]:=[1,6,12,18];
- if Instant.RadioButton4.Checked then EatingTime:=[3,5,9,11,14,17,19,23]
- else if Instant.RadioButton6.Checked then EatingTime:=[3,9,14,17,19,23]
- else if Instant.RadioButton7.Checked then EatingTime:=[3,9,14,23];
- end
- else
- begin
- RoboticHour[rFeedInfo.Parlour]:=[1,5,10,15,20];
- if Instant.RadioButton4.Checked then EatingTime:=[3,6,9,11,14,17,19,23]
- else if Instant.RadioButton6.Checked then EatingTime:=[3,9,14,17,19,23]
- else if Instant.RadioButton7.Checked then EatingTime:=[3,9,14,23];
- end;
- ParlourHour[1]:=[];
- // RoboticHour[rFeedInfo.Parlour]:=[5,16];
- if (FSGrazing[1]) or (FSGrazingAll[1]) then
- GrazingHour[1]:=GrazingHour[1]-RoboticHour[1];
- end
- else if WeekOfLactation=1 then
- begin
- ParlourFeeds[rFeedInfo.Parlour]:=2;
- ParlourHour[rFeedInfo.Parlour]:=[5,16];
- end
- else if rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-2]<=2*RoboticsYield then
- begin
- ParlourFeeds[rFeedInfo.Parlour]:=2;
- ParlourHour[rFeedInfo.Parlour]:=[5,16];
- end
- else if rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-2]<=3*RoboticsYield then
- begin
- ParlourFeeds[rFeedInfo.Parlour]:=3;
- ParlourHour[rFeedInfo.Parlour]:=[5,13,20];
- end
- else if rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-2]<=4*RoboticsYield then
- begin
- ParlourFeeds[rFeedInfo.Parlour]:=4;
- ParlourHour[rFeedInfo.Parlour]:=[5,11,17,22];
- end
- else
- begin
- ParlourFeeds[rFeedInfo.Parlour]:=5;
- ParlourHour[rFeedInfo.Parlour]:=[5,8,13,19,24];
- end;
- end;
- //Work out Parlour Feed to be fed
- if TMRRobotic then
- begin
- rFeedInfo.RoboticPerMeal1:=StrToFloat(FeedingStrategy.Edit9.Text)
- /kgToOther/RoboticFeeds[rFeedInfo.Parlour];
- if SingleRun then LactationDay1:=StrToFloat(Instant.Edit63.Text)/kgToOther;
- PF:=(LactationDay1-StrToFloat(FeedingStrategy.Edit17.Text)/kgToOther)
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF>(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text) then
- PF:=(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF<0 then PF:=0;
- rFeedInfo.RoboticPerMeal2:=PF/RoboticFeeds[rFeedInfo.Parlour];
- end
- else if (FSParlour[rFeedInfo.Diet]) and (rFeedInfo.Diet<>4) and (rFeedInfo.Diet<>5) then
- if WeekOfLactation<=rFeedInfo.ParlourWeeks[1] then
- if Fixed_MilkConcentrate[1] then
- rFeedInfo.ParlourPerMeal:=StrToFloat(FeedingStrategy.Edit9.Text)
- /kgToOther/ParlourFeeds[rFeedInfo.Parlour]
- else
- begin
- if WeekOfLactation=1 then
- begin
- if SingleRun then LactationDay1:=StrToFloat(Instant.Edit63.Text)/kgToOther;
- PF:=(LactationDay1-StrToFloat(FeedingStrategy.Edit17.Text)/kgToOther)
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF>(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text) then
- PF:=(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF<0 then PF:=0;
- if FeedingStrategy.Edit9.Enabled then
- PF:=PF+StrToFloat(FeedingStrategy.Edit9.Text)/kgToOther;
- rFeedInfo.ParlourPerMeal:=PF/ParlourFeeds[rFeedInfo.Parlour];
- end
- else
- begin
- if SingleRun then
- PF:=(StrToFloat(Instant.Edit63.Text)/kgToOther
- -StrToFloat(FeedingStrategy.Edit17.Text)/kgToOther)
- *StrToFloat(FeedingStrategy.Edit13.Text)
- else
- PF:=(rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-2]
- -StrToFloat(FeedingStrategy.Edit17.Text)/kgToOther)
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF>(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text) then
- PF:=(StrToFloat(FeedingStrategy.Edit21.Text)
- -StrToFloat(FeedingStrategy.Edit17.Text))/kgToOther
- *StrToFloat(FeedingStrategy.Edit13.Text);
- if PF<0 then PF:=0;
- if FeedingStrategy.Edit9.Enabled then
- PF:=PF+StrToFloat(FeedingStrategy.Edit9.Text)/kgToOther;
- rFeedInfo.ParlourPerMeal:=PF/ParlourFeeds[rFeedInfo.Parlour];
- end;
- end;
- if TMRRobotic then
- begin
- if rFeedInfo.RoboticPerMeal1>MaxParlourPerMeal then
- rFeedInfo.RoboticPerMeal1:=MaxParlourPerMeal;
- rFeedInfo.RoboticPerMeal1:=rFeedInfo.RoboticPerMeal1
- *ParlourTotalDM[rFeedInfo.Parlour]/100;
- if rFeedInfo.RoboticPerMeal2>MaxParlourPerMeal then
- rFeedInfo.RoboticPerMeal2:=MaxParlourPerMeal;
- rFeedInfo.RoboticPerMeal2:=rFeedInfo.RoboticPerMeal2
- *RoboticTotalDM2[rFeedInfo.Parlour]/100;
- rFeedInfo.LiquidPerMeal:=0.5/kgToOther/RoboticFeeds[rFeedInfo.Parlour]
- *rFeedInfo.LiquidFeed.DM/100;
- end
- else
- begin
- if rFeedInfo.ParlourPerMeal>MaxParlourPerMeal then
- rFeedInfo.ParlourPerMeal:=MaxParlourPerMeal;
- rFeedInfo.ParlourPerMeal:=rFeedInfo.ParlourPerMeal
- *ParlourTotalDM[rFeedInfo.Parlour]/100;
- end;
- if SingleRun then LactationDay1:=StrToFloat(Instant.Edit63.Text)/kgToOther;
- Conceptus(WeekOfLactation*7,rFeedInfo.Mated[YearOfLactation]*7);//ConcepDay
- if LeftStr(Instant.Edit66.Text,1)<>'-' then
- CalcCSandGrowth(WeekOfLactation*7,rFeedInfo.Mated[YearOfLactation]*7,
- YearOfLactation,rFeedInfo.CalvCS[YearOfLactation],
- MatProtein,ProteinWt);
- if (WeekOfLactation=1) or (CowParity=2) then BdyWt:=0
- else BdyWt:=rNutrientsAbsorbed.BodyWeight[CowParity,WeekOfLactation-2];
- if {(YearOfLactation=3) and} (WeekOfLactation=1) then
- rNutrientsAbsorbed.DMI[CowParity,WeekOfLactation+1]:=0;
- CalcEEReq(WeekOfLactation,CowParity,LactationLength,ptrNutAbsorbed,ptrAnimal);
- {Actual Weight is the lipid free empty body weight of the animal, divided by the
- lipid free empty body weight of the chosen mature animal multiplied by the weight
- of the animal calculated at condition score of 2.5. It is used to calculate maximum
- intake and also to calculate rumen volume }
- if Beef then
- begin
- if BeefCorrection then
- rFeedInfo.ActualWeight:=Animal.LipidFreeEmptyBody/Animal.MatureLFEB
- *Animal.WeightAt2Point5
- else
- rFeedInfo.ActualWeight:=Animal.WeightArray[CowParity,WeekOfLactation-1];
- end
- else
- rFeedInfo.ActualWeight:=Animal.LFEB/Animal.MatureLFEB*Animal.WeightAt2Point5;
- // rFeedInfo.ActualWeight:=675;
- {MaxIntakePerHour: the maximum amount that can be eaten per hour based on Active
- Fibre content of the intake (see Bioparamilk\v1.6 against v1.8\Active fibre vs
- intake rate.xls). As well as Active Fibre influencing intake, the size of the animal
- also does.}
- if Beef then
- rFeedInfo.MaxIntakePerHourAF10:=power(10,((log10(10)-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- *power(rFeedInfo.ActualWeight/Animal.WeightAt2Point5,0.86)
- else
- rFeedInfo.MaxIntakePerHourAF10:=power(10,((log10(10)-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73);
- if rFeedInfo.DietToFed[rFeedInfo.Diet] then
- begin
- if Beef then
- rFeedInfo.MaxIntakePerHour:=power(10,((log10(pemNDF[rFeedInfo.Diet])-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- *power(rFeedInfo.ActualWeight/Animal.WeightAt2Point5,0.86)
- else if YearOfLactation=3 then
- rFeedInfo.MaxIntakePerHour:=power(10,((log10(pemNDF[rFeedInfo.Diet])-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- else
- rFeedInfo.MaxIntakePerHour:=power(10,((log10(pemNDF[rFeedInfo.Diet])-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- *power(rFeedInfo.ActualWeight/Animal.WeightAt2Point5,0.86);
- rFeedInfo.MaxIntakePerHour:=0.85*rFeedInfo.MaxIntakePerHour; //0.75
- if LeftStr(Instant.Edit66.Text,1)='-' then rFeedInfo.MaxIntakePerHour:=1.25*rFeedInfo.MaxIntakePerHour;
- if FSGrazingpemNDF then
- begin
- if YearOfLactation=3 then
- rFeedInfo.MaxIntakePerHourPGrazing:=power(10,((log10(ActiveFibreGrazing)-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- else
- rFeedInfo.MaxIntakePerHourPGrazing:=power(10,((log10(ActiveFibreGrazing)-0.5314)
- *-0.9154)+1.0792)*power(rFeedInfo.ActualWeight,0.73)/power(650,0.73)
- *power(rFeedInfo.ActualWeight/Animal.WeightAt2Point5,0.86);
- // put MaxIntakePerHourPGrazing down by 0.75 to match MaxIntakePerHour
- rFeedInfo.MaxIntakePerHourPGrazing:=0.75*rFeedInfo.MaxIntakePerHourPGrazing;
- if LeftStr(Instant.Edit66.Text,1)='-' then
- rFeedInfo.MaxIntakePerHourPGrazing:=1.25*rFeedInfo.MaxIntakePerHourPGrazing;
- end;
- end;
- //Bert Tolkamp reckons that for example if the cow has locomotion problems and
- //intake is reduced, the cow is able to eat at a quicker rate - up to 3x.
- //L. A. Gonza´ lez, B. J. Tolkamp, M. P. Coffey, A. Ferret, and I. Kyriazakis
- //Changes in Feeding Behavior as Possible Indicators for the Automatic
- //Monitoring of Health Disorders in Dairy Cows J. Dairy Sci. 91:1017–1028, 2008
- //Auto sets NoOfMeals to 7!
- if NoOfMeals<11 then
- begin
- rFeedInfo.MaxIntakePerHour:=rFeedInfo.MaxIntakePerHour*(10-NoOfMeals);
- rFeedInfo.MaxIntakePerHourPGrazing:=rFeedInfo.MaxIntakePerHourPGrazing*(10-NoOfMeals);
- end
- else
- begin
- rFeedInfo.MaxIntakePerHour:=rFeedInfo.MaxIntakePerHour*(10-7);
- rFeedInfo.MaxIntakePerHourPGrazing:=rFeedInfo.MaxIntakePerHourPGrazing*(10-7);
- end;
- WhyWontItWork:=3;
- if (rFeedInfo.DietToFed[1]) and (WeekOfLactation<=rFeedInfo.WeekToEnd[1])
- and (HerdProbsS[YearOfLactation-1,0]>0) then
- begin
- rFeedInfo.FourOrFive:=False;
- IfDietTrue(WeekOfLactation,Lignin,MatProtein);
- end
- else if (rFeedInfo.DietToFed[2]) and (WeekOfLactation>rFeedInfo.WeekToEnd[1])
- and (WeekOfLactation<=rFeedInfo.WeekToEnd[2]) and (HerdProbsS[YearOfLactation-1,1]>0) then
- begin
- rFeedInfo.FourOrFive:=False;
- IfDietTrue(WeekOfLactation,Lignin,MatProtein);
- end
- else if (rFeedInfo.DietToFed[3]) and (WeekOfLactation>rFeedInfo.WeekToEnd[2])
- and (WeekOfLactation<=Round(LactationLength/7)) and (HerdProbsS[YearOfLactation-1,2]>0) then
- begin
- rFeedInfo.FourOrFive:=False;
- IfDietTrue(WeekOfLactation,Lignin,MatProtein);
- end
- //take out and (WeekOfLactation<=TimeToFinish-3) ??
- else if (rFeedInfo.DietToFed[4]) and (WeekOfLactation>Round(LactationLength/7))
- {and (WeekOfLactation<=TimeToFinish-3)} and (HerdProbsS[YearOfLactation-1,3]>0) then
- begin
- rFeedInfo.FourOrFive:=True;
- rFeedInfo.ParlourPerMeal:=0;
- rFeedInfo.RumFillUpper:=rFeedInfo.RumFillUpper*0.95;
- IfDietTrue(WeekOfLactation,Lignin,MatProtein);
- end
- else if (rFeedInfo.DietToFed[5]) and (WeekOfLactation>TimeToFinish-3)
- and (WeekOfLactation<=TimeToFinish) and (HerdProbsS[YearOfLactation-1,4]>0) then
- begin
- rFeedInfo.FourOrFive:=True;
- rFeedInfo.ParlourPerMeal:=0;
- rFeedInfo.RumFillUpper:=rFeedInfo.RumFillUpper*0.95;
- IfDietTrue(WeekOfLactation,Lignin,MatProtein);
- end
- else
- begin
- rNutrientsAbsorbed.DMI[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.EESupplied[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.DietME[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.MilkFromP[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.MPMaint[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.MEMaint[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.ParlourDMI[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.ProteinToEnergy[CowParity,WeekOfLactation-1]:=0;
- end;
- if rNutrientsAbsorbed.MilkFromP[CowParity,WeekOfLactation-1]<0 then
- rNutrientsAbsorbed.MilkFromP[CowParity,WeekOfLactation-1]:=0;
- //BodyChange is individual time point and BodyWeight is accumalation of BodyChange
- AnimalLipid:=AnimalLipid+deltaL*1.07*7;
- rNutrientsAbsorbed.BodyChange[CowParity,WeekOfLactation-1]:=
- deltaL*1.07+(deltaP-ProteinLoss)*4;//LostProtein
- if WeekOfLactation=1 then
- rNutrientsAbsorbed.BodyWeight[CowParity,weekOfLactation-1]:=0
- else
- rNutrientsAbsorbed.BodyWeight[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.BodyWeight[CowParity,WeekOfLactation-2]
- +rNutrientsAbsorbed.BodyChange[CowParity,WeekOfLactation-1]*7;
- rNutrientsAbsorbed.EESupplied[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.DietME[CowParity,WeekOfLactation-1]
- *rNutrientsAbsorbed.DMI[CowParity,WeekOfLactation-1];
- // if not SingleRun then ProgressBar1.Position:=Round(PBar/PBarCount*100);
- if (Beef) and (not SingleRun) then
- begin
- rNutrientsAbsorbed.PotentialMilk[CowParity,WeekOfLactation-1]:=
- Animal.WeightArray[CowParity,WeekOfLactation-1]/10;
- rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-1]:=
- Animal.Protein[CowParity,WeekOfLactation-1]/2;
- rNutrientsAbsorbed.MilkFromP[CowParity,WeekOfLactation-1]:=
- Animal.Lipid[CowParity,WeekOfLactation-1]/2;
- rNutrientsAbsorbed.ParlourDMI[CowParity,WeekOfLactation-1]:=
- Animal.CS[CowParity,WeekOfLactation-1]*10;
- end;
- end; //of for WeekOfLactation
- end; //of if LactationNo[YearOfLactation]>0 then
- //ProgressBar1.Position:=0;
- //if not Sheep then Report.Visible:=True;
- //Finish:=GetTickCount;
- //Results.Label24.Caption:=IntToStr(Finish-Start);
- //WhyWontItWork:=4;
- SpeedButton6.Enabled:=True;
- SpeedButton7.Enabled:=True;
- SpeedButton8.Enabled:=True;
- SpeedButton10.Enabled:=True;
- RumenRaftFactor:=0;
- for n := 1 to 24 do
- RumenRaftFactor:=RumenRaftFactor+UNDFForage[n];
- RumenRaftFactor:=RumenRaftFactor/24;
- SpeedButton6.Click; //Results
- SpeedButton6.Down:=True;
- if WhatIfBoolean then WhatIfForm.Show;
- //save output
- if DietTrue then Welcome.SaveFormulation;
- SpeedButton7Click(Main); //Save
- AutoCreatePreMix1.Enabled:=True;
- finally
- NotRunYet:=False; RunpH6:=False;
- if not Administrator then
- begin
- DBNotConnected:=1;
- SavingResults:=True;
- SaveFormulations;
- EnDecryptFile(DatabaseDirectory+'\DBFormulation.ph6');
- SavePreMixes;
- EnDecryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- SaveResults;
- FormulationHigh:=Length(DBFormulation);
- PreMixFeedsHigh:=Length(DBPreMixes);
- WriteIniFile;
- DBNotConnected:=0;
- end;
- RunpH6:=True;
- Screen.Cursor:=SaveCursor;
- end;//try
- end;//of if not CanRun which means DM is zero on something
- end;
- procedure TMain.IfDietTrue(WeekOfLactation: Integer;Lignin,MatProtein: Single);
- var
- n,WofLSt: Integer;
- ProportionRumVol: Single;
- begin
- WofLSt:=0;
- ptrAnimal:=@Animal;
- rFeedInfo.EReq:=rNutrientsAbsorbed.EReq[CowParity,WeekOfLactation-1];
- if ChopLength then ProportionRumVol:=0.175 else ProportionRumVol:=0.165;
- if Beef or Sheep then
- begin
- rFeedInfo.RVol:=rFeedInfo.ActualWeight*0.165*JerseyOpt;
- end
- else
- begin
- if rFeedInfo.FourOrFive then
- begin
- WofLSt:=WeekOfLactation-43;
- rFeedInfo.RVol:=rFeedInfo.ActualWeight*JerseyOpt*(0.15-0.025/7*WofLSt);
- end
- else
- begin
- rFeedInfo.RVol:=rFeedInfo.ActualWeight*ProportionRumVol*JerseyOpt;//0.165*(0.5+0.5*(1-exp(-0.0899*(WeekOfLactation-1)*7)));
- end;
- end;
- rFeedInfo.RumSA:=251360*power(rFeedInfo.RVol/4189.333,0.667);// 'cm2
- rFeedInfo.RLoad:=rFeedInfo.RVol*0.15;
- rFeedInfo.PPass:=ParticlePassagePpn*1.15*(1/0.8)*0.07095/power(rFeedInfo.ActualWeight,0.27)*JerseyOpt;
- rFeedInfo.LongParticleBR:=0.1436*power(CalcLig(rFeedInfo.Diet,DMIDiet1),-0.4572)
- *power(rFeedInfo.ActualWeight,-0.27){*ForageDMBelow30Ppn};
- if MicrobesAcidosis then
- begin
- if SingleRun then rFeedInfo.MilkWater:=StrToFloat(Instant.Edit63.Text)
- /kgToOther/HoursInDay
- else
- if WeekOfLactation=1 then
- rFeedInfo.MilkWater:=LactationDay1/HoursInDay
- else
- rFeedInfo.MilkWater:=rNutrientsAbsorbed.MilkFromE[CowParity,WeekOfLactation-2]/HoursInDay;
- end;
- try
- NutrientSupply(ptrFeedInfo,@Feeding,ptrNutAbsorbed);
- except
- on Exception do MessageBeep(0);
- end;
- rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]:=0;
- for n:=0 to 23 do
- begin
- rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]
- +rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH;
- if n=0 then
- begin
- rNutrientsAbsorbed.pHmin[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH;
- rNutrientsAbsorbed.pHmax[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.pHmin[CowParity,WeekOfLactation-1];
- end;
- if rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH
- >rNutrientsAbsorbed.pHmax[CowParity,WeekOfLactation-1] then
- rNutrientsAbsorbed.pHmax[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH;
- if rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH
- <rNutrientsAbsorbed.pHmin[CowParity,WeekOfLactation-1] then
- rNutrientsAbsorbed.pHmin[CowParity,WeekOfLactation-1]:=
- rNutrientsAbsorbed.aNutAbsorbedElement[CowParity,WeekOfLactation-1,n].pH;
- end;
- try
- begin
- if not FSGrazingAll[rFeedInfo.Diet] then
- for n:=0 to rFeedInfo.iNoFeeds-1 do
- rNutrientsAbsorbed.DietME[CowParity,WeekOfLactation-1]:=rNutrientsAbsorbed.DietME[CowParity,WeekOfLactation-1]
- +rFeedInfo.TMRFeed[n].ME*StrToFloat(FeedOrder[n,7+rFeedInfo.Diet])/Thousand;
- ParlourME:=0;
- for n:=0 to rFeedInfo.iParlour-1 do
- ParlourME:=ParlourME+rFeedInfo.ParlourFeed[n].ME*PMParlourAmount[n]/100;
- RoboticME:=0;
- for n:=0 to rFeedInfo.iRobotic-1 do
- RoboticME:=RoboticME+rFeedInfo.RoboticFeed[n].ME*PMRoboticAmount[n]/100;
- end
- except
- on Exception do MessageBeep(0);
- end;
- if CowParity=2 then
- begin
- if WeekOfLactation<Animal.Tstar/DaysInWeek then
- begin
- ProteinLoss:=rNutrientsAbsorbed.ProteinFromBody[WeekOfLactation-1];
- BodyProteinLoss:=BodyProteinLoss+ProteinLoss*7;
- BodyProteinGain:=0;
- end
- else
- begin
- ProteinLoss:=0;
- end;
- end
- else
- begin
- ProteinLoss:=0;
- BodyProteinLoss:=0;
- BodyProteinGain:=0;
- end;
- try
- NutrientUse(ptrNutAbsorbed,ptrAnimal,rFeedInfo.CalvWeight[CowParity+1],ProteinLoss,BodyProteinGain,
- LostProtein,WeekOfLactation,CowParity)
- except
- on Exception do MessageBeep(0);
- end;
- rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]:=rNutrientsAbsorbed.pHav[CowParity,WeekOfLactation-1]/24;
- DegradableRatio(rNutrientsAbsorbed.AvQ[CowParity,WeekOfLactation-1],
- rNutrientsAbsorbed.AvS[CowParity,WeekOfLactation-1],
- rNutrientsAbsorbed.AvR[CowParity,WeekOfLactation-1],
- WeekOfLactation-1);
- if (FSParlour[rFeedInfo.Diet]) or (TMRRobotic) then
- begin
- if TMRRobotic then
- rNutrientsAbsorbed.ParlourDMI[CowParity,WeekOfLactation-1]:=
- rFeedInfo.RoboticPerMeal1*RoboticFeeds[rFeedInfo.Parlour]
- else
- rNutrientsAbsorbed.ParlourDMI[CowParity,WeekOfLactation-1]:=
- rFeedInfo.ParlourPerMeal*ParlourFeeds[rFeedInfo.Parlour];
- rNutrientsAbsorbed.RoboticDMI[CowParity,WeekOfLactation-1]:=
- rFeedInfo.RoboticPerMeal2*RoboticFeeds[rFeedInfo.Parlour];
- if rFeedInfo.iLiquid=0 then
- rNutrientsAbsorbed.LiquidDMI[CowParity,WeekOfLactation-1]:=0
- else
- rNutrientsAbsorbed.LiquidDMI[CowParity,WeekOfLactation-1]:=
- rFeedInfo.LiquidPerMeal*RoboticFeeds[rFeedInfo.Parlour];
- end
- else
- begin
- rNutrientsAbsorbed.ParlourDMI[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.RoboticDMI[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.LiquidDMI[CowParity,WeekOfLactation-1]:=0;
- end;
- if not TMRRobotic then
- begin
- rNutrientsAbsorbed.RoboticDMI[CowParity,WeekOfLactation-1]:=0;
- rNutrientsAbsorbed.LiquidDMI[CowParity,WeekOfLactation-1]:=0;
- end;
- end;
- function TMain.CopyDir(const fromDir, toDir: string): Boolean;
- var
- fos: TSHFileOpStruct;
- begin
- ZeroMemory(@fos, SizeOf(fos));
- with fos do
- begin
- wFunc := FO_COPY;
- fFlags := FOF_FILESONLY;
- pFrom := PChar(fromDir + #0);
- pTo := PChar(toDir)
- end;
- Result := (0 = ShFileOperation(fos));
- end;
- procedure TMain.Currency1Click(Sender: TObject);
- begin
- if not Assigned(SelectCurrency) then
- Application.CreateForm(TSelectCurrency, SelectCurrency);
- if SelectCurrency.ShowModal=mrOK then
- begin
- Welcome.Label1.Caption:=WCCurrency;
- Welcome.Label2.Caption:=WCAbbrev;
- end;
- end;
- function TMain.MoveDir(const fromDir, toDir: string): Boolean;
- var
- fos: TSHFileOpStruct;
- begin
- ZeroMemory(@fos, SizeOf(fos));
- with fos do
- begin
- wFunc := FO_MOVE;
- fFlags := FOF_FILESONLY;
- pFrom := PChar(fromDir + #0);
- pTo := PChar(toDir)
- end;
- Result := (0 = ShFileOperation(fos));
- end;
- procedure TMain.SetUpDBFeedLabels;
- begin
- if not FileExists(DatabaseDirectory+'\DBFeedLabels.ph6') then
- CopyFile(PWideChar(DatabaseDirectory+'\Stored\DBFeedLabels.ph6'),PWideChar(DatabaseDirectory+'\DBFeedLabels.ph6'),False);
- if (FileExists(DatabaseDirectory+'\DBFeedLabels.ph6')) or (not DBConnected) then
- begin
- EnDeCryptFile(DatabaseDirectory+'\DBFeedLabels.ph6');
- OpenFeedLabels;
- EnDeCryptFile(DatabaseDirectory+'\DBFeedLabels.ph6');
- if rTranslate.no225='' then
- begin
- DeleteFile(DatabaseDirectory+'\DBFeedLabels.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\Stored\DBFeedLabels.ph6'),PWideChar(DatabaseDirectory+'\DBFeedLabels.ph6'),False);
- EnDeCryptFile(DatabaseDirectory+'\DBFeedLabels.ph6');
- OpenFeedLabels;
- EnDeCryptFile(DatabaseDirectory+'\DBFeedLabels.ph6');
- end;
- end
- else
- ReadLanguage;
- end;
- procedure TMain.SetUpDBFeedPrices;
- begin
- if (FileExists(DatabaseDirectory+'\DBFeedPrices.ph6')) or (not DBConnected)
- or (DBNotConnected=1) then
- begin
- EnDeCryptFile(DatabaseDirectory+'\DBFeedPrices.ph6');
- OpenFeedPrices;
- EnDeCryptFile(DatabaseDirectory+'\DBFeedPrices.ph6');
- if FeedPrice[1]>0 then
- begin
- DeleteFile(DatabaseDirectory+'\Daily\DBFeedPrices.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBFeedPrices.ph6'),PWideChar(DatabaseDirectory+'\Daily\DBFeedPrices.ph6'),False);
- end;
- end
- else
- ReadFeedPrice;
- end;
- procedure TMain.ReadDBPreMix(n: Integer);
- begin
- while not FDQuery1.Eof do
- begin
- DBPreMixes[n].New:=0;
- DBPreMixes[n].ID:=FDQuery1.FieldByName('ID').AsInteger;
- DBPreMixes[n].TypeF:=FDQuery1.FieldByName('Type').AsString;
- DBPreMixes[n].Name:=FDQuery1.FieldByName('NameEn').AsString;
- DBPreMixes[n].FC_1:=FDQuery1.FieldByName('FC1').AsString;
- DBPreMixes[n].FC_2:=FDQuery1.FieldByName('FC2').AsString;
- DBPreMixes[n].FC_3:=FDQuery1.FieldByName('FC3').AsString;
- DBPreMixes[n].FC_4:=FDQuery1.FieldByName('FC4').AsString;
- DBPreMixes[n].FC_5:=FDQuery1.FieldByName('FC5').AsString;
- DBPreMixes[n].FC_6:=FDQuery1.FieldByName('FC6').AsString;
- DBPreMixes[n].FC_7:=FDQuery1.FieldByName('FC7').AsString;
- DBPreMixes[n].FC_8:=FDQuery1.FieldByName('FC8').AsString;
- DBPreMixes[n].FC_9:=FDQuery1.FieldByName('FC9').AsString;
- DBPreMixes[n].FC_10:=FDQuery1.FieldByName('FC10').AsString;
- DBPreMixes[n].FC_11:=FDQuery1.FieldByName('FC11').AsString;
- DBPreMixes[n].FC_12:=FDQuery1.FieldByName('FC12').AsString;
- DBPreMixes[n].FC_13:=FDQuery1.FieldByName('FC13').AsString;
- DBPreMixes[n].FC_14:=FDQuery1.FieldByName('FC14').AsString;
- DBPreMixes[n].FC_15:=FDQuery1.FieldByName('FC15').AsString;
- DBPreMixes[n].FC_16:=FDQuery1.FieldByName('FC16').AsString;
- DBPreMixes[n].FC_17:=FDQuery1.FieldByName('FC17').AsString;
- DBPreMixes[n].FC_18:=FDQuery1.FieldByName('FC18').AsString;
- DBPreMixes[n].FN_1:=FDQuery1.FieldByName('FN1').AsString;
- DBPreMixes[n].FN_2:=FDQuery1.FieldByName('FN2').AsString;
- DBPreMixes[n].FN_3:=FDQuery1.FieldByName('FN3').AsString;
- DBPreMixes[n].FN_4:=FDQuery1.FieldByName('FN4').AsString;
- DBPreMixes[n].FN_5:=FDQuery1.FieldByName('FN5').AsString;
- DBPreMixes[n].FN_6:=FDQuery1.FieldByName('FN6').AsString;
- DBPreMixes[n].FN_7:=FDQuery1.FieldByName('FN7').AsString;
- DBPreMixes[n].FN_8:=FDQuery1.FieldByName('FN8').AsString;
- DBPreMixes[n].FN_9:=FDQuery1.FieldByName('FN9').AsString;
- DBPreMixes[n].FN_10:=FDQuery1.FieldByName('FN10').AsString;
- DBPreMixes[n].FN_11:=FDQuery1.FieldByName('FN11').AsString;
- DBPreMixes[n].FN_12:=FDQuery1.FieldByName('FN12').AsString;
- DBPreMixes[n].FN_13:=FDQuery1.FieldByName('FN13').AsString;
- DBPreMixes[n].FN_14:=FDQuery1.FieldByName('FN14').AsString;
- DBPreMixes[n].FN_15:=FDQuery1.FieldByName('FN15').AsString;
- DBPreMixes[n].FN_16:=FDQuery1.FieldByName('FN16').AsString;
- DBPreMixes[n].FN_17:=FDQuery1.FieldByName('FN17').AsString;
- DBPreMixes[n].FN_18:=FDQuery1.FieldByName('FN18').AsString;
- DBPreMixes[n].FA_1:=FDQuery1.FieldByName('FN1%').AsFloat;
- DBPreMixes[n].FA_2:=FDQuery1.FieldByName('FN2%').AsFloat;
- DBPreMixes[n].FA_3:=FDQuery1.FieldByName('FN3%').AsFloat;
- DBPreMixes[n].FA_4:=FDQuery1.FieldByName('FN4%').AsFloat;
- DBPreMixes[n].FA_5:=FDQuery1.FieldByName('FN5%').AsFloat;
- DBPreMixes[n].FA_6:=FDQuery1.FieldByName('FN6%').AsFloat;
- DBPreMixes[n].FA_7:=FDQuery1.FieldByName('FN7%').AsFloat;
- DBPreMixes[n].FA_8:=FDQuery1.FieldByName('FN8%').AsFloat;
- DBPreMixes[n].FA_9:=FDQuery1.FieldByName('FN9%').AsFloat;
- DBPreMixes[n].FA_10:=FDQuery1.FieldByName('FN10%').AsFloat;
- DBPreMixes[n].FA_11:=FDQuery1.FieldByName('FN11%').AsFloat;
- DBPreMixes[n].FA_12:=FDQuery1.FieldByName('FN12%').AsFloat;
- DBPreMixes[n].FA_13:=FDQuery1.FieldByName('FN13%').AsFloat;
- DBPreMixes[n].FA_14:=FDQuery1.FieldByName('FN14%').AsFloat;
- DBPreMixes[n].FA_15:=FDQuery1.FieldByName('FN15%').AsFloat;
- DBPreMixes[n].FA_16:=FDQuery1.FieldByName('FN16%').AsFloat;
- DBPreMixes[n].FA_17:=FDQuery1.FieldByName('FN17%').AsFloat;
- DBPreMixes[n].FA_18:=FDQuery1.FieldByName('FN18%').AsFloat;
- DBPreMixes[n].FP_1:=FDQuery1.FieldByName('FP_1').AsInteger;
- DBPreMixes[n].FP_2:=FDQuery1.FieldByName('FP_2').AsInteger;
- DBPreMixes[n].FP_3:=FDQuery1.FieldByName('FP_3').AsInteger;
- DBPreMixes[n].FP_4:=FDQuery1.FieldByName('FP_4').AsInteger;
- DBPreMixes[n].FP_5:=FDQuery1.FieldByName('FP_5').AsInteger;
- DBPreMixes[n].FP_6:=FDQuery1.FieldByName('FP_6').AsInteger;
- DBPreMixes[n].FP_7:=FDQuery1.FieldByName('FP_7').AsInteger;
- DBPreMixes[n].FP_8:=FDQuery1.FieldByName('FP_8').AsInteger;
- DBPreMixes[n].FP_9:=FDQuery1.FieldByName('FP_9').AsInteger;
- DBPreMixes[n].FP_10:=FDQuery1.FieldByName('FP_10').AsInteger;
- DBPreMixes[n].FP_11:=FDQuery1.FieldByName('FP_11').AsInteger;
- DBPreMixes[n].FP_12:=FDQuery1.FieldByName('FP_12').AsInteger;
- DBPreMixes[n].FP_13:=FDQuery1.FieldByName('FP_13').AsInteger;
- DBPreMixes[n].FP_14:=FDQuery1.FieldByName('FP_14').AsInteger;
- DBPreMixes[n].FP_15:=FDQuery1.FieldByName('FP_15').AsInteger;
- DBPreMixes[n].FP_16:=FDQuery1.FieldByName('FP_16').AsInteger;
- DBPreMixes[n].FP_17:=FDQuery1.FieldByName('FP_17').AsInteger;
- DBPreMixes[n].FP_18:=FDQuery1.FieldByName('FP_18').AsInteger;
- DBPreMixes[n].Cost:=FDQuery1.FieldByName('Price').AsFloat;
- DBPreMixes[n].BlendType:=FDQuery1.FieldByName('BlendType').AsString;
- inc(n);
- FDQuery1.Next;
- end;
- end;
- procedure TMain.SetUpDBPreMixes;
- var
- n: Integer;
- begin
- //DBNotConnected:=0;
- if (DBConnected) and (DBNotConnected=0) then
- begin
- if (FileExists(DatabaseDirectory+'\DBPreMixes.ph6')) and (NewBlends=False)
- and (Administrator=False) and (UpdateYesNo=False) and (not DifferentHD) then
- begin
- n:=PreMixFeedsHigh;
- DBPreMixes:=nil;
- SetLength(DBPreMixes,n);
- EnDeCryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- OpenPreMix(n);
- EnDeCryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- // if n>PreMixFeedsHigh then
- // begin
- // SetLength(DBPreMixes,PreMixFeedsHigh+(n-PreMixFeedsHigh));
- // SetUpQueryPM(1);
- // ReadDBPreMix(PreMixFeedsHigh);
- // PreMixFeedsHigh:=Length(DBPreMixes);
- // FDQuery1.Close;
- // end;
- end
- else
- begin
- SetUpQueryPM(0);
- PreMixFeedsHigh:=FDQuery1.RecordCount;
- DBPreMixes:=nil;
- SetLength(DBPreMixes,PreMixFeedsHigh);
- n:=0;
- ReadDBPreMix(n);
- end;
- FDQuery1.Close;
- end
- else
- begin
- DBPreMixes:=nil;
- if PreMixFeedsHigh>0 then
- begin
- SetLength(DBPreMixes,PreMixFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- OpenPreMix(PreMixFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBPreMixes.ph6');
- end;
- end;
- end;
- procedure TMain.ReadDBClient(n: Integer);
- begin
- while not FDQuery1.Eof do
- begin
- DBClientFeeds[n].New:=0;
- DBClientFeeds[n].ID:=FDQuery1.FieldByName('ID').AsInteger;
- DBClientFeeds[n].Cost:=FDQuery1.FieldByName('Cost').AsInteger;
- DBClientFeeds[n].TypeF:=FDQuery1.FieldByName('Type').AsString;
- DBClientFeeds[n].Forage:=FDQuery1.FieldByName('Forage').AsString;
- DBClientFeeds[n].ForageFr:=FDQuery1.FieldByName('ForageFr').AsString;
- DBClientFeeds[n].ForageUS:=FDQuery1.FieldByName('ForageUS').AsString;
- DBClientFeeds[n].ForageSp:=FDQuery1.FieldByName('ForageSp').AsString;
- DBClientFeeds[n].Code:=FDQuery1.FieldByName('Code').AsString;
- if FDQuery1.FieldByName('Sup').AsInteger=1 then
- DBClientFeeds[n].Sup:=False
- else
- DBClientFeeds[n].Sup:=True;
- if FDQuery1.FieldByName('LongP').AsInteger=1 then
- DBClientFeeds[n].Long:=True
- else
- DBClientFeeds[n].Long:=False;
- DBClientFeeds[n].LongForage:=False;
- DBClientFeeds[n].TCHO:=FDQuery1.FieldByName('TCHO').AsFloat;
- DBClientFeeds[n].NDF:=FDQuery1.FieldByName('NDF').AsFloat;
- DBClientFeeds[n].PemNDF:=FDQuery1.FieldByName('PemNDF').AsFloat;
- DBClientFeeds[n].CP:=FDQuery1.FieldByName('CP').AsFloat;
- DBClientFeeds[n].RateBcho:=FDQuery1.FieldByName('RateBcho').AsFloat;
- DBClientFeeds[n].Bcho:=FDQuery1.FieldByName('Bcho').AsFloat;
- DBClientFeeds[n].Acho:=FDQuery1.FieldByName('Acho').AsFloat;
- DBClientFeeds[n].SNDF:=FDQuery1.FieldByName('SNDF').AsFloat;
- DBClientFeeds[n].Starch:=FDQuery1.FieldByName('Starch').AsFloat;
- DBClientFeeds[n].RateAcho:=FDQuery1.FieldByName('RateAcho').AsFloat;
- DBClientFeeds[n].RateBCP:=FDQuery1.FieldByName('RateBCP').AsFloat;
- DBClientFeeds[n].BCP:=FDQuery1.FieldByName('BCP').AsFloat;
- DBClientFeeds[n].ACP:=FDQuery1.FieldByName('ACP').AsFloat;
- DBClientFeeds[n].RateACP:=FDQuery1.FieldByName('RateACP').AsFloat;
- DBClientFeeds[n].Nlag:=FDQuery1.FieldByName('Nlag').AsFloat;
- DBClientFeeds[n].Ash:=FDQuery1.FieldByName('Ash').AsFloat;
- DBClientFeeds[n].Fat:=FDQuery1.FieldByName('Fat').AsFloat;
- DBClientFeeds[n].VFA:=FDQuery1.FieldByName('VFA').AsFloat;
- DBClientFeeds[n].Lactic:=FDQuery1.FieldByName('Lactic').AsFloat;
- DBClientFeeds[n].NH3:=FDQuery1.FieldByName('NH3').AsFloat;
- DBClientFeeds[n].DM:=FDQuery1.FieldByName('DM').AsFloat;
- DBClientFeeds[n].GasA:=FDQuery1.FieldByName('GasA').AsFloat;
- DBClientFeeds[n].GasB:=FDQuery1.FieldByName('GasB').AsFloat;
- DBClientFeeds[n].GasARate:=FDQuery1.FieldByName('GasARate').AsFloat;
- DBClientFeeds[n].GasBRate:=FDQuery1.FieldByName('GasBRate').AsFloat;
- DBClientFeeds[n].GasBLag:=FDQuery1.FieldByName('GasBLag').AsFloat;
- DBClientFeeds[n].Starchfim:=FDQuery1.FieldByName('Starchfim').AsFloat;
- DBClientFeeds[n].Fip:=FDQuery1.FieldByName('Fip').AsFloat;
- DBClientFeeds[n].ME:=FDQuery1.FieldByName('ME').AsFloat;
- DBClientFeeds[n].An:=FDQuery1.FieldByName('An').AsFloat;
- DBClientFeeds[n].Sn:=FDQuery1.FieldByName('Sn').AsFloat;
- DBClientFeeds[n].Bn:=FDQuery1.FieldByName('Bn').AsFloat;
- DBClientFeeds[n].Cn:=FDQuery1.FieldByName('Cn').AsFloat;
- DBClientFeeds[n].Adin:=FDQuery1.FieldByName('Adin').AsFloat;
- DBClientFeeds[n].Lys:=FDQuery1.FieldByName('Lys').AsFloat;
- DBClientFeeds[n].Thr:=FDQuery1.FieldByName('Thr').AsFloat;
- DBClientFeeds[n].Met:=FDQuery1.FieldByName('Met').AsFloat;
- DBClientFeeds[n].Cys:=FDQuery1.FieldByName('Cys').AsFloat;
- DBClientFeeds[n].His:=FDQuery1.FieldByName('His').AsFloat;
- DBClientFeeds[n].Sdm:=FDQuery1.FieldByName('Sdm').AsFloat;
- DBClientFeeds[n].Tfa:=FDQuery1.FieldByName('Tfa').AsFloat;
- DBClientFeeds[n].Adm:=FDQuery1.FieldByName('Adm').AsFloat;
- DBClientFeeds[n].Bdm:=FDQuery1.FieldByName('Bdm').AsFloat;
- DBClientFeeds[n].Cdm:=FDQuery1.FieldByName('Cdm').AsFloat;
- DBClientFeeds[n].Domd:=FDQuery1.FieldByName('Domd').AsFloat;
- DBClientFeeds[n].Ph:=FDQuery1.FieldByName('Ph').AsFloat;
- DBClientFeeds[n].Ca:=FDQuery1.FieldByName('Ca').AsFloat;
- DBClientFeeds[n].P:=FDQuery1.FieldByName('P').AsFloat;
- DBClientFeeds[n].Mg:=FDQuery1.FieldByName('Mg').AsFloat;
- DBClientFeeds[n].K:=FDQuery1.FieldByName('K').AsFloat;
- DBClientFeeds[n].Na:=FDQuery1.FieldByName('Na').AsFloat;
- DBClientFeeds[n].Cl:=FDQuery1.FieldByName('Cl').AsFloat;
- DBClientFeeds[n].S:=FDQuery1.FieldByName('S').AsFloat;
- DBClientFeeds[n].Cu:=FDQuery1.FieldByName('Cu').AsFloat;
- DBClientFeeds[n].Zn:=FDQuery1.FieldByName('Zn').AsFloat;
- DBClientFeeds[n].Mn:=FDQuery1.FieldByName('Mn').AsFloat;
- DBClientFeeds[n].Co:=FDQuery1.FieldByName('Co').AsFloat;
- DBClientFeeds[n].I:=FDQuery1.FieldByName('I').AsFloat;
- DBClientFeeds[n].Se:=FDQuery1.FieldByName('Se').AsFloat;
- DBClientFeeds[n].Fe:=FDQuery1.FieldByName('Fe').AsFloat;
- DBClientFeeds[n].Mo:=FDQuery1.FieldByName('Mo').AsFloat;
- inc(n);
- FDQuery1.Next;
- end;
- end;
- procedure TMain.SetUpDBClientFeeds;
- var
- n,LCClientFeedsHigh,m: Integer;
- begin
- //DBNotConnected:=0;
- if (DBConnected) and (DBNotConnected=0) then
- begin
- //DBClientFeeds has to be there or it is created. If UpdateYesNo is selected, DBClientFeeds is created
- //if in the Database, more is there relative to ClientFeedsHigh (one or more added by someone), then n will be higher
- //than ClientFeedsHigh and extra are put in
- if (FileExists(DatabaseDirectory+'\DBClientFeeds.ph6')) and
- {(NewClients=False) and} (Administrator=False) and (UpdateYesNo=False)
- and (not DifferentHD) then //{((n>=ClientFeedsHigh) or }
- begin
- n:=ClientFeedsHigh;
- m:=n;
- DBClientFeeds:=nil;
- SetLength(DBClientFeeds,n);
- EnDeCryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- OpenClient(ClientFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- if (n>m) then
- begin
- // SetLength(DBClientFeeds,ClientFeedsHigh+(n-ClientFeedsHigh));
- SetUpQuery(1);
- ReadDBClient(m);
- ClientFeedsHigh:=Length(DBClientFeeds);
- FDQuery1.Close;
- end;
- end
- else
- begin
- SetUpQuery(0);
- ClientFeedsHigh:=FDQuery1.RecordCount;
- DBClientFeeds:=nil;
- SetLength(DBClientFeeds,ClientFeedsHigh);
- n:=0;
- //put try except in here to catch possible bug in reading FDQuery1
- ReadDBClient(n);
- end;
- FDQuery1.Close;
- end
- else
- begin
- DBClientFeeds:=nil;
- if ClientFeedsHigh>0 then
- begin
- SetLength(DBClientFeeds,ClientFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- LCClientFeedsHigh:=linecount(DatabaseDirectory+'\DBClientFeeds.ph6');
- if ClientFeedsHigh<LCClientFeedsHigh then
- begin
- DBClientFeeds:=nil;
- SetLength(DBClientFeeds,LCClientFeedsHigh);
- OpenClient(LCClientFeedsHigh);
- end
- else
- begin
- OpenClient(ClientFeedsHigh);
- end;
- EnDeCryptFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- end;
- end;
- end;
- procedure TMain.SetUpDBMasterFeeds;
- var
- n,m: Integer;
- begin
- if DBConnected then
- begin
- if (FileExists(DatabaseDirectory+'\DBMasterFeeds.ph6')) {and (n=MasterFeedsHigh) }
- and (NewMaster=False) and (Administrator=False) and (UpdateYesNo=False)
- and (not DifferentHD) then
- begin
- n:=MasterFeedsHigh;
- DBMasterFeeds:=nil;
- SetLength(DBMasterFeeds,n);
- EnDeCryptFile(DatabaseDirectory+'\DBMasterFeeds.ph6');
- OpenMaster(n);
- EnDeCryptFile(DatabaseDirectory+'\DBMasterFeeds.ph6');
- end
- else
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Master');
- SQL.Add('WHERE "Show"=0');
- Open;
- EnableControls;
- end;
- m:=FDQuery1.RecordCount;
- MasterFeedsHigh:=m;
- DBMasterFeeds:=nil;
- SetLength(DBMasterFeeds,m);
- n:=0;
- FDQuery1.First;
- while not FDQuery1.Eof do
- begin
- DBMasterFeeds[n].New:=0;
- DBMasterFeeds[n].ID:=FDQuery1.FieldByName('ID').AsInteger;
- DBMasterFeeds[n].Cost:=FDQuery1.FieldByName('Cost').AsInteger;
- DBMasterFeeds[n].TypeF:=FDQuery1.FieldByName('Type').AsString;
- DBMasterFeeds[n].Forage:=FDQuery1.FieldByName('Forage').AsString;
- DBMasterFeeds[n].ForageFr:=FDQuery1.FieldByName('ForageFr').AsString;
- DBMasterFeeds[n].ForageUS:=FDQuery1.FieldByName('ForageUS').AsString;
- DBMasterFeeds[n].ForageSp:=FDQuery1.FieldByName('ForageSp').AsString;
- DBMasterFeeds[n].Code:=FDQuery1.FieldByName('Code').AsString;
- if FDQuery1.FieldByName('Sup').AsString='1' then
- DBMasterFeeds[n].Sup:=False
- else
- DBMasterFeeds[n].Sup:=True;
- if FDQuery1.FieldByName('LongP').AsString='1' then
- DBMasterFeeds[n].Long:=True
- else
- DBMasterFeeds[n].Long:=False;
- DBMasterFeeds[n].LongForage:=False;
- DBMasterFeeds[n].TCHO:=FDQuery1.FieldByName('TCHO').AsFloat;
- DBMasterFeeds[n].NDF:=FDQuery1.FieldByName('NDF').AsFloat;
- DBMasterFeeds[n].PemNDF:=FDQuery1.FieldByName('PemNDF').AsFloat;
- DBMasterFeeds[n].CP:=FDQuery1.FieldByName('CP').AsFloat;
- DBMasterFeeds[n].RateBcho:=FDQuery1.FieldByName('RateBcho').AsFloat;
- DBMasterFeeds[n].Bcho:=FDQuery1.FieldByName('Bcho').AsFloat;
- DBMasterFeeds[n].Acho:=FDQuery1.FieldByName('Acho').AsFloat;
- DBMasterFeeds[n].SNDF:=FDQuery1.FieldByName('SNDF').AsFloat;
- DBMasterFeeds[n].Starch:=FDQuery1.FieldByName('Starch').AsFloat;
- DBMasterFeeds[n].RateAcho:=FDQuery1.FieldByName('RateAcho').AsFloat;
- DBMasterFeeds[n].RateBCP:=FDQuery1.FieldByName('RateBCP').AsFloat;
- DBMasterFeeds[n].BCP:=FDQuery1.FieldByName('BCP').AsFloat;
- DBMasterFeeds[n].ACP:=FDQuery1.FieldByName('ACP').AsFloat;
- DBMasterFeeds[n].RateACP:=FDQuery1.FieldByName('RateACP').AsFloat;
- DBMasterFeeds[n].Nlag:=FDQuery1.FieldByName('Nlag').AsFloat;
- DBMasterFeeds[n].Ash:=FDQuery1.FieldByName('Ash').AsFloat;
- DBMasterFeeds[n].Fat:=FDQuery1.FieldByName('Fat').AsFloat;
- DBMasterFeeds[n].VFA:=FDQuery1.FieldByName('VFA').AsFloat;
- DBMasterFeeds[n].Lactic:=FDQuery1.FieldByName('Lactic').AsFloat;
- DBMasterFeeds[n].NH3:=FDQuery1.FieldByName('NH3').AsFloat;
- DBMasterFeeds[n].DM:=FDQuery1.FieldByName('DM').AsFloat;
- DBMasterFeeds[n].GasA:=FDQuery1.FieldByName('GasA').AsFloat;
- DBMasterFeeds[n].GasB:=FDQuery1.FieldByName('GasB').AsFloat;
- DBMasterFeeds[n].GasARate:=FDQuery1.FieldByName('GasARate').AsFloat;
- DBMasterFeeds[n].GasBRate:=FDQuery1.FieldByName('GasBRate').AsFloat;
- DBMasterFeeds[n].GasBLag:=FDQuery1.FieldByName('GasBLag').AsFloat;
- DBMasterFeeds[n].Starchfim:=FDQuery1.FieldByName('Starchfim').AsFloat;
- DBMasterFeeds[n].Fip:=FDQuery1.FieldByName('Fip').AsFloat;
- DBMasterFeeds[n].ME:=FDQuery1.FieldByName('ME').AsFloat;
- DBMasterFeeds[n].An:=FDQuery1.FieldByName('An').AsFloat;
- DBMasterFeeds[n].Sn:=FDQuery1.FieldByName('Sn').AsFloat;
- DBMasterFeeds[n].Bn:=FDQuery1.FieldByName('Bn').AsFloat;
- DBMasterFeeds[n].Cn:=FDQuery1.FieldByName('Cn').AsFloat;
- DBMasterFeeds[n].Adin:=FDQuery1.FieldByName('Adin').AsFloat;
- DBMasterFeeds[n].Lys:=FDQuery1.FieldByName('Lys').AsFloat;
- DBMasterFeeds[n].Thr:=FDQuery1.FieldByName('Thr').AsFloat;
- DBMasterFeeds[n].Met:=FDQuery1.FieldByName('Met').AsFloat;
- DBMasterFeeds[n].Cys:=FDQuery1.FieldByName('Cys').AsFloat;
- DBMasterFeeds[n].His:=FDQuery1.FieldByName('His').AsFloat;
- DBMasterFeeds[n].Sdm:=FDQuery1.FieldByName('Sdm').AsFloat;
- DBMasterFeeds[n].Tfa:=FDQuery1.FieldByName('Tfa').AsFloat;
- DBMasterFeeds[n].Adm:=FDQuery1.FieldByName('Adm').AsFloat;
- DBMasterFeeds[n].Bdm:=FDQuery1.FieldByName('Bdm').AsFloat;
- DBMasterFeeds[n].Cdm:=FDQuery1.FieldByName('Cdm').AsFloat;
- DBMasterFeeds[n].Domd:=FDQuery1.FieldByName('Domd').AsFloat;
- DBMasterFeeds[n].Ph:=FDQuery1.FieldByName('Ph').AsFloat;
- DBMasterFeeds[n].Ca:=FDQuery1.FieldByName('Ca').AsFloat;
- DBMasterFeeds[n].P:=FDQuery1.FieldByName('P').AsFloat;
- DBMasterFeeds[n].Mg:=FDQuery1.FieldByName('Mg').AsFloat;
- DBMasterFeeds[n].K:=FDQuery1.FieldByName('K').AsFloat;
- DBMasterFeeds[n].Na:=FDQuery1.FieldByName('Na').AsFloat;
- DBMasterFeeds[n].Cl:=FDQuery1.FieldByName('Cl').AsFloat;
- DBMasterFeeds[n].S:=FDQuery1.FieldByName('S').AsFloat;
- DBMasterFeeds[n].Cu:=FDQuery1.FieldByName('Cu').AsFloat;
- DBMasterFeeds[n].Zn:=FDQuery1.FieldByName('Zn').AsFloat;
- DBMasterFeeds[n].Mn:=FDQuery1.FieldByName('Mn').AsFloat;
- DBMasterFeeds[n].Co:=FDQuery1.FieldByName('Co').AsFloat;
- DBMasterFeeds[n].I:=FDQuery1.FieldByName('I').AsFloat;
- DBMasterFeeds[n].Se:=FDQuery1.FieldByName('Se').AsFloat;
- DBMasterFeeds[n].Fe:=FDQuery1.FieldByName('Fe').AsFloat;
- DBMasterFeeds[n].Mo:=FDQuery1.FieldByName('Mo').AsFloat;
- inc(n);
- FDQuery1.Next;
- end;
- end;
- FDQuery1.Close;
- end
- else
- begin
- DBMasterFeeds:=nil;
- SetLength(DBMasterFeeds,MasterFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBMasterFeeds.ph6');
- OpenMaster(MasterFeedsHigh);
- EnDeCryptFile(DatabaseDirectory+'\DBMasterFeeds.ph6');
- end;
- end;
- procedure TMain.GetMinerals;
- var
- n,m: Integer;
- FeedName: array of TFeedName;
- begin
- if (DBConnected) and (not (FileExists(DatabaseDirectory+'\DBMinerals.ph6'))
- or (NewMineral)) then
- begin
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT *');
- SQL.Add('FROM Minerals ');
- SQL.Add('WHERE ConsultantID =:apptype OR ConsultantID =-1');
- FDQuery1.Params[0].Value:=Consultant;
- Open;
- EnableControls;
- end;
- Mineral:=nil;
- SetLength(Mineral,FDQuery1.RecordCount);
- FDQuery1.First;
- n:=0;
- while not FDQuery1.Eof do
- begin
- Mineral[n].TypeOfMineral:=FDQuery1.FieldByName('Type').AsInteger;
- Mineral[n].MineralID:=FDQuery1.FieldByName('MineralID').AsInteger;
- Mineral[n].ForageID:=FDQuery1.FieldByName('ForageID').AsInteger;
- Mineral[n].FarmerID:=FDQuery1.FieldByName('FarmerID').AsInteger;
- Mineral[n].Ca:=FDQuery1.FieldByName('Ca').AsSingle;
- Mineral[n].P:=FDQuery1.FieldByName('P').AsSingle;
- Mineral[n].Mg:=FDQuery1.FieldByName('Mg').AsSingle;
- Mineral[n].K:=FDQuery1.FieldByName('K').AsSingle;
- Mineral[n].Na:=FDQuery1.FieldByName('Na').AsSingle;
- Mineral[n].Cl:=FDQuery1.FieldByName('Cl').AsSingle;
- Mineral[n].S:=FDQuery1.FieldByName('S').AsSingle;
- Mineral[n].Cu:=FDQuery1.FieldByName('Cu').AsSingle;
- Mineral[n].Zn:=FDQuery1.FieldByName('Zn').AsSingle;
- Mineral[n].Mn:=FDQuery1.FieldByName('Mn').AsSingle;
- Mineral[n].Co:=FDQuery1.FieldByName('Co').AsSingle;
- Mineral[n].I:=FDQuery1.FieldByName('I').AsSingle;
- Mineral[n].Se:=FDQuery1.FieldByName('Se').AsSingle;
- Mineral[n].Fe:=FDQuery1.FieldByName('Fe').AsSingle;
- Mineral[n].Mo:=FDQuery1.FieldByName('Mo').AsSingle;
- inc(n);
- FDQuery1.Next;
- end;
- with FDQuery1 do
- begin
- DisableControls;
- Close;
- SQL.Clear;
- SQL.Add('SELECT ID , Forage ');
- SQL.Add('FROM Client ');
- SQL.Add('WHERE Consultant =:apptype');
- FDQuery1.Params[0].Value:=Consultant;
- Open;
- EnableControls;
- end;
- FeedName:=nil;
- SetLength(FeedName,FDQuery1.RecordCount);
- n:=0;
- FDQuery1.First;
- while not FDQuery1.Eof do
- begin
- FeedName[n].ForageID:=FDQuery1.FieldByName('ID').AsInteger;
- FeedName[n].FeedNameString:=FDQuery1.FieldByName('Forage').AsString;
- inc(n);
- FDQuery1.Next;
- end;
- FDQuery1.Close;
- FDConnection1.Connected:=False;
- for n := 0 to Length(FeedName)-1 do
- begin
- for m := 0 to Length(Mineral)-1 do
- begin
- if Mineral[m].ForageID=FeedName[n].ForageID then
- Mineral[m].ForageName:=FeedName[n].FeedNameString;
- end;
- end;
- SaveMinerals;
- EnDeCryptFile(DatabaseDirectory+'\DBMinerals.ph6');
- end
- else
- begin
- end;
- end;
- procedure TMain.DateToRestrictCDB;
- var
- RDB: String;
- IndexPosn: Integer;
- YearRDB,MonthRDB,DayRDB: Word;
- begin
- RDB:=DateChosenToRestrictDB;
- IndexPosn:=LastDelimiter('-',RDB);
- YearRDB:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- IndexPosn:=LastDelimiter('-',RDB);
- MonthRDB:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- DayRDB:=StrToInt(RDB);
- RestrictedDate:=EncodeDate(YearRDB,MonthRDB,DayRDB);
- DateInteger:=Trunc(RestrictedDate);
- RDB:=DateChosenToRestrictDBPM;
- IndexPosn:=LastDelimiter('-',RDB);
- YearRDB:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- IndexPosn:=LastDelimiter('-',RDB);
- MonthRDB:=StrToInt(Copy(RDB,IndexPosn+1,Length(RDB)-IndexPosn));
- Delete(RDB,IndexPosn,Length(RDB)-IndexPosn+1);
- DayRDB:=StrToInt(RDB);
- RestrictedDatePM:=EncodeDate(YearRDB,MonthRDB,DayRDB);
- DateIntegerPM:=Trunc(RestrictedDatePM);
- //RestrictedDateFarmer:=EncodeDate(YearRDB,MonthRDB,DayRDB);
- //DateIntegerFarmer:=YearChosenToRestrictDBFarmer;
- end;
- procedure TMain.SpeedButton1Click(Sender: TObject);
- begin
- Instant.Show;
- if (MUL) and (ForageCalc) then ForageEnough.Show;
- end;
- procedure TMain.SpeedButton8Click(Sender: TObject);
- var
- Checks,m,n,t,TimePoint: Integer;
- begin
- if ChoosePrint.ShowModal=mrOK then
- begin
- Screen.Cursor:=crHourGlass;
- try
- begin
- m:=0;t:=0;
- for n:=1 to 12 do
- begin
- if FeedLength[n].Start<FeedLength[n].Finish then inc(m);
- end;
- Checks:=0;
- if ChoosePrint.CheckBox5.Checked then Checks:=Checks+1;
- if ChoosePrint.CheckBox7.Checked then Checks:=Checks+1;
- if ChoosePrint.CheckBox12.Checked then Checks:=Checks+m;
- if (ChoosePrint.CheckBox12.Checked) and (PreMixParlourNo>1) then Checks:=Checks+1;
- if (ChoosePrint.CheckBox12.Checked) and (PreMixRoboticNo>1) then Checks:=Checks+1;
- Printer.BeginDoc;
- try
- begin
- Printer.Title:=rTranslate.no13;
- if ChoosePrint.CheckBox5.Checked then
- begin
- if Beef then TimePoint:=1
- else
- begin
- if LeftStr(Instant.Edit66.Text,1)='-' then
- TimePoint:=Round(LactationLength/DaysInWeek)+7
- +StrToInt(Instant.Edit66.Text)
- else
- TimePoint:=StrToInt(Instant.Edit66.Text);
- end;
- SingleRunOutPut(Printer.Canvas,@Feeding,Printer.PageWidth,Printer.PageHeight,
- TimePoint,1);
- if Checks-1>1 then Printer.NewPage;
- end;
- if ChoosePrint.CheckBox7.Checked then
- begin
- Diets1(Printer.Canvas,@Feeding,Printer.PageWidth,Printer.PageHeight,1);
- if Checks-1>1 then Printer.NewPage;
- end;
- if ChoosePrint.CheckBox12.Checked then
- begin
- for n:=1 to m do
- begin
- PrintPreMix(Printer.Canvas,Printer.PageWidth,Printer.PageHeight,n,t,1);
- if Checks-1>1 then Printer.NewPage;
- end;
- if PreMixParlourNo>1 then
- begin
- PreMixParlour(Printer.Canvas,Printer.PageWidth,Printer.PageHeight,ChoosePrint.Edit1.Text);
- if Checks-1>1 then Printer.NewPage;
- end;
- if PreMixRoboticNo>1 then
- begin
- PreMixRobotic(Printer.Canvas,Printer.PageWidth,Printer.PageHeight,ChoosePrint.Edit1.Text);
- if Checks-1>1 then Printer.NewPage;
- end;
- end;
- Printer.EndDoc;
- end
- except
- on Exception do
- begin
- Printer.Abort;
- Printer.EndDoc;
- Raise;
- end;
- end;
- end
- finally
- Screen.Cursor:=crDefault;
- end;
- end;
- end;
- procedure TMain.TrackBar1EndDrag(Sender, Target: TObject; X, Y: Integer);
- begin
- SpeedButton6.Click;
- end;
- procedure TMain.SpeedButton7Click(Sender: TObject);
- begin
- if Farmer.FD<>'' then
- begin
- if (Farmer.Code<>'') then
- begin
- SaveAll;
- end;
- end;
- end;
- procedure TMain.SpeedButton10Click(Sender: TObject);
- var
- FilePath,CurrentDate,D1,D2,CurrentTime,T1: String;
- m,n,t,TimePoint,IndexPosn: Integer;
- begin
- CurrentDate:=DateToStr(Date);
- IndexPosn:=LastDelimiter('/',CurrentDate);
- D1:=Copy(CurrentDate,IndexPosn+1,Length(CurrentDate)-IndexPosn);
- Delete(CurrentDate,IndexPosn,Length(CurrentDate)-IndexPosn+1);
- IndexPosn:=LastDelimiter('/',CurrentDate);
- D2:=Copy(CurrentDate,IndexPosn+1,Length(CurrentDate)-IndexPosn);
- Delete(CurrentDate,IndexPosn,Length(CurrentDate)-IndexPosn+1);
- CurrentTime:=TimeToStr(Time);
- IndexPosn:=LastDelimiter(':',CurrentTime);
- Delete(CurrentTime,IndexPosn,Length(CurrentTime)-IndexPosn+1);
- IndexPosn:=LastDelimiter(':',CurrentTime);
- T1:=Copy(CurrentTime,IndexPosn+1,Length(CurrentTime)-IndexPosn);
- Delete(CurrentTime,IndexPosn,Length(CurrentTime)-IndexPosn+1);
- PDFFileName:='';
- TodayDate:=CurrentDate+'-'+D2+'-'+D1;
- if (PDF.ShowModal=mrOK) or (RunPDF) then
- begin
- PdfBox1.PaperSizeName:='A4';
- if BatchMode then
- begin
- FilePath:=BatchModePath+'\Completed\'+Farmer.Code+'\'+Farmer.FD;
- end
- else
- begin
- FilePath:=ClientDirectory+'\'+Farmer.Code+'\'+Farmer.FD;
- end;
- if not DirectoryExists(FilePath) then ForceDirectories(FilePath);
- PDFFileName:=CurrentDate+'-'+D2+'-'+D1+' '
- +CurrentTime+'h'+T1+'m'+' '+Farmer.FD;
- if SetNameP.ShowModal=mrOK then
- PDFFileName:=SetNameP.Edit1.Text;
- if PDF.CheckBox5.Checked then
- begin
- PdfBox1.FileName:=FilePath+'\'+PDFFileName+' SR.pdf';
- PdfBox1.BeginDoc;
- if Beef then TimePoint:=1
- else
- begin
- if LeftStr(Instant.Edit66.Text,1)='-' then
- TimePoint:=Round(LactationLength/DaysInWeek)+7
- +StrToInt(Instant.Edit66.Text)
- else
- TimePoint:=StrToInt(Instant.Edit66.Text);
- end;
- SingleRunPDF(PdfBox1,@Feeding,PdfBox1.PageWidth,PdfBox1.PageHeight,
- TimePoint,LangID);
- PdfBox1.NewPage(True);
- ModelInput(PdfBox1,PdfBox1.PageWidth,PdfBox1.PageHeight);
- PdfBox1.EndDoc;
- end;
- if PDF.CheckBox12.Checked then
- begin
- m:=0;t:=0;
- for n:=1 to 16 do
- begin
- if FeedLength[n].Start<FeedLength[n].Finish then inc(m);
- end;
- if m>0 then
- for n:=1 to m do
- begin
- PdfBox1.FileName:=FilePath+'\'+PDFFileName+' PreMix '+IntToStr(n)+'.pdf'; //premix
- PdfBox1.BeginDoc;
- PreMixpdf(PdfBox1,PdfBox1.PageWidth,PdfBox1.PageHeight,n,t,PDF.Edit1.Text);
- PdfBox1.EndDoc;
- end;
- if PreMixParlourNo>1 then
- begin
- PdfBox1.FileName:=FilePath+'\'+PDFFileName+' PreMix Parlour.pdf';
- PdfBox1.BeginDoc;
- PreMixParlourpdf(PdfBox1,PdfBox1.PageWidth,PdfBox1.PageHeight,PDF.Edit1.Text);
- PdfBox1.EndDoc;
- end;
- if PreMixRoboticNo>1 then
- begin
- PdfBox1.FileName:=FilePath+'\'+PDFFileName+' PreMix Bin 2.pdf';
- PdfBox1.BeginDoc;
- PreMixRoboticpdf(PdfBox1,PdfBox1.PageWidth,PdfBox1.PageHeight,PDF.Edit1.Text);
- PdfBox1.EndDoc;
- end;
- end;
- if PDF.CheckBox7.Checked then
- begin
- PdfBox1.Orientation:=poLandscape;
- PdfBox1.FileName:=FilePath+'\'+PDFFileName+' Diet1.pdf';
- PdfBox1.BeginDoc;
- Diet1PDF(PdfBox1,@Feeding,PdfBox1.PageWidth,PdfBox1.PageHeight);
- PdfBox1.EndDoc;
- PdfBox1.Orientation:=poPortrait;
- end;
- end;
- end;
- procedure TMain.Save1Click(Sender: TObject);
- begin
- Main.SpeedButton7Click(Self);
- end;
- procedure TMain.SaveAs1Click(Sender: TObject);
- begin
- if IMustSave then
- Main.SpeedButton7Click(Self)
- else
- ShowMessage('You cannot Save until you have:'+#13#10+#13#10+'Run the model, or'
- +#13#10+'made further changes that require Saving');
- end;
- procedure TMain.Open1Click(Sender: TObject);
- begin
- Main.SpeedButton10Click(Self);
- end;
- procedure TMain.Optimize1Click(Sender: TObject);
- begin
- BatchMode:=True;
- Zaoying:=True;
- end;
- procedure TMain.pH6Help11Click(Sender: TObject);
- var
- CallHelp: Boolean;
- begin
- HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
- if kgToOther=1 then
- Application.HelpFile:=DatabaseDirectory+'\pH6+.chm'
- else
- Application.HelpFile:=DatabaseDirectory+'\pH6+.chm';
- HH(0,0,CallHelp);
- end;
- procedure TMain.Quit1Click(Sender: TObject);
- begin
- Application.Terminate;
- end;
- procedure TMain.SpeedButton4Click(Sender: TObject);
- begin
- FeedingStrategy.Show;
- end;
- procedure TMain.PrinterSetup1Click(Sender: TObject);
- begin
- PrinterSetupDialog1.Execute;
- end;
- procedure TMain.DeleteaFeed1Click(Sender: TObject);
- var
- t,text,text1: String;
- begin
- if DeleteFeed.ShowModal=mrOK then
- begin
- if LangID=2 then
- begin
- text:='Voulez vous supprimer';
- text1:='a partir de la base de donnees?';
- end
- else
- begin
- text:='Do you want to delete ';
- text1:=' from the database?';
- end;
- if MessageDlg(text+DeleteFeed.ComboBox2.Text+text1
- ,mtConfirmation,mbYesNoCancel,0)=mrYes then
- begin
- if DeleteFeed.ComboBox2.Text<>'' then
- begin
- FDTable1.TableName:='"Neil"."Client"';
- FDTable1.Open;
- FDTable1.First;
- while not FDTable1.Eof do
- begin
- if LangID=1 then t:= FDTable1.Fieldbyname('Forage').AsString
- else if LangID=2 then t:= FDTable1.Fieldbyname('ForageFr').AsString
- else if LangID=3 then t:= FDTable1.Fieldbyname('ForageUS').AsString
- else if LangID=4 then t:= FDTable1.Fieldbyname('ForageSp').AsString;
- if DeleteFeed.ComboBox1.Text=FDTable1.FieldByName('Type').AsString then
- if DeleteFeed.ComboBox2.Text=t then
- FDTable1.Delete;
- FDTable1.Next;
- end;
- FDTable1.Close;
- end;
- end;
- end;
- DeleteFeed.ComboBox1.Text:='';
- DeleteFeed.ComboBox2.Text:='';
- end;
- procedure TMain.DeleteaPreMix1Click(Sender: TObject);
- var
- t,text,text1: String;
- begin
- if DeletePreMix.ShowModal=mrOK then
- begin
- if LangID=2 then
- begin
- text:='Voulez vous supprimer';
- text1:='a partir de la base de donnees?';
- end
- else
- begin
- text:='Do you want to delete ';
- text1:=' from the database?';
- end;
- if MessageDlg(text+DeletePreMix.ComboBox1.Text+text1
- ,mtConfirmation,mbYesNoCancel,0)=mrYes then
- begin
- if DeletePreMix.ComboBox1.Text<>'' then
- begin
- FDTable1.TableName:='"Neil"."Blends"';
- FDTable1.Open;
- FDTable1.First;
- while not FDTable1.Eof do
- begin
- if LangID=1 then t:= FDTable1.Fieldbyname('NameEn').AsString
- else if LangID=2 then t:= FDTable1.Fieldbyname('NameFr').AsString
- else if LangID=3 then t:= FDTable1.Fieldbyname('NameUS').AsString
- else if LangID=4 then t:= FDTable1.Fieldbyname('NameSp').AsString;
- if DeletePreMix.ComboBox1.Text=t then
- FDTable1.Delete;
- FDTable1.Next;
- end;
- FDTable1.Close;
- end;
- end;
- end;
- DeletePreMix.ComboBox1.Text:='';
- end;
- procedure TMain.L1Click(Sender: TObject);
- const
- DivideBy=1.1;
- var
- LangIDOld: Integer;
- kgToOtherOld{,MJToOtherOld}: Single;
- begin
- with TLanguage.Create(nil) do
- try
- if Language.ShowModal=mrOK then
- begin
- LangIDOld:=LangID;
- kgToOtherOld:=kgToOther;
- if Language.RadioButton1.Checked then LangID:=1
- else if Language.RadioButton2.Checked then LangID:=2
- else if Language.RadioButton7.Checked then LangID:=3;
- if Language.RadioButton3.Checked then kgToOther:=1
- else kgToOther:=2.2046;
- if Language.RadioButton5.Checked then MJToOther:=1
- else MJToOther:=0.2389;
- if LangID<>LangIDOld then
- begin
- ReadLanguage;
- File1.Caption:=rTranslate.no2;
- Open1.Caption:=rTranslate.no10;
- SaveAs1.Caption:=rTranslate.no11;
- PrinterSetup1.Caption:=rTranslate.no16;
- Quit1.Caption:=rTranslate.no15;
- Maintenance1.Caption:=rTranslate.no3;
- Help1.Caption:=rTranslate.no5;
- SpeedButton1.Caption:=rTranslate.no8;
- SpeedButton4.Caption:=rTranslate.no7;
- btnRun.Caption:=rTranslate.no9+' pH6+ Dairy';
- SpeedButton10.Hint:=rTranslate.no10;
- SpeedButton7.Hint:=rTranslate.no11;
- SpeedButton5.Caption:=rTranslate.no12;
- SpeedButton6.Caption:=rTranslate.no13;
- SpeedButton8.Hint:=rTranslate.no14;
- SpeedButton3.Caption:=rTranslate.no15;
- end;
- if kgToOther>kgToOtherOld then
- begin
- Instant.Edit61.Text:=FloatToStrF(StrToFloat(Instant.Edit61.Text)*kgToOther,ffFixed,4,0);
- Instant.Edit63.Text:=FloatToStrF(StrToFloat(Instant.Edit63.Text)*kgToOther,ffFixed,3,0);
- end
- else if kgToOther<kgToOtherOld then
- begin
- Instant.Edit61.Text:=FloatToStrF(StrToFloat(Instant.Edit61.Text)/kgToOtherOld,ffFixed,3,0);
- Instant.Edit63.Text:=FloatToStrF(StrToFloat(Instant.Edit63.Text)/kgToOtherOld,ffFixed,2,0);
- end;
- FeedingStrategy.TMR_ConcLabels;
- Instant.TMRLabels;
- FeedsAdded.AddFoodLabelsFW;
- OutputF.OutformLabels;
- OutputF.DrawGraph1;
- if ActiveMDIChild=OutputF then
- begin
- Instant.Show;
- OutputF.Show;
- end;
- end;
- finally
- Free;
- end;
- end;
- procedure TMain.ReadFeedPrice;
- begin
- FDTable1.TableName:=' FeedPricesbyConsultant ';
- FDTable1.Open;
- if FDTable1.Locate('Consultant',Consultant,[]) then
- else FDTable1.Locate('Consultant',1,[]);
- with FDTable1 do
- begin
- FeedPrice[1]:=FieldByName('F1').AsInteger;
- FeedPrice[2]:=FieldByName('F2').AsInteger;
- FeedPrice[3]:=FieldByName('F3').AsInteger;
- FeedPrice[4]:=FieldByName('F4').AsInteger;
- FeedPrice[5]:=FieldByName('F5').AsInteger;
- FeedPrice[6]:=FieldByName('F6').AsInteger;
- FeedPrice[7]:=FieldByName('F7').AsInteger;
- FeedPrice[8]:=FieldByName('F8').AsInteger;
- FeedPrice[9]:=FieldByName('F9').AsInteger;
- FeedPrice[10]:=FieldByName('F10').AsInteger;
- FeedPrice[11]:=FieldByName('F11').AsInteger;
- FeedPrice[12]:=FieldByName('F12').AsInteger;
- FeedPrice[13]:=FieldByName('F13').AsInteger;
- FeedPrice[14]:=FieldByName('F14').AsInteger;
- FeedPrice[15]:=FieldByName('F15').AsInteger;
- FeedPrice[16]:=FieldByName('F16').AsInteger;
- FeedPrice[17]:=FieldByName('F17').AsInteger;
- FeedPrice[18]:=FieldByName('F18').AsInteger;
- FeedPrice[19]:=FieldByName('F19').AsInteger;
- FeedPrice[20]:=FieldByName('F20').AsInteger;
- FeedPrice[21]:=FieldByName('F21').AsInteger;
- FeedPrice[22]:=FieldByName('F22').AsInteger;
- FeedPrice[23]:=FieldByName('F23').AsInteger;
- FeedPrice[24]:=FieldByName('F24').AsInteger;
- FeedPrice[25]:=FieldByName('F25').AsInteger;
- FeedPrice[26]:=FieldByName('F26').AsInteger;
- FeedPrice[27]:=FieldByName('F27').AsInteger;
- FeedPrice[28]:=FieldByName('F28').AsInteger;
- FeedPrice[29]:=FieldByName('F29').AsInteger;
- FeedPrice[30]:=FieldByName('F30').AsInteger;
- FeedPrice[31]:=FieldByName('F31').AsInteger;
- FeedPrice[32]:=FieldByName('F32').AsInteger;
- FeedPrice[33]:=FieldByName('F33').AsInteger;
- FeedPrice[34]:=FieldByName('F34').AsInteger;
- FeedPrice[35]:=FieldByName('F35').AsInteger;
- FeedPrice[36]:=FieldByName('F36').AsInteger;
- FeedPrice[37]:=FieldByName('F37').AsInteger;
- FeedPrice[38]:=FieldByName('F38').AsInteger;
- FeedPrice[39]:=FieldByName('F39').AsInteger;
- FeedPrice[40]:=FieldByName('F40').AsInteger;
- FeedPrice[41]:=FieldByName('F41').AsInteger;
- FeedPrice[42]:=FieldByName('F42').AsInteger;
- FeedPrice[43]:=FieldByName('F43').AsInteger;
- FeedPrice[44]:=FieldByName('F44').AsInteger;
- FeedPrice[45]:=FieldByName('F45').AsInteger;
- FeedPrice[46]:=FieldByName('F46').AsInteger;
- FeedPrice[47]:=FieldByName('F47').AsInteger;
- FeedPrice[48]:=FieldByName('F48').AsInteger;
- FeedPrice[49]:=FieldByName('F49').AsInteger;
- FeedPrice[50]:=FieldByName('F50').AsInteger;
- FeedPrice[51]:=FieldByName('F51').AsInteger;
- FeedPrice[52]:=FieldByName('F52').AsInteger;
- FeedPrice[53]:=FieldByName('F53').AsInteger;
- FeedPrice[54]:=FieldByName('F54').AsInteger;
- FeedPrice[55]:=FieldByName('F55').AsInteger;
- FeedPrice[56]:=FieldByName('F56').AsInteger;
- FeedPrice[57]:=FieldByName('F57').AsInteger;
- FeedPrice[58]:=FieldByName('F58').AsInteger;
- FeedPrice[59]:=FieldByName('F59').AsInteger;
- FeedPrice[60]:=FieldByName('F60').AsInteger;
- FeedPrice[61]:=FieldByName('F61').AsInteger;
- FeedPrice[62]:=FieldByName('F62').AsInteger;
- FeedPrice[63]:=FieldByName('F63').AsInteger;
- FeedPrice[64]:=FieldByName('F64').AsInteger;
- FeedPrice[65]:=FieldByName('F65').AsInteger;
- FeedPrice[66]:=FieldByName('F66').AsInteger;
- FeedPrice[67]:=FieldByName('F67').AsInteger;
- FeedPrice[68]:=FieldByName('F68').AsInteger;
- FeedPrice[69]:=FieldByName('F69').AsInteger;
- FeedPrice[70]:=FieldByName('F70').AsInteger;
- FeedPrice[71]:=FieldByName('F71').AsInteger;
- FeedPrice[72]:=FieldByName('F72').AsInteger;
- FeedPrice[73]:=FieldByName('F73').AsInteger;
- FeedPrice[74]:=FieldByName('F74').AsInteger;
- FeedPrice[75]:=FieldByName('F75').AsInteger;
- FeedPrice[76]:=FieldByName('F76').AsInteger;
- FeedPrice[77]:=FieldByName('F77').AsInteger;
- FeedPrice[78]:=FieldByName('F78').AsInteger;
- FeedPrice[79]:=FieldByName('F79').AsInteger;
- FeedPrice[80]:=FieldByName('F80').AsInteger;
- FeedPrice[81]:=FieldByName('F81').AsInteger;
- FeedPrice[82]:=FieldByName('F82').AsInteger;
- FeedPrice[83]:=FieldByName('F83').AsInteger;
- FeedPrice[84]:=FieldByName('F84').AsInteger;
- FeedPrice[85]:=FieldByName('F85').AsInteger;
- FeedPrice[86]:=FieldByName('F86').AsInteger;
- FeedPrice[87]:=FieldByName('F87').AsInteger;
- FeedPrice[88]:=FieldByName('F88').AsInteger;
- FeedPrice[89]:=FieldByName('F89').AsInteger;
- FeedPrice[90]:=FieldByName('F90').AsInteger;
- FeedPrice[91]:=FieldByName('F91').AsInteger;
- FeedPrice[92]:=FieldByName('F92').AsInteger;
- FeedPrice[93]:=FieldByName('F93').AsInteger;
- FeedPrice[94]:=FieldByName('F94').AsInteger;
- FeedPrice[95]:=FieldByName('F95').AsInteger;
- FeedPrice[96]:=FieldByName('F96').AsInteger;
- FeedPrice[97]:=FieldByName('F97').AsInteger;
- FeedPrice[98]:=FieldByName('F98').AsInteger;
- FeedPrice[99]:=FieldByName('F99').AsInteger;
- FeedPrice[100]:=FieldByName('F100').AsInteger;
- FeedPrice[101]:=FieldByName('F101').AsInteger;
- FeedPrice[102]:=FieldByName('F102').AsInteger;
- FeedPrice[103]:=FieldByName('F103').AsInteger;
- FeedPrice[104]:=FieldByName('F104').AsInteger;
- FeedPrice[105]:=FieldByName('F105').AsInteger;
- FeedPrice[106]:=FieldByName('F106').AsInteger;
- FeedPrice[107]:=FieldByName('F107').AsInteger;
- FeedPrice[108]:=FieldByName('F108').AsInteger;
- FeedPrice[109]:=FieldByName('F109').AsInteger;
- FeedPrice[110]:=FieldByName('F110').AsInteger;
- FeedPrice[111]:=FieldByName('F111').AsInteger;
- FeedPrice[112]:=FieldByName('F112').AsInteger;
- FeedPrice[113]:=FieldByName('F113').AsInteger;
- FeedPrice[114]:=FieldByName('F114').AsInteger;
- FeedPrice[115]:=FieldByName('F115').AsInteger;
- FeedPrice[116]:=FieldByName('F116').AsInteger;
- FeedPrice[117]:=FieldByName('F117').AsInteger;
- FeedPrice[118]:=FieldByName('F118').AsInteger;
- FeedPrice[119]:=FieldByName('F119').AsInteger;
- FeedPrice[120]:=FieldByName('F120').AsInteger;
- FeedPrice[121]:=FieldByName('F121').AsInteger;
- FeedPrice[122]:=FieldByName('F122').AsInteger;
- FeedPrice[123]:=FieldByName('F123').AsInteger;
- FeedPrice[124]:=FieldByName('F124').AsInteger;
- FeedPrice[125]:=FieldByName('F125').AsInteger;
- FeedPrice[126]:=FieldByName('F126').AsInteger;
- FeedPrice[127]:=FieldByName('F127').AsInteger;
- FeedPrice[128]:=FieldByName('F128').AsInteger;
- FeedPrice[129]:=FieldByName('F129').AsInteger;
- FeedPrice[130]:=FieldByName('F130').AsInteger;
- FeedPrice[131]:=FieldByName('F131').AsInteger;
- FeedPrice[132]:=FieldByName('F132').AsInteger;
- FeedPrice[133]:=FieldByName('F133').AsInteger;
- FeedPrice[134]:=FieldByName('F134').AsInteger;
- FeedPrice[135]:=FieldByName('F135').AsInteger;
- FeedPrice[136]:=FieldByName('F136').AsInteger;
- FeedPrice[137]:=FieldByName('F137').AsInteger;
- FeedPrice[138]:=FieldByName('F138').AsInteger;
- FeedPrice[139]:=FieldByName('F139').AsInteger;
- FeedPrice[140]:=FieldByName('F140').AsInteger;
- FeedPrice[141]:=FieldByName('F141').AsInteger;
- FeedPrice[142]:=FieldByName('F142').AsInteger;
- FeedPrice[143]:=FieldByName('F143').AsInteger;
- FeedPrice[144]:=FieldByName('F144').AsInteger;
- FeedPrice[145]:=FieldByName('F145').AsInteger;
- FeedPrice[146]:=FieldByName('F146').AsInteger;
- FeedPrice[147]:=FieldByName('F147').AsInteger;
- FeedPrice[148]:=FieldByName('F148').AsInteger;
- FeedPrice[149]:=FieldByName('F149').AsInteger;
- FeedPrice[150]:=FieldByName('F150').AsInteger;
- FeedPrice[151]:=FieldByName('M1').AsInteger;
- FeedPrice[152]:=FieldByName('M2').AsInteger;
- FeedPrice[153]:=FieldByName('M3').AsInteger;
- FeedPrice[154]:=FieldByName('M4').AsInteger;
- FeedPrice[155]:=FieldByName('M5').AsInteger;
- FeedPrice[156]:=FieldByName('M6').AsInteger;
- FeedPrice[157]:=FieldByName('M7').AsInteger;
- FeedPrice[158]:=FieldByName('M8').AsInteger;
- FeedPrice[159]:=FieldByName('M9').AsInteger;
- FeedPrice[160]:=FieldByName('M10').AsInteger;
- FeedPrice[161]:=FieldByName('M11').AsInteger;
- FeedPrice[162]:=FieldByName('M12').AsInteger;
- FeedPrice[163]:=FieldByName('M13').AsInteger;
- FeedPrice[164]:=FieldByName('M14').AsInteger;
- FeedPrice[165]:=FieldByName('M15').AsInteger;
- FeedPrice[166]:=FieldByName('M16').AsInteger;
- FeedPrice[167]:=FieldByName('M17').AsInteger;
- FeedPrice[168]:=FieldByName('M18').AsInteger;
- FeedPrice[169]:=FieldByName('M19').AsInteger;
- FeedPrice[170]:=FieldByName('M20').AsInteger;
- FeedPrice[171]:=FieldByName('M21').AsInteger;
- FeedPrice[172]:=FieldByName('M22').AsInteger;
- FeedPrice[173]:=FieldByName('M23').AsInteger;
- FeedPrice[174]:=FieldByName('M24').AsInteger;
- FeedPrice[175]:=FieldByName('M25').AsInteger;
- FeedPrice[176]:=FieldByName('M26').AsInteger;
- FeedPrice[177]:=FieldByName('M27').AsInteger;
- FeedPrice[178]:=FieldByName('M28').AsInteger;
- FeedPrice[179]:=FieldByName('M29').AsInteger;
- FeedPrice[180]:=FieldByName('M30').AsInteger;
- FeedPrice[181]:=FieldByName('M31').AsInteger;
- FeedPrice[182]:=FieldByName('M32').AsInteger;
- FeedPrice[183]:=FieldByName('M33').AsInteger;
- FeedPrice[184]:=FieldByName('M34').AsInteger;
- FeedPrice[185]:=FieldByName('M35').AsInteger;
- FeedPrice[186]:=FieldByName('M36').AsInteger;
- FeedPrice[187]:=FieldByName('M37').AsInteger;
- FeedPrice[188]:=FieldByName('M38').AsInteger;
- FeedPrice[189]:=FieldByName('M39').AsInteger;
- FeedPrice[190]:=FieldByName('M40').AsInteger;
- FeedPrice[191]:=FieldByName('M41').AsInteger;
- FeedPrice[192]:=FieldByName('M42').AsInteger;
- FeedPrice[193]:=FieldByName('M43').AsInteger;
- FeedPrice[194]:=FieldByName('M44').AsInteger;
- FeedPrice[195]:=FieldByName('M45').AsInteger;
- FeedPrice[196]:=FieldByName('M46').AsInteger;
- FeedPrice[197]:=FieldByName('M47').AsInteger;
- FeedPrice[198]:=FieldByName('M48').AsInteger;
- FeedPrice[199]:=FieldByName('M49').AsInteger;
- FeedPrice[200]:=FieldByName('M50').AsInteger;
- FeedPrice[201]:=FieldByName('G1').AsInteger;
- FeedPrice[202]:=FieldByName('G2').AsInteger;
- FeedPrice[203]:=FieldByName('G3').AsInteger;
- FeedPrice[204]:=FieldByName('G4').AsInteger;
- FeedPrice[205]:=FieldByName('G5').AsInteger;
- FeedPrice[206]:=FieldByName('G6').AsInteger;
- FeedPrice[207]:=FieldByName('G7').AsInteger;
- FeedPrice[208]:=FieldByName('G8').AsInteger;
- FeedPrice[209]:=FieldByName('G9').AsInteger;
- FeedPrice[210]:=FieldByName('G10').AsInteger;
- FeedPrice[211]:=FieldByName('G11').AsInteger;
- FeedPrice[212]:=FieldByName('G12').AsInteger;
- FeedPrice[213]:=FieldByName('G13').AsInteger;
- FeedPrice[214]:=FieldByName('G14').AsInteger;
- FeedPrice[215]:=FieldByName('G15').AsInteger;
- FeedPrice[216]:=FieldByName('G16').AsInteger;
- FeedPrice[217]:=FieldByName('G17').AsInteger;
- FeedPrice[218]:=FieldByName('G18').AsInteger;
- FeedPrice[219]:=FieldByName('G19').AsInteger;
- FeedPrice[220]:=FieldByName('G20').AsInteger;
- FeedPrice[221]:=FieldByName('G21').AsInteger;
- FeedPrice[222]:=FieldByName('G22').AsInteger;
- FeedPrice[223]:=FieldByName('G23').AsInteger;
- FeedPrice[224]:=FieldByName('G24').AsInteger;
- FeedPrice[225]:=FieldByName('G25').AsInteger;
- FeedPrice[226]:=FieldByName('G26').AsInteger;
- FeedPrice[227]:=FieldByName('G27').AsInteger;
- FeedPrice[228]:=FieldByName('G28').AsInteger;
- FeedPrice[229]:=FieldByName('G29').AsInteger;
- FeedPrice[230]:=FieldByName('G30').AsInteger;
- FeedPrice[231]:=FieldByName('G31').AsInteger;
- FeedPrice[232]:=FieldByName('G32').AsInteger;
- FeedPrice[233]:=FieldByName('G33').AsInteger;
- FeedPrice[234]:=FieldByName('G34').AsInteger;
- FeedPrice[235]:=FieldByName('G35').AsInteger;
- FeedPrice[236]:=FieldByName('G36').AsInteger;
- FeedPrice[237]:=FieldByName('G37').AsInteger;
- FeedPrice[238]:=FieldByName('G38').AsInteger;
- FeedPrice[239]:=FieldByName('G39').AsInteger;
- FeedPrice[240]:=FieldByName('G40').AsInteger;
- FeedPrice[241]:=FieldByName('G41').AsInteger;
- FeedPrice[242]:=FieldByName('G42').AsInteger;
- FeedPrice[243]:=FieldByName('G43').AsInteger;
- FeedPrice[244]:=FieldByName('G44').AsInteger;
- FeedPrice[245]:=FieldByName('G45').AsInteger;
- FeedPrice[246]:=FieldByName('G46').AsInteger;
- FeedPrice[247]:=FieldByName('G47').AsInteger;
- FeedPrice[248]:=FieldByName('G48').AsInteger;
- FeedPrice[249]:=FieldByName('G49').AsInteger;
- FeedPrice[250]:=FieldByName('G50').AsInteger;
- end;
- FDTable1.Close;
- end;
- procedure TMain.ReadLanguage;
- begin
- FDTable1.TableName:=' EnFrUSSp ';
- FDTable1.Open;
- FDTable1.First;
- while not FDTable1.Eof do
- begin
- if LangID=FDTable1.Fieldbyname('Language').AsInteger then
- begin
- with FDTable1 do
- begin
- rTranslate.no1:= FieldByName('1').AsString;
- rTranslate.no2:= FieldByName('2').AsString;
- rTranslate.no3:= FieldByName('3').AsString;
- rTranslate.no4:= FieldByName('4').AsString;
- rTranslate.no5:= FieldByName('5').AsString;
- rTranslate.no6:= FieldByName('6').AsString;
- rTranslate.no7:= FieldByName('7').AsString;
- rTranslate.no8:= FieldByName('8').AsString;
- rTranslate.no9:= FieldByName('9').AsString;
- rTranslate.no10:= FieldByName('10').AsString;
- rTranslate.no11:= FieldByName('11').AsString;
- rTranslate.no12:= FieldByName('12').AsString;
- rTranslate.no13:= FieldByName('13').AsString;
- rTranslate.no14:= FieldByName('14').AsString;
- rTranslate.no15:= FieldByName('15').AsString;
- rTranslate.no16:= FieldByName('16').AsString;
- rTranslate.no17:= FieldByName('17').AsString;
- rTranslate.no18:= FieldByName('18').AsString;
- rTranslate.no19:= FieldByName('19').AsString;
- rTranslate.no20:= FieldByName('20').AsString;
- rTranslate.no21:= FieldByName('21').AsString;
- rTranslate.no22:= FieldByName('22').AsString;
- rTranslate.no23:= FieldByName('23').AsString;
- rTranslate.no24:= FieldByName('24').AsString;
- rTranslate.no25:= FieldByName('25').AsString;
- rTranslate.no26:= FieldByName('26').AsString;
- rTranslate.no27:= FieldByName('27').AsString;
- rTranslate.no28:= FieldByName('28').AsString;
- rTranslate.no29:= FieldByName('29').AsString;
- rTranslate.no30:= FieldByName('30').AsString;
- rTranslate.no31:= FieldByName('31').AsString;
- rTranslate.no32:= FieldByName('32').AsString;
- rTranslate.no33:= FieldByName('33').AsString;
- rTranslate.no34:= FieldByName('34').AsString;
- rTranslate.no35:= FieldByName('35').AsString;
- rTranslate.no36:= FieldByName('36').AsString;
- rTranslate.no37:= FieldByName('37').AsString;
- rTranslate.no38:= FieldByName('38').AsString;
- rTranslate.no39:= FieldByName('39').AsString;
- rTranslate.no40:= FieldByName('40').AsString;
- rTranslate.no41:= FieldByName('41').AsString;
- rTranslate.no42:= FieldByName('42').AsString;
- rTranslate.no43:= FieldByName('43').AsString;
- rTranslate.no44:= FieldByName('44').AsString;
- rTranslate.no45:= FieldByName('45').AsString;
- rTranslate.no46:= FieldByName('46').AsString;
- rTranslate.no47:= FieldByName('47').AsString;
- rTranslate.no48:= FieldByName('48').AsString;
- rTranslate.no49:= FieldByName('49').AsString;
- rTranslate.no50:= FieldByName('50').AsString;
- rTranslate.no51:= FieldByName('51').AsString;
- rTranslate.no52:= FieldByName('52').AsString;
- rTranslate.no53:= FieldByName('53').AsString;
- rTranslate.no54:= FieldByName('54').AsString;
- rTranslate.no55:= FieldByName('55').AsString;
- rTranslate.no56:= FieldByName('56').AsString;
- rTranslate.no57:= FieldByName('57').AsString;
- rTranslate.no58:= FieldByName('58').AsString;
- rTranslate.no59:= FieldByName('59').AsString;
- rTranslate.no60:= FieldByName('60').AsString;
- rTranslate.no61:= FieldByName('61').AsString;
- rTranslate.no62:= FieldByName('62').AsString;
- rTranslate.no63:= FieldByName('63').AsString;
- rTranslate.no64:= FieldByName('64').AsString;
- rTranslate.no65:= FieldByName('65').AsString;
- rTranslate.no66:= FieldByName('66').AsString;
- rTranslate.no67:= FieldByName('67').AsString;
- rTranslate.no68:= FieldByName('68').AsString;
- rTranslate.no69:= FieldByName('69').AsString;
- rTranslate.no70:= FieldByName('70').AsString;
- rTranslate.no71:= FieldByName('71').AsString;
- rTranslate.no72:= FieldByName('72').AsString;
- rTranslate.no73:= FieldByName('73').AsString;
- rTranslate.no74:= FieldByName('74').AsString;
- rTranslate.no75:= FieldByName('75').AsString;
- rTranslate.no76:= FieldByName('76').AsString;
- rTranslate.no77:= FieldByName('77').AsString;
- rTranslate.no78:= FieldByName('78').AsString;
- rTranslate.no79:= FieldByName('79').AsString;
- rTranslate.no80:= FieldByName('80').AsString;
- rTranslate.no81:= FieldByName('81').AsString;
- rTranslate.no82:= FieldByName('82').AsString;
- rTranslate.no83:= FieldByName('83').AsString;
- rTranslate.no84:= FieldByName('84').AsString;
- rTranslate.no85:= FieldByName('85').AsString;
- rTranslate.no86:= FieldByName('86').AsString;
- rTranslate.no87:= FieldByName('87').AsString;
- rTranslate.no88:= FieldByName('88').AsString;
- rTranslate.no89:= FieldByName('89').AsString;
- rTranslate.no90:= FieldByName('90').AsString;
- rTranslate.no91:= FieldByName('91').AsString;
- rTranslate.no92:= FieldByName('92').AsString;
- rTranslate.no93:= FieldByName('93').AsString;
- rTranslate.no94:= FieldByName('94').AsString;
- rTranslate.no95:= FieldByName('95').AsString;
- rTranslate.no96:= FieldByName('96').AsString;
- rTranslate.no97:= FieldByName('97').AsString;
- rTranslate.no98:= FieldByName('98').AsString;
- rTranslate.no99:= FieldByName('99').AsString;
- rTranslate.no100:= FieldByName('100').AsString;
- rTranslate.no101:= FieldByName('101').AsString;
- rTranslate.no102:= FieldByName('102').AsString;
- rTranslate.no103:= FieldByName('103').AsString;
- rTranslate.no104:= FieldByName('104').AsString;
- rTranslate.no105:= FieldByName('105').AsString;
- rTranslate.no106:= FieldByName('106').AsString;
- rTranslate.no107:= FieldByName('107').AsString;
- rTranslate.no108:= FieldByName('108').AsString;
- rTranslate.no109:= FieldByName('109').AsString;
- rTranslate.no110:= FieldByName('110').AsString;
- rTranslate.no111:= FieldByName('111').AsString;
- rTranslate.no112:= FieldByName('112').AsString;
- rTranslate.no113:= FieldByName('113').AsString;
- rTranslate.no114:= FieldByName('114').AsString;
- rTranslate.no115:= FieldByName('115').AsString;
- rTranslate.no116:= FieldByName('116').AsString;
- rTranslate.no117:= FieldByName('117').AsString;
- rTranslate.no118:= FieldByName('118').AsString;
- rTranslate.no119:= FieldByName('119').AsString;
- rTranslate.no120:= FieldByName('120').AsString;
- rTranslate.no121:= FieldByName('121').AsString;
- rTranslate.no122:= FieldByName('122').AsString;
- rTranslate.no123:= FieldByName('123').AsString;
- rTranslate.no124:= FieldByName('124').AsString;
- rTranslate.no125:= FieldByName('125').AsString;
- rTranslate.no126:= FieldByName('126').AsString;
- rTranslate.no127:= FieldByName('127').AsString;
- rTranslate.no128:= FieldByName('128').AsString;
- rTranslate.no129:= FieldByName('129').AsString;
- rTranslate.no130:= FieldByName('130').AsString;
- rTranslate.no131:= FieldByName('131').AsString;
- rTranslate.no132:= FieldByName('132').AsString;
- rTranslate.no133:= FieldByName('133').AsString;
- rTranslate.no134:= FieldByName('134').AsString;
- rTranslate.no135:= FieldByName('135').AsString;
- rTranslate.no136:= FieldByName('136').AsString;
- rTranslate.no137:= FieldByName('137').AsString;
- rTranslate.no138:= FieldByName('138').AsString;
- rTranslate.no139:= FieldByName('139').AsString;
- rTranslate.no140:= FieldByName('140').AsString;
- rTranslate.no141:= FieldByName('141').AsString;
- rTranslate.no142:= FieldByName('142').AsString;
- rTranslate.no143:= FieldByName('143').AsString;
- rTranslate.no144:= FieldByName('144').AsString;
- rTranslate.no145:= FieldByName('145').AsString;
- rTranslate.no146:= FieldByName('146').AsString;
- rTranslate.no147:= FieldByName('147').AsString;
- rTranslate.no148:= FieldByName('148').AsString;
- rTranslate.no149:= FieldByName('149').AsString;
- rTranslate.no150:= FieldByName('150').AsString;
- rTranslate.no151:= FieldByName('151').AsString;
- rTranslate.no152:= FieldByName('152').AsString;
- rTranslate.no153:= FieldByName('153').AsString;
- rTranslate.no154:= FieldByName('154').AsString;
- rTranslate.no155:= FieldByName('155').AsString;
- rTranslate.no156:= FieldByName('156').AsString;
- rTranslate.no157:= FieldByName('157').AsString;
- rTranslate.no158:= FieldByName('158').AsString;
- rTranslate.no159:= FieldByName('159').AsString;
- rTranslate.no160:= FieldByName('160').AsString;
- rTranslate.no161:= FieldByName('161').AsString;
- rTranslate.no162:= FieldByName('162').AsString;
- rTranslate.no163:= FieldByName('163').AsString;
- rTranslate.no164:= FieldByName('164').AsString;
- rTranslate.no165:= FieldByName('165').AsString;
- rTranslate.no166:= FieldByName('166').AsString;
- rTranslate.no167:= FieldByName('167').AsString;
- rTranslate.no168:= FieldByName('168').AsString;
- rTranslate.no169:= FieldByName('169').AsString;
- rTranslate.no170:= FieldByName('170').AsString;
- rTranslate.no171:= FieldByName('171').AsString;
- rTranslate.no172:= FieldByName('172').AsString;
- rTranslate.no173:= FieldByName('173').AsString;
- rTranslate.no174:= FieldByName('174').AsString;
- rTranslate.no175:= FieldByName('175').AsString;
- rTranslate.no176:= FieldByName('176').AsString;
- rTranslate.no177:= FieldByName('177').AsString;
- rTranslate.no178:= FieldByName('178').AsString;
- rTranslate.no179:= FieldByName('179').AsString;
- rTranslate.no180:= FieldByName('180').AsString;
- rTranslate.no181:= FieldByName('181').AsString;
- rTranslate.no182:= FieldByName('182').AsString;
- rTranslate.no183:= FieldByName('183').AsString;
- rTranslate.no185:= FieldByName('185').AsString;
- rTranslate.no188:= FieldByName('188').AsString;
- rTranslate.no189:= FieldByName('189').AsString;
- rTranslate.no190:= FieldByName('190').AsString;
- rTranslate.no191:= FieldByName('191').AsString;
- rTranslate.no192:= FieldByName('192').AsString;
- rTranslate.no193:= FieldByName('193').AsString;
- rTranslate.no194:= FieldByName('194').AsString;
- rTranslate.no195:= FieldByName('195').AsString;
- rTranslate.no196:= FieldByName('196').AsString;
- rTranslate.no197:= FieldByName('197').AsString;
- rTranslate.no198:= FieldByName('198').AsString;
- rTranslate.no199:= FieldByName('199').AsString;
- rTranslate.no200:= FieldByName('200').AsString;
- rTranslate.no201:= FieldByName('201').AsString;
- rTranslate.no202:= FieldByName('202').AsString;
- rTranslate.no203:= FieldByName('203').AsString;
- rTranslate.no204:= FieldByName('204').AsString;
- rTranslate.no205:= FieldByName('205').AsString;
- rTranslate.no206:= FieldByName('206').AsString;
- rTranslate.no207:= FieldByName('207').AsString;
- rTranslate.no208:= FieldByName('208').AsString;
- rTranslate.no209:= FieldByName('209').AsString;
- rTranslate.no210:= FieldByName('210').AsString;
- rTranslate.no211:= FieldByName('211').AsString;
- rTranslate.no212:= FieldByName('212').AsString;
- rTranslate.no213:= FieldByName('213').AsString;
- rTranslate.no214:= FieldByName('214').AsString;
- rTranslate.no215:= FieldByName('215').AsString;
- rTranslate.no216:= FieldByName('216').AsString;
- rTranslate.no217:= FieldByName('217').AsString;
- rTranslate.no218:= FieldByName('218').AsString;
- rTranslate.no219:= FieldByName('219').AsString;
- rTranslate.no220:= FieldByName('220').AsString;
- rTranslate.no221:= FieldByName('221').AsString;
- rTranslate.no222:= FieldByName('222').AsString;
- rTranslate.no223:= FieldByName('223').AsString;
- rTranslate.no224:= FieldByName('224').AsString;
- rTranslate.no225:= FieldByName('225').AsString;
- rTranslate.no226:= FieldByName('226').AsString;
- rTranslate.no227:= FieldByName('227').AsString;
- rTranslate.no228:= FieldByName('228').AsString;
- rTranslate.no229:= FieldByName('229').AsString;
- rTranslate.no230:= FieldByName('230').AsString;
- rTranslate.no231:= FieldByName('231').AsString;
- rTranslate.no232:= FieldByName('232').AsString;
- rTranslate.no233:= FieldByName('233').AsString;
- rTranslate.no234:= FieldByName('234').AsString;
- rTranslate.no235:= FieldByName('235').AsString;
- rTranslate.no236:= FieldByName('236').AsString;
- rTranslate.no237:= FieldByName('237').AsString;
- rTranslate.no238:= FieldByName('238').AsString;
- rTranslate.no239:= FieldByName('239').AsString;
- rTranslate.no240:= FieldByName('240').AsString;
- rTranslate.no241:= FieldByName('241').AsString;
- rTranslate.no242:= FieldByName('242').AsString;
- rTranslate.no243:= FieldByName('243').AsString;
- rTranslate.no244:= FieldByName('244').AsString;
- rTranslate.no245:= FieldByName('245').AsString;
- rTranslate.no246:= FieldByName('246').AsString;
- rTranslate.no247:= FieldByName('247').AsString;
- rTranslate.no248:= FieldByName('248').AsString;
- rTranslate.no249:= FieldByName('249').AsString;
- rTranslate.no250:= FieldByName('250').AsString;
- rTranslate.no251:= FieldByName('251').AsString;
- rTranslate.no252:= FieldByName('252').AsString;
- rTranslate.no253:= FieldByName('253').AsString;
- rTranslate.no254:= FieldByName('254').AsString;
- rTranslate.no255:= FieldByName('255').AsString;
- rTranslate.no256:= FieldByName('256').AsString;
- rTranslate.no257:= FieldByName('257').AsString;
- rTranslate.no258:= FieldByName('258').AsString;
- rTranslate.no259:= FieldByName('259').AsString;
- rTranslate.no260:= FieldByName('260').AsString;
- rTranslate.no261:= FieldByName('261').AsString;
- rTranslate.no262:= FieldByName('262').AsString;
- rTranslate.no263:= FieldByName('263').AsString;
- rTranslate.no264:= FieldByName('264').AsString;
- rTranslate.no265:= FieldByName('265').AsString;
- rTranslate.no266:= FieldByName('266').AsString;
- rTranslate.no267:= FieldByName('267').AsString;
- rTranslate.no268:= FieldByName('268').AsString;
- rTranslate.no269:= FieldByName('269').AsString;
- rTranslate.no270:= FieldByName('270').AsString;
- rTranslate.no271:= FieldByName('271').AsString;
- rTranslate.no272:= FieldByName('272').AsString;
- rTranslate.no273:= FieldByName('273').AsString;
- rTranslate.no274:= FieldByName('274').AsString;
- rTranslate.no275:= FieldByName('275').AsString;
- rTranslate.no276:= FieldByName('276').AsString;
- rTranslate.no277:= FieldByName('277').AsString;
- rTranslate.no278:= FieldByName('278').AsString;
- rTranslate.no279:= FieldByName('279').AsString;
- rTranslate.no280:= FieldByName('280').AsString;
- rTranslate.no281:= FieldByName('281').AsString;
- rTranslate.no282:= FieldByName('282').AsString;
- rTranslate.no283:= FieldByName('283').AsString;
- rTranslate.no284:= FieldByName('284').AsString;
- rTranslate.no285:= FieldByName('285').AsString;
- rTranslate.no286:= FieldByName('286').AsString;
- rTranslate.no287:= FieldByName('287').AsString;
- rTranslate.no288:= FieldByName('288').AsString;
- rTranslate.no289:= FieldByName('289').AsString;
- rTranslate.no290:= FieldByName('290').AsString;
- rTranslate.no291:= FieldByName('291').AsString;
- end;
- end;
- FDTable1.Next
- end;
- FDTable1.Close;
- end;
- procedure TMain.RestrictDB1Click(Sender: TObject);
- begin
- {if (SavingResults) or (DBNotConnected=1) then
- begin
- ShowMessage('You cannot alter the period in which you select data as you have results to save.'
- +#10#13+'Close pH6+ Dairy down, open pH6+ Dairy and then change the period of selecting data.');
- end
- else }if not DBConnected then
- begin
- ShowMessage('No internet connection!');
- end
- else if RestrictDBto.ShowModal=mrOK then
- begin
- if (SavingResults) or (DBNotConnected=1) then
- begin
- SavingData:=True;
- SpeedButton3Click(Self);
- SavingResults:=False; SavingData:=False;
- end;
- UpdateYesNo:=True;
- SetUpDBFormulation;
- SetUpDBResults;
- SetUpDBClientFeeds;
- SetUpDBFarmer;
- SetUpDBPreMixes;
- Welcome.LoadFarmersData;
- OldFormulationHigh:=FormulationHigh;
- OldResultsHigh:=ResultsHigh;
- OldClientFeedsHigh:=ClientFeedsHigh;
- OldFarmerHigh:=FarmerHigh;
- OldPreMixFeedsHigh:=PreMixFeedsHigh;
- UpdateYesNo:=False;
- end;
- end;
- procedure TMain.ViewProtein1Click(Sender: TObject);
- begin
- if not Assigned(ProteinUsed) then
- ProteinUsed:=TProteinUsed.Create(Self);
- ProteinUsed.Show;
- end;
- procedure TMain.WhatIf2Click(Sender: TObject);
- begin
- if not Assigned(WhatIfForm) then
- Application.CreateForm(TWhatIfForm, WhatIfForm);
- if WhatIfBoolean then
- begin
- WhatIfBoolean:=False;
- WhatIf2.Checked:=False;
- WhatIfForm.Close;
- WhatIfForm.WhatIfOutputs(3);
- WhatIfForm.WhatIfOutputs(2);
- WhatIfForm.WhatIfOutputs(1);
- end
- else
- begin
- WhatIfBoolean:=True;
- WhatIf2.Checked:=True;
- WhatIfNumber:=1;
- WhatIfForm.CheckBox2.Checked:=False;
- WhatIfForm.CheckBox3.Checked:=False;
- end;
- end;
- procedure TMain.ViewEnergy1Click(Sender: TObject);
- begin
- EnergyUsed:=TEnergyUsed.Create(Self);
- EnergyUsed.Show;
- end;
- procedure TMain.ViewMGP1Click(Sender: TObject);
- var
- crDefault: TCursor;
- begin
- crDefault:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- MGPUsed := TMGPUsed.Create(self);
- try
- MGPUsed.Show;
- finally
- // MGPUsed.Free;
- Screen.Cursor:=crDefault;
- end;//MGPUsed.Show;
- end;
- procedure TMain.NewFarmer1Click(Sender: TObject);
- begin
- Welcome.Show;
- end;
- procedure TMain.FormDestroy(Sender: TObject);
- begin
- WriteIniFile;
- end;
- procedure TMain.WriteIniFile;
- var
- IniFile : TIniFile;
- begin
- if not Administrator then
- begin
- if DBConnected and RunpH6 then
- DBNotConnected:=0
- else
- DBNotConnected:=1;
- EnDeCryptFile(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');
- IniFile := TIniFile.Create(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');//ChangeFileExt(Application.ExeName,'.ini'));
- with IniFile do
- begin
- WriteInteger('Language','LangID',LangID);
- WriteFloat('Language','kgToOther',kgToOther);
- WriteFloat('Language','MJToOther',MJToOther);
- WriteBool('Maintenance','Batch',BatchMode);
- WriteBool('Maintenance','ShowAFFile',ShowAFFile);
- WriteInteger('Maintenance','MasterFeedsHigh',MasterFeedsHigh);
- WriteInteger('Maintenance','ClientFeedsHigh',ClientFeedsHigh);
- WriteInteger('Maintenance','PreMixFeedsHigh',PreMixFeedsHigh);
- WriteInteger('Maintenance','FormulationHigh',FormulationHigh);
- WriteInteger('Maintenance','FarmerHigh',FarmerHigh);
- WriteInteger('Maintenance','ResultsHigh',ResultsHigh);
- WriteBool('Maintenance','DBResultsChange',DBResultsChange);
- WriteInteger('Maintenance','DBNotConnected',DBNotConnected);
- WriteFloat('Maintenance','DateLastUsed',DateLastUsed);
- WriteString('Maintenance','User',User);
- WriteString('Maintenance','Password',Password);
- WriteString('Maintenance','UserName',User_Name);
- WriteString('Maintenance','PW',PW);
- WriteBool('Maintenance','ProgramCrashed',False);
- WriteInteger('Maintenance','OldClientFeedsHigh',OldClientFeedsHigh);
- WriteInteger('Maintenance','OldMasterFeedsHigh',OldMasterFeedsHigh);
- WriteInteger('Maintenance','OldPreMixFeedsHigh',OldPreMixFeedsHigh);
- WriteInteger('Maintenance','OldFarmerHigh',OldFarmerHigh);
- WriteInteger('Maintenance','OldFormulationHigh',OldFormulationHigh);
- WriteInteger('Maintenance','OldResultsHigh',OldResultsHigh);
- WriteFloat('Maintenance','ForagefNDFfactor',ForagefNDFfactor);
- WriteInteger('Maintenance','MineralsHigh',MineralsHigh);
- WriteString('Maintenance','DateStarted',DateStarted);
- WriteString('Maintenance','DateChosenToRestrictDB',DateChosenToRestrictDB);
- WriteInteger('Maintenance','DifferentHDNo',DifferentHDNo);
- WriteInteger('Maintenance','HighFormulationPos',HighFormulationPos);
- WriteInteger('Maintenance','HighFormulationNeg',HighFormulationNeg);
- WriteInteger('Maintenance','HighResultsPos',HighResultsPos);
- WriteInteger('Maintenance','HighResultsNeg',HighResultsNeg);
- WriteInteger('Maintenance','HighClientNeg',HighClientNeg);
- WriteString('Maintenance','DateChosenToRestrictDBPM',DateChosenToRestrictDBPM);
- WriteInteger('Maintenance','HighPreMixesPos',HighPreMixesPos);
- WriteInteger('Maintenance','HighPreMixesNeg',HighPreMixesNeg);
- WriteInteger('Maintenance','YearChosenToRestrictDBFarmer',YearChosenToRestrictDBFarmer);
- WriteFloat('Maintenance','AccessServer',AccessServer);
- WriteString('Maintenance','WCCountry',WCCountry);
- WriteString('Maintenance','WCCurrency',WCCurrency);
- WriteString('Maintenance','WCAbbrev',WCAbbrev);
- WriteString('Maintenance','WCISO',WCISO);
- WriteString('Maintenance','WCCent',WCCent);
- WriteInteger('Maintenance','WCFraction',WCFraction);
- end;
- IniFile.Free;
- EnDeCryptFile(DatabaseDirectory+'\'+BeefOrCow+' CD.ini');
- if FileExists(DatabaseDirectory+'\'+BeefOrCow+' CD.ini') then
- CopyFile(PWideChar(DatabaseDirectory+'\'+BeefOrCow+' CD.ini'),PWideChar(GetDocuments+'\reg_pH6+.ph6'),False);
- end;
- end;
- procedure TMain.FromDatabase1Click(Sender: TObject);
- var
- crDefault: TCursor;
- TempDBNotConnected: Integer;
- begin
- crDefault:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- if FDConnection1.Ping then
- begin
- TempDBNotConnected:=DBNotConnected;
- DBNotConnected:=0;
- UpdateYesNo:=True;
- FDConnection1.Connected:=True;
- SetUpDBMasterFeeds;
- SetUpDBClientFeeds;
- SetUpDBPreMixes;
- SetUpDBFarmer;
- SetUpDBFormulation;
- SetUpDBResults;
- SetUpDBFeedLabels;
- UpdateYesNo:=False;
- FDConnection1.Connected:=False;
- Welcome.LoadFarmersData;
- Instant.LoadMainData;
- FeedingStrategy.LoadComboData;
- FeedingStrategy.LoadLiquidFeeds;
- DBNotConnected:=TempDBNotConnected;
- end
- else
- ShowMessage('No internet connection!');
- Screen.Cursor:=crDefault;
- end;
- procedure TMain.ModelOptions1Click(Sender: TObject);
- begin
- with TOptions.Create(nil) do
- try
- if Options.ShowModal=mrOK then
- begin
- if Options.CheckBox3.Checked=True then version1_01_16:=True
- else version1_01_16:=False;
- { if Options.CheckBox1.Checked=True then LagTimeParlour:=True
- else LagTimeParlour:=False;
- if Options.CheckBox2.Checked=True then
- begin
- ChopLength:=True;
- Instant.ComboBox1Change(Instant);
- end
- else
- begin
- ChopLength:=False;
- Instant.ComboBox1Change(Instant);
- end;
- for FeedNo:=0 to rFeedInfo.iNoFeeds-1 do
- begin
- if rFeedInfo.ACHOintoWSCsNDF then
- rFeedInfo.TMRFeed[FeedNo].C1:=rFeedInfo.TMRFeed[FeedNo].ACHO
- -rFeedInfo.TMRFeed[FeedNo].QuickStarch-rFeedInfo.TMRFeed[FeedNo].C1sNDF//WSC
- else
- rFeedInfo.TMRFeed[FeedNo].C1:=rFeedInfo.TMRFeed[FeedNo].ACHO-rFeedInfo.TMRFeed[FeedNo].QuickStarch;//WSC
- if rFeedInfo.TMRFeed[FeedNo].C1<0 then rFeedInfo.TMRFeed[FeedNo].C1:=0;
- end;
- if rFeedInfo.iParlour>0 then
- for FeedNo:=0 to rFeedInfo.iParlour-1 do
- begin
- if rFeedInfo.ACHOintoWSCsNDF then
- rFeedInfo.ParlourFeed[FeedNo].C1:=rFeedInfo.ParlourFeed[FeedNo].ACHO
- -rFeedInfo.ParlourFeed[FeedNo].QuickStarch
- -rFeedInfo.ParlourFeed[FeedNo].C1sNDF//WSC
- else
- rFeedInfo.ParlourFeed[FeedNo].C1:=rFeedInfo.ParlourFeed[FeedNo].ACHO
- -rFeedInfo.ParlourFeed[FeedNo].QuickStarch;//WSC
- if rFeedInfo.ParlourFeed[FeedNo].C1<0 then rFeedInfo.ParlourFeed[FeedNo].C1:=0;
- end;
- if rFeedInfo.iGrazing>0 then
- begin
- if rFeedInfo.ACHOintoWSCsNDF then
- rFeedInfo.GrazingFeed.C1:=rFeedInfo.GrazingFeed.ACHO
- -rFeedInfo.GrazingFeed.QuickStarch-rFeedInfo.GrazingFeed.C1sNDF//WSC
- else
- rFeedInfo.GrazingFeed.C1:=rFeedInfo.GrazingFeed.ACHO-rFeedInfo.GrazingFeed.QuickStarch;//WSC
- if rFeedInfo.GrazingFeed.C1<0 then rFeedInfo.GrazingFeed.C1:=0;
- end;
- if Options.CheckBox2.Checked=True then rFeedInfo.DynamicWater:=True
- else rFeedInfo.DynamicWater:=False;
- if Options.CheckBox3.Checked=True then rFeedInfo.LagTime:=True
- else rFeedInfo.LagTime:=False;
- if Options.CheckBox4.Checked=True then
- begin
- rFeedInfo.Long:=True;
- end
- else rFeedInfo.Long:=False;
- if Options.CheckBox5.Checked=True then MicrobesAcidosis:=True
- else MicrobesAcidosis:=False;
- if Options.CheckBox6.Checked=True then rFeedInfo.LPBRwithRumination:=True
- else rFeedInfo.LPBRwithRumination:=False;
- if Options.Checkbox7.Checked=True then rFeedInfo.Pectins:=True
- else rFeedInfo.Pectins:=False; }
- end;
- finally
- Free;
- end;
- end;
- procedure TMain.ModifyRates1Click(Sender: TObject);
- begin
- if not Assigned(ChangeRates) then
- TChangeRates.Create(Self);
- ChangeRates.Show;
- end;
- procedure TMain.ReadFileMinerals;
- var
- SupS: TextFile;
- NewLine: String;
- IndexPosn1,m,p: Integer;
- ex: Boolean;
- begin
- ex:=True;
- CopyFile(PWideChar(ExtractFilePath(Paramstr(0))+'Minerals.mrq'),
- PWideChar(DatabaseDirectory+'min.nsj'),ex);
- AssignFile(SupS,DatabaseDirectory+'min.nsj');
- Reset(SupS);
- while not EOF(SupS) do
- begin
- ReadLn(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.NaReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- ReadLn(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.KReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.CaReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.MgReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.ClReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 14 do
- begin
- p:=15-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.PReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.SReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.CuReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.SeReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.ZnReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.MnReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- Readln(SupS,NewLine);//header
- ReadLn(Sups,Newline);
- IndexPosn1:=LastDelimiter(',',NewLine);
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- for m:=1 to 4 do
- begin
- p:=5-m;
- IndexPosn1:=LastDelimiter(',',NewLine);
- Minerals.MoReq[p]:=StrToFloat(Copy(NewLine,IndexPosn1+1,Length(NewLine)-IndexPosn1));
- Delete(NewLine,IndexPosn1,Length(NewLine)-IndexPosn1+1);
- end;
- end;
- CloseFile(SupS);
- DeleteFile(DatabaseDirectory+'min.nsj');
- end;
- function TMain.HH(Command: Word; Data: Integer;
- var CallHelp: Boolean): Boolean;
- begin
- if (Command = 0) and (Data = 0) then
- HtmlHelp(Application.Handle,
- PWideChar(Application.HelpFile),
- HH_DISPLAY_TOC, 0);
- {if (Command = 1) then
- HtmlHelp(Application.Handle,
- PChar(Format('%s::/H%5.5d.htm',
- [Application.HelpFile, Data])),
- HH_DISPLAY_TOPIC, 0);}
- CallHelp := False;
- end;
- procedure TMain.ForagesfromDatabase1Click(Sender: TObject);
- var
- crDefault: TCursor;
- m,n,TempDBNotConnected: Integer;
- OldCombo: String;
- begin
- crDefault:=Screen.Cursor;
- Screen.Cursor:=crHourGlass;
- if FDConnection1.Ping then
- begin
- UpdateYesNo:=True;
- if FileExists(DatabaseDirectory+'\OldDBClientFeeds.ph6') then
- DeleteFile(DatabaseDirectory+'\OldDBClientFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),PWideChar(DatabaseDirectory+'\OldDBClientFeeds.ph6'),False);
- try
- begin
- FDConnection1.Connected:=True;
- if DBNotConnected=1 then
- begin
- AreAmendClient;
- FDTable1.TableName:=' Client ';
- FDTable1.Open;
- for n := 0 to Length(AmendClient)-1 do
- begin
- if AmendClient[n].New=-1 then //delete
- begin
- if FDTable1.Locate('Consultant;ID',VarArrayOf([Consultant,AmendClient[n].ID]),[]) then
- begin
- FDTable1.Delete;
- end;
- end
- else if AmendClient[n].New=1 then //insert
- begin
- for m := 0 to Length(DBClientFeeds)-1 do
- if AmendClient[n].ID=DBClientFeeds[m].ID then
- begin
- InsertClient(DBClientFeeds[m],1);
- DBClientFeeds[m].New:=0;
- end;
- end
- else if AmendClient[n].New=-2 then //append new cost or new DM
- begin
- for m := 0 to Length(DBClientFeeds)-1 do
- if AmendClient[n].ID=DBClientFeeds[m].ID then
- begin
- InsertClient(DBClientFeeds[m],-2);
- DBClientFeeds[m].New:=0;
- AmendClient[n].New:=0;
- end;
- end;
- end;
- FDTable1.Close;
- end;
- end;
- except
- begin
- if FileExists(DatabaseDirectory+'\DBClientFeeds.ph6') then
- DeleteFile(DatabaseDirectory+'\DBClientFeeds.ph6');
- CopyFile(PWideChar(DatabaseDirectory+'\OldDBClientFeeds.ph6'),PWideChar(DatabaseDirectory+'\DBClientFeeds.ph6'),False);
- end;
- end;
- TempDBNotConnected:=DBNotConnected;
- DBNotConnected:=0;
- SetUpDBClientFeeds;
- DBNotConnected:=TempDBNotConnected;
- UpdateYesNo:=False;
- FDConnection1.Connected:=False;
- // Instant.LoadMainData;
- FeedingStrategy.LoadLiquidFeeds;
- if Instant.ComboBox5.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox1.Text;
- Instant.ComboBoxFill(Instant.ComboBox1,Instant.ComboBox5);
- Instant.ComboBox1.Text:=OldCombo;
- end;
- if Instant.ComboBox6.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox2.Text;
- Instant.ComboBoxFill(Instant.ComboBox2,Instant.ComboBox6);
- Instant.ComboBox2.Text:=OldCombo;
- end;
- if Instant.ComboBox7.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox3.Text;
- Instant.ComboBoxFill(Instant.ComboBox3,Instant.ComboBox7);
- Instant.ComboBox3.Text:=OldCombo;
- end;
- if Instant.ComboBox8.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox4.Text;
- Instant.ComboBoxFill(Instant.ComboBox4,Instant.ComboBox8);
- Instant.ComboBox4.Text:=OldCombo;
- end;
- if Instant.ComboBox9.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox10.Text;
- Instant.ComboBoxFill(Instant.ComboBox10,Instant.ComboBox9);
- Instant.ComboBox10.Text:=OldCombo;
- end;
- if Instant.ComboBox11.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox12.Text;
- Instant.ComboBoxFill(Instant.ComboBox12,Instant.ComboBox11);
- Instant.ComboBox12.Text:=OldCombo;
- end;
- if Instant.ComboBox13.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox14.Text;
- Instant.ComboBoxFill(Instant.ComboBox14,Instant.ComboBox13);
- Instant.ComboBox14.Text:=OldCombo;
- end;
- if Instant.ComboBox15.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox16.Text;
- Instant.ComboBoxFill(Instant.ComboBox16,Instant.ComboBox15);
- Instant.ComboBox16.Text:=OldCombo;
- end;
- if Instant.ComboBox17.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox18.Text;
- Instant.ComboBoxFill(Instant.ComboBox18,Instant.ComboBox17);
- Instant.ComboBox18.Text:=OldCombo;
- end;
- if Instant.ComboBox19.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox20.Text;
- Instant.ComboBoxFill(Instant.ComboBox20,Instant.ComboBox19);
- Instant.ComboBox20.Text:=OldCombo;
- end;
- if Instant.ComboBox21.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox22.Text;
- Instant.ComboBoxFill(Instant.ComboBox22,Instant.ComboBox21);
- Instant.ComboBox22.Text:=OldCombo;
- end;
- if Instant.ComboBox23.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox24.Text;
- Instant.ComboBoxFill(Instant.ComboBox24,Instant.ComboBox23);
- Instant.ComboBox24.Text:=OldCombo;
- end;
- if Instant.ComboBox25.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox26.Text;
- Instant.ComboBoxFill(Instant.ComboBox26,Instant.ComboBox25);
- Instant.ComboBox26.Text:=OldCombo;
- end;
- if Instant.ComboBox27.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox28.Text;
- Instant.ComboBoxFill(Instant.ComboBox28,Instant.ComboBox27);
- Instant.ComboBox28.Text:=OldCombo;
- end;
- if Instant.ComboBox29.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox30.Text;
- Instant.ComboBoxFill(Instant.ComboBox30,Instant.ComboBox29);
- Instant.ComboBox30.Text:=OldCombo;
- end;
- if Instant.ComboBox31.Text=Welcome.ComboBox1.Text then
- begin
- OldCombo:=Instant.ComboBox32.Text;
- Instant.ComboBoxFill(Instant.ComboBox32,Instant.ComboBox31);
- Instant.ComboBox32.Text:=OldCombo;
- end;
- end
- else
- begin
- ShowMessage('No internet connection!');
- end;
- Screen.Cursor:=crDefault;
- end;
- procedure TMain.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- SpeedButton3Click(Main);
- end;
- procedure TMain.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- begin
- HtmlHelp(0, nil, HH_CLOSE_ALL, 0);
- end;
- procedure TMain.PreMixes1Click(Sender: TObject);
- begin
- if not Assigned(BlendPage) then
- Application.CreateForm(TBlendPage, BlendPage);
- BlendPage.Show;
- end;
- procedure TMain.About1Click(Sender: TObject);
- begin
- if AboutForm.ShowModal=mrOK then
- ;
- end;
- procedure TMain.SpeedButton11Click(Sender: TObject);
- begin
- Welcome.Show;
- end;
- procedure TMain.ShowAddFeedIngredients1Click(Sender: TObject);
- begin
- if not Assigned(FeedsAdded) then
- Application.CreateForm(TFeedsAdded, FeedsAdded);
- FeedsAdded.Show;
- end;
- procedure TMain.ShowDiet1Click(Sender: TObject);
- begin
- if EnlargeDiet then
- begin
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeDiet:=True;
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- end;
- end;
- procedure TMain.ShowGraphs1Click(Sender: TObject);
- begin
- if EnlargeGraphs then
- begin
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=True;
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- end;
- end;
- procedure TMain.ShowMilk1Click(Sender: TObject);
- begin
- if EnlargeMilk then
- begin
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeMilk:=True;
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- end;
- end;
- procedure TMain.ShowMinerals1Click(Sender: TObject);
- begin
- if EnlargeMinerals then
- begin
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeMinerals:=True;
- end;
- end;
- procedure TMain.ShowNutrients1Click(Sender: TObject);
- begin
- if EnlargeNutrients then
- begin
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeNutrients:=True;
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- end;
- end;
- procedure TMain.ShowRumenFunctions1Click(Sender: TObject);
- begin
- if EnlargeRumen then
- begin
- EnlargeRumen:=False;
- ShowRumenFunctions1.Checked:=False;
- EnlargeOutput:=False;
- Enlarge1.Checked:=False;
- end
- else
- begin
- EnlargeOutput:=True;
- Enlarge1.Checked:=True;
- EnlargeGraphs:=False;
- ShowGraphs1.Checked:=False;
- EnlargeDiet:=False;
- ShowDiet1.Checked:=False;
- EnlargeMilk:=False;
- ShowMilk1.Checked:=False;
- EnlargeNutrients:=False;
- ShowNutrients1.Checked:=False;
- EnlargeRumen:=True;
- EnlargeMinerals:=False;
- ShowMinerals1.Checked:=False;
- end;
- end;
- procedure TMain.Analysebcp1Click(Sender: TObject);
- begin
- // BatchMode:=True;
- // Timer1Timer(Main);
- end;
- procedure TMain.AreTheyChecked(var NotChecked: TNonChecked);
- begin
- if Instant.ListCheckBox[1].Checked then
- begin
- NotChecked[1]:=0;
- end
- else if Instant.ComboBox5.Text<>'' then
- begin
- NotChecked[1]:=1;
- end
- else NotChecked[1]:=-1;
- if Instant.ListCheckBox[2].Checked then
- begin
- NotChecked[2]:=0;
- end
- else if Instant.ComboBox6.Text<>'' then
- begin
- NotChecked[2]:=2;
- end
- else NotChecked[2]:=-1;
- if Instant.ListCheckBox[3].Checked then
- begin
- NotChecked[3]:=0;
- end
- else if Instant.ComboBox7.Text<>'' then
- begin
- NotChecked[3]:=3;
- end
- else NotChecked[3]:=-1;
- if Instant.ListCheckBox[4].Checked then
- begin
- NotChecked[4]:=0;
- end
- else if Instant.ComboBox8.Text<>'' then
- begin
- NotChecked[4]:=4;
- end
- else NotChecked[4]:=-1;
- if Instant.ListCheckBox[5].Checked then
- begin
- NotChecked[5]:=0;
- end
- else if Instant.ComboBox9.Text<>'' then
- begin
- NotChecked[5]:=5;
- end
- else NotChecked[5]:=-1;
- if Instant.ListCheckBox[6].Checked then
- begin
- NotChecked[6]:=0;
- end
- else if Instant.ComboBox11.Text<>'' then
- begin
- NotChecked[6]:=6;
- end
- else NotChecked[6]:=-1;
- if Instant.ListCheckBox[7].Checked then
- begin
- NotChecked[7]:=0;
- end
- else if Instant.ComboBox13.Text<>'' then
- begin
- NotChecked[7]:=7;
- end
- else NotChecked[7]:=-1;
- if Instant.ListCheckBox[8].Checked then
- begin
- NotChecked[8]:=0;
- end
- else if Instant.ComboBox15.Text<>'' then
- begin
- NotChecked[8]:=8;
- end
- else NotChecked[8]:=-1;
- if Instant.ListCheckBox[9].Checked then
- begin
- NotChecked[9]:=0;
- end
- else if Instant.ComboBox17.Text<>'' then
- begin
- NotChecked[9]:=9;
- end
- else NotChecked[9]:=-1;
- if Instant.ListCheckBox[10].Checked then
- begin
- NotChecked[10]:=0;
- end
- else if Instant.ComboBox19.Text<>'' then
- begin
- NotChecked[10]:=10;
- end
- else NotChecked[10]:=-1;
- if Instant.ListCheckBox[11].Checked then
- begin
- NotChecked[11]:=0;
- end
- else if Instant.ComboBox21.Text<>'' then
- begin
- NotChecked[11]:=11;
- end
- else NotChecked[11]:=-1;
- if Instant.ListCheckBox[12].Checked then
- begin
- NotChecked[12]:=0;
- end
- else if Instant.ComboBox23.Text<>'' then
- begin
- NotChecked[12]:=12;
- end
- else NotChecked[12]:=-1;
- if Instant.ListCheckBox[13].Checked then
- begin
- NotChecked[13]:=0;
- end
- else if Instant.ComboBox25.Text<>'' then
- begin
- NotChecked[13]:=13;
- end
- else NotChecked[13]:=-1;
- if Instant.ListCheckBox[14].Checked then
- begin
- NotChecked[14]:=0;
- end
- else if Instant.ComboBox27.Text<>'' then
- begin
- NotChecked[14]:=14;
- end
- else NotChecked[14]:=-1;
- if Instant.ListCheckBox[15].Checked then
- begin
- NotChecked[15]:=0;
- end
- else if Instant.ComboBox29.Text<>'' then
- begin
- NotChecked[15]:=15;
- end
- else NotChecked[15]:=-1;
- if Instant.ListCheckBox[16].Checked then
- begin
- NotChecked[16]:=0;
- end
- else if Instant.ComboBox31.Text<>'' then
- begin
- NotChecked[16]:=16;
- end
- else NotChecked[16]:=-1;
- end;
- procedure TMain.SeeWhatChecked(var n,m: Integer);
- begin
- if Instant.ListCheckBox[1].Checked then n:=n+1;
- if Instant.ListCheckBox[2].Checked then n:=n+1;
- if Instant.ListCheckBox[3].Checked then n:=n+1;
- if Instant.ListCheckBox[4].Checked then n:=n+1;
- if Instant.ListCheckBox[5].Checked then n:=n+1;
- if Instant.ListCheckBox[6].Checked then n:=n+1;
- if Instant.ListCheckBox[7].Checked then n:=n+1;
- if Instant.ListCheckBox[8].Checked then n:=n+1;
- if Instant.ListCheckBox[9].Checked then n:=n+1;
- if Instant.ListCheckBox[10].Checked then n:=n+1;
- if Instant.ListCheckBox[11].Checked then n:=n+1;
- if Instant.ListCheckBox[12].Checked then n:=n+1;
- if Instant.ListCheckBox[13].Checked then n:=n+1;
- if Instant.ListCheckBox[14].Checked then n:=n+1;
- if Instant.ListCheckBox[15].Checked then n:=n+1;
- if Instant.ListCheckBox[16].Checked then n:=n+1;
- if (Instant.ListCheckBox[1].Checked) and (Instant.ComboBox5.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[2].Checked) and (Instant.ComboBox6.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[3].Checked) and (Instant.ComboBox7.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[4].Checked) and (Instant.ComboBox8.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[5].Checked) and (Instant.ComboBox9.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[6].Checked) and (Instant.ComboBox11.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[7].Checked) and (Instant.ComboBox13.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[8].Checked) and (Instant.ComboBox15.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[9].Checked) and (Instant.ComboBox17.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[10].Checked) and (Instant.ComboBox19.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[11].Checked) and (Instant.ComboBox21.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[12].Checked) and (Instant.ComboBox23.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[13].Checked) and (Instant.ComboBox25.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[14].Checked) and (Instant.ComboBox27.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[15].Checked) and (Instant.ComboBox29.Text='Pre-Mix') then m:=m+1;
- if (Instant.ListCheckBox[16].Checked) and (Instant.ComboBox31.Text='Pre-Mix') then m:=m+1;
- end;
- procedure TMain.SeeWhatCheckedPreMix(var n: Integer);
- var
- HowManyFeeds,id: Integer;
- WhatPrice: Single;
- begin
- if Instant.ListCheckBox[1].Checked then
- begin
- if Instant.ComboBox5.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox1.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[2].Checked then
- begin
- if Instant.ComboBox6.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox2.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[3].Checked then
- begin
- if Instant.ComboBox7.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox3.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[4].Checked then
- begin
- if Instant.ComboBox8.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox4.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[5].Checked then
- begin
- if Instant.ComboBox9.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox5.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[6].Checked then
- begin
- if Instant.ComboBox11.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox12.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[7].Checked then
- begin
- if Instant.ComboBox13.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox14.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[8].Checked then
- begin
- if Instant.ComboBox15.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox16.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[9].Checked then
- begin
- if Instant.ComboBox17.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox18.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[10].Checked then
- begin
- if Instant.ComboBox19.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox20.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[11].Checked then
- begin
- if Instant.ComboBox21.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox22.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[12].Checked then
- begin
- if Instant.ComboBox23.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox24.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[13].Checked then
- begin
- if Instant.ComboBox25.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox26.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[14].Checked then
- begin
- if Instant.ComboBox27.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox28.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[15].Checked then
- begin
- if Instant.ComboBox29.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox30.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- if Instant.ListCheckBox[16].Checked then
- begin
- if Instant.ComboBox31.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox32.Text,HowManyFeeds,WhatPrice,id);
- n:=n+HowManyFeeds;
- end
- else
- begin
- n:=n+1;
- end;
- end;
- end;
- procedure TMain.AddForage1Click(Sender: TObject);
- begin
- if not Assigned(ConvertTopH6plus) then
- Application.CreateForm(TConvertTopH6plus, ConvertTopH6plus);
- //try
- if DBConnected then
- ConvertTopH6plus.ShowModal
- else
- ShowMessage('No internet connection!');
- //finally
- // ConvertTopH6plus.Free;
- //end;
- end;
- procedure TMain.AddPreMix(n,ID: Integer;PreM: TCategory;Total: Single);
- var
- TPrice: Single;
- begin
- if LangID=1 then DBPreMixes[n].Name:=SetNameP.Edit1.Text
- else if LangID=2 then DBPreMixes[n].Name:=SetNameP.Edit1.Text
- else if LangID=3 then DBPreMixes[n].Name:=SetNameP.Edit1.Text
- else if LangID=4 then DBPreMixes[n].Name:=SetNameP.Edit1.Text;
- DBPreMixes[n].TypeF:='Pre-Mix';
- //Put data into premix
- DBPreMixes[n].FC_1:=PreM.Category[1];
- DBPreMixes[n].FN_1:=PreM.FName[1];
- DBPreMixes[n].FA_1:=PreM.FAmount[1]/Total*100;
- NewPreMix[0].FC_1:=PreM.Category[1];
- NewPreMix[0].FN_1:=PreM.FName[1];
- NewPreMix[0].FA_1:=PreM.FAmount[1]/Total*100;
- DBPreMixes[n].FC_2:=PreM.Category[2];
- DBPreMixes[n].FN_2:=PreM.FName[2];
- DBPreMixes[n].FA_2:=PreM.FAmount[2]/Total*100;
- NewPreMix[0].FC_2:=PreM.Category[2];
- NewPreMix[0].FN_2:=PreM.FName[2];
- NewPreMix[0].FA_2:=PreM.FAmount[2]/Total*100;
- DBPreMixes[n].FC_3:=PreM.Category[3];
- DBPreMixes[n].FN_3:=PreM.FName[3];
- DBPreMixes[n].FA_3:=PreM.FAmount[3]/Total*100;
- NewPreMix[0].FC_3:=PreM.Category[3];
- NewPreMix[0].FN_3:=PreM.FName[3];
- NewPreMix[0].FA_3:=PreM.FAmount[3]/Total*100;
- DBPreMixes[n].FC_4:=PreM.Category[4];
- DBPreMixes[n].FN_4:=PreM.FName[4];
- DBPreMixes[n].FA_4:=PreM.FAmount[4]/Total*100;
- NewPreMix[0].FC_4:=PreM.Category[4];
- NewPreMix[0].FN_4:=PreM.FName[4];
- NewPreMix[0].FA_4:=PreM.FAmount[4]/Total*100;
- DBPreMixes[n].FC_5:=PreM.Category[5];
- DBPreMixes[n].FN_5:=PreM.FName[5];
- DBPreMixes[n].FA_5:=PreM.FAmount[5]/Total*100;
- NewPreMix[0].FC_5:=PreM.Category[5];
- NewPreMix[0].FN_5:=PreM.FName[5];
- NewPreMix[0].FA_5:=PreM.FAmount[5]/Total*100;
- DBPreMixes[n].FC_6:=PreM.Category[6];
- DBPreMixes[n].FN_6:=PreM.FName[6];
- DBPreMixes[n].FA_6:=PreM.FAmount[6]/Total*100;
- NewPreMix[0].FC_6:=PreM.Category[6];
- NewPreMix[0].FN_6:=PreM.FName[6];
- NewPreMix[0].FA_6:=PreM.FAmount[6]/Total*100;
- DBPreMixes[n].FC_7:=PreM.Category[7];
- DBPreMixes[n].FN_7:=PreM.FName[7];
- DBPreMixes[n].FA_7:=PreM.FAmount[7]/Total*100;
- NewPreMix[0].FC_7:=PreM.Category[7];
- NewPreMix[0].FN_7:=PreM.FName[7];
- NewPreMix[0].FA_7:=PreM.FAmount[7]/Total*100;
- DBPreMixes[n].FC_8:=PreM.Category[8];
- DBPreMixes[n].FN_8:=PreM.FName[8];
- DBPreMixes[n].FA_8:=PreM.FAmount[8]/Total*100;
- NewPreMix[0].FC_8:=PreM.Category[8];
- NewPreMix[0].FN_8:=PreM.FName[8];
- NewPreMix[0].FA_8:=PreM.FAmount[8]/Total*100;
- DBPreMixes[n].FC_9:=PreM.Category[9];
- DBPreMixes[n].FN_9:=PreM.FName[9];
- DBPreMixes[n].FA_9:=PreM.FAmount[9]/Total*100;
- NewPreMix[0].FC_9:=PreM.Category[9];
- NewPreMix[0].FN_9:=PreM.FName[9];
- NewPreMix[0].FA_9:=PreM.FAmount[9]/Total*100;
- DBPreMixes[n].FC_10:=PreM.Category[10];
- DBPreMixes[n].FN_10:=PreM.FName[10];
- DBPreMixes[n].FA_10:=PreM.FAmount[10]/Total*100;
- NewPreMix[0].FC_10:=PreM.Category[10];
- NewPreMix[0].FN_10:=PreM.FName[10];
- NewPreMix[0].FA_10:=PreM.FAmount[10]/Total*100;
- DBPreMixes[n].FC_11:=PreM.Category[11];
- DBPreMixes[n].FN_11:=PreM.FName[11];
- DBPreMixes[n].FA_11:=PreM.FAmount[11]/Total*100;
- NewPreMix[0].FC_11:=PreM.Category[11];
- NewPreMix[0].FN_11:=PreM.FName[11];
- NewPreMix[0].FA_11:=PreM.FAmount[11]/Total*100;
- DBPreMixes[n].FC_12:=PreM.Category[12];
- DBPreMixes[n].FN_12:=PreM.FName[12];
- DBPreMixes[n].FA_12:=PreM.FAmount[12]/Total*100;
- NewPreMix[0].FC_12:=PreM.Category[12];
- NewPreMix[0].FN_12:=PreM.FName[12];
- NewPreMix[0].FA_12:=PreM.FAmount[12]/Total*100;
- DBPreMixes[n].FC_13:=PreM.Category[13];
- DBPreMixes[n].FN_13:=PreM.FName[13];
- DBPreMixes[n].FA_13:=PreM.FAmount[13]/Total*100;
- NewPreMix[0].FC_13:=PreM.Category[13];
- NewPreMix[0].FN_13:=PreM.FName[13];
- NewPreMix[0].FA_13:=PreM.FAmount[13]/Total*100;
- DBPreMixes[n].FC_14:=PreM.Category[14];
- DBPreMixes[n].FN_14:=PreM.FName[14];
- DBPreMixes[n].FA_14:=PreM.FAmount[14]/Total*100;
- NewPreMix[0].FC_14:=PreM.Category[14];
- NewPreMix[0].FN_14:=PreM.FName[14];
- NewPreMix[0].FA_14:=PreM.FAmount[14]/Total*100;
- DBPreMixes[n].FC_15:=PreM.Category[15];
- DBPreMixes[n].FN_15:=PreM.FName[15];
- DBPreMixes[n].FA_15:=PreM.FAmount[15]/Total*100;
- NewPreMix[0].FC_15:=PreM.Category[15];
- NewPreMix[0].FN_15:=PreM.FName[15];
- NewPreMix[0].FA_15:=PreM.FAmount[15]/Total*100;
- DBPreMixes[n].FC_16:=PreM.Category[16];
- DBPreMixes[n].FN_16:=PreM.FName[16];
- DBPreMixes[n].FA_16:=PreM.FAmount[16]/Total*100;
- NewPreMix[0].FC_16:=PreM.Category[16];
- NewPreMix[0].FN_16:=PreM.FName[16];
- NewPreMix[0].FA_16:=PreM.FAmount[16]/Total*100;
- DBPreMixes[n].FC_17:=PreM.Category[17];
- DBPreMixes[n].FN_17:=PreM.FName[17];
- DBPreMixes[n].FA_17:=PreM.FAmount[17]/Total*100;
- NewPreMix[0].FC_17:=PreM.Category[17];
- NewPreMix[0].FN_17:=PreM.FName[17];
- NewPreMix[0].FA_17:=PreM.FAmount[17]/Total*100;
- DBPreMixes[n].FC_18:=PreM.Category[18];
- DBPreMixes[n].FN_18:=PreM.FName[18];
- DBPreMixes[n].FA_18:=PreM.FAmount[18]/Total*100;
- NewPreMix[0].FC_18:=PreM.Category[18];
- NewPreMix[0].FN_18:=PreM.FName[18];
- NewPreMix[0].FA_18:=PreM.FAmount[18]/Total*100;
- TPrice:=0;
- for n := 1 to 18 do
- TPrice:=TPrice+PreM.FPrice[n]/Total;
- DBPreMixes[n].Cost:=TPrice;
- NewPreMix[0].Cost:=TPrice;
- DBPreMixes[n].New:=1;
- DBPreMixes[n].ID:=ID;
- end;
- procedure TMain.AdjustfNDF1Click(Sender: TObject);
- begin
- if not Assigned(AdjustfNDF) then
- Application.CreateForm(TAdjustfNDF, AdjustfNDF);
- if AdjustfNDF.ShowModal=mrOK then
- begin
- DBClientFeeds[AdjustfNDFClientFeed].New:=-3;
- DBClientFeeds[AdjustfNDFClientFeed].GasA:=((1-(AdjustfNDF.ScrollBar1.Position-45)/(85-45))*(85-45)+45)/fNDFasProp; //AdjustfNDF.ScrollBar1.Position
- if Instant.ComboBox1.Text<>'' then Instant.ComboBox1Change(Self);
- end;
- end;
- procedure TMain.Admin1Click(Sender: TObject);
- begin
- if not Assigned(Admin) then
- Application.CreateForm(TAdmin, Admin);
- Administrator:=True;
- Admin.Show;
- end;
- procedure TMain.AutoCreatePreMix1Click(Sender: TObject);
- {var
- n,m,HowManyFeeds,id,I,HighID: Integer;
- TotalAmount,TPrice,WhatPrice,PerCent: Single;
- //Category,FName: array[1..18] of String;
- //FAmount,FPrice: array[1..18] of Single;
- NotChecked: TNonChecked;
- UnCheckedIngredient: array of Integer;
- NameOfTable,FeedName: String;
- AddPre: Boolean;
- NewPMix: TCategory; }
- begin
- {AutoSolveName:=True;
- n:=0;m:=0;UnCheckedIngredient:=nil;
- for n := 1 to 16 do
- NotChecked[n]:=0;
- n:=0;
- if AutoCreatePreMix then
- begin
- SeeWhatCheckedPreMix(n);
- end
- else
- begin
- SeeWhatChecked(n,m);
- end;
- if n<2 then
- begin
- ShowMessage('Please select at least two ingredients!');
- end
- else if (m>0) and (not AutoCreatePreMix) then
- begin
- ShowMessage('Please do not select a Pre-Mix!');
- end
- else if n>18 then
- begin
- ShowMessage('You have selected more than 18 ingredients! At the moment, that''s not allowed');
- end
- else
- begin
- //Set name
- if SetNameP.ShowModal=mrOK then
- begin
- AutoPM:=True;
- NewPreMix:=nil;
- SetLength(NewPreMix,1);
- for n := 1 to 18 do
- begin
- NewPMix.Category[n]:='';
- NewPMix.FName[n]:='';
- NewPMix.FAmount[n]:=0;
- NewPMix.FPrice[n]:=0;
- end;
- TotalAmount:=0;
- n:=0;
- if Instant.ListCheckBox[1].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit6.Text);
- if Instant.ComboBox5.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox1.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox1.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit6.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox5.Text;
- NewPMix.FName[n]:=Instant.ComboBox1.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit6.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[0].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[2].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit7.Text);
- if Instant.ComboBox6.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox2.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox2.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit7.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox6.Text;
- NewPMix.FName[n]:=Instant.ComboBox2.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit7.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[1].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[3].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit8.Text);
- if Instant.ComboBox7.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox3.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox3.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit8.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox7.Text;
- NewPMix.FName[n]:=Instant.ComboBox3.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit8.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[2].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[4].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit9.Text);
- if Instant.ComboBox8.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox4.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox4.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit9.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox8.Text;
- NewPMix.FName[n]:=Instant.ComboBox4.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit9.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[3].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[5].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit13.Text);
- if Instant.ComboBox9.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox10.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox10.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit13.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox9.Text;
- NewPMix.FName[n]:=Instant.ComboBox10.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit13.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[4].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[6].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit16.Text);
- if Instant.ComboBox11.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox12.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox12.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit16.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox11.Text;
- NewPMix.FName[n]:=Instant.ComboBox12.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit16.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[5].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[7].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit18.Text);
- if Instant.ComboBox13.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox14.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox14.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit18.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox13.Text;
- NewPMix.FName[n]:=Instant.ComboBox14.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit18.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[6].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[8].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit20.Text);
- if Instant.ComboBox15.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox16.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox16.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit20.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox15.Text;
- NewPMix.FName[n]:=Instant.ComboBox16.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit20.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[7].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[9].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit22.Text);
- if Instant.ComboBox17.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox18.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox18.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit22.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox17.Text;
- NewPMix.FName[n]:=Instant.ComboBox18.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit22.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[8].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[10].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit24.Text);
- if Instant.ComboBox19.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox20.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox20.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit24.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox19.Text;
- NewPMix.FName[n]:=Instant.ComboBox20.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit24.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[9].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[11].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit26.Text);
- if Instant.ComboBox21.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox22.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox22.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit26.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox21.Text;
- NewPMix.FName[n]:=Instant.ComboBox22.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit26.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[10].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[12].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit28.Text);
- if Instant.ComboBox23.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox24.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox24.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit28.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox23.Text;
- NewPMix.FName[n]:=Instant.ComboBox24.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit28.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[11].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[13].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit1.Text);
- if Instant.ComboBox25.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox26.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox26.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit1.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox25.Text;
- NewPMix.FName[n]:=Instant.ComboBox26.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit1.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[12].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[14].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit2.Text);
- if Instant.ComboBox27.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox28.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox28.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit2.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox27.Text;
- NewPMix.FName[n]:=Instant.ComboBox28.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit2.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[13].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[15].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit3.Text);
- if Instant.ComboBox29.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox30.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox30.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit3.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox29.Text;
- NewPMix.FName[n]:=Instant.ComboBox30.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit3.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[14].Cost*NewPMix.FAmount[n];
- end;
- end;
- if Instant.ListCheckBox[16].Checked then
- begin
- TotalAmount:=TotalAmount+StrToFloat(Instant.Edit4.Text);
- if Instant.ComboBox31.Text='Pre-Mix' then
- begin
- Instant.GetPreMixNo(Instant.ComboBox32.Text,HowManyFeeds,WhatPrice,id);
- for m:=1 to HowManyFeeds do
- begin
- n:=n+1;
- Instant.GetPreMixAmounts(Instant.ComboBox32.Text,NameOfTable,FeedName,PerCent,m);
- NewPMix.FName[n]:=FeedName+'PRMX';
- NewPMix.Category[n]:=NameOfTable;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit4.Text)*PerCent/100;
- NewPMix.FPrice[n]:=WhatPrice*NewPMix.FAmount[n];
- end;
- end
- else
- begin
- n:=n+1;
- NewPMix.Category[n]:=Instant.ComboBox31.Text;
- NewPMix.FName[n]:=Instant.ComboBox32.Text;
- NewPMix.FAmount[n]:=StrToFloat(Instant.Edit4.Text);
- NewPMix.FPrice[n]:=rFeedInfo.TMRFeed[15].Cost*NewPMix.FAmount[n];
- end;
- end;
- AddPre:=False;
- if Length(DBPreMixes)>0 then
- begin
- for I := 0 to Length(DBPreMixes)-1 do
- if DBPreMixes[I].Name=SetNameP.Edit1.Text then
- begin
- AddPreMix(I,DBPreMixes[I].ID,NewPMix,TotalAmount);
- AddPre:=True;
- end;
- if not AddPre then
- begin
- HighID:=0;
- for I := 0 to Length(DBPreMixes)-1 do
- begin
- if DBPreMixes[I].ID>HighID then
- HighID:=DBPreMixes[I].ID; //HighID will be highest ID number
- end;
- I:=Length(DBPreMixes)+1;
- SetLength(DBPreMixes,I);
- AddPreMix(I-1,HighID+1,NewPMix,TotalAmount);
- end;
- end
- else
- begin
- HighID:=0;
- DBPreMixes:=nil;
- SetLength(DBPreMixes,1);
- AddPreMix(0,HighID+1,NewPMix,TotalAmount);
- end;
- //put all checkbox selected at end
- AreTheyChecked(NotChecked);
- m:=0;
- UnCheckedIngredient:=nil;
- for n := 1 to 16 do//16 downto 1 do
- begin
- if NotChecked[n]>0 then
- begin
- m:=m+1;
- SetLength(UnCheckedIngredient,m);
- UnCheckedIngredient[m-1]:=n;
- end;
- end;
- if m>1 then
- begin
- for n := 0 to m-2 do
- if UnCheckedIngredient[n]+1<>UnCheckedIngredient[n+1] then
- //Move Ingredient [n] to Ingredient [n+1]+1
- begin
- MoveIngredient(UnCheckedIngredient[n+1],UnCheckedIngredient[n]+1);
- UnCheckedIngredient[n+1]:=UnCheckedIngredient[n]+1;
- end;
- end;
- //remove selected fields from TMR form
- for n:=1 to 16 do
- if Instant.ListCheckBox[17-n].Checked then
- begin
- Instant.RemoveFeedFromTMR1Click(Self);
- Instant.ListCheckBox[17-n].Checked:=False;
- end;
- //put premix into TMR form
- n:=0;
- if Instant.ComboBox1.Text<>'' then n:=n+1;
- if Instant.ComboBox2.Text<>'' then n:=n+1;
- if Instant.ComboBox3.Text<>'' then n:=n+1;
- if Instant.ComboBox4.Text<>'' then n:=n+1;
- if Instant.ComboBox10.Text<>'' then n:=n+1;
- if Instant.ComboBox12.Text<>'' then n:=n+1;
- if Instant.ComboBox14.Text<>'' then n:=n+1;
- if Instant.ComboBox16.Text<>'' then n:=n+1;
- if Instant.ComboBox18.Text<>'' then n:=n+1;
- if Instant.ComboBox20.Text<>'' then n:=n+1;
- if Instant.ComboBox22.Text<>'' then n:=n+1;
- if Instant.ComboBox24.Text<>'' then n:=n+1;
- if Instant.ComboBox26.Text<>'' then n:=n+1;
- if Instant.ComboBox28.Text<>'' then n:=n+1;
- if Instant.ComboBox30.Text<>'' then n:=n+1;
- if Instant.ComboBox32.Text<>'' then n:=n+1;
- case n+1 of
- 1: begin
- NewPremixes:=True;
- Instant.ComboBox5.Text:='Pre-Mix';
- Instant.ComboBox5Change(Instant);
- Instant.ComboBox1.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox1Change(Instant);
- Instant.Edit6.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 2: begin
- NewPremixes:=True;
- Instant.ComboBox6.Text:='Pre-Mix';
- Instant.ComboBox6Change(Instant);
- Instant.ComboBox2.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox2Change(Instant);
- Instant.Edit7.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 3: begin
- NewPremixes:=True;
- Instant.ComboBox7.Text:='Pre-Mix';
- Instant.ComboBox7Change(Instant);
- Instant.ComboBox3.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox3Change(Instant);
- Instant.Edit8.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 4: begin
- NewPremixes:=True;
- Instant.ComboBox8.Text:='Pre-Mix';
- Instant.ComboBox8Change(Instant);
- Instant.ComboBox4.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox4Change(Instant);
- Instant.Edit9.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 5: begin
- NewPremixes:=True;
- Instant.ComboBox9.Text:='Pre-Mix';
- Instant.ComboBox9Change(Instant);
- Instant.ComboBox10.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox10Change(Instant);
- Instant.Edit13.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 6: begin
- NewPremixes:=True;
- Instant.ComboBox11.Text:='Pre-Mix';
- Instant.ComboBox11Change(Instant);
- Instant.ComboBox12.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox12Change(Instant);
- Instant.Edit16.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 7: begin
- NewPremixes:=True;
- Instant.ComboBox13.Text:='Pre-Mix';
- Instant.ComboBox13Change(Instant);
- Instant.ComboBox14.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox14Change(Instant);
- Instant.Edit18.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 8: begin
- NewPremixes:=True;
- Instant.ComboBox15.Text:='Pre-Mix';
- Instant.ComboBox15Change(Instant);
- Instant.ComboBox16.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox16Change(Instant);
- Instant.Edit20.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 9: begin
- NewPremixes:=True;
- Instant.ComboBox17.Text:='Pre-Mix';
- Instant.ComboBox17Change(Instant);
- Instant.ComboBox18.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox18Change(Instant);
- Instant.Edit22.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 10: begin
- NewPremixes:=True;
- Instant.ComboBox19.Text:='Pre-Mix';
- Instant.ComboBox19Change(Instant);
- Instant.ComboBox20.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox20Change(Instant);
- Instant.Edit24.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 11: begin
- NewPremixes:=True;
- Instant.ComboBox21.Text:='Pre-Mix';
- Instant.ComboBox21Change(Instant);
- Instant.ComboBox22.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox22Change(Instant);
- Instant.Edit26.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 12: begin
- NewPremixes:=True;
- Instant.ComboBox23.Text:='Pre-Mix';
- Instant.ComboBox23Change(Instant);
- Instant.ComboBox24.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox24Change(Instant);
- Instant.Edit28.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 13: begin
- NewPremixes:=True;
- Instant.ComboBox25.Text:='Pre-Mix';
- Instant.ComboBox25Change(Instant);
- Instant.ComboBox26.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox26Change(Instant);
- Instant.Edit1.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 14: begin
- NewPremixes:=True;
- Instant.ComboBox27.Text:='Pre-Mix';
- Instant.ComboBox27Change(Instant);
- Instant.ComboBox28.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox28Change(Instant);
- Instant.Edit2.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 15: begin
- NewPremixes:=True;
- Instant.ComboBox29.Text:='Pre-Mix';
- Instant.ComboBox29Change(Instant);
- Instant.ComboBox30.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox30Change(Instant);
- Instant.Edit3.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- 16: begin
- NewPremixes:=True;
- Instant.ComboBox31.Text:='Pre-Mix';
- Instant.ComboBox31Change(Instant);
- Instant.ComboBox32.Text:=SetNameP.Edit1.Text;
- Instant.ComboBox32Change(Instant);
- Instant.Edit4.Text:=FloatToStrF(TotalAmount,ffFixed,5,3);
- NewPremixes:=False;
- end;
- end;
- AutoPM:=False;
- end;
- end;
- AutoSolveName:=False;}
- end;
- procedure TMain.MoveIngredient(FromIng,ToIng: Integer);
- var
- FromCategory,FromName,FromAmount: String;
- begin
- case FromIng of
- 1: begin
- FromCategory:=Instant.ComboBox5.Text;
- FromName:=Instant.ComboBox1.Text;
- FromAmount:=Instant.Edit6.Text;
- Instant.ComboBox5.Text:='';
- Instant.ComboBox1.Text:='';
- Instant.Edit6.Text:='';
- end;
- 2: begin
- FromCategory:=Instant.ComboBox6.Text;
- FromName:=Instant.ComboBox2.Text;
- FromAmount:=Instant.Edit7.Text;
- Instant.ComboBox6.Text:='';
- Instant.ComboBox2.Text:='';
- Instant.Edit7.Text:='';
- end;
- 3: begin
- FromCategory:=Instant.ComboBox7.Text;
- FromName:=Instant.ComboBox3.Text;
- FromAmount:=Instant.Edit8.Text;
- Instant.ComboBox7.Text:='';
- Instant.ComboBox3.Text:='';
- Instant.Edit8.Text:='';
- end;
- 4: begin
- FromCategory:=Instant.ComboBox8.Text;
- FromName:=Instant.ComboBox4.Text;
- FromAmount:=Instant.Edit9.Text;
- Instant.ComboBox8.Text:='';
- Instant.ComboBox4.Text:='';
- Instant.Edit9.Text:='';
- end;
- 5: begin
- FromCategory:=Instant.ComboBox9.Text;
- FromName:=Instant.ComboBox10.Text;
- FromAmount:=Instant.Edit13.Text;
- Instant.ComboBox9.Text:='';
- Instant.ComboBox10.Text:='';
- Instant.Edit13.Text:='';
- end;
- 6: begin
- FromCategory:=Instant.ComboBox11.Text;
- FromName:=Instant.ComboBox12.Text;
- FromAmount:=Instant.Edit16.Text;
- Instant.ComboBox11.Text:='';
- Instant.ComboBox12.Text:='';
- Instant.Edit16.Text:='';
- end;
- 7: begin
- FromCategory:=Instant.ComboBox13.Text;
- FromName:=Instant.ComboBox14.Text;
- FromAmount:=Instant.Edit18.Text;
- Instant.ComboBox13.Text:='';
- Instant.ComboBox14.Text:='';
- Instant.Edit18.Text:='';
- end;
- 8: begin
- FromCategory:=Instant.ComboBox15.Text;
- FromName:=Instant.ComboBox16.Text;
- FromAmount:=Instant.Edit20.Text;
- Instant.ComboBox15.Text:='';
- Instant.ComboBox16.Text:='';
- Instant.Edit20.Text:='';
- end;
- 9: begin
- FromCategory:=Instant.ComboBox17.Text;
- FromName:=Instant.ComboBox18.Text;
- FromAmount:=Instant.Edit22.Text;
- Instant.ComboBox17.Text:='';
- Instant.ComboBox18.Text:='';
- Instant.Edit22.Text:='';
- end;
- 10: begin
- FromCategory:=Instant.ComboBox19.Text;
- FromName:=Instant.ComboBox20.Text;
- FromAmount:=Instant.Edit24.Text;
- Instant.ComboBox19.Text:='';
- Instant.ComboBox20.Text:='';
- Instant.Edit24.Text:='';
- end;
- 11: begin
- FromCategory:=Instant.ComboBox21.Text;
- FromName:=Instant.ComboBox22.Text;
- FromAmount:=Instant.Edit26.Text;
- Instant.ComboBox21.Text:='';
- Instant.ComboBox22.Text:='';
- Instant.Edit26.Text:='';
- end;
- 12: begin
- FromCategory:=Instant.ComboBox23.Text;
- FromName:=Instant.ComboBox24.Text;
- FromAmount:=Instant.Edit28.Text;
- Instant.ComboBox23.Text:='';
- Instant.ComboBox24.Text:='';
- Instant.Edit28.Text:='';
- end;
- 13: begin
- FromCategory:=Instant.ComboBox25.Text;
- FromName:=Instant.ComboBox26.Text;
- FromAmount:=Instant.Edit1.Text;
- Instant.ComboBox25.Text:='';
- Instant.ComboBox26.Text:='';
- Instant.Edit1.Text:='';
- end;
- 14: begin
- FromCategory:=Instant.ComboBox27.Text;
- FromName:=Instant.ComboBox28.Text;
- FromAmount:=Instant.Edit2.Text;
- Instant.ComboBox27.Text:='';
- Instant.ComboBox28.Text:='';
- Instant.Edit2.Text:='';
- end;
- 15: begin
- FromCategory:=Instant.ComboBox29.Text;
- FromName:=Instant.ComboBox30.Text;
- FromAmount:=Instant.Edit3.Text;
- Instant.ComboBox29.Text:='';
- Instant.ComboBox30.Text:='';
- Instant.Edit3.Text:='';
- end;
- 16: begin
- FromCategory:=Instant.ComboBox31.Text;
- FromName:=Instant.ComboBox32.Text;
- FromAmount:=Instant.Edit4.Text;
- Instant.ComboBox31.Text:='';
- Instant.ComboBox32.Text:='';
- Instant.Edit4.Text:='';
- end;
- end;
- Instant.ListCheckBox[ToIng].Checked:=False;
- case ToIng of
- 1: begin
- Instant.ComboBox5.Text:=FromCategory;
- Instant.ComboBox5Change(Self);
- Instant.ComboBox1.Text:=FromName;
- Instant.ComboBox1Change(Self);
- Instant.Edit6.Text:=FromAmount;
- end;
- 2: begin
- Instant.ComboBox6.Text:=FromCategory;
- Instant.ComboBox6Change(Self);
- Instant.ComboBox2.Text:=FromName;
- Instant.ComboBox2Change(Self);
- Instant.Edit7.Text:=FromAmount;
- end;
- 3: begin
- Instant.ComboBox7.Text:=FromCategory;
- Instant.ComboBox7Change(Self);
- Instant.ComboBox3.Text:=FromName;
- Instant.ComboBox3Change(Self);
- Instant.Edit8.Text:=FromAmount;
- end;
- 4: begin
- Instant.ComboBox8.Text:=FromCategory;
- Instant.ComboBox8Change(Self);
- Instant.ComboBox4.Text:=FromName;
- Instant.ComboBox4Change(Self);
- Instant.Edit9.Text:=FromAmount;
- end;
- 5: begin
- Instant.ComboBox9.Text:=FromCategory;
- Instant.ComboBox9Change(Self);
- Instant.ComboBox10.Text:=FromName;
- Instant.ComboBox10Change(Self);
- Instant.Edit13.Text:=FromAmount;
- end;
- 6: begin
- Instant.ComboBox11.Text:=FromCategory;
- Instant.ComboBox11Change(Self);
- Instant.ComboBox12.Text:=FromName;
- Instant.ComboBox12Change(Self);
- Instant.Edit16.Text:=FromAmount;
- end;
- 7: begin
- Instant.ComboBox13.Text:=FromCategory;
- Instant.ComboBox13Change(Self);
- Instant.ComboBox14.Text:=FromName;
- Instant.ComboBox14Change(Self);
- Instant.Edit18.Text:=FromAmount;
- end;
- 8: begin
- Instant.ComboBox15.Text:=FromCategory;
- Instant.ComboBox15Change(Self);
- Instant.ComboBox16.Text:=FromName;
- Instant.ComboBox16Change(Self);
- Instant.Edit20.Text:=FromAmount;
- end;
- 9: begin
- Instant.ComboBox17.Text:=FromCategory;
- Instant.ComboBox17Change(Self);
- Instant.ComboBox18.Text:=FromName;
- Instant.ComboBox18Change(Self);
- Instant.Edit22.Text:=FromAmount;
- end;
- 10: begin
- Instant.ComboBox19.Text:=FromCategory;
- Instant.ComboBox19Change(Self);
- Instant.ComboBox20.Text:=FromName;
- Instant.ComboBox20Change(Self);
- Instant.Edit24.Text:=FromAmount;
- end;
- 11: begin
- Instant.ComboBox21.Text:=FromCategory;
- Instant.ComboBox21Change(Self);
- Instant.ComboBox22.Text:=FromName;
- Instant.ComboBox22Change(Self);
- Instant.Edit26.Text:=FromAmount;
- end;
- 12: begin
- Instant.ComboBox23.Text:=FromCategory;
- Instant.ComboBox23Change(Self);
- Instant.ComboBox24.Text:=FromName;
- Instant.ComboBox24Change(Self);
- Instant.Edit28.Text:=FromAmount;
- end;
- 13: begin
- Instant.ComboBox25.Text:=FromCategory;
- Instant.ComboBox25Change(Self);
- Instant.ComboBox26.Text:=FromName;
- Instant.ComboBox26Change(Self);
- Instant.Edit1.Text:=FromAmount;
- end;
- 14: begin
- Instant.ComboBox27.Text:=FromCategory;
- Instant.ComboBox27Change(Self);
- Instant.ComboBox28.Text:=FromName;
- Instant.ComboBox28Change(Self);
- Instant.Edit2.Text:=FromAmount;
- end;
- 15: begin
- Instant.ComboBox29.Text:=FromCategory;
- Instant.ComboBox29Change(Self);
- Instant.ComboBox30.Text:=FromName;
- Instant.ComboBox30Change(Self);
- Instant.Edit3.Text:=FromAmount;
- end;
- 16: begin
- Instant.ComboBox31.Text:=FromCategory;
- Instant.ComboBox31Change(Self);
- Instant.ComboBox32.Text:=FromName;
- Instant.ComboBox32Change(Self);
- Instant.Edit4.Text:=FromAmount;
- end;
- end;
- end;
- procedure TMain.SetIngPriceClick(Sender: TObject);
- begin
- if not Assigned(AlterFeedPrices) then
- Application.CreateForm(TAlterFeedPrices, AlterFeedPrices);
- AlterFeedPrices.Show;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement