1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
void Angela001Frame::OnListBox1Select(wxCommandEvent& event)
{
if (RadioButton_amountDescending)
{
try
{
wxMessageBox("Descending", "DESC");
Grid_View_Recipes->ClearGrid();
wxString recipeName = ListBox1->GetString(ListBox1->GetSelection());
db->Open("zyx.db");
wxSQLite3Statement stmt3 = db->PrepareStatement("SELECT recipe_id, note, standard "
"FROM recipes "
"WHERE recipe_name = ?");
stmt3.Bind(1, recipeName);
wxSQLite3ResultSet result22 = stmt3.ExecuteQuery();
/* CHECK THE FIELD "standard" TO SEE HOW WE LABEL THE GRID */
if (result22.GetInt(2) == 0)
Grid_View_Recipes->SetColLabelValue(1, "GRAMS");
else
Grid_View_Recipes->SetColLabelValue(1, "OUNCES");
int recipe_ID = result22.GetInt(0);
TextCtrl1->SetValue(result22.GetAsString(1)); // UPDATE NOTE
int newRow = 0;
wxSQLite3Statement stmt2 = db->PrepareStatement("SELECT ingredient, amount "
"FROM recipe_ingredients "
"INNER JOIN recipes ON recipes.recipe_id = recipe_ingredients.recipe_id "
"WHERE recipe_ingredients.recipe_id = ?"
"ORDER BY amount DESC");
stmt2.Bind(1, recipe_ID);
wxSQLite3ResultSet result1 = stmt2.ExecuteQuery();
int colCount1 = result1.GetColumnCount();
while (result1.NextRow())
{
for (int i = 0; i < colCount1; i++) // VARIABLE i MOVES THE COLUMN CELL OVER
{
Grid_View_Recipes->SetCellValue(newRow, i, result1.GetAsString(i)); // UPDATE CURRENT CELL
}
newRow++;
}
stmt2.Finalize();
} catch(wxSQLite3Exception& e) {
}
db->Close();
}
if (RadioButton_amountAscending)
{
try
{
wxMessageBox("Ascending", "ASC");
Grid_View_Recipes->ClearGrid();
wxString recipeName = ListBox1->GetString(ListBox1->GetSelection());
db->Open("zyx.db");
wxSQLite3Statement stmt3 = db->PrepareStatement("SELECT recipe_id, note, standard "
"FROM recipes "
"WHERE recipe_name = ?");
stmt3.Bind(1, recipeName);
wxSQLite3ResultSet result22 = stmt3.ExecuteQuery();
/* CHECK THE FIELD "standard" TO SEE HOW WE LABEL THE GRID */
if (result22.GetInt(2) == 0)
Grid_View_Recipes->SetColLabelValue(1, "GRAMS");
else
Grid_View_Recipes->SetColLabelValue(1, "OUNCES");
int recipe_ID = result22.GetInt(0);
TextCtrl1->SetValue(result22.GetAsString(1)); // UPDATE NOTE
int newRow = 0;
wxSQLite3Statement stmt2 = db->PrepareStatement("SELECT ingredient, amount "
"FROM recipe_ingredients "
"INNER JOIN recipes ON recipes.recipe_id = recipe_ingredients.recipe_id "
"WHERE recipe_ingredients.recipe_id = ?"
"ORDER BY amount ASC");
stmt2.Bind(1, recipe_ID);
wxSQLite3ResultSet result1 = stmt2.ExecuteQuery();
int colCount1 = result1.GetColumnCount();
while (result1.NextRow())
{
for (int i = 0; i < colCount1; i++) // VARIABLE i MOVES THE COLUMN CELL OVER
{
Grid_View_Recipes->SetCellValue(newRow, i, result1.GetAsString(i)); // UPDATE CURRENT CELL
}
newRow++;
}
stmt2.Finalize();
} catch(wxSQLite3Exception& e) {
}
db->Close();
}
}
|