public bool SaveDish(int id_dish, string name_dish, int?id_selection, bool availability, string price1, string price2)    //сохранение изменений
        {
            decimal rub  = decimal.Parse(price1);
            decimal kop  = decimal.Parse(price2) * decimal.Parse((0.01).ToString());
            var     dish = db.list_of_dishes.FirstOrDefault(w => w.id_dish == id_dish);

            if ((name_dish != "") && (price != 0) && (id_selection != null))
            {
                if (dish == null)
                {
                    dish         = new list_of_dishes();
                    dish.id_dish = id_dish;
                }
                dish.name_dish    = employee.Savestring(name_dish);
                dish.id_selection = id_selection;
                dish.availability = availability;
                dish.price        = rub + kop;
                db.list_of_dishes.AddOrUpdate(dish);
                db.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static list_of_dishes DynamicDish(dynamic dish)   //перевод из динамического типа в тип list_of_dish
        {
            list_of_dishes Newdish = new list_of_dishes();

            Newdish.id_dish      = dish.id_dish;
            Newdish.name_dish    = dish.name_dish;
            Newdish.id_selection = dish.id_selection;
            Newdish.availability = dish.availability;
            Newdish.price        = dish.price;
            return(Newdish);
        }
        public ADD_EDIT_DISH(employee emp, dynamic dish)
        {
            InitializeComponent();
            this.emp  = emp;
            this.dish = list_of_dishes.DynamicDish(dish);
            maskedTextBoxPriceP.Text = (Math.Truncate(dish.price)).ToString();
            maskedTextBoxPriceK.Text = ((dish.price - Math.Truncate(dish.price)) * 100).ToString();
            name_dish.Text           = dish.name_dish;
            var comboList = menu.ComboSel();

            foreach (menu i in comboList)
            {
                comboSelection.Items.Add(i.name_selection);
            }
            if (dish.name_selection != null)
            {
                comboSelection.SelectedItem = dish.name_selection;
            }
            checkBoxAv.Checked = dish.availability;
        }
Пример #4
0
        private void comboSelection_SelectedIndexChanged(object sender, EventArgs e)
        {
            list_of_dishes dish = new list_of_dishes();

            selectList.DataSource = dish.SelectListDish(comboSelection.SelectedItem.ToString());
        }