public ActionResult Create(string id, string s, string p) { shSectionService _section = new shSectionService(); shProductService _product = new shProductService(); shProductSet section = new shProductSet(); if (!string.IsNullOrWhiteSpace(s)) { section = _section.FindByKey(s); ViewBag.parent = string.IsNullOrWhiteSpace(section.ParentId) ? 0 : 1; } section.ProductGuid = id; ViewBag.ProductName = _product.ProductName(id); ViewBag.ProductGuid = id; IEnumerable <shProductSet> dsSection = _section.DanhSachSection() .Where(x => x.ProductGuid == id && x.ParentId == null && x.SectionGuid != s) .OrderBy(x => x.SectionId); ViewBag.dsSection = new SelectList(dsSection, "SectionGuid", "SectionName", null); ViewBag.p = p; return(View(section)); }
public List <TreeView> GetProductTreeview(bool isSection, string ProductGuid) { shSectionService _section = new shSectionService(); shSizeService _size = new shSizeService(); IEnumerable <shProductSet> dsSection = _section.DanhSachSection().Where(x => x.ProductGuid == ProductGuid && string.IsNullOrWhiteSpace(x.ParentId)); List <TreeView> dsTreeview = new List <TreeView>(); TreeView zTree = null; TreeView childZtree = null; foreach (var section in dsSection) { // cấp sản phẩm nhỏ zTree = new TreeView(); zTree.isParent = true; zTree.id = section.SectionGuid; zTree.pId = section.ProductGuid; List <TreeView> dsChildTreeview = null; //IEnumerable<shSize> dsChildSize = _size.DanhSachSize_BySectionGuid(section.SectionGuid, null, null); IEnumerable <shProductSet> dsChildSection = _section.DanhSachSection().Where(x => x.ParentId == section.SectionGuid).OrderBy(x => x.SortOrder); if (dsChildSection.Count() > 0) { dsChildTreeview = new List <TreeView>(); foreach (var childSection in dsChildSection) { // Cấp kích thước + Giá tiền childZtree = new TreeView(); childZtree.id = childSection.SectionGuid; childZtree.pId = childSection.ParentId; childZtree.name = childSection.SectionName; childZtree.isParent = false; childZtree.children = null; childZtree.click = "shProduct('' , '" + childSection.SectionGuid + "', '', '1')"; dsChildTreeview.Add(childZtree); } zTree.children = dsChildTreeview; zTree.open = true; zTree.click = "shProduct('', '" + section.SectionGuid + "', '', '1')"; zTree.name = section.SectionName + "[" + dsChildSection.Count() + "]"; } else { // Chưa có Kích Thước zTree.click = "shProduct('' , '" + section.SectionGuid + "', '', '1')"; zTree.open = false; zTree.name = section.SectionName; } //zTree.name += "<a href='javascript:void(0)' onclick='Edit()'>" + // "<span class='fa fa-pencil-square-o' style='transform: scale(1.3, 1.3);' title='Sửa'>" + // "</span></a>"; dsTreeview.Add(zTree); } return(dsTreeview); }