/// <summary> /// 修改代码数据 /// </summary> /// <param name="Title"></param> /// <param name="Code"></param> /// <param name="Id"></param> /// <returns></returns> public string ModifyCode(string Title, string Code, string Id, string OldTitle, string Visible) { if (Title != OldTitle) { var test = CodeData.Where(x => x.Title == Title).ToList(); if (test.Count > 0) { return(ToJson("出错,已存在改标题")); } KindModel kindmodel = new KindModel("Kind_tb"); kindmodel.objectId = Id; kindmodel.Name = Title; if (kind.ModifyData(kindmodel)) { var data_ = KindData.Where(x => x.objectId == Id).Single(); data_.Name = Title; } else { return(ToJson("出错,修改分类失败")); } } var data = CodeData.Where(x => x.Title == OldTitle).Single(); CodeModel model = new CodeModel("Code_tb"); model.objectId = data.objectId; model.Title = Title; model.Code = Code; model.Visible = Visible; if (code.ModifyData(model)) { data.Title = Title; data.Code = Code; data.Visible = Visible; } //添加修改记录-------------------- if (Visible == "Visible") { OperationModel operationModel = new OperationModel("OperationNews_tb"); operationModel.User = (string)SessionHelp.Get("UserName"); operationModel.Operate = "修改了"; operationModel.Title = Title; List <string> PathKind = new List <string>(); string id; id = KindData.Where(x => x.objectId == Id).Single().ParentId; KindPath(id, ref PathKind); operationModel.Kind = PathKind[PathKind.Count - 1]; operate.Create(operationModel); } //添加修改记录------------------- return(ToJson("修改成功")); }
//添加分类数据 public string AddKind(string ParentId, string Name) { int count = (from a in KindCodeOperation.KindData where a.ParentId == ParentId && a.Name == Name select a).ToList().Count; if (count > 0) { return("已存在该分类"); } KindModel model = new KindModel { ParentId = ParentId, Name = Name, fTable = "Kind_tb" }; string returnId = kind.Create(model); if (returnId != null) { model.objectId = returnId; KindCodeOperation.KindData.Add(model); } else { return(ToJson("添加分类失败")); } return(ToJson(returnId)); }
/// <summary> /// 添加代码 /// </summary> /// <param name="Title"></param> /// <param name="Kind"></param> /// <param name="Code"></param> /// <param name="Author"></param> /// <returns></returns> public string AddData(CodeModel model) { try { string codeId, ParentId = model.objectId;//将model里的分类id提取出来作为父项分类id,之前暂存进去的 string kindId; var data = CodeData.Where(x => x.Title == model.Title).ToList(); if (data.Count > 0) { return("出错,此标题已存在"); } KindModel kindmodel = new KindModel("Kind_tb"); kindmodel.ParentId = ParentId; kindmodel.Name = model.Title; kindId = kind.Create(kindmodel); if (kindId != null) { kindmodel.objectId = kindId; KindData.Add(kindmodel); model.KindObjectId = kindId; codeId = code.Create(model);; if (codeId != null) { model.objectId = codeId; CodeData.Add(model); if (model.Visible == "Visible") { OperationModel operationModel = new OperationModel("OperationNews_tb"); operationModel.User = (string)SessionHelp.Get("UserName"); List <string> PathKind = new List <string>(); KindPath(ParentId, ref PathKind); operationModel.Kind = PathKind[PathKind.Count - 1]; operationModel.Operate = "添加了"; operationModel.Title = model.Title; operate.Create(operationModel); } return(kindId); } else { return("出错,添加代码成功,添加标题失败"); } } else { return("出错,添加代码失败"); } } catch (Exception e) { return("出错," + e.Message); } }