protected void ddlLoaiSanpham_SelectedIndexChanged(object sender, EventArgs e) { lblThongbaoLoaiSanphamNgungKinhdoanh.Text = string.Empty; SanphamController brlSanpham = new SanphamController(); List <SanphamModel> glstSanpham; int loaiSanphamID = Convert.ToInt32(ddlLoaiSanpham.SelectedValue); if (loaiSanphamID < 1) { glstSanpham = brlSanpham.SanphamGetbyPK(0); } else { glstSanpham = brlSanpham.SanphamGetbyFK_iloaiSanphamID(loaiSanphamID); List <LoaiSanphamModel> glstLoaisanpham = brlSanpham.LoaiSanphamGetbyPK(loaiSanphamID); if (glstLoaisanpham.Count > 0) { if (glstLoaisanpham[0].IsNgungKinhdoanh) { lblThongbaoLoaiSanphamNgungKinhdoanh.Text = string.Format("Thông báo: Loại sản phẩm <b>\"{0}\"</b> này đã ngừng kinh doanh.", glstLoaisanpham[0].sTenLoaiSanpham); } } } glstSanpham.Sort((sp1, sp2) => sp1.sTenSanpham.CompareTo(sp2.sTenSanpham)); rptSanpham.DataSource = glstSanpham; rptSanpham.DataBind(); }
private void hienthiThongtinSanpham(long sanphamID) { SanphamController BRLsanpham = new SanphamController(); List <SanphamModel> glstSanpham = BRLsanpham.SanphamGetbyPK(sanphamID); if (glstSanpham.Count < 1) { Response.Redirect("~/DanhsachSanpham.aspx"); } int loaispID = glstSanpham[0].FK_iLoaiSanphamID; if (loaispID > 0) { List <LoaiSanphamModel> glstLoaiSanpham = BRLsanpham.LoaiSanphamGetbyPK(loaispID); if (glstSanpham.Count > 0) { lblLoaiSanpham.Text = glstLoaiSanpham[0].sTenLoaiSanpham; } } imageSanpham.ImageUrl = string.Format("~/{0}", glstSanpham[0].sHinhanh); lblTenSanpham.Text = glstSanpham[0].sTenSanpham; decimal giaDangapdung = BRLsanpham.GetGiaDangApdungByFKSanphamID(glstSanpham[0].PK_iSanphamID); if (giaDangapdung > 0) { lblGiaChuaKhuyenmai.Text = string.Format("{0:C0}", giaDangapdung); } else { lblGiaChuaKhuyenmai.Text = "Liên hệ"; } }
protected void rptSanpham_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SanphamModel sanpham = e.Item.DataItem as SanphamModel; if (sanpham != null) { Image imgSanpham = e.Item.FindControl("imgSanpham") as Image; if (imgSanpham != null) { imgSanpham.ImageUrl = string.Format("~/{0}", sanpham.sHinhanh); } Literal ltrGiaDangApdung = e.Item.FindControl("ltrGiaDangApdung") as Literal; SanphamController brlSanpham = new SanphamController(); if (ltrGiaDangApdung != null) { decimal giaDangApdung = brlSanpham.GetGiaDangApdungByFKSanphamID(sanpham.PK_iSanphamID); ltrGiaDangApdung.Text = giaDangApdung < 0 ? "Liên hệ" : giaDangApdung.ToString("C0"); } Literal ltrLoaiSanpham = e.Item.FindControl("ltrLoaiSanpham") as Literal; if (ltrLoaiSanpham != null) { int loaiSanphamID = sanpham.FK_iLoaiSanphamID; if (loaiSanphamID > 0) { List <LoaiSanphamModel> glstLoaisanpham = brlSanpham.LoaiSanphamGetbyPK(loaiSanphamID); if (glstLoaisanpham.Count > 0) { ltrLoaiSanpham.Text = glstLoaisanpham[0].sTenLoaiSanpham; } } } Literal ltrKhuyenmaiDangApdung = e.Item.FindControl("ltrKhuyenmaiDangApdung") as Literal; if (ltrKhuyenmaiDangApdung != null) { int khuyenmaiDangapdung = Convert.ToInt32(brlSanpham.GetKhuyenmaiDangApdungByFKSanphamID(sanpham.PK_iSanphamID) * 100); ltrKhuyenmaiDangApdung.Text = khuyenmaiDangapdung < 0 ? string.Empty : string.Format("{0}%", khuyenmaiDangapdung); } HyperLink hrefDieuChinhgia = e.Item.FindControl("hrefDieuChinhgia") as HyperLink; if (hrefDieuChinhgia != null) { hrefDieuChinhgia.NavigateUrl = string.Format("~/DieuchinhGia.aspx?gsp={0}", sanpham.PK_iSanphamID); } HyperLink hrefDieuChinhKhuyenmai = e.Item.FindControl("hrefDieuChinhKhuyenmai") as HyperLink; if (hrefDieuChinhKhuyenmai != null) { hrefDieuChinhKhuyenmai.NavigateUrl = string.Format("~/DieuchinhKhuyenmai.aspx?kmsp={0}", sanpham.PK_iSanphamID); } HyperLink hrefCongthuc = e.Item.FindControl("hrefCongthuc") as HyperLink; if (hrefCongthuc != null) { hrefCongthuc.NavigateUrl = string.Format("~/Congthuc.aspx?ctsp={0}", sanpham.PK_iSanphamID); } } //sanpham } //ItemType }
private void hienthiDulieuKhiSuaSanpham() { ltrThemSuaSanpham.Text = "Cập nhật thông tin sản phẩm"; panelNgungcungcap.Visible = true; btnThemSanpham.Visible = false; btnCapnhatSanpham.Visible = true; lblLoaiSanphamNayNgungkinhdoanh.Text = string.Empty; long sanphamID = Convert.ToInt64(Request.QueryString[m_QUERYSUA]); if (sanphamID < 1) { throw new ApplicationException("Mã sản phẩm không hợp lệ."); } SanphamController BrlSanpham = new SanphamController(); List <SanphamModel> glstSanpham = BrlSanpham.SanphamGetbyPK(sanphamID); if (glstSanpham.Count < 1) { throw new ApplicationException("Sản phẩm cần sửa không tồn tại."); } txtTensanpham.Text = glstSanpham[0].sTenSanpham; txtXuatxu.Text = glstSanpham[0].sXuatxu; txtMota.Text = glstSanpham[0].sMota; privewimg.ImageUrl = string.Format("~/{0}", glstSanpham[0].sHinhanh); cbIsNgungcungcap.Checked = glstSanpham[0].isNgungcungcap; hienthiLoaisanpham(); int loaiSanphamID = glstSanpham[0].FK_iLoaiSanphamID; if (loaiSanphamID > 0) { List <LoaiSanphamModel> glstLoaiSanpham = BrlSanpham.LoaiSanphamGetbyPK(loaiSanphamID); if (glstLoaiSanpham.Count > 0) { if (glstLoaiSanpham[0].IsNgungKinhdoanh) { lblLoaiSanphamNayNgungkinhdoanh.Text = string.Format("Thông báo: Loại sản phẩm <b>\"{0}\"</b> đã ngừng kinh doanh,<br>nếu cập nhật sản phẩm này sẽ chuyển sang loại sản phẩm được chọn.", glstLoaiSanpham[0].sTenLoaiSanpham); } ddlLoaiSanpham.ClearSelection(); ListItem itemLoaisanpham = ddlLoaiSanpham.Items.FindByValue(loaiSanphamID.ToString()); if (itemLoaisanpham != null) { itemLoaisanpham.Selected = true; } } } }
private void hienthiThongtinSanpham(long sanphamID) { SanphamController BRLsanpham = new SanphamController(); List <SanphamModel> glstSanpham = BRLsanpham.SanphamGetbyPK(sanphamID); if (glstSanpham.Count < 1) { Response.Redirect("~/DanhsachSanpham.aspx"); } int loaispID = glstSanpham[0].FK_iLoaiSanphamID; if (loaispID > 0) { List <LoaiSanphamModel> glstLoaiSanpham = BRLsanpham.LoaiSanphamGetbyPK(loaispID); if (glstSanpham.Count > 0) { lblLoaiSanpham.Text = glstLoaiSanpham[0].sTenLoaiSanpham; } } imageSanpham.ImageUrl = string.Format("~/{0}", glstSanpham[0].sHinhanh); lblTenSanpham.Text = glstSanpham[0].sTenSanpham; }