public string ClearProductListByCategory(string CategoryNo) { string result = ""; ProductRulesService SortService = new ProductRulesService(); result = SortService.DelProductByCategoryNo(CategoryNo) + ""; result = SortService.DelSortRuleByCategoryNo(CategoryNo) + ""; return(result); }
public string SaveProductSort(PageDateInfo PageDateList) { PageDateList.CategoryNo = PageDateList.CategoryNo; ProductRulesService PsortService = new ProductRulesService(); string result = "0"; //没有执行规则 int sortInt = 0; if (PageDateList.ProductList != null) { sortInt = sortInt + PageDateList.ProductList.Count(); } if (PageDateList.RuleList != null) { for (int i = 0; i < PageDateList.RuleList.Count(); i++) { if (PageDateList.RuleList[i].ProductList != null) { sortInt = sortInt + PageDateList.RuleList[i].ProductList.Count(); } if (PageDateList.RuleList[i].RuleList != null) { for (int k = 0; k < PageDateList.RuleList[i].RuleList.Count(); k++) { if (PageDateList.RuleList[i].RuleList[k].ProductList != null) { sortInt = sortInt + PageDateList.RuleList[i].RuleList[k].ProductList.Count(); } } } } } if (PageDateList.IsRule == "0") { PsortService.DelSortRuleByCategoryNo(PageDateList.CategoryNo); PsortService.DelProductByCategoryNo(PageDateList.CategoryNo); PsortService.UpdateCateogryTime(PageDateList.CategoryNo, PageDateList.IsLast); if (PageDateList.ProductList != null) { for (int i = 0; i < PageDateList.ProductList.Count(); i++) { SWfsSortProduct pdto = new SWfsSortProduct(); pdto.Sort = sortInt; pdto.RuleId = -1; pdto.ProductNo = PageDateList.ProductList[i].ProductNo; pdto.DateCreate = DateTime.Now; pdto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.productlist[i].ocscategoryno; PsortService.AddProductToSortSingle(pdto); sortInt = sortInt - 1; } } } else { PsortService.DelSortRuleByCategoryNo(PageDateList.CategoryNo); PsortService.DelProductByCategoryNo(PageDateList.CategoryNo); PsortService.UpdateCateogryTime(PageDateList.CategoryNo, PageDateList.IsLast); string parentid = "0"; if (PageDateList.RuleList != null) { for (int i = 0; i < PageDateList.RuleList.Count(); i++) { SWfsSortRule pruledto = new SWfsSortRule(); pruledto.OcsCategoryNo = PageDateList.CategoryNo; pruledto.ParentId = 0; pruledto.RuleObjectName = PageDateList.RuleList[i].RuleName; pruledto.RuleObjectNo = PageDateList.RuleList[i].RuleNo; pruledto.RuleType = Convert.ToInt16(PageDateList.RuleList[i].RuleType); pruledto.Sort = PageDateList.RuleList.Count() - i; parentid = PsortService.AddRuleToSort(pruledto); if (PageDateList.RuleList[i].RuleList != null) { for (int j = 0; j < PageDateList.RuleList[i].RuleList.Count(); j++) { SWfsSortRule ruledto = new SWfsSortRule(); ruledto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.categoryno; ruledto.ParentId = Convert.ToInt32(parentid); ruledto.RuleObjectName = PageDateList.RuleList[i].RuleList[j].RuleName; ruledto.RuleObjectNo = PageDateList.RuleList[i].RuleList[j].RuleNo; ruledto.RuleType = Convert.ToInt16(PageDateList.RuleList[i].RuleList[j].RuleType); ruledto.Sort = PageDateList.RuleList[i].RuleList.Count() - j; string ruleid = PsortService.AddRuleToSort(ruledto); if (PageDateList.RuleList[i].RuleList[j].ProductList != null) { for (int k = 0; k < PageDateList.RuleList[i].RuleList[j].ProductList.Count(); k++) { SWfsSortProduct ptdto = new SWfsSortProduct(); ptdto.Sort = sortInt; ptdto.RuleId = Convert.ToInt32(ruleid); ptdto.ProductNo = PageDateList.RuleList[i].RuleList[j].ProductList[k].ProductNo; ptdto.DateCreate = DateTime.Now; ptdto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.rulelist[i].rulelist[k].productlist[k].ocscategoryno; PsortService.AddProductToSortSingle(ptdto); sortInt = sortInt - 1; } } } } if (PageDateList.RuleList[i].ProductList != null) { for (int l = 0; l < PageDateList.RuleList[i].ProductList.Count(); l++) { SWfsSortProduct podto = new SWfsSortProduct(); podto.Sort = sortInt; podto.RuleId = Convert.ToInt32(parentid); podto.ProductNo = PageDateList.RuleList[i].ProductList[l].ProductNo; podto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.rulelist[i].productlist[l].ocscategoryno; podto.DateCreate = DateTime.Now; PsortService.AddProductToSortSingle(podto); sortInt = sortInt - 1; } } if (PageDateList.ProductList != null) { for (int m = 0; m < PageDateList.ProductList.Count(); m++) { SWfsSortProduct dto = new SWfsSortProduct(); dto.Sort = sortInt; dto.RuleId = 0; dto.ProductNo = PageDateList.ProductList[m].ProductNo; dto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.productlist[m].ocscategoryno; dto.DateCreate = DateTime.Now; PsortService.AddProductToSortSingle(dto); sortInt = sortInt - 1; } } } } } return(result); }