private void button1_Click(object sender, EventArgs e) { RecBL = new RecipeBL(); RecBO = new RecipeBO(); try { RecBO.recipe = textBox1.Text.Trim(); RecBO.cat = comboBox1.Text.Trim(); RecBO.recipeid = Convert.ToString(RecipeID); if (SelectedAction == "New") { if (RecBL.checkRecipeName(RecBO).Rows.Count == 0) { if (dataGridView1.Rows.Count != 0 && textBox1.Text != "" && comboBox1.Text != "") { RecBL.makeRecipeAvail(RecBO); RecBL.updateRecipe(RecBO); time = 0; notifier("Dish Successfully added!"); lblNotif.Left = (this.ClientSize.Width - lblNotif.Size.Width) / 2; this.panel3.BackColor = System.Drawing.Color.DodgerBlue; acceptbutton = true; this.DialogResult = DialogResult.OK; } else { time = 0; notifier("Fill Dish description and add ingredients to dish!"); lblNotif.Left = (this.ClientSize.Width - lblNotif.Size.Width) / 2; this.panel3.BackColor = System.Drawing.Color.Tomato; } } else { time = 0; notifier("Dish name is already registered!"); lblNotif.Left = (this.ClientSize.Width - lblNotif.Size.Width) / 2; this.panel3.BackColor = System.Drawing.Color.Tomato; } } else { RecBO.recipeid = Convert.ToString(RecipeID); RecBO.recipe = textBox1.Text.Trim(); bool notaltered = !(RecBL.checkRecipe(RecBO).Rows.Count == 1); bool unique = !(RecBL.checkRecipeName(RecBO).Rows.Count == 1); if (string.Equals(textBox1.Text, origDesc, StringComparison.CurrentCultureIgnoreCase)) { notaltered = true; unique = true; } if (notaltered && unique) { RecBO.recipeid = Convert.ToString(RecipeID); RecBO.recipe = textBox1.Text.Trim(); RecBO.cat = comboBox1.Text.Trim(); if (MessageBox.Show("Done updating dish?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { RecBL.updateRecipe(RecBO); recipename = textBox1.Text.Trim(); acceptbutton = true; this.DialogResult = DialogResult.OK; } } } } catch (Exception) { throw; } }