protected void rptGroup_ItemDataBound(object sender, RepeaterItemEventArgs e) { RepeaterItem item = e.Item; if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { string id = DataBinder.Eval(item.DataItem, "Id").ToString(); string itemCnt = DataBinder.Eval(item.DataItem, "Items").ToString(); DataTable dtPro = ProductService.Product_GetByTop("", "Active = 1 AND IsPopular=1 AND GroupId=" + id, "Id DESC"); if (dtPro.Rows.Count == 0) { item.Visible = false; } Repeater rptPro = (Repeater)item.FindControl("rptPro"); Repeater rptProducts04 = (Repeater)item.FindControl("rptProducts04"); if (rptPro != null) { HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART]; switch (itemCnt) { case "4": rptProducts04.DataSource = StringClass.ModifyDataProduct(dtPro, cookie); rptProducts04.DataBind(); break; default: rptPro.DataSource = StringClass.ModifyDataProduct(dtPro, cookie); rptPro.DataBind(); break; } } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Page.RouteData.Values["Id"] != null) { chudeId = Page.RouteData.Values["Id"] as string; } DataTable dtPro = null; if (!IsPostBack) { if (Request.QueryString["key"] != null) { string key = StringClass.SqlInjection(Request.QueryString["key"].ToString()); dtPro = ProductService.Product_GetByTop("12", "Active=1 AND (Name like '%" + key + "%' OR Detail like '%" + key + "%' OR Content like '%" + key + "%')", "Id DESC"); } else if (Microsoft.VisualBasic.Information.IsNumeric(chudeId)) { dtPro = ProductService.Product_GetByTop("", "Active=1 AND ChudeId like '%," + chudeId + ",%'", "Ord"); } else if (string.IsNullOrEmpty(level)) { dtPro = ProductService.Product_GetByTop("12", "Active=1", "Ord"); } else { dtPro = ProductService.Product_GetByTop("", "Active=1 AND GroupId IN (Select Id from GroupProduct Where Active=1 AND Left(Level,Len('" + level + "'))='" + level + "')", "Id DESC"); } HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART]; switch (itemCnt) { case "4": rptProducts04.DataSource = StringClass.ModifyDataProduct(dtPro, cookie); rptProducts04.DataBind(); break; default: rptProducts.DataSource = StringClass.ModifyDataProduct(dtPro, cookie); rptProducts.DataBind(); break; } } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values["Id"] != null) { id = Page.RouteData.Values["Id"] as string; } if (Page.RouteData.Values["groupName"] != null) { groupname = Page.RouteData.Values["groupName"] as string; } if (Session["Info"] != null) { cus = (Customers)Session["Info"]; isLogin = true; DataTable dtCount = DownloadHistoryService.DownloadHistory_GetByUserId(cus.Id); if (dtCount.Rows.Count < 2) { isValidDownload = true; } } try { if (Microsoft.VisualBasic.Information.IsNumeric(id)) { DataTable pro = ProductService.Product_GetById(id); if (pro.Rows.Count > 0) { name = pro.Rows[0]["Name"].ToString(); Page.Title = name; content = pro.Rows[0]["Content"].ToString(); ltrDetail.Text = pro.Rows[0]["Detail"].ToString(); sImage_01 = pro.Rows[0]["Image1"].ToString(); sPrice = pro.Rows[0]["Price"].ToString(); hdPrice.Value = sPrice; if (sPrice.IndexOf(",") > -1) { sPrice = sPrice.Split(Char.Parse(","))[0]; } if (pro.Rows[0]["IsSpecial"].ToString() == "1") { isShowDownload = true; } if (!IsPostBack) { string strSize = pro.Rows[0]["Image5"].ToString(); string[] lSize; if (strSize.IndexOf(",") > -1) { lSize = strSize.Split(Char.Parse(",")); } else { lSize = new string[] { strSize }; } for (int i = 0; i < lSize.Length; i++) { if (lSize[i] == string.Empty) { continue; } ddlSize.Items.Add(new ListItem(lSize[i], lSize[i])); } ddlSize.DataBind(); ddlSize.SelectedIndex = 0; //Hiển thị sản phẩm tương tự List <GroupProduct> lstG = GroupProductService.GroupProduct_GetById(pro.Rows[0]["GroupId"].ToString()); string itemCnt = string.Empty; if (lstG.Count > 0) { itemCnt = lstG[0].Items; } if (string.IsNullOrEmpty(itemCnt) || itemCnt == "0") { itemCnt = "3"; } DataTable dtRelated = ProductService.Product_GetByTop((Int16.Parse(itemCnt) * 2).ToString(), "Active = 1 AND GroupId='" + pro.Rows[0]["GroupId"].ToString() + "' AND Id <> '" + id + "'", "Ord"); if (dtRelated.Rows.Count > 0) { HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART]; switch (itemCnt) { case "4": rptProducts04.DataSource = StringClass.ModifyDataProduct(dtRelated, cookie); rptProducts04.DataBind(); break; default: rptProducts.DataSource = StringClass.ModifyDataProduct(dtRelated, cookie); rptProducts.DataBind(); break; } } } } } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace); } }