public void LoadTable() { flpTable.Controls.Clear(); List <Table> listTable = new List <Table>(); FoodTableDAL TblDAL = new FoodTableDAL(); listTable = TblDAL.GetListTable(); foreach (Table item in listTable) { Button btn = new Button() { Width = FoodTableDAL.TableWidth, Height = FoodTableDAL.TableHeight }; btn.Text = item.Name + Environment.NewLine + item.Status; btn.Click += btn_Click; btn.Tag = item; switch (item.Status) { case "Trống": btn.BackColor = Color.Blue; break; default: btn.BackColor = Color.Red; break; } flpTable.Controls.Add(btn); } }
public void LoadTable() { flpTable.Controls.Clear(); List <Table> listTable = new List <Table>(); FoodTableDAL TblDAL = new FoodTableDAL(); listTable = TblDAL.GetListTable(); foreach (Table item in listTable) { Button btn = new Button() { Width = 80, Height = 80 }; btn.Text = item.Name + "\n" + item.Status; btn.Click += btn_Click; // Lưu giá trị của table này vào thẻ Tag btn.Tag = item; if (item.Status == "Trống") { btn.BackColor = Color.Blue; } else { btn.BackColor = Color.Red; } flpTable.Controls.Add(btn); } }
void LoadCmbTable(ComboBox cmb) { cmb.DataSource = ftDAL.GetListTable(); cmb.DisplayMember = "TableName"; }