private bool allotProducts(List<int> proIDs, List<int> classIds) { if (proIDs.Count < 1) { return true; } Model.products.TypeProducts model = new Model.products.TypeProducts(); skywolfORM.ORM.ORM orm = new skywolfORM.ORM.ORM(); for (int intLoop = 0; intLoop < proIDs.Count; intLoop++) { if (orm.Delete("delete TypeProducts where piID=" + proIDs[intLoop])) { for (int intLoops = 0; intLoops < classIds.Count; intLoops++) { model = new Model.products.TypeProducts(); model.piID = proIDs[intLoop]; model.ptID = classIds[intLoops]; orm.Add(model); } } else { return false; } } return true; }
private string delType(int id) { skywolfORM.ORM.ORM orm = new skywolfORM.ORM.ORM(); Model.products.productsClassify model = new Model.products.productsClassify(); model = (Model.products.productsClassify)orm.Load(model, id); if (model == null) { return "{\"success\":false,\"msg\":\"该分类不存在或已被删除!\"}"; } int parentID = model.pcParentID; if (!checkHasLeaf(parentID)) { return "{\"success\":false,\"msg\":\"该分类存在子分类请先删除子分类!\"}"; } if (orm.Delete(model)) { return "{\"success\":true,\"msg\":\"删除分类成功!\"}"; } return "{\"success\":false,\"msg\":\"删除分类失败!\"}"; }
private string delType(int id) { skywolfORM.ORM.ORM orm = new skywolfORM.ORM.ORM(); Model.products.productsType model = new Model.products.productsType(); model = (Model.products.productsType)orm.Load(model, id); if (model == null) { return "{\"success\":false,\"msg\":\"该类型不存在或已被删除!\"}"; } if (model.isLeaf == 1) { return "{\"success\":false,\"msg\":\"该类型存在子类型,请先删除子类型!\"}"; } int parentID = model.ptParentID; if (orm.Delete(model)) { if (parentID > 0) { List<Model.products.productsType> lists = orm.List(model, "ptParentID=" + parentID).OfType<Model.products.productsType>().ToList(); if (lists.Count < 1) { model = (Model.products.productsType)orm.Load(model, parentID); if (model != null) { model.isLeaf = 2; if (orm.Update(model)) { return "{\"success\":true,\"msg\":\"删除类型成功!\"}"; } } } } return "{\"success\":true,\"msg\":\"删除类型成功!\"}"; } return "{\"success\":false,\"msg\":\"删除类型失败!\"}"; }