public static void ReGroup(List <Z01ProductCategory> records, List <Z01ProductCategory> newRecords, long?parentID, string prefix, long removeID) { prefix = " " + prefix + "─"; IEnumerable <Z01ProductCategory> thisGroups = records.Where(s => s.ParentID == parentID && s.CategoryID != removeID).OrderBy(s => s.DisplayOrder); foreach (Z01ProductCategory tGroup in thisGroups) { Z01ProductCategory nGroup = new Z01ProductCategory(); nGroup.CategoryID = tGroup.CategoryID; nGroup.Code = tGroup.Code; if (tGroup.ParentID != 0 && prefix != "├") { nGroup.Title = prefix + " " + tGroup.Title; } else { nGroup.Title = tGroup.Title; } newRecords.Add(nGroup); //if (tGroup.ParentID != 0 && prefix != "├") // nGroup.Title = prefix + " " + tGroup.Title; //newRecords.Add(tGroup); ReGroup(records, newRecords, tGroup.CategoryID, prefix, removeID); } }
public ActionResult Edit(System.Int64? id, long? xParentID, string act) { Z01ProductCategory entity = null; if (id.HasValue && id > 0) { if (act == "detail") { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) return RedirectToAction("NoPermission", "Error"); ViewData["VTitle"] = "查看产品分类信息"; ViewData["IsDetail"] = true; } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) return RedirectToAction("NoPermission", "Error"); ViewData["VTitle"] = "修改产品分类信息"; } entity = Z01ProductCategoryHelper.Create(db, id.Value); ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.ParentID, id.Value); } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) return RedirectToAction("NoPermission", "Error"); ViewData["VTitle"] = "新增产品分类"; entity = new Z01ProductCategory(); ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, xParentID, 0); } string returnUrl = Request["ReturnUrl"]; if (returnUrl.IsNullOrEmpty()) returnUrl = "/" + _ContollerName; ViewData["ReturnUrl"] = returnUrl; return View(entity); }
public ActionResult Details(System.Int64 id) { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) { return(RedirectToAction("NoPermission", "Error")); } Z01ProductCategory entity = Z01ProductCategoryHelper.Create(db, id); return(View(entity)); }
public ActionResult Edit(System.Int64?id, Z01ProductCategory entity) { EAP.Logic.Z01.Helper.ClearProductCategories(); entity.CategoryID = id; ValidateZ01ProductCategory(entity); if (!ModelState.IsValid) { return(View(entity)); } try { if (id.HasValue && id > 0) { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) { return(RedirectToAction("NoPermission", "Error")); } if (id == entity.ParentID) { ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, null, id.Value); ModelState.AddModelError("ParentID Error", "父分类不可以是自己。"); } if (!ModelState.IsValid) { return(View(entity)); } db.Update(entity); } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) { return(RedirectToAction("NoPermission", "Error")); } entity.CategoryID = null; entity.TenantID = _tenant.TenantID; db.Insert(entity); } return(Return()); } catch { return(View(entity)); } }
public ActionResult Edit(System.Int64?id, long?xParentID, string act) { Z01ProductCategory entity = null; if (id.HasValue && id > 0) { if (act == "detail") { if ((_crud & Zippy.SaaS.Entity.CRUD.Read) != Zippy.SaaS.Entity.CRUD.Read) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "查看产品分类信息"; ViewData["IsDetail"] = true; } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "修改产品分类信息"; } entity = Z01ProductCategoryHelper.Create(db, id.Value); ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, entity.ParentID, id.Value); } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) { return(RedirectToAction("NoPermission", "Error")); } ViewData["VTitle"] = "新增产品分类"; entity = new Z01ProductCategory(); ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, xParentID, 0); } string returnUrl = Request["ReturnUrl"]; if (returnUrl.IsNullOrEmpty()) { returnUrl = "/" + _ContollerName; } ViewData["ReturnUrl"] = returnUrl; return(View(entity)); }
protected void ValidateZ01ProductCategory(Z01ProductCategory entity) { if (string.IsNullOrEmpty(entity.Title)) { ModelState.AddModelError("Title required", "标题:必须填写"); } else if (entity.Title.Length > 300) { ModelState.AddModelError("Title string length error", "标题:填写的内容太多"); } if (!string.IsNullOrEmpty(entity.Code) && entity.Code.Length > 30) { ModelState.AddModelError("Code string length error", "编号:填写的内容太多"); } if (!string.IsNullOrEmpty(entity.Content) && entity.Content.Length > 2000) { ModelState.AddModelError("Content string length error", "描述:填写的内容太多"); } }
public static void ReGroup(List<Z01ProductCategory> records, List<Z01ProductCategory> newRecords, long? parentID, string prefix, long removeID) { prefix = " " + prefix + "─"; IEnumerable<Z01ProductCategory> thisGroups = records.Where(s => s.ParentID == parentID && s.CategoryID != removeID).OrderBy(s => s.DisplayOrder); foreach (Z01ProductCategory tGroup in thisGroups) { Z01ProductCategory nGroup = new Z01ProductCategory(); nGroup.CategoryID = tGroup.CategoryID; nGroup.Code = tGroup.Code; if (tGroup.ParentID != 0 && prefix != "├") nGroup.Title = prefix + " " + tGroup.Title; else nGroup.Title = tGroup.Title; newRecords.Add(nGroup); //if (tGroup.ParentID != 0 && prefix != "├") // nGroup.Title = prefix + " " + tGroup.Title; //newRecords.Add(tGroup); ReGroup(records, newRecords, tGroup.CategoryID, prefix, removeID); } }
public static int Update(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { return(db.Update(entity)); }
/// <summary> /// 获取 [产品分类 的 分类] 的 [产品分类关系] 集合 /// </summary> public static List <Z01ProductInCategory> GetCategoryID_Z01ProductInCategorys(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { if (entity.CategoryID.HasValue) { return(db.Take <Z01ProductInCategory>("CategoryID=@CategoryID", db.CreateParameter("CategoryID", entity.CategoryID))); } return(new List <Z01ProductInCategory>()); }
public ActionResult Edit(System.Int64? id, Z01ProductCategory entity) { EAP.Logic.Z01.Helper.ClearProductCategories(); entity.CategoryID = id; ValidateZ01ProductCategory(entity); if (!ModelState.IsValid) return View(entity); try { if (id.HasValue && id > 0) { if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) return RedirectToAction("NoPermission", "Error"); if (id == entity.ParentID) { ViewData["ParentIDOptions"] = Z01ProductCategoryHelper.GetParentIDEntitiesHtmlOption(db, _tenant.TenantID.Value, null, id.Value); ModelState.AddModelError("ParentID Error", "父分类不可以是自己。"); } if (!ModelState.IsValid) return View(entity); db.Update(entity); } else { if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create) return RedirectToAction("NoPermission", "Error"); entity.CategoryID = null; entity.TenantID = _tenant.TenantID; db.Insert(entity); } return Return(); } catch { return View(entity); } }
public static Z01ProductCategory GetParentIDEntity(this Z01ProductCategory entity) { Zippy.Data.IDalProvider db = Zippy.Data.DalFactory.CreateProvider(); return(db.FindUnique <Z01ProductCategory>("CategoryID=@CategoryID", db.CreateParameter("CategoryID", entity.ParentID))); }
protected void ValidateZ01ProductCategory(Z01ProductCategory entity) { if (string.IsNullOrEmpty(entity.Title)) ModelState.AddModelError("Title required", "标题:必须填写"); else if (entity.Title.Length > 300) ModelState.AddModelError("Title string length error", "标题:填写的内容太多"); if (!string.IsNullOrEmpty(entity.Code) && entity.Code.Length > 30) ModelState.AddModelError("Code string length error", "编号:填写的内容太多"); if (!string.IsNullOrEmpty(entity.Content) && entity.Content.Length > 2000) ModelState.AddModelError("Content string length error", "描述:填写的内容太多"); }
public static int Insert(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { int rtn = db.Insert(entity); return rtn; }
/// <summary> /// 获取 [产品分类 的 分类] 的 [产品分类关系] 集合 /// </summary> public static List<Z01ProductInCategory> GetCategoryID_Z01ProductInCategorys(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { if (entity.CategoryID.HasValue) return db.Take<Z01ProductInCategory>("CategoryID=@CategoryID", db.CreateParameter("CategoryID", entity.CategoryID)); return new List<Z01ProductInCategory>(); }
public static int Update(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { return db.Update(entity); }
public static Z01ProductCategory Create(Zippy.Data.IDalProvider db, Int64 _CategoryID) { Z01ProductCategory rtn = db.FindUnique <Z01ProductCategory>(_CategoryID); return(rtn); }
public static int Insert(Zippy.Data.IDalProvider db, Z01ProductCategory entity) { int rtn = db.Insert(entity); return(rtn); }