private void loadTables() { tea01Entities2 db = new tea01Entities2(); var tables = db.TableSpaces.ToList(); listButtonTable = new List <buttonCustom>(); foreach (var i in tables) { buttonCustom btn = new buttonCustom(); btn.Text = i.TableName; btn.idItem = i.TableId; btn.Size = new Size(180, 80); Image image; btn.Click += (s, e) => { inforTable.Text = btn.Text; updateGridViewCustomerActive(i.TableId); currentIdTable = i.TableId; if (i.Status == 1) { btnSubmitTable.Text = "Xác nhận chọn: " + i.TableName; idTableChoose = i.TableId; } else { MessageBox.Show("Bàn này đã đủ người"); btnSubmitTable.Text = "Xác nhận chọn: "; idTableChoose = ""; } }; if (i.Status == 1) { image = Image.FromFile("D:\\TeaManagement\\Project\\bin\\Debug\\Images\\tableActive.png"); } else { image = Image.FromFile("D:\\TeaManagement\\Project\\bin\\Debug\\Images\\tableNotActive.png"); } btn.Image = image; btn.BackgroundImageLayout = ImageLayout.Stretch; /*btn.ImageAlign = ContentAlignment.MiddleRight; * btn.TextAlign = ContentAlignment.MiddleLeft; */ listButtonTable.Add(btn); } panel.Controls.Clear(); foreach (buttonCustom i in listButtonTable) { panel.Controls.Add(i); } }
private void updatePanelTopping() { tea01Entities2 db = new tea01Entities2(); var toppings = db.Toppings.ToList(); Random rand = new Random(); Color[] c = { Color.Red, Color.Blue, Color.Green, Color.Cyan, Color.Magenta }; listButtonTopping = new List <buttonCustom>(); foreach (var i in toppings) { //Bunifu.UI.WinForms.BunifuButton.BunifuButton btn = new Bunifu.UI.WinForms.BunifuButton.BunifuButton(); buttonCustom btn = new buttonCustom(); btn.Text = i.ToppingName + " " + i.Price + "đ"; btn.idItem = i.ToppingId; btn.Size = new Size(120, 80); Image image; Label lb = new Label(); lb.Size = new Size(20, 20); lb.Text = "0"; btn.Click += (s, e) => { currentTopping = btn; currentLabelTopping = lb; toppingClick(); }; btn.BackColor = c[rand.Next(0, c.Length)]; btn.ForeColor = Color.White; btn.Font = new Font(btn.Font.FontFamily, 10); btn.Font = new Font(btn.Font, FontStyle.Bold); btn.ForeColorChanged += (s, e) => { btn.Font = new Font(btn.Font, FontStyle.Bold); }; btn.BackgroundImageLayout = ImageLayout.Stretch; /*btn.ImageAlign = ContentAlignment.MiddleRight; * btn.TextAlign = ContentAlignment.MiddleLeft; */ listButtonTopping.Add(btn); listLabelTopping.Add(lb); } panelTopping.Controls.Clear(); for (int i = 0; i < listButtonTopping.Count; i++) { panelTopping.Controls.Add(listButtonTopping[i]); panelTopping.Controls.Add(listLabelTopping[i]); } }
private void updatePanelTea() { tea01Entities2 db = new tea01Entities2(); var drinks = db.Drinks.ToList(); listButtonTea = new List <buttonCustom>(); foreach (var i in drinks) { //Bunifu.UI.WinForms.BunifuButton.BunifuButton btn = new Bunifu.UI.WinForms.BunifuButton.BunifuButton(); buttonCustom btn = new buttonCustom(); btn.Text = i.DrinkName + " " + i.Price.ToString() + "đ"; btn.idItem = i.DrinkId; btn.Size = new Size(120, 80); Image image; Label lb = new Label(); lb.Size = new Size(20, 20); lb.Text = "0"; btn.Click += (s, e) => { //MessageBox.Show(btn.idItem); currentTea = btn; currentLabel = lb; teaClick(); }; image = Image.FromFile(i.Image); btn.BackgroundImage = image; btn.ForeColor = Color.White; btn.Font = new Font(btn.Font.FontFamily, 10); btn.Font = new Font(btn.Font, FontStyle.Bold); btn.ForeColorChanged += (s, e) => { btn.Font = new Font(btn.Font, FontStyle.Bold); }; btn.BackgroundImageLayout = ImageLayout.Stretch; /*btn.ImageAlign = ContentAlignment.MiddleRight; * btn.TextAlign = ContentAlignment.MiddleLeft; */ listButtonTea.Add(btn); listLabelTea.Add(lb); } panelTea.Controls.Clear(); for (int i = 0; i < listButtonTea.Count; i++) { panelTea.Controls.Add(listButtonTea[i]); panelTea.Controls.Add(listLabelTea[i]); } }
private void comboBox_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox.SelectedItem.ToString() == "Tất cả") { updatePanelTea(); } else { String[] i = comboBox.SelectedItem.ToString().Split('-'); tea01Entities2 db = new tea01Entities2(); DrinkType type = db.DrinkTypes.Find(i[1]); listButtonTea.Clear(); listButtonTea = new List <buttonCustom>(); listLabelTea.Clear(); listLabelTea = new List <Label>(); foreach (var iter in type.Drinks) { buttonCustom btn = new buttonCustom(); btn.Text = iter.DrinkName + " " + iter.Price.ToString() + "đ"; btn.idItem = iter.DrinkId; btn.Size = new Size(120, 80); Image image; Label lb = new Label(); lb.Size = new Size(20, 20); lb.Text = "0"; btn.Click += (s, ee) => { //MessageBox.Show(btn.idItem); currentTea = btn; currentLabel = lb; teaClick(); }; image = Image.FromFile(iter.Image); btn.BackgroundImage = image; btn.ForeColor = Color.White; btn.Font = new Font(btn.Font.FontFamily, 10); btn.Font = new Font(btn.Font, FontStyle.Bold); btn.ForeColorChanged += (s, ee) => { btn.Font = new Font(btn.Font, FontStyle.Bold); }; btn.BackgroundImageLayout = ImageLayout.Stretch; /*btn.ImageAlign = ContentAlignment.MiddleRight; * btn.TextAlign = ContentAlignment.MiddleLeft; */ listButtonTea.Add(btn); listLabelTea.Add(lb); } panelTea.Controls.Clear(); for (int ii = 0; ii < listButtonTea.Count; ii++) { panelTea.Controls.Add(listButtonTea[ii]); panelTea.Controls.Add(listLabelTea[ii]); } } }