public void DeleteAllSubNodes(CraftType node) { List<CraftType> deleteNodes = GetAllSubNodes(node.ID); foreach (CraftType each in deleteNodes) { DeleteAllSubNodes(each); } db.CraftTypes.Remove(node); }
/// <summary> /// 增加crafttype /// </summary> /// <param name="model">tableName实体</param> /// <returns>执行状态</returns> public bool AddNewAndUpdateLeaf(CraftType model) { try { db.CraftTypes.Add(model); db.SaveChanges(); //更新父节点为folder样式,即IsLeaf = "0" if (model.Belongsid != -1)//第一层在数据库中没有父节点,不需要更新 { CraftType parentNode = db.CraftTypes.First(s => s.ID == model.Belongsid); if (parentNode != null && !parentNode.IsLeaf.Equals("0")) { parentNode.IsLeaf = "0"; base.Update<CraftType>(parentNode, parentNode.ID); } } return true; } catch { return false; } }
public bool EditProductType() { string id = Request["id"]; string text = Request["text"]; string pid = Request["pid"]; string IsLeaf = Request["IsLeaf"]; if (Tools.IsValidInput(ref id, true) && Tools.IsValidInput(ref text, true) && Tools.IsValidInput(ref pid, true) && Tools.IsValidInput(ref IsLeaf, true)) { CraftType type = new CraftType(); type.ID = Convert.ToInt32(id); type.Name = text; type.Belongsid = Convert.ToInt32(pid); type.IsLeaf = (IsLeaf == "true" ? "1" : "0"); type.level = 0; //level没用到,所以随便置0 return new CraftTypeBLL().Update(type); } return false; }
public bool AddProductType() { CraftType type = new CraftType(); string text = Request["text"]; string pid = Request["pid"]; string IsLeaf = Request["IsLeaf"]; if (Tools.IsValidInput(ref text, true) && Tools.IsValidInput(ref pid, true) && Tools.IsValidInput(ref IsLeaf, true)) { type.Name = text; type.Belongsid = Convert.ToInt32(pid); type.level = 0;//level基本没什么用,所以给0 type.IsLeaf = "1";//初始化新添加的节点都是叶子//(IsLeaf=="true"?"1":"0"); return new CraftTypeBLL().AddNewAndUpdateLeaf(type); } else { return false; } }
/// <summary> /// 增加crafttype /// </summary> /// <param name="model">tableName实体</param> /// <returns>执行状态</returns> public bool AddNewAndUpdateLeaf(CraftType model) { model.FId = GetFId((int)model.Belongsid); return dal.AddNewAndUpdateLeaf(model); }
/// <summary> /// 更新crafttype实体 /// </summary> /// <param name="model">tableName实体</param> /// <returns>执行状态</returns> public bool Update(CraftType model) { return dal.Update(model); }
public bool Update(CraftType model) { try { base.Update<CraftType>(model, model.ID); return true; } catch { return false; } }