public JsonResult Editorganization(FormCollection form) { Common.Json json = new Common.Json(); B_Organization b_org = new B_Organization(); B_Organization_type b_orgtype = new B_Organization_type(); B_Manager b_manager = new B_Manager(); Domain.Organization model = b_org.Get(Convert.ToInt32(form["id"])); model.name = form["txt_name"]; model.parent_id = Convert.ToInt32(form["txt_parent_id"]); if (model.parent_id != 0) { var m = b_org.Get(model.parent_id); if (string.IsNullOrEmpty(model.parent_ids)) { model.parent_ids = model.parent_id + ","; } else { model.parent_ids = m.parent_ids + m.parent_id + ","; } model.levels = m.levels + 1; } else { model.levels = 0; } model.orgtype = b_orgtype.Get(Convert.ToInt32(form["txt_orgtype_id"])); model.sort_id = Convert.ToInt32(form["txt_sort_id"]); model.status = Convert.ToInt32(form["txt_status"]); b_org.Update(model); json.msg = "修改成功!"; return(Json(json)); }
public JsonResult GetOrganization(int id) { B_Organization b_org = new B_Organization(); var model = b_org.Get(id); return(Json(model)); }
public JsonResult AddOrganization(FormCollection form) { Common.Json json = new Common.Json(); B_Organization b_org = new B_Organization(); B_Organization_type b_orgtype = new B_Organization_type(); B_Manager b_manager = new B_Manager(); Domain.Organization model = new Domain.Organization(); model.name = form["txt_name"]; model.parent_id = Convert.ToInt32(form["txt_parent_id"]); if (model.parent_id != 0) { var m = b_org.Get(model.parent_id); if (string.IsNullOrEmpty(model.parent_ids)) { model.parent_ids = model.parent_id + ","; } else { model.parent_ids = m.parent_ids + m.parent_id + ","; } model.levels = m.levels + 1; } else { model.levels = 0; } model.orgtype = b_orgtype.Get(Convert.ToInt32(form["txt_orgtype_id"])); model.sort_id = Convert.ToInt32(form["txt_sort_id"]); model.add_manager = b_manager.Get(Convert.ToInt32(base.User.Identity.Name)); model.add_time = DateTime.Now; model.status = Convert.ToInt32(form["txt_status"]); var res = b_org.Save(model); if (res <= 0) { json.status = -1; json.msg = "添加失败!"; return(Json(json)); } json.msg = "添加成功!"; return(Json(json)); }