private void TinhTien() { ThanhTien = 0; for (int i = 0; i < listItem.Count; i++) { int value = (int)(listItem[i].Tag); v_SanPham sp = dsVSP.Find(x => x.MaSP == value); ThanhTien += (int)sp.GiaBan * listItem[i].SoLuong; } if (listItem.Count == 0) { pnThanhToan.Visible = false; } else { lblThanhTien.Text = "× " + string.Format("{0:n0}", ThanhTien) + " &đ"; } }
private void DetailProduct_Load(object sender, EventArgs e) { try { blSP = new BLSanPham(); blNL = new BLNguyenLieu(); dsNL = blNL.dsNguyenLieu(); dsSP = blSP.dsSanPham(); cbNguyenLieu.BeginUpdate(); dsNL.ForEach(x => cbNguyenLieu.Items.Add(x.TenNL)); cbNguyenLieu.EndUpdate(); if (Them == true) { lblName.Text = "ADD"; } else { v_SanPham vsp = blSP.dsVSanPham().Find(x => x.MaSP == sp.MaSP); lblName.Text = "EDIT"; txtTenSP.Text = sp.TenSP; txtGiaBan.Text = vsp.GiaBan.ToString(); txtGiaGoc.Text = vsp.GiaGoc.ToString(); txtLoiNhuan.Text = sp.LoiNhuan.ToString(); txtGiamGia.Text = sp.GiamGia.ToString(); picSP.BackgroundImage = ConvertImage((byte[])sp.HinhSP.ToArray()); pnKind.Visible = false; pnPhanTram.Location = new Point(pnKind.Location.X, pnKind.Location.Y + 10); dsDGV = blNL.dsNguyenLieuDGV(sp); LoadData(); } } catch { MessageBox.Show("Bạn không có quyền truy cập"); } }