protected void Update_Click(object sender, EventArgs e) { if (Page.IsValid) { Data.GroupProduct obj = new Data.GroupProduct(); obj.Id = Id; obj.Name = txtName.Text; obj.Level = Level + "00000"; obj.Position = chkPosition.Checked ? "1" : "0"; obj.Ord = txtOrd.Text != "" ? txtOrd.Text : "1"; obj.Active = chkActive.Checked ? "1" : "0"; obj.Items = txtItems.Text.Trim(); if (Insert == true) { GroupProductService.GroupProduct_Insert(obj); } else { GroupProductService.GroupProduct_Update(obj); } BindGrid(); pnView.Visible = true; pnUpdate.Visible = false; Level = ""; Insert = false; } }
private void BindGrid() { if (drlnhom.SelectedValue == "") { grdProduct.DataSource = ProductService.Product_GetByAll(); grdProduct.DataBind(); if (grdProduct.PageCount <= 1) { grdProduct.PagerStyle.Visible = false; } else { grdProduct.PagerStyle.Visible = true; } } else { String level = String.Empty; List <Data.GroupProduct> listG = GroupProductService.GroupProduct_GetById(drlnhom.SelectedValue); if (listG.Count > 0) { level = listG[0].Level; } grdProduct.DataSource = ProductService.Product_GetByTop("", "GroupId IN (Select Id From GroupProduct WHERE left(Level,len('" + level + "'))='" + level + "')", "Ord"); grdProduct.DataBind(); if (grdProduct.PageCount <= 1) { grdProduct.PagerStyle.Visible = false; } else { grdProduct.PagerStyle.Visible = true; } } }
private void BindGrid() { grdGroupProduct.DataSource = GroupProductService.GroupProduct_GetByAll(); grdGroupProduct.DataBind(); if (grdGroupProduct.PageCount <= 1) { grdGroupProduct.PagerStyle.Visible = false; } else { grdGroupProduct.PagerStyle.Visible = true; } }
public void TestCaseSetup() { _groupProductDB = new GroupProductDB { Id = "00000000-0000-0000-0000-000000000004", GroupBoardId = "00000000-0000-0000-0000-000000000003", Information = "Information", ProductId = "2" }; _groupProduct = new GroupProduct { Id = "00000000-0000-0000-0000-000000000004", GroupBoardId = "00000000-0000-0000-0000-000000000003", Information = "Information", ProductId = "2" }; _groupBoardDB = new GroupBoardDB { Id = "00000000-0000-0000-0000-000000000003", CreatorId = "2", Information = "Some product", Name = "Best", Created = DateTime.UtcNow, Deleted = null, IsNotDeleted = true, Modified = DateTime.UtcNow, GroupId = "00000000-0000-0000-0000-000000000001", GroupProducts = null }; _groupUserDB = new GroupUserDB { GroupId = "00000000-0000-0000-0000-000000000001", RightToCreateBoards = true }; _groupRepositoryMock = new Mock <IGroupRepository>(); var config = new MapperConfiguration(cfg => { cfg.AddProfile(new GroupProfile()); cfg.AddProfile(new GroupBoardProfile()); cfg.AddProfile(new GroupProductProfile()); cfg.AddProfile(new GroupUserProfile()); cfg.AddProfile(new GroupCommentProfile()); }); _mapper = (new Mapper(config)).DefaultContext.Mapper; _groupProductService = new GroupProductService(_groupRepositoryMock.Object, _mapper); _selectedBoardList = new List <GroupBoardDB>(); _selectedUserList = new List <GroupUserDB>(); _selectedProductList = new List <GroupProductDB>(); }
protected void Page_Load(object sender, EventArgs e) { if (Page.RouteData.Values["GroupId"] != null) { id = Page.RouteData.Values["GroupId"] as string; } if (Page.RouteData.Values["Id"] != null) { chudeId = Page.RouteData.Values["Id"] as string; } if (!IsPostBack) { if (Microsoft.VisualBasic.Information.IsNumeric(id)) { List <Data.GroupProduct> listGroup = GroupProductService.GroupProduct_GetById(id); if (listGroup.Count > 0) { DataTable dt = GroupProductService.GroupProduct_GetByTop("", "Active = 1 AND Len(Level) > " + listGroup[0].Level.Length + " AND Left(Level,Len('" + listGroup[0].Level + "'))='" + listGroup[0].Level + "' AND Id <> " + id, ""); if (dt.Rows.Count > 0) { idU_ProductList.Visible = false; U_GroupProductList.Visible = true; U_GroupProductList.GroupProduct = dt; } else { idU_ProductList.Visible = true; U_GroupProductList.Visible = false; idU_ProductList.Level = listGroup[0].Level; idU_ProductList.ItemCount = listGroup[0].Items; } lblGroupName.Text = listGroup[0].Name; } } else if (Microsoft.VisualBasic.Information.IsNumeric(chudeId)) { DataTable chude = ChudeService.Chude_GetById(chudeId); if (chude.Rows.Count > 0) { lblGroupName.Text = chude.Rows[0]["Name"].ToString(); idU_ProductList.ChudeId = chudeId; } } if (Request.QueryString["key"] != null) { lblGroupName.Text = Request.QueryString["key"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { DataTable dtConfig = ConfigService.Config_GetByTop("1", "", ""); if (dtConfig.Rows.Count > 0) { Page.Title = dtConfig.Rows[0]["Title"].ToString(); Page.MetaDescription = dtConfig.Rows[0]["Description"].ToString(); Page.MetaKeywords = dtConfig.Rows[0]["Keyword"].ToString(); } //Giới thiệu về chúng tôi DataTable dt = PageService.Page_GetByTop("1", "Name like N'%giới thiệu%'", ""); if (dt.Rows.Count > 0) { sAboutName = dt.Rows[0]["Name"].ToString(); sContents = dt.Rows[0]["Description"].ToString(); sUrl = dt.Rows[0]["Link"].ToString(); } dt.Clear(); HttpCookie cookie = Request.Cookies[Consts.GUID_SHOPPING_CART]; DataTable dtGroup = GroupProductService.GroupProduct_GetByTop("", "Active=1 And Position=1", "Level, Ord"); DataTable dtTop = dtGroup.AsEnumerable().Take(2).CopyToDataTable(); for (int i = 0; i < dtGroup.Rows.Count; i++) { if (i < 2) { dtGroup.Rows[i].Delete(); } } dtGroup.AcceptChanges(); rptGroup.DataSource = StringClass.ModifyDataGroupProduct(dtTop); rptGroup.DataBind(); rptGroup01.DataSource = StringClass.ModifyDataGroupProduct(dtGroup); rptGroup01.DataBind(); } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message + "\n" + ex.StackTrace); } }
protected void grdGroupProduct_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); string strA = ""; string str = e.Item.Cells[2].Text; SqlDataProvider sql = new SqlDataProvider(); switch (e.CommandName) { case "AddSub": Level = strCA; AddButton_Click(source, e); break; case "Edit": Insert = false; Id = strCA; List <Data.GroupProduct> listE = GroupProductService.GroupProduct_GetById(Id); Level = listE[0].Level.Substring(0, listE[0].Level.Length - 5); txtName.Text = listE[0].Name; chkPosition.Checked = listE[0].Position == "1" || listE[0].Position == "True"; txtItems.Text = listE[0].Items; txtOrd.Text = listE[0].Ord; chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "True"; pnView.Visible = false; pnUpdate.Visible = true; break; case "Active": strA = str == "1" ? "0" : "1"; sql.ExecuteNonQuery("Update [GroupProduct] set Active=" + strA + " Where Id='" + strCA + "'"); BindGrid(); break; case "Delete": GroupProductService.GroupProduct_Delete(strCA); BindGrid(); break; case "cmdPosition": str = e.Item.Cells[3].Text; strA = str == "True" ? "False" : "True"; sql.ExecuteNonQuery("Update [GroupProduct] set Position='" + strA + "' Where Id='" + strCA + "'"); BindGrid(); break; } }
private void LoadDropDownListPageLink() { ddlLink.Items.Clear(); ddlLink.Items.Add(new ListItem("Trang chủ", "/")); DataTable dt = new DataTable(); dt = GroupNewsService.GroupNews_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Tin tức", "#")); for (int i = 0; i < dt.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(dt.Rows[i]["Name"].ToString(), dt.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_TIN_TUC, dt.Rows[i]["Id"].ToString(), dt.Rows[i]["Name"].ToString()))); } List <Data.GroupImages> listG = GroupImagesService.GroupImages_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Hình ảnh", "#")); if (listG.Count > 0) { for (int i = 0; i < listG.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listG[i].Name, listG[i].Level + "00000"), "/Thu-vien-anh/" + listG[i].Id + "/" + StringClass.NameToTag(listG[i].Name))); } } DataTable listGProduct = GroupProductService.GroupProduct_GetByTop("", "Active=1", "Level, Ord"); ddlLink.Items.Add(new ListItem("Sản phẩm", "#")); if (listGProduct.Rows.Count > 0) { for (int i = 0; i < listGProduct.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listGProduct.Rows[i]["Name"].ToString(), listGProduct.Rows[i]["Level"].ToString() + "00000"), PageHelper.GeneralGroupUrl(Consts.CON_SAN_PHAM, listGProduct.Rows[i]["Id"].ToString(), listGProduct.Rows[i]["Name"].ToString()))); } } DataTable listChude = ChudeService.Chude_GetByTop("", "Active=1", "Ord"); ddlLink.Items.Add(new ListItem("Chủ đề", "#")); if (listChude.Rows.Count > 0) { for (int i = 0; i < listChude.Rows.Count; i++) { ddlLink.Items.Add(new ListItem(StringClass.ShowNameLevel(listChude.Rows[i]["Name"].ToString(), "0000000000"), "/chu-de/chu-de-" + listChude.Rows[i]["Id"].ToString() + "/" + StringClass.NameToTag(listChude.Rows[i]["Name"].ToString()))); } } ddlLink.Items.Add(new ListItem("Liên hệ", "/lien-he")); ddlLink.DataBind(); }
private void LoadDropDownListGroupProduct() { ddlGroupProduct.Items.Clear(); drlnhom.Items.Clear(); ddlGroupProduct.Items.Add(new ListItem("--Chọn nhóm sản phẩm--", "")); drlnhom.Items.Add(new ListItem("--Chọn nhóm sản phẩm--", "")); DataTable dtGroup; dtGroup = GroupProductService.GroupProduct_GetByTop("", "Active = 1", "Level, Ord"); for (int i = 0; i < dtGroup.Rows.Count; i++) { DataRow row = dtGroup.Rows[i]; ddlGroupProduct.Items.Add(new ListItem(Common.StringClass.ShowNameLevel(row["Name"].ToString(), row["Level"].ToString()), row["Id"].ToString())); drlnhom.Items.Add(new ListItem(Common.StringClass.ShowNameLevel(row["Name"].ToString(), row["Level"].ToString()), row["Id"].ToString())); } ddlGroupProduct.DataBind(); drlnhom.DataBind(); }
protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdGroupProduct.Items.Count; i++) { item = grdGroupProduct.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; GroupProductService.GroupProduct_Delete(strId); } } } grdGroupProduct.CurrentPageIndex = 0; BindGrid(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { string groupId = string.Empty; string level = string.Empty; int count = 0; string strUrl = string.Empty; List <GroupProduct> listG = GroupProductService.GroupProduct_GetByTop("", "Active=1", "Level, Ord"); if (listG.Count > 0) { for (int i = 0; i < listG.Count; i++) { if (listG[i].Level.Length == 5) { List <GroupProduct> listSub = listG.Where(l => l.Level.Length == 10 && l.Level.Substring(0, 5) == listG[i].Level).ToList(); ltrmenu.Text += "<div class='layered_filter'>\n"; ltrmenu.Text += "<div class='layered_subtitle_heading'>\n"; count = ProductService.Product_GetCount(listG[i].Level); ltrmenu.Text += "<input type='checkbox' class='checkbox' name='layer_id_attribute_group_" + (i + 1).ToString() + "' id='layered_id_attribute_group_" + (i + 1).ToString() + "' value='" + listG[i].Id + "' />\n"; ltrmenu.Text += "<label for='layer_id_attribute_group_" + (i + 1).ToString() + "'>\n"; strUrl = PageHelper.GeneralGroupUrl(Consts.CON_SAN_PHAM, listG[i].Id, listG[i].Name); ltrmenu.Text += "<a href='" + strUrl + "'>"; ltrmenu.Text += "<strong>" + listG[i].Name + "</strong>\n"; count = ProductService.Product_GetCount(listG[i].Level); ltrmenu.Text += "<span>(" + count.ToString() + ")</span></a>\n</label></div>\n"; if (listSub.Count > 0) { ltrmenu.Text += "<ul id='ul_layered_id_attribute_group_" + (i + 1).ToString() + "' class='col-lg-12 layered_filter_ul'>\n"; for (int j = 0; j < listSub.Count; j++) { ltrmenu.Text += "<li class='nomargin hiddable col-lg-12'>\n"; ltrmenu.Text += "<input type='checkbox' class='checkbox' name='layered_id_attribute_group_" + (j + 1).ToString() + "' id='layered_id_attribute_group_" + (j + 1).ToString() + "' value='" + listSub[j].Id + "' />\n"; ltrmenu.Text += "<label for='layered_id_attribute_group_" + (j + 1).ToString() + "'>\n"; strUrl = PageHelper.GeneralGroupUrl(Consts.CON_SAN_PHAM, listSub[j].Id, listSub[j].Name); ltrmenu.Text += "<a href='" + strUrl + "'>"; ltrmenu.Text += "<strong>" + listSub[j].Name + "</strong>\n"; count = ProductService.Product_GetCount(listSub[j].Level); ltrmenu.Text += "<span>(" + count.ToString() + ")</span></a>\n</label>\n</li>\n"; } ltrmenu.Text += "</ul>\n"; } ltrmenu.Text += "</div>\n"; } } } DataTable dtSub = GroupNewsService.GroupNews_GetByTop("", "Active=1 And left(Level,5)='" + level + "' And len(Level) = 10", "Level, Ord"); if (dtSub.Rows.Count > 0) { for (int i = 0; i < dtSub.Rows.Count; i++) { ltrmenu.Text += "<h3><a href='/" + dtSub.Rows[i]["Id"] + "/" + StringClass.NameToTag(dtSub.Rows[i]["Name"].ToString()) + ".aspx' title='" + dtSub.Rows[i]["Name"] + "'>" + dtSub.Rows[i]["Name"] + "</a></h3>"; DataTable dt3 = NewsService.News_GetByTop("5", "Active=1 And GroupNewsId='" + dtSub.Rows[i]["Id"] + "'", "Date Desc"); if (dt3.Rows.Count > 0) { ltrmenu.Text += "<div class='content-menu'><ul>"; for (int j = 0; j < dt3.Rows.Count; j++) { if ("1".Equals(dt3.Rows[j]["Index"].ToString())) { ltrmenu.Text += "<li><a href='/" + dtSub.Rows[i]["Id"] + "/" + StringClass.NameToTag(dtSub.Rows[i]["Name"].ToString()) + "/" + dt3.Rows[j]["Id"] + "/" + StringClass.NameToTag(dt3.Rows[j]["Name"].ToString()) + ".aspx' title='" + dt3.Rows[j]["Name"] + "'>" + dt3.Rows[j]["Name"] + "</a><img src='/Images/icon_hot.gif' style='margin-left:2px' /></li>"; } else { ltrmenu.Text += "<li><a href='/" + dtSub.Rows[i]["Id"] + "/" + StringClass.NameToTag(dtSub.Rows[i]["Name"].ToString()) + "/" + dt3.Rows[j]["Id"] + "/" + StringClass.NameToTag(dt3.Rows[j]["Name"].ToString()) + ".aspx' title='" + dt3.Rows[j]["Name"] + "'>" + dt3.Rows[j]["Name"] + "</a></li>"; } } ltrmenu.Text += "</ul></div>"; } } } } catch (Exception ex) { MailSender.SendMail("", "", "Error System", ex.Message); } } }
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); } }