Ejemplo n.º 1
0
        /// <summary>
        /// method for adding pizza to the database
        /// </summary>
        private void SaveExecute()
        {
            try
            {
                using (PanPizzaEntities context = new PanPizzaEntities())
                {
                    tblPizza newPizza = new tblPizza();

                    newPizza.SizeID     = size.SizeID;
                    newPizza.Salami     = pizza.Salami;
                    newPizza.Ham        = pizza.Ham;
                    newPizza.Kulen      = pizza.Kulen;
                    newPizza.Ketchup    = pizza.Ketchup;
                    newPizza.Mayonnaise = pizza.Mayonnaise;
                    newPizza.HotPepper  = pizza.HotPepper;
                    newPizza.Olives     = pizza.Olives;
                    newPizza.Oregano    = pizza.Oregano;
                    newPizza.Sesame     = pizza.Sesame;
                    newPizza.Cheese     = pizza.Cheese;

                    newPizza.PizzaID = pizza.PizzaID;
                    newPizza.Price   = price;

                    context.tblPizzas.Add(newPizza);
                    context.SaveChanges();

                    MessageBox.Show("The new pizza added successfully");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong inputs, please check your size input.");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// method for getting all sizes to the list
 /// </summary>
 /// <returns></returns>
 private List <tblSize> GetAllSize()
 {
     try
     {
         using (PanPizzaEntities context = new PanPizzaEntities())
         {
             List <tblSize> list = new List <tblSize>();
             list = (from x in context.tblSizes select x).ToList();
             return(list);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }