protected void btnSave_Click(object sender, EventArgs e) { #region 务端验证 if (txtRoleName.Text.Trim().Length == 0) { Alert("请输入角色名称!"); Select(txtRoleName); return; } if (CommonMethod.FinalString(Request.Form["fun"]).Length == 0) { Alert("请选择角色拥有的权限!"); return; } #endregion #region 角色信息保存 USER_SHARE_ROLESMODEL roleModel = null; //日志信息 USER_SHARE_LOGMODEL logModel = new USER_SHARE_LOGMODEL(); logModel.LOGID = CommonBusiness.GetSeqID("S_USER_SHARE_LOG"); logModel.OPERATEDATE = DateTime.Now; logModel.OPERATORID = AccountId; logModel.PROJECTID = ProjectId; logModel.COMPANYID = CompanyId; if (RoleId > 0) { roleModel = RoleBusiness.GetRoleModel(RoleId); logModel.OPERATETYPE = int.Parse(ShareEnum.LogType.EditRole.ToString("d")); logModel.OPERATECONTENT = string.Format("修改角色信息,修改后角色名称:{0}, 角色Id:{1} ", txtRoleName.Text.Trim(), RoleId); } else { roleModel = new USER_SHARE_ROLESMODEL(); roleModel.ROLEID = CommonBusiness.GetSeqID("S_USER_SHARE_ROLES"); roleModel.CreatorId = AccountId; roleModel.CreateDate = DateTime.Now; roleModel.COMPANYID = CompanyId; roleModel.STATUS = int.Parse(ShareEnum.RoleStatus.Normal.ToString("d")); logModel.OPERATETYPE = int.Parse(ShareEnum.LogType.AddRole.ToString("d")); logModel.OPERATECONTENT = string.Format("新增角色信息,角色名称:{0},公司编码:{1} ", txtRoleName.Text.Trim(), CompanyCode); } roleModel.PROJECTID = ValidatorHelper.ToInt(ddlProject.SelectedValue, 0); roleModel.ROLENAME = txtRoleName.Text.Trim(); roleModel.ROLEDESC = txtRoleDesc.Text.Trim(); bool blSuccess = false; string strRoleFuns = Request.Form["fun"]; #region 账号信息 List <RoleAccountModel> raModel = new List <RoleAccountModel>(); RoleAccountModel model = null; foreach (ListItem item in cblAccounts.Items) { model = new RoleAccountModel(); model.AccountId = ValidatorHelper.ToInt(item.Value.Split('$')[0], 0); model.IsChecked = item.Selected; raModel.Add(model); } #endregion #region 角色拥有车辆分组 string strGroup = string.Empty; foreach (TreeNode tn in tvGroups.Nodes) { if (tn.Checked) { strGroup += tn.Value + ","; } } strGroup = strGroup.TrimEnd(','); #endregion if (RoleId == 0) { blSuccess = RoleBusiness.AddARole(roleModel, strRoleFuns, strGroup, raModel, logModel); } else { blSuccess = RoleBusiness.EditRole(roleModel, strRoleFuns, strGroup, raModel, logModel); } Alert((RoleId > 0 ? "修改" : "新增") + "角色" + (blSuccess ? "成功" : "失败,请重试!")); ExecScript("parent.__doPostBack('ctl00$MainContent$btnSearch','');"); #endregion }