Exemplo n.º 1
0
 public DataTable getIngredients(clsRecipe rec)
 {
     _strSQL = "SELECT Name, Description, Season FROM Ingredients, Recipe_Contains WHERE Ingr_fk = Ingr_id AND Rec_fk = "
               + rec.id + ";";
     executesql();
     return(_dtResult);
 }
Exemplo n.º 2
0
 public frmShowRecipe(frmShowResults resultsForm, clsRecipe thisRec)
 {
     _data        = new clsSQL();
     _resultsForm = resultsForm;
     _thisRecipe  = thisRec;
     _ingredients = _data.getIngredients(_thisRecipe);
     InitializeComponent();
     populate();
 }
Exemplo n.º 3
0
        public void addRecipe(clsRecipe recNewRecipe, List <clsIngredient> ingredientsUsed,
                              List <String> stylesUsed, List <String> catsUsed)
        {
            _strSQL = "INSERT INTO Recipes (Season, Directions, Favorite, Name) VALUES ('" + recNewRecipe.season + "', '" +
                      recNewRecipe.directions + "', '" + recNewRecipe.favorite + "', '" + recNewRecipe.name + "'); SELECT TOP 1 Rec_id " +
                      "FROM RECIPES ORDER BY Rec_id DESC;";
            executesql();
            int recID = Convert.ToInt32(_dtResult.Rows[0]["Rec_id"]);

            containsInsert(ingredientsUsed, recID);
            recStylesInsert(stylesUsed, recID);
            recCatsInsert(catsUsed, recID);
        }
 public frmAddRecipe()
 {
     _recNewRecipe    = new clsRecipe();
     _data            = new clsSQL();
     _ingredientsUsed = new List <clsIngredient>();
     _stylesUsed      = new List <String>();
     _catsUsed        = new List <String>();
     lstIngredients   = new ListView();
     lstCategories    = new ListView();
     lstStyles        = new ListView();
     InitializeComponent();
     populateIngredients();
     populateCategories();
     populateStyles();
 }
Exemplo n.º 5
0
        private void btnFavorite_Click(object sender, EventArgs e)
        {
            clsRecipe rec  = new clsRecipe();
            clsSQL    data = new clsSQL();

            // str = DataGridView1.Rows[DataGridView.SelectedRows[0].Index].Cells[X].Value.ToString();
            rec.id         = Int32.Parse(dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[1].Value.ToString());
            rec.name       = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[2].Value.ToString();
            rec.season     = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[3].Value.ToString();
            rec.directions = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[4].Value.ToString();
            Char[] chararr = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[5].Value.ToString().ToCharArray();
            rec.favorite = chararr[0];
            data.favoriteRecipe(rec);
            MessageBox.Show(rec.name + " has been added to your favorites!");
            dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[5].Value = "Y";
        }
Exemplo n.º 6
0
        private void showView()
        {
            clsRecipe rec = new clsRecipe();

            // str = DataGridView1.Rows[DataGridView.SelectedRows[0].Index].Cells[X].Value.ToString();
            rec.id         = Int32.Parse(dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[1].Value.ToString());
            rec.name       = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[2].Value.ToString();
            rec.season     = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[3].Value.ToString();
            rec.directions = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[4].Value.ToString();
            Char[] chararr = dgvResults.Rows[dgvResults.SelectedRows[0].Index].Cells[5].Value.ToString().ToCharArray();
            rec.favorite = chararr[0];

            frmShowRecipe showRec = new frmShowRecipe(this, rec);

            showRec.Show();
            this.Hide();
        }
Exemplo n.º 7
0
 public DataTable getCategories(clsRecipe rec)
 {
     _strSQL = "SELECT Name FROM Categories, Recipe_Categories WHERE Cat_id = Cat_fk AND Rec_fk = " + rec.id + ";";
     executesql();
     return(_dtResult);
 }
Exemplo n.º 8
0
 public DataTable getStyles(clsRecipe rec)
 {
     _strSQL = "SELECT Name FROM Styles, Recipe_Styles  WHERE Style_id = Style_fk AND Rec_fk = " + rec.id + ";";
     executesql();
     return(_dtResult);
 }
Exemplo n.º 9
0
 public void favoriteRecipe(clsRecipe rec)
 {
     _strSQL = "UPDATE Recipes SET Favorite = 'Y' WHERE Rec_id = " + rec.id + ";";
     executesql();
 }