示例#1
0
 private void tsBtnAdd_Click(object sender, EventArgs e)
 {
     using (var userForm = new UserEditForm(null, true))
     {
         if (userForm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             if (DoServiceCall("Пользователь успешно добавлен",
                               () =>
             {
                 return(_service.CreateUser(userForm.User, _loginInfo.SessionGuid));
             }))
             {
                 UpdateUsersGrid();
             }
         }
     }
 }
示例#2
0
        private void tsBtnEdit_Click(object sender, EventArgs e)
        {
            string userName;

            if (!SelectedUser(out userName))
            {
                return;
            }

            UserParam user = null;

            if (!DoServiceCall(null,
                               () =>
            {
                var result = _service.GetUser(userName, _loginInfo.SessionGuid);
                user = result.Data;
                return(result);
            }))
            {
                return;
            }

            using (var userForm = new UserEditForm(user, false))
            {
                if (userForm.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    if (DoServiceCall("Пользователь успешно изменен",
                                      () =>
                    {
                        return(_service.UpdateUser(userForm.User, _loginInfo.SessionGuid));
                    }))
                    {
                        UpdateUsersGrid();
                    }
                }
            }
        }