public void loadProduct() { flowLayoutProduct.Controls.Clear(); List <ListProduct> listProducts = new List <ListProduct>(); PRODUCTs pd = new PRODUCTs(); DataTable dt = new DataTable(); dt = pd.getPRODUCTS(); if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { ListProduct product = new ListProduct(item); listProducts.Add(product); } foreach (ListProduct item in listProducts) { Button bt = new Button() { Width = ListProduct.Width, Height = ListProduct.Height }; bt.Font = new Font("Times New Roman", 22F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); bt.ForeColor = Color.Navy; bt.BackColor = flowLayoutProduct.BackColor; bt.BackgroundImage = item.picture; bt.BackgroundImageLayout = ImageLayout.Zoom; bt.FlatAppearance.BorderColor = Color.Navy; bt.FlatAppearance.BorderSize = 5; bt.FlatStyle = FlatStyle.Flat; bt.Text = item.Name; bt.TextAlign = ContentAlignment.BottomCenter; bt.Tag = item; flowLayoutProduct.Controls.Add(bt); flowLayoutProduct.Refresh(); } } }
//HÀM XỬ LÝ public void loadMachine() { flowLayoutMachine.Controls.Clear(); List <ListMachine> listMachines = new List <ListMachine>(); ADDMACHINES mc = new ADDMACHINES(); DataTable dt = new DataTable(); dt = mc.getMACHINE(); if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { ListMachine machine = new ListMachine(item); listMachines.Add(machine); } foreach (ListMachine item in listMachines) { Button bt = new Button() { Width = ListMachine.Width, Height = ListMachine.Height }; bt.Font = new Font("Times New Roman", 22F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); bt.ForeColor = Color.Navy; bt.BackColor = flowLayoutMachine.BackColor; bt.BackgroundImage = item.Picture; bt.BackgroundImageLayout = ImageLayout.Zoom; bt.FlatAppearance.BorderColor = Color.Navy; bt.FlatAppearance.BorderSize = 5; bt.FlatStyle = FlatStyle.Flat; bt.Text = item.NameMachine; bt.TextAlign = ContentAlignment.BottomCenter; bt.Tag = item; this.flowLayoutMachine.Controls.Add(bt); this.flowLayoutMachine.Refresh(); } } }