void win_SubmitEvent(AddUserGroup obj) { try { foreach (var item in UserGroups) { if (item.UserGroupName == obj.UserGroupInstance.UserGroupName) { MessageBox.Show("已存在相同名称的分组!"); return; } } ErrType rst = _businessService.AddUserGroups(obj.UserGroupInstance, _loginID); if (rst.Err != ERR.SUCCESS) { MessageBox.Show("添加用户分组失败:" + rst.ErrMsg); } else { UserGroups.Add(obj.UserGroupInstance); MessageBox.Show("添加用户分组成功"); obj.Close(); } } catch (Exception ex) { MessageBox.Show("添加用户分组失败:" + ex.Message); } }
/// <summary> /// 添加用户分组 /// </summary> private void AddUserGroupEx() { AddUserGroup win = new AddUserGroup(); win.SubmitEvent += new Action<AddUserGroup>(win_SubmitEvent); win.ShowDialog(); }