Пример #1
0
 private void toolStripMenuItem3_Click(object sender, EventArgs e)
 {
     recBO = new RecipeBO();
     recBL = new RecipeBL();
     try
     {
         if (RecipeID != "" && RecipeID != null)
         {
             recBO.recipeid = RecipeID;
             recBO.recipe   = "";
             recBO.cat      = cat;
             if (status == "AVAILABLE")
             {
                 recBL.makeRecipeUnavail(recBO);
                 radioButton1.Checked = !radioButton1.Checked;
             }
             else
             {
                 recBL.makeRecipeAvail(recBO);
                 radioButton1.Checked = !radioButton1.Checked;
             }
             time     = 0;
             RecipeID = "";
             notifier("Dish successfully status changed.");
             lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
             this.panel3.BackColor = System.Drawing.Color.DodgerBlue;
             RecipeBO.recipe       = "";
             RecipeBO.cat          = cat;
         }
         else
         {
             time = 0;
             notifier("Please select a dish.");
             lblNotif.Left         = (this.ClientSize.Width - lblNotif.Size.Width) / 2;
             this.panel3.BackColor = System.Drawing.Color.Tomato;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
 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;
     }
 }