private void diagAddRecipe_FormClosing(object sender, FormClosingEventArgs e)
 {
     RecBO = new RecipeBO();
     RecBL = new RecipeBL();
     try
     {
         if (acceptbutton != true && cancelButton == false)
         {
             if (MessageBox.Show("Dish/Changes will not be saved." + Environment.NewLine + "Are you sure you want to cancel?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
             {
                 RecBO.status   = "0";
                 RecBO.recipeid = Convert.ToString(RecipeID);
                 RecBL.ChangeRecipeInuse(RecBO);
                 while (numOfAddedIng >= 0)
                 {
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBO.ingid    = newlyaddeding[numOfAddedIng];
                     RecBL.removeNewlyAddedIngToRecipe(RecBO);
                     numOfAddedIng     = numOfAddedIng - 1;
                     this.DialogResult = DialogResult.Cancel;
                 }
                 if (SelectedAction == "Update")
                 {
                     RecBO.status   = oldStatus;
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBL.ChangeRecipeInuse(RecBO);
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     RecBL.deleteAllRecIng(RecBO);
                     RecBO.recipeid = Convert.ToString(RecipeID);
                     foreach (DataRow row in origIng.Rows)
                     {
                         RecBO.recipeid = row.ItemArray[0].ToString();
                         RecBO.ingid    = row.ItemArray[1].ToString();
                         RecBO.meas     = row.ItemArray[2].ToString();
                         RecBL.addRecipeIng(RecBO);
                         this.DialogResult = DialogResult.Cancel;
                     }
                 }
             }
             else
             {
                 e.Cancel = true;
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        private void dataGridView2_DoubleClick(object sender, EventArgs e)
        {
            RecBL = new RecipeBL();
            RecBO = new RecipeBO();
            foreach (DataGridViewRow row in dataGridView2.SelectedRows)
            {
                selectedIng = row.Cells[0].Value.ToString();
            }
            RecBO.recipeid = Convert.ToString(RecipeID);
            RecBO.ingid    = selectedIng;
            DataTable dt = RecBL.checkRecipeIng(RecBO);

            if (dt.Rows.Count == 0)
            {
                diagRecipeMeas diagMeas = new diagRecipeMeas(selectedIng);
                if (diagMeas.ShowDialog() == DialogResult.OK)
                {
                    newlyaddeding[numOfAddedIng] = selectedIng;
                    numOfAddedIng  = numOfAddedIng + 1;
                    RecBO.recipeid = Convert.ToString(RecipeID);
                    RecBO.ingid    = selectedIng;
                    RecBO.meas     = diagMeas.meas;
                    RecBL.addRecipeIng(RecBO);
                    RecBO.recipeid           = Convert.ToString(RecipeID);
                    dataGridView1.DataSource = RecBL.getIngByRecID(RecBO);
                    time = 0;
                    notifier("Ingredient Successfully added!");
                    lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                    this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
                }
            }
            else
            {
                time = 0;
                notifier("Ingredient is already included!");
                lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
                this.panel3.BackColor = System.Drawing.Color.Tomato;
            }
        }