9 #include <wx/spinctrl.h>
10 #include <wx/choice.h>
43 void OnBirdChoice(wxCommandEvent& );
44 void OnSaveButton(wxCommandEvent& );
45 void OnCancelButton(wxCommandEvent& );
46 void OnHatchChoice(wxCommandEvent& );
47 void OnBatchName(wxCommandEvent& );
48 int GetIncubationDays(
int TypeSelect,
string BreedName);
51 BatchDialog( wxWindow* parent, wxWindowID
id = wxID_ANY,
const wxString& title = wxT(
"New Batch"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCLOSE_BOX|wxCAPTION|wxSYSTEM_MENU );
55 BatchDialog::BatchDialog( wxWindow* parent, wxWindowID
id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) : wxDialog( parent, id, title, pos, size, style )
57 this->SetSizeHints( wxDefaultSize, wxDefaultSize );
63 this->SetForegroundColour( wxColor(ColorRed[8],ColorGreen[8],ColorBlue[8]) );
64 this->SetBackgroundColour( wxColor(ColorRed[7],ColorGreen[7],ColorBlue[7]) );
66 bSizer1 =
new wxBoxSizer( wxVERTICAL );
69 gSizer1 =
new wxGridSizer( 8, 2, 0, 0 );
71 wxArrayString birdChoiceChoices;
72 birdChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, birdChoiceChoices, 0 );
75 gSizer1->Add(
birdChoice, 0, wxALL|wxEXPAND, 5 );
77 wxArrayString breedChoiceChoices;
78 breedChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, breedChoiceChoices, 0 );
83 wxArrayString groupChoiceChoices;
84 groupChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, groupChoiceChoices, 0 );
89 wxArrayString IncubatorChoiceChoices;
90 IncubatorChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, IncubatorChoiceChoices, 0 );
96 wxTextValidator textVal(wxFILTER_INCLUDE_CHAR_LIST,NULL);
99 batchText =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0,textVal );
100 gSizer1->Add(
batchText, 0, wxALL|wxEXPAND, 5 );
102 batchNameStat =
new wxStaticText(
this, wxID_ANY,
l(
"Batch Name"), wxDefaultPosition, wxDefaultSize, 0 );
104 gSizer1->Add(
batchNameStat, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
106 eggNumSpinner =
new wxSpinCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10000, 1 );
110 NumberOfEggs =
new wxStaticText(
this, wxID_ANY,
l(
"Eggs"), wxDefaultPosition, wxDefaultSize, 0 );
112 gSizer1->Add(
NumberOfEggs, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
114 wxArrayString candleChoiceChoices;
115 candleChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, candleChoiceChoices, 0 );
119 showCandleText =
new wxStaticText(
this, wxID_ANY,
l(
"Candle Date"), wxDefaultPosition, wxDefaultSize, 0 );
121 gSizer1->Add(
showCandleText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
123 StartDatePicker =
new wxDatePickerCtrl(
this, wxID_ANY, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize, wxDP_DEFAULT );
126 showStartText =
new wxStaticText(
this, wxID_ANY,
l(
"Start Date"), wxDefaultPosition, wxDefaultSize, 0 );
128 gSizer1->Add(
showStartText, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 );
130 wxString hatchChoiceChoices[] = {
l(
"Automatic Calculation"),
l(
"Set Hatch Date") };
131 int hatchChoiceNChoices =
sizeof( hatchChoiceChoices ) /
sizeof( wxString );
132 hatchChoice =
new wxChoice(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,hatchChoiceNChoices, hatchChoiceChoices , 0 );
137 showHatchText =
new wxStaticText(
this, wxID_ANY,
l(
"Hatch Date"), wxDefaultPosition, wxDefaultSize, 0 );
139 gSizer1->Add(
showHatchText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
141 cancelButton =
new wxButton(
this, wxID_ANY,
l(
"Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
144 saveButton =
new wxButton(
this, wxID_ANY,
l(
"Save"), wxDefaultPosition,wxDefaultSize, 0 );
146 gSizer1->Add(
saveButton, 0, wxALL|wxEXPAND, 5 );
149 bSizer1->Add( gSizer1, 0, wxEXPAND, 5 );
150 bSizer1->SetSizeHints(
this);
157 this->SetSizer( bSizer1 );
162 for(counter = 0; counter < 50; counter++)
163 candleChoice->Append(
l(
"Candle On Day ") + to_string(counter));
186 for (counter = 0; counter < Inc.size();counter++)
195 wxMessageDialog dialog(
this,
196 l(
"Please Select A Bird Type First!"));
202 wxMessageDialog dialog(
this,
203 l(
"Please Enter Batch Name!"));
209 wxMessageDialog dialog(
this,
210 (
"Name Exists! Please Enter A New Name!"));
218 WXdate.GetDay(wxDateTime::Local),
219 WXdate.GetMonth(wxDateTime::Local) + 1,
220 WXdate.GetYear(wxDateTime::Local)
256 wxMessageDialog* dialog =
new wxMessageDialog(
this,
317 wxMessageDialog dialog(
this,
318 l(
"Please Select A Bird Type First!"));
324 DateDialog dialog(
this,2002,
l(
"Select Hatch Date"));
332 wxDateTime::Month(wxDateTime::Jan + Date.
GetMonth() - 1),
344 wxDateTime startD(date.
GetDay(),
345 wxDateTime::Month(wxDateTime::Jan + date.
GetMonth() - 1),
HK_Database Database(HATCHKEEPER_DATA+"HatchKeeper.db")
std::string l(std::string Text)
A Helper Function For HK_Language.
A Dialog For Adding A New Batch.
wxDatePickerCtrl * StartDatePicker
wxStaticText * showCandleText
int GetIncubationDays(int TypeSelect, string BreedName)
Returns Incubation Days, Returns Default Days From The Selected Type If Breed Days Unavailible.
wxStaticText * NumberOfEggs
wxStaticText * batchNameStat
void OnSaveButton(wxCommandEvent &)
Saves The New Batch To The Database.
bool WasCanceled()
Returns True If The Cancel Button Was Clicked.
wxSpinCtrl * eggNumSpinner
void OnCancelButton(wxCommandEvent &)
Cancels Add Batch And Closes Dialog.
void OnHatchChoice(wxCommandEvent &)
Fired When The Hatch Date Dropdown Changes.
void OnBatchName(wxCommandEvent &)
Fired When Batch Name Changes.
wxStaticText * showHatchText
BatchDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxT("New Batch"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCLOSE_BOX|wxCAPTION|wxSYSTEM_MENU)
Constructor.
wxStaticText * showStartText
wxChoice * IncubatorChoice
void OnBirdChoice(wxCommandEvent &)
Fired When Type Changes.
This Dialog Allows The User To Select A Date.
HK_Date GetDate()
Returns Selected Date.
Holds Data For One Batch, Includes Basic Set/Get Methods.
vector< string > GetSQL()
Returns An SQL String To Set Batch In Database.
int GetValidID()
Returns An ID That Isn't Used By Any HK_Batch In This HK_Batches Instance.
bool IsValidName(string Name)
Returns True If Name Isn't Already In Use.
bool Execute(string SQL)
Executes SQL Statments.
string GetErrors()
Returns sqlite3_errmsg(HK_DB))
A Class For Managing Dates.
int GetMonth()
Returns Month Value.
bool SubtractDays(int Days)
Subtracts Days To This HK_Date.
bool AddDays(int Days)
Adds Days To This HK_Date.
int GetDay()
Returns Day Value.
int GetYear()
Returns Year Value.
std::string GetValidChars()
Returns Chars That Are Allowed In Text Controls.
vector< string > GetArray(int Selection)
Returns The Selected Value As An Array Of Strings.
vector< int > GetIntArray(int Selection)
Returns The Selected Value As An Array Of Integers.
int GetInt(int Selection)
Returns The Selected Setting Value As An Integer.
HK_Date GetDate(int Select)
Returns The Selected Stored Date.
int GetCount()
Returns The Number Of Elements Stored.
int GetNumber(int Select)
Returns The Selected Stored Number.
string GetName(int Select)
Returns The Selected Stored Name.
string GetText(int Select)
Returns The Selected Stored Text.