8 #include "../headers/Advanced.h"
80 string sql =
"INSERT INTO Advanced VALUES(" + to_string(
GetID()) +
"," +
83 string tag1 =
"", tag2 =
"", tag3 =
"";
84 string fertile =
"", pip =
"";
85 string result =
"", resDate =
"", eggCom =
"";
86 string dWeight =
"", dComment =
"";
89 vector<HK_Weight> weights;
90 vector<string> daycomms;
99 result += to_string(Egg.
GetResult()) +
"/";
105 for(b = 0; b < (
GetDays() - 1); b++)
106 dWeight += weights[b].GetString() +
"/";
107 dWeight += weights[b].GetString() +
"&";
111 for(b = 0; b < (
GetDays() - 1); b++) {
112 dComment += daycomms[b] +
"|";
114 dComment += daycomms[b] +
"&";
129 for(b = 0; b < (
GetDays() - 1); b++)
130 dWeight += weights[b].GetString() +
"/";
131 dWeight += weights[b].GetString();
135 for(b = 0; b < (
GetDays() - 1); b++)
136 dComment += daycomms[b] +
"|";
137 dComment += daycomms[b];
140 sql +=
"'" + tag1 +
"','" + tag2 +
"','" + tag3 +
"','";
142 sql += fertile +
"','" + pip +
"','";
144 sql += result +
"','" + resDate +
"','" + eggCom +
"','";
146 sql += dWeight +
"','" + dComment +
"');";
154 int A = 0,B = 0,Fertile = 0,Chicks = 0;
155 vector<string> Sql, Results;
157 Sql.push_back(
" EggComments = '");
158 Sql.push_back(
" Tag1 = '");
159 Sql.push_back(
" Tag2 = '");
160 Sql.push_back(
" Tag3 = '");
161 Sql.push_back(
" Fertile = '");
162 Sql.push_back(
" Pipped = '");
163 Sql.push_back(
" Result = '");
164 Sql.push_back(
" ResultDate = '");
165 Sql.push_back(
" DayWeight = '");
166 Sql.push_back(
" DayComment = '");
179 Sql[5] += to_string(
HK_AdvEggs[A].GetPipped()) +
"/";
181 Sql[6] += to_string(
HK_AdvEggs[A].GetResult()) +
"/";
185 Sql[7] +=
HK_AdvEggs[A].GetDate().ToSortable(
"/") +
"&";
187 for(B = 0; B < (
GetDays() - 1); B++)
188 Sql[8] += to_string(
HK_AdvEggs[A].GetDayWeight()[B].GetFloat()) +
"/";
189 Sql[8] +=
HK_AdvEggs[A].GetDayWeight()[B].GetString() +
"&";
191 for(B = 0; B < (
GetDays() - 1); B++)
192 Sql[9] +=
HK_AdvEggs[A].GetDayComments()[B] +
"|";
193 Sql[9] +=
HK_AdvEggs[A].GetDayComments()[B] +
"&";
204 Sql[5] += to_string(
HK_AdvEggs[A].GetPipped());
206 Sql[6] += to_string(
HK_AdvEggs[A].GetResult());
210 Sql[7] +=
HK_AdvEggs[A].GetDate().ToSortable(
"/");
212 for(B = 0; B < (
GetDays() - 1); B++)
213 Sql[8] +=
HK_AdvEggs[A].GetDayWeight()[B].GetString() +
"/";
214 Sql[8] +=
HK_AdvEggs[A].GetDayWeight()[B].GetString();
216 for(B = 0; B < (
GetDays() - 1); B++)
217 Sql[9] +=
HK_AdvEggs[A].GetDayComments()[B] +
"|";
221 string Temp =
"UPDATE Advanced SET ";
223 for(C = 0; C < Sql.size() - 1; C++)
224 Temp += Sql[C] +
"', ";
225 Temp += Sql[C] +
"' WHERE ID = " + to_string(
HK_AdvID) +
";";
228 Results.push_back(
" UPDATE Batches SET FertileEggs = " + to_string(Fertile) +
" WHERE ID = " + to_string(
HK_AdvID) +
";");
229 Results.push_back(
" UPDATE Batches SET ChicksHatched = " + to_string(Chicks) +
" WHERE ID = " + to_string(
HK_AdvID) +
";");
230 Results.push_back(Temp);
HK_Egg GetEgg(int Select)
Returns The Selected Egg.
int GetEggCount()
Returns The Number Of Eggs.
void SetEggs(vector< HK_Egg > Eggs)
Sets All Eggs At Once.
vector< HK_Egg > HK_AdvEggs
void SetUpdate(bool Status)
Sets Update Status For This HK_Advanced.
HK_KeyValue Search(string Value, string BatchName)
Searches Eggs For Matches To Value.
vector< string > GetUpdate()
Returns An Array Of SQL Strings To Update Database.
void AddEgg(HK_Egg Egg)
Adds An HK_Egg To HK_AdvEggs Vector.
int GetChicks()
Returns The Number Of Eggs That Hatched Based On HK_Egg Data.
int GetDays()
Returns Incubation Days.
void SetID(int ID)
Sets ID.
HK_Advanced()
Default Constructor.
int CalcAvgLoss()
Returns The Average Weight Loss For All Eggs In Batch.
void Clear()
Clears All Data From This Object.
void SetEgg(HK_Egg Egg, int Select)
Sets Selected Egg.
int GetFertile()
Returns The Number Of Eggs That Are Fertile Based On HK_Egg Data.
void SetUnit(int Unit)
Sets Weight Unit Used.
void SetDays(int Days)
Sets Incubation Days.
int GetUnit()
Returns Weight Unit.
bool GetUpdateStatus()
Returns True If This HK_Advanced Has Data That Needs To Be Updated.
void Set(int ID, int Unit, int Days, vector< HK_Egg > Eggs)
Initialize In One Function Call.
vector< HK_Egg > GetEggs()
Returns An Array Of HK_Egg Objects.
std::string ToSortable(std::string Separator)
Generate A Sortable String For Database.
A Class For Storing And Retieving Data For One Egg.
int GetResult()
Returns -1 If No Result, 0 If Hatched, And 2 If Egg Quit.
string GetComments()
Returns Egg Comments.
string GetTag2()
Returns Tag 2 As A String.
HK_Date GetDate()
Returns The Date For The Result.
string GetTag3()
Returns Tag 3 As A String.
vector< string > GetDayComments()
Returns An Array Containing A Comment For Every Day.
vector< HK_Weight > GetDayWeight()
Returns An Array Containing A Weight For Every Day.
int GetPipped()
Returns 0 If Egg Is Not Pipped And 1 If It Is.
string GetTag1()
Returns Tag 1 As A String.
int GetFertile()
Returns 0 If Egg Is Not Fertile And 1 If It Is.
A Key and Value Type Storage.
void Add(string Key, string Value)
Adds A Key And Value;.