private void NumericValueChanged(object sender, EventArgs e) { myNumericUpDown n = sender as myNumericUpDown; foreach (var item in lsOrder) { if (item.FoodDrinkID == n.objectID) { item.Quantity = Convert.ToInt32(n.Value); item.Price = float.Parse(foodDrinkBLL.GetFoodPrice(item.FoodDrinkID).ToString()); // item.Price *= item.Quantity; } } }
public void Load(List <FoodDrink> lstFood, bool isFood) { int count = 0; int x = 0, y = 10, z = 0; int width = 80, height = 80; foreach (FoodDrink item in lstFood) { if (item.IsAvailable == false) { continue; } int foodID = item.FoodDrinkID; //Visible Item myButtonEdit picBox = new myButtonEdit(); myCheckBoxEdit checkBox = new myCheckBoxEdit(); myLabelEdit labelName = new myLabelEdit(); myLabelEdit description = new myLabelEdit(); myNumericUpDown number = new myNumericUpDown(); checkBox.objectID = foodID; picBox.objectID = foodID; number.objectID = foodID; x = (count % 2 == 0) ? 0 : x + 500; // Location picBox.Location = new Point(x, y); labelName.Location = new Point(x + width + 10, y); description.Location = new Point(x + width + 10, y + 30); checkBox.Location = new Point(x + width + 220, y); number.Location = new Point(x + width + 260, y + 10); // Sau 2 món thì Xuống dòng if (count % 2 != 0) { y += 100; } //Numeric number.Value = 1; number.Maximum = 20; number.Minimum = 1; number.Width = 30; // Label Name labelName.Text = item.FoodDrinkName; labelName.Name = "FoodName" + foodID; labelName.AutoSize = false; labelName.Width = 200; labelName.Height = 30; labelName.Font = new Font("SVN-Avo", 15); labelName.ForeColor = Color.Black; // Description description.Text = item.Description; description.Name = "FoodDes" + foodID; description.Font = new Font("SVN-Avo", 12); description.ForeColor = Color.Black; description.Width = 200; description.Height = 70; // PicBox picBox.ImageLocation = item.ImageURL; picBox.Name = "FoodPic" + foodID; picBox.ClientSize = new Size(width, height); picBox.SizeMode = PictureBoxSizeMode.StretchImage; // checkBox checkBox.Name = "FoodDel" + foodID; checkBox.ClientSize = new Size(40, 40); checkBox.Width = 20; // List //lslabelName.Add(labelName); //lsdescription.Add(description); //lspicBox.Add(picBox); //lspicDelete.Add(picDelete); //lstxtName.Add(txtName); //lstxtDes.Add(txtDescription); lsNumeric.Add(number); checkBox.Click += new EventHandler(CheckBoxClick); number.ValueChanged += new EventHandler(NumericValueChanged); number.Visible = false; number.Enabled = false; if (isFood == true) { panel_Food.Controls.Add(picBox); panel_Food.Controls.Add(labelName); panel_Food.Controls.Add(description); panel_Food.Controls.Add(checkBox); panel_Food.Controls.Add(number); } else { panel_Drink.Controls.Add(picBox); panel_Drink.Controls.Add(labelName); panel_Drink.Controls.Add(description); panel_Drink.Controls.Add(checkBox); panel_Drink.Controls.Add(number); } count++; } }