private void Menu_Click(object sender, EventArgs e) { pnThanhToan.Visible = true; PicItem pi = sender as PicItem; pi.Count++; listItem.Remove(listItem.Find(i => i.Tag == pi.Tag)); Item item = new Item() { Tag = pi.Tag, PicSP = pi.PicSP, TenSP = pi.TenSP, GiaBan = "× " + pi.GiaBan, SoLuong = pi.Count, }; listItem.Add(item); flpSanPham.Controls.Clear(); listItem.ForEach(i => flpSanPham.Controls.Add(i)); TinhTien(); for (int i = 0; i < listItem.Count; i++) { listItem[i].Click += MenuItemClick; } }
private void Menu_Load(object sender, EventArgs e) { pnThanhToan.Visible = false; string message; bool result = blSP.Reader(out message); if (result == false) { MessageBox.Show(message); } dsSP = blSP.dsSP; for (int i = 0; i < dsSP.Count; i++) { if (dsSP[i].TT_Ban == false) { continue; } listPi[i] = new PicItem() { Tag = dsSP[i].MaSP, TenSP = dsSP[i].TenSP, GiaBan = string.Format("{0:n0}", dsSP[i].GiaBan) + " &đ", PicSP = dsSP[i].HinhSP, Count = 0, }; listPi[i].Click += Menu_Click; AddControl(listPi[i]); } }
public void AddControl(PicItem pi) { int Ma = (int)pi.Tag; if (Ma >= 100 && Ma < 200) { flpBurger.Controls.Add(pi); } else if (Ma >= 200 && Ma < 300) { flpChicken.Controls.Add(pi); } else if (Ma >= 300 && Ma < 400) { flpChickenSet.Controls.Add(pi); } else if (Ma >= 400 && Ma < 500) { flpCombo.Controls.Add(pi); } else if (Ma >= 500 && Ma < 600) { flpValue.Controls.Add(pi); } else if (Ma >= 600 && Ma < 700) { flpSet.Controls.Add(pi); } else if (Ma >= 700 && Ma < 800) { flpDessert.Controls.Add(pi); } else { flpDrink.Controls.Add(pi); } }
private void Menu_Load(object sender, EventArgs e) { pnThanhToan.Visible = false; dsSP = blSP.dsSanPham(); for (int i = 0; i < dsSP.Count; i++) { if (dsSP[i].TT_Ban == false) { continue; } listPi[i] = new PicItem() { Tag = dsSP[i].MaSP, TenSP = dsSP[i].TenSP, GiaBan = string.Format("{0:n0}", dsSP[i].GiaBan) + " &đ", PicSP = ConvertImage((byte[])dsSP[i].HinhSP.ToArray()), Count = 0, }; listPi[i].Click += Menu_Click; AddControl(listPi[i]); } }