public HttpResponseMessage SaveSysDeptForm(Sys_Dept obj) { DBHelper <Sys_Dept> dbhelp = new DBHelper <Sys_Dept>(); var result = obj.DeptID == 0 ? dbhelp.Add(obj) : dbhelp.Update(obj); return(Json(true, result == 1 ? "保存成功!" : "保存失败")); }
public ActionResult CreateDept(FormCollection collection) { try { string name = collection.Get("Name"); string note = collection.Get("Note"); using (LoanDataDataContext udatabase = new LoanDataDataContext()) { Sys_Dept act = new Sys_Dept(); act.Name = name; act.Note = note; udatabase.Sys_Depts.InsertOnSubmit(act); udatabase.SubmitChanges(); } var jsonObj = new { test = "Department Has Been Created" }; return(Json(jsonObj)); } catch (Exception exc) { var jsonObj = new { Error = exc.Message }; return(Json(jsonObj)); } }
public ActionResult UpdateDept(FormCollection collection) { try { string id = collection.Get("ID"); string name = collection.Get("Name"); string note = collection.Get("Note"); using (LoanDataDataContext udatabase = new LoanDataDataContext()) { Sys_Dept act = udatabase.Sys_Depts.FirstOrDefault(u => u.ID == int.Parse(id)); act.Name = name; act.Note = note; udatabase.SubmitChanges(); } var jsonObj = new { test = "Department Has Been Updated" }; return(Json(jsonObj)); } catch (Exception exc) { var jsonObj = new { Error = exc.Message }; return(Json(jsonObj)); } }
public HttpResponseMessage DeleteSysDeptRow(Sys_Dept obj) { var result = new DBHelper <Sys_Dept>().Remove(obj); return(Json(true, result == 1 ? "删除成功!" : "删除失败")); }