private void DoSave() { SelectRoles = advRoleTree.GetTypeList <Maticsoft.Model.SMT_ROLE_INFO>(new List <CheckState> { CheckState.Checked }); CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_ROLE_FUN roleBll = new Maticsoft.BLL.SMT_ROLE_FUN(); Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where FUN_ID=" + _orgId + " and ROLE_TYPE=2"); foreach (var item in SelectRoles) { roleBll.Add(new Maticsoft.Model.SMT_ROLE_FUN() { ROLE_ID = item.ID, ROLE_TYPE = 2, FUN_ID = _orgId }); } this.Invoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "保存失败:" + ex.Message); log.Error("保存授权角色失败:", ex); } }); waiting.Show(this); }
private void btnOk_Click(object sender, EventArgs e) { //读取菜单权限 List <Maticsoft.Model.SMT_FUN_MENUPOINT> funs = GetSelectModels <Maticsoft.Model.SMT_FUN_MENUPOINT>(advPrivate, CheckState.Indeterminate, CheckState.Checked); //读取部门菜单 List <Maticsoft.Model.SMT_ORG_INFO> orgs = null; if (deptTree.IsLoaded) { orgs = GetSelectModels <Maticsoft.Model.SMT_ORG_INFO>(deptTree.Tree, CheckState.Checked); } //读取门参数 List <Maticsoft.Model.SMT_DOOR_INFO> doors = null; if (doorTree.IsLoaded) { doors = GetSelectModels <Maticsoft.Model.SMT_DOOR_INFO>(doorTree.Tree, CheckState.Checked); } //读取人脸参数 List <Maticsoft.Model.SMT_FACERECG_DEVICE> faces = null; if (faceDevTree.IsLoaded) { faces = GetSelectModels <Maticsoft.Model.SMT_FACERECG_DEVICE>(faceDevTree.Tree, CheckState.Checked); } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_ROLE_FUN rolefunBll = new Maticsoft.BLL.SMT_ROLE_FUN(); Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and (ROLE_TYPE=1 or ROLE_TYPE is null)"); if (funs.Count > 0) { foreach (var item in funs) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 1; rolefunBll.Add(rf); } } SmtLog.InfoFormat("用户", "更新角色:{0}菜单权限,个数:{1}.", _roleInfo.ROLE_NAME, funs.Count); if (orgs != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=2"); foreach (var item in orgs) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 2; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}部门权限,个数:{1}.", _roleInfo.ROLE_NAME, orgs.Count); } if (doors != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=3"); foreach (var item in doors) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 3; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}门禁权限,个数:{1}.", _roleInfo.ROLE_NAME, doors.Count); } if (faces != null) { Maticsoft.DBUtility.DbHelperSQL.ExecuteSql("delete from SMT_ROLE_FUN where ROLE_ID=" + _roleInfo.ID + " and ROLE_TYPE=4"); foreach (var item in faces) { Maticsoft.Model.SMT_ROLE_FUN rf = new Maticsoft.Model.SMT_ROLE_FUN(); rf.ROLE_ID = _roleInfo.ID; rf.FUN_ID = item.ID; rf.ROLE_TYPE = 4; rolefunBll.Add(rf); } SmtLog.InfoFormat("用户", "更新角色:{0}人脸设备权限,个数:{1}.", _roleInfo.ROLE_NAME, faces.Count); } this.Invoke(new Action(() => { this.DialogResult = DialogResult.OK; this.Close(); })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "更新角色权限失败:" + ex.Message); log.Error("更新角色权限失败:", ex); } }); waiting.Show(this); }