Exemplo n.º 1
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            frmUserRoleEdit.Visibility = Visibility.Hidden;
            var UserID = int.Parse(txtUserID.Text);
            var RoleID = txtRoleID.Text.ToString();

            if (chkBoxActive.IsChecked == true)
            {
                active = true;
            }
            else
            {
                active = false;
            }

            try
            {
                if (insertUpdate.Equals("i"))
                {
                    myUserRoleManager.AddNewUserRole(_accessToken.UserID, RoleID);
                    lblMessage.Content = "Record Inserted successfully.";
                }
                else
                if (insertUpdate.Equals("u"))
                {
                    var res = myUserRoleManager.EditUserRoleStatus(UserID, RoleID, active);
                    if (res == true)
                    {
                        lblCrudRes.Content = "Record Updated successfully.";
                        lblMessage.Content = "Operation Succeeded. ";
                    }
                    else
                    {
                        lblMessage.Content = "Operation failed. ";
                    }
                }
            }
            catch (Exception)
            {
                lblCrudRes.Content = "Operation Failed, check out!";
            }
            finally
            {
                insertUpdate       = "";
                txtUserID.Text     = "";
                txtRoleID.Text     = "";
                lblCrudRes.Content = "";
                PopulateUserRoleGrid();
            }
        }