private void InitEdit(Guid Id) { var bll = new SiteMenus(); var model = bll.GetModel(Id); if (model != null) { hId.Value = model.Id.ToString(); hParentId.Value = model.ParentId.ToString(); txtTitle.Value = model.Title; txtUrl.Value = model.Url; txtDescr.Value = model.Descr; txtSort.Value = model.Sort.ToString(); } }
public ResResultModel SaveMenus(MenusModel model) { try { if (!HttpContext.Current.User.IsInRole("Administrators")) { throw new ArgumentException(MC.Role_InvalidError); } if (model == null) { return(ResResult.Response(false, MC.Request_Params_InvalidError)); } if (string.IsNullOrWhiteSpace(model.Title)) { return(ResResult.Response(false, MC.Request_Params_InvalidError)); } var Id = Guid.Empty; var parentId = Guid.Empty; if (model.Id != null && !string.IsNullOrWhiteSpace(model.Id.ToString())) { Guid.TryParse(model.Id.ToString(), out Id); } if (model.ParentId != null && !string.IsNullOrWhiteSpace(model.ParentId.ToString())) { Guid.TryParse(model.ParentId.ToString(), out parentId); } var appBll = new Applications(); var appId = appBll.GetAspnetAppId(Membership.ApplicationName); var bll = new SiteMenus(); int effect = 0; var modelInfo = new SiteMenusInfo(Guid.Parse(appId.ToString()), Id, parentId, model.IdStep, model.Title, model.Url, model.Descr, model.Sort, DateTime.Now); if (Id.Equals(Guid.Empty)) { //MenusDataProxy.ValidateAccess((int)EnumData.EnumOperationAccess.新增, true); modelInfo.Id = Guid.NewGuid(); modelInfo.IdStep = (modelInfo.Id + "," + modelInfo.IdStep).Trim(','); effect = bll.InsertByOutput(modelInfo); } else { //MenusDataProxy.ValidateAccess((int)EnumData.EnumOperationAccess.编辑, true); var oldInfo = bll.GetModel(Id); effect = bll.Update(modelInfo); } if (effect < 1) { return(ResResult.Response(false, "操作失败,数据库操作异常")); } return(ResResult.Response(true, "操作成功", modelInfo.Id)); } catch (Exception ex) { return(ResResult.Response(false, "操作异常:" + ex.Message + "")); } }