Example #1
0
        private void loadDataDrinkTopping(Panel pn, string type)
        {
            List <Drinks> list = new DrinksBUS().GetDrinks_Topping(type);
            Button        obt  = new Button()
            {
                Width = 0, Location = new Point(0, 0)
            };

            foreach (var item in list)
            {
                Button bt = new Button()
                {
                    Width    = Const.BUTTON_WIDTH,
                    Height   = Const.BUTTON_HEIGHT,
                    Location = new Point(obt.Location.X + obt.Width, obt.Location.Y),
                    Text     = item.Name,
                    Tag      = item.Price
                };
                bt.Click += btn_Click;
                pn.Controls.Add(bt);
                obt = bt;
                if (obt.Location.X + Const.BUTTON_WIDTH >= pn.Width)
                {
                    obt.Location = new Point(0, obt.Location.Y + Const.BUTTON_HEIGHT);
                    obt.Width    = Const.BUTTON_WIDTH;
                    obt.Height   = Const.BUTTON_HEIGHT;
                }
            }
        }
Example #2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string id          = txtID.Text.Trim();
            string type        = txtType.Text.Trim();
            string name        = txtName.Text.Trim();
            string ingredients = txtIngredients.Text.Trim();
            int    price       = int.Parse(txtPrice.Text.Trim());
            Drink  newdrinks   = new Drink()
            {
                ID          = id,
                Type        = type,
                Name        = name,
                Ingredients = ingredients,
                Price       = price
            };

            Clear();
            bool result = new DrinksBUS().Update(newdrinks);

            if (result)
            {
                lbdebug.Text = ("SUCCESS!");
                List <Drink> drinks = new DrinksBUS().GetAll();
                GridView.DataSource = drinks;
                GridView.DataBind();
            }
            else
            {
                lbdebug.Text = ("FAIL!");
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <Drink> drinks = new DrinksBUS().GetAll();

            GridView.DataSource = drinks;
            GridView.DataBind();
        }
Example #4
0
        protected void bntSearch_Click(object sender, EventArgs e)
        {
            string       keyword = txtkeyword.Text.Trim();
            List <Drink> drinks  = new DrinksBUS().Search(keyword);

            GridView.DataSource = drinks;
            GridView.DataBind();
        }
Example #5
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string id        = txtID.Text.Trim();
            Drink  newdrinks = new Drink()
            {
                ID = id
            };

            Clear();
            bool result = new DrinksBUS().Delete(id);

            if (result)
            {
                lbdebug.Text = ("SUCCESS!");
                List <Drink> drinks = new DrinksBUS().GetAll();
                GridView.DataSource = drinks;
                GridView.DataBind();
            }
            else
            {
                lbdebug.Text = ("FAIL!");
            }
        }