public ActionResult Edit(string id, string ParentId) { ViewBag.ParentName = _dba.ExecuteScalar<string>("SELECT Name FROM dbo.Sec_Organization WHERE OrganizationId=#OrganizationId#", new { OrganizationId = ParentId }); SecOrganization model = new SecOrganization(); model.ParentId = ParentId; if (id != null) { model = _organizationService.Get(id); } return View(model); }
public JsonResult Save(SecOrganization model) { MyJsonResult mjr = new MyJsonResult(); using (var dba = DbAccessor.Create()) { try { dba.BeginTran(); model.ModifiedById = SecurityContext.Current.User.UserId; model.ModifiedDate = DateTime.Now; if (model.OrganizationId == null) { model.OrganizationId = Guid.NewGuid().ToString(); model.Status = (int)StatusType.Enabled; model.CreatedById = SecurityContext.Current.User.UserId; model.CreatedDate = DateTime.Now; dba.ExecuteNonQuery("Security.Organization.Insert", model); } else { dba.UpdateFields(model, "Name", "Code", "MobilePhone", "ModifiedById", "ModifiedDate"); } dba.CommitTran(); mjr.Success = true; mjr.Message = "保存成功!"; } catch (Exception ex) { dba.RollbackTran(); mjr.Success = false; mjr.Message = ex.Message; } } return Json(mjr); }