Ejemplo n.º 1
0
        public void loadTable(int tabType)//tabType = 1: tại chỗ, 2: Mang về, 3: Đặt chỗ, 4: Giao hàng
        {
            flpTable.Controls.Clear();
            List <Table> ListTables = TableDAO.Instance.LoadTable(tabType);

            foreach (Table item in ListTables)
            {
                Button btn = new Button()
                {
                    Width = TableDAO.BanWidth, Height = TableDAO.BanWidth
                };
                btn.Text             = item.TabName + Environment.NewLine + item.Status;
                btn.Tag              = item;
                btn.Name             = item.ID.ToString();
                btn.Font             = new Font("Arial", 18);
                btn.FlatStyle        = FlatStyle.Standard;
                btn.Margin           = new Padding(20);
                btn.ContextMenuStrip = cmsTable;
                btn.MouseHover      += (s, e) =>
                {
                    btn.BackColor = Color.Orange;
                };
                btn.MouseLeave += (s, e) =>
                {
                    Table tb = TableDAO.Instance.GetTable(item.ID);
                    if (tb.Status == "Trống")
                    {
                        btn.BackColor = Color.White;
                    }
                    else
                    {
                        btn.BackColor = Color.BlueViolet;
                    }
                };
                btn.Click += (s, e) =>
                {
                    fBill_Info f = new fBill_Info(item, userName);
                    f.idShift  = idShift;
                    f.parent   = this; //Thiết lập ràng buộc với form con
                    f.btParent = btn;  //Thiết lập ràng buộc với form con
                    f.Text     = item.TabName;
                    Hide();
                    f.Show();
                };
                switch (item.Status)
                {
                case "Trống":
                    btn.BackColor = Color.White;
                    flpTable.Controls.Add(btn);
                    break;

                default:
                    btn.BackColor = Color.BlueViolet;
                    flpTable.Controls.Add(btn);
                    break;
                }
            }
        }