Beispiel #1
0
 private void SubmitBtn_Click(object sender, EventArgs e)
 {
     if (submitValidation())
     {
         if (RadioBtnBar.Checked == true)
         {
             if (int.TryParse(TxtBxLength.Text, out length))
             {
                 BarTop newBarTop = new BarTop
                 {
                     Length  = length,
                     Width   = width,
                     ColorID = GetColorId(ComboBoxColorList.Text)
                 };
                 //changeListBarTops.Add(newBarTop);
                 BarsArray.Add(newBarTop);
                 TxtBxLength.Clear();
             }
         }
         else if (RadioBtnVanity.Checked == true)
         {
             if (int.TryParse(TxtBxLength.Text, out length))
             {
                 Vanity newVainity = new Vanity
                 {
                     Length  = length,
                     ColorID = GetColorId(ComboBoxColorList.Text)
                 };
                 //changeListVanity.Add(newVainity);
                 BarsArray.Add(newVainity);
                 TxtBxLength.Clear();
             }
         }
         else if (RadioBtnKitchen.Checked == true)
         {
             if (int.TryParse(TxtBxLength.Text, out length))
             {
                 Kitchen newKitchen = new Kitchen
                 {
                     Length  = length,
                     ColorID = GetColorId(ComboBoxColorList.Text)
                 };
                 //changeListKitchen.Add(newKitchen);
                 BarsArray.Add(newKitchen);
                 TxtBxLength.Clear();
             }
         }
         ChangeListBoxUpdate();
     }
     else
     {
         // MessageBox.Show($"Please enter required information");
     }
 }
Beispiel #2
0
        /// <summary>
        /// Submits Pending Changes to the Database
        /// </summary>
        private void SubmitDatabaseChanges()
        {
            // Using arrayList
            foreach (var item in BarsArray)
            {
                if (item.GetType() == typeof(BarTop))
                {
                    BarTop bar = (BarTop)item; // Explicit cast var item to BarTop object
                    dbContext.BarTops.InsertOnSubmit(bar);
                }
                if (item.GetType() == typeof(Kitchen))
                {
                    Kitchen kitchen = (Kitchen)item;
                    dbContext.Kitchens.InsertOnSubmit(kitchen);
                }
                if (item.GetType() == typeof(Vanity))
                {
                    Vanity vanity = (Vanity)item;
                    dbContext.Vanities.InsertOnSubmit(vanity);
                }
            }

            try
            {
                dbContext.SubmitChanges();
                BarsArray.Clear();
            }
            catch (System.Data.SqlClient.SqlException)
            {
                MessageBox.Show("You cannot remove a color that has inventory");
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            InfoList.Items.Clear();
        }
 partial void DeleteVanity(Vanity instance);
 partial void UpdateVanity(Vanity instance);
 partial void InsertVanity(Vanity instance);
 private void detach_Vanities(Vanity entity)
 {
     this.SendPropertyChanging();
     entity.Color = null;
 }
 private void attach_Vanities(Vanity entity)
 {
     this.SendPropertyChanging();
     entity.Color = this;
 }