Example #1
0
        public void addDish(BE.Dish new_dish)
        {
            loadDishesFile();
            loadConfigFile();
            // בדיקה האם המנה קיימת
            XElement dishCheck = (from d in DS_XML.dishesRoot.Elements()
                                  where uint.Parse(d.Element("ID").Value) == new_dish.dishID
                                  select d).FirstOrDefault();

            if (dishCheck != null)
            {
                throw new Exception("מנה זו כבר קיימת במערכת");
            }
            if (Client.clientmaxID == 99999999)
            {
                throw new Exception("שגיאת מערכת: לא ניתן להוסיף מנות חדשות. מספר המנה יחרוג משמונה תווים");
            }
            //  הוספת מנה חדשה
            XElement id     = new XElement("ID", Dish.dishMaxId++);
            XElement name   = new XElement("Name", new_dish.dishName);
            XElement size   = new XElement("Size", new_dish.dishSize);
            XElement price  = new XElement("Price", new_dish.priceOfSingleDish);
            XElement kosher = new XElement("Kosher", new_dish.dishLevelOfKosher);
            XElement dish   = new XElement("Dish", id, name, size, price, kosher);

            DS_XML.dishesRoot.Add(dish);
            DS_XML.dishesRoot.Save(DS_XML.dishesPath);
            // שמירת מס' הזיהוי הרץ
            DS_XML.configRoot.Element("DishMaxID").Value = Dish.dishMaxId.ToString();
            DS_XML.configRoot.Save(DS_XML.configPath);
        }
Example #2
0
 public void AddDish(Dish dish)
 {
     if (SearchDishById(dish.DishNumber) == null)
     {
         DataSource.dishList.Add(dish);
     }
     else
         throw new alreadyExists("DAL error: Id " + dish.DishNumber + " already exists in data source");
 }
Example #3
0
        public XElement ConvertDish(BE.Dish d)//converts form XElement Dish
        {
            XElement dishElement = new XElement("Dish");

            foreach (PropertyInfo item in typeof(BE.Dish).GetProperties())
            {
                dishElement.Add
                (
                    new XElement(item.Name, item.GetValue(d, null))
                );
            }

            return(dishElement);
        }
Example #4
0
 public void UpdateDish(Dish dish)
 {
     for (int i = 0; i < DataSource.dishList.Count(); i++)
     {
         if (DataSource.dishList[i].DishNumber == dish.DishNumber)
         {
             DataSource.dishList[i].DishName = dish.DishName;
             DataSource.dishList[i].cookingExtent = dish.cookingExtent;
             DataSource.dishList[i].DishPrice = dish.DishPrice;
             DataSource.dishList[i].dishSize = dish.dishSize;
             DataSource.dishList[i].kosherLevel = dish.kosherLevel;
             break;
         }
     }
 }
Example #5
0
        public void AddDish(Dish dish)//Add Dish
        {
            if (SearchDishById(dish.DishNumber) == null)
            {
                XElement id = new XElement("id", dish.DishNumber);
                XElement Name = new XElement("Name", dish.DishName);
                XElement Price = new XElement("Price", dish.DishPrice);
                XElement KosherLevel = new XElement("KosherLevel", dish.kosherLevel);
                XElement Category = new XElement("Category", dish.DishCategory);
                XElement dis = new XElement("Dish_details", Name, Price, KosherLevel);

                DishRoot.Add(new XElement("Dish", id, dis, Category));
                DishRoot.Save(DishPath);
            }
            else
                throw new alreadyExists("DAL error: Id " + dish.DishNumber + " already exists in data source");
        }
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BE.Dish tempDish = bl.getDish(int.Parse(textBoxID.Text));

                if (tempDish == null) // if the id doesn't exists within the Dishlist.
                {
                    throw new Exception("Dish with given id not found.");
                }
                bl.deleteDish(tempDish.dishID);
                throw new Exception("Dish with id: " + tempDish.dishID + " has been deleted.");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #7
0
 public void RemoveDish(Dish dish)
 {
     mydish.RemoveDish(dish.DishNumber);
 }
Example #8
0
 public void AddDish(Dish dish)
 {
     mydish.AddDish(dish);
 }
Example #9
0
 public void UpdateDish(Dish dish)
 {
     mydish.UpdateDish(dish);
 }
Example #10
0
 public void RemoveDish(Dish dish)
 {
     dal_func.RemoveDish(dish);
 }
Example #11
0
 public void AddDish(Dish dish)
 {
     dal_func.AddDish(dish);
 }
Example #12
0
 public void UpdateDish(Dish dish)
 {
     dal_func.UpdateDish(dish);
 }
Example #13
0
 public void UpdateDish(Dish dish)//update Dish
 {
     if (RemoveDish(dish.DishNumber))
         AddDish(dish);
     else
         throw new NullReferenceException("Dish not found!");
 }
        private void buttonUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BE.Dish tempDish = bl.getDish(int.Parse(textBoxID.Text));

                if (tempDish == null) // if the id doesn't exists within the branchlist.
                {
                    throw new Exception("Dish with given id not found.");
                }

                else
                {
                    //If the textBox == "", meaning it's empty, it wont update that info.

                    string name;
                    if (textBoxName.Text == "")
                    {
                        name = tempDish.dishName;
                    }
                    else
                    {
                        name = textBoxName.Text;
                    }

                    int price;
                    if (textBoxPrice.Text == "")
                    {
                        price = (int)tempDish.dishPrice;
                    }
                    else
                    {
                        name = textBoxName.Text;
                    }

                    dishHechser hechser;
                    if ((dishHechser)comboBoxHechser.SelectedItem < 0)
                    {
                        hechser = tempDish.dishHechserDish;
                    }
                    else
                    {
                        hechser = (dishHechser)comboBoxHechser.SelectedItem;
                    }

                    dishSize size;
                    if ((dishSize)comboBoxSize.SelectedItem < 0)
                    {
                        size = tempDish.dishSizeDish;
                    }
                    else
                    {
                        size = (dishSize)comboBoxSize.SelectedItem;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #15
0
 public void RemoveDish(Dish dish)
 {
     //if (dish == null && DataSource.dishList.Remove(dish))
     //    throw new NullReferenceException("the dish  not found");
     DataSource.dishList.Remove(dish);
 }