public JsonResult submitEditNoteSort(int ParentID, string sortName, int Id, int type = 0) { try { Sys_NoteSort model = new Sys_NoteSort() { Id = Id, SortName = sortName, Type = type, ParentID = ParentID }; if (Id > 0) { noteSortBL.UpdateSys_NoteSort(model); } else { noteSortBL.AddSys_NoteSort(model); } return(Json(new { result = 1, content = "操作成功!" }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, content = "操作失败" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// /// </summary> /// <param name="Id"></param> /// <param name="sortName"></param> /// <param name="flag">0:新增 1: 修改</param> /// <returns></returns> public ActionResult FAQ_EditNoteSort(int Id = 0, int flag = 0) { Sys_NoteSort noteSort = new Sys_NoteSort(); if (Id != 0) { noteSort = noteSortBL.GetSys_NoteSort(Id); } if (flag == 1)//编辑 选中的接点 { if (noteSort != null) { if (noteSort.ParentID == 0) { ViewBag.ParentName = "所有类别"; } else { var temp = noteSortBL.GetSys_NoteSort(noteSort.ParentID); if (temp == null) { ViewBag.ParentName = "所有类别"; } else { ViewBag.ParentName = temp.SortName; } } } return(View(noteSort)); } else//新增 { var tempAdd = new Sys_NoteSort(); tempAdd.ParentID = Id; var tempParent = noteSortBL.GetSys_NoteSort(noteSort.Id); if (tempParent == null) { ViewBag.ParentName = "所有类别"; } else { ViewBag.ParentName = tempParent.SortName; } return(View(tempAdd)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateSys_NoteSort(Sys_NoteSort model) { using (IDbConnection connection = OpenConnection()) { const string updateSql = @"update Sys_NoteSort set SortName=@SortName,ParentID=@ParentID,IsDelete=@IsDelete where Id=@Id "; var param = new { model.Id, model.SortName, model.ParentID, model.IsDelete }; return(connection.Execute(updateSql, param) > 0); } }
/// <summary> /// 增加一条数据 /// </summary> public void AddSys_NoteSort(Sys_NoteSort model) { using (IDbConnection connection = OpenConnection()) { const string strSql = @"insert into Sys_NoteSort(SortName,ParentID,Type,IsDelete) values(@SortName,@ParentID,@Type,0) SELECT @@Identity AS ID "; var param = new { model.SortName, model.ParentID, model.Type }; decimal id = connection.Query <decimal>(strSql, param) .FirstOrDefault(); model.Id = decimal.ToInt32(id); } }
/// <summary> /// 更新一条数据 /// </summary> public bool UpdateSys_NoteSort(Sys_NoteSort model) { return(_noteSortDB.UpdateSys_NoteSort(model)); }
/// <summary> /// 增加一条数据 /// </summary> public void AddSys_NoteSort(Sys_NoteSort model) { _noteSortDB.AddSys_NoteSort(model); }