Пример #1
0
        private async void AuthorizeButton_Click(object sender, RoutedEventArgs e)
        {
            User.Name     = UserNameBox.Text;
            User.Password = UserPasswordBox.Text;

            if (User.Name != string.Empty && User.Password != string.Empty)
            {
                bool isRegistred = Convert.ToBoolean(await ApiManager.Read($"api/authorization/isRegistred/{User.Name}/{User.Password}"));
                if (isRegistred)
                {
                    MainWindow     mainWindow     = new MainWindow();
                    SignalRManager signalRManager = new SignalRManager();

                    ApiManager.Change("api/authorization/login", $"{{'Name':'{User.Name}', 'Password':'******'}}");
                    signalRManager.OnConnect();

                    Close();
                    mainWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Вы не зарегестрированы!");
                }

                UserNameBox.Clear();
                UserPasswordBox.Clear();
            }
            else
            {
                MessageBox.Show("Заполните все поля!");
            }
        }
Пример #2
0
        /// <summary>
        /// Eventmetode for loginknapp
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (!_brukerNavnValidated || !_passordValidated)
            {
                return;
            }

            if (_dbConnect.CheckPassword(_finalBrukernavn, _finalPassord))
            {
                SpillerNavn      = _finalBrukernavn;
                SpillerID        = _dbConnect.GetPlayerId(_finalBrukernavn);
                SpillerHighScore = _dbConnect.GetPersonalBest(SpillerID);
                //   AllHighScore = _dbConnect.GetHighScores();

                //Program.cs sjekker om DoRun er true, lukker så dette formet sånn at tråden kan kjøre spillet.
                if (!String.IsNullOrEmpty(SpillerNavn) && !String.IsNullOrEmpty(SpillerID.ToString()) &&
                    !String.IsNullOrEmpty(SpillerHighScore.ToString()))
                {
                    DoRun = true;
                    Close();
                }
                else
                {
                    errorProviderUserName.SetError(UserNameBox,
                                                   "Database error");
                }
            }
            else
            {
                UserNameBox.Clear();
                PasswordBox.Clear();
                DoRun = false;
                errorProviderUserName.SetError(UserNameBox, "Wrong username or password!");
            }
        }
Пример #3
0
 private void ClearTextBoxes()
 {
     UserNameBox.Clear();
     ComputerNameBox.Clear();
     RamBox.Clear();
     RamUsageBox.Clear();
     CpuUsageBox.Clear();
     CpuBox.Clear();
     IpBox.Clear();
     AverageDiskQueueLengthBox.Clear();
     AvailableDiskSpaceGBBox.Clear();
     VideoCardBox.Clear();
 }
Пример #4
0
        private void Login_Click(object sender, EventArgs e)
        {
            string UserName = UserNameBox.Text;
            string password = PasswordBox.Text;

            if (UserName == null || UserName.Equals(""))
            {
                MessageBox.Show("Must enter your credentials!");
            }
            else if (LoginChecker.CheckIfValid(UserName, password, ref student)) //Validate the login
            {
                LoggedIn = true;
                Console.WriteLine("user is: " + UserName + "\n" + " pass is: " + password);
                WelcomeUser.Text = "Welcome to the Nation, " + UserName + "!";
                UserNameBox.Clear();
                PasswordBox.Clear();
            }
            else
            {
                MessageBox.Show("Invalid Login!");
            }
        }
Пример #5
0
        //----< Handle Login Button Click >-------------------------------------

        private void LogInButton_Click(object sender, RoutedEventArgs e)
        {
            if (!isLoggedIn)
            {
                CsEndPoint userEndPoint = new CsEndPoint();
                userEndPoint.machineAddress = "localhost";
                userEndPoint.port           = 9000;
                CsMessage msg = new CsMessage();
                msg.add("to", CsEndPoint.toString(userEndPoint));
                msg.add("from", CsEndPoint.toString(endPoint_));
                msg.add("command", "check_credentials");
                msg.add("userName", UserNameBox.Text);
                msg.add("password", PasswordBox.Text);
                UserNameBox.Clear();
                PasswordBox.Clear();
                translater.postMessage(msg);
                CsMessage replyMsg = translater.getMessage();
                if (replyMsg.value("credentialCheck") == "credential_good_is_admin")
                {
                    UserNameBox.Clear();
                    PasswordBox.Clear();
                    isLoggedIn                    = true;
                    LogInButton.Content           = "Log Out";
                    CreateNewUserButton.IsEnabled = true;
                    tabItem2.IsEnabled            = true;
                    tabItem3.IsEnabled            = true;
                    tabItem4.IsEnabled            = true;
                    Console.Write("\nValid - Admin");
                }
                else if (replyMsg.value("credentialCheck") == "credential_good_not_admin")
                {
                    UserNameBox.Clear();
                    PasswordBox.Clear();
                    isLoggedIn          = true;
                    LogInButton.Content = "Log Out";
                    tabItem2.IsEnabled  = true;
                    tabItem3.IsEnabled  = true;
                    tabItem4.IsEnabled  = true;
                    Console.Write("\nValid - Not Admin");
                }
                else if (replyMsg.value("credentialCheck") == "credential_not_good")
                {
                    Console.Write("\nNot Valid");
                }
                else
                {
                    Console.Write("\nLog In Error");
                }
            }
            else
            {
                UserNameBox.Clear();
                PasswordBox.Clear();
                isLoggedIn                    = false;
                LogInButton.Content           = "Log In";
                CreateNewUserButton.IsEnabled = false;
                CreateNewUserButton.Content   = "Create New User";
                tabItem2.IsEnabled            = false;
                tabItem3.IsEnabled            = false;
                tabItem4.IsEnabled            = false;
                Console.Write("\nLogging Out");
            }
        }
Пример #6
0
 private void UserNameBox_GotFocus(object sender, RoutedEventArgs e)
 {
     UserNameBox.Clear();
     UserNameBox.Foreground = Brushes.Black;
 }
Пример #7
0
 private void UsernameClearButton_Click(object sender, EventArgs e)
 {
     UserNameBox.Clear();
 }
Пример #8
0
 private void ClearAll()
 {
     IPmaskedTextBox.Clear();
     UserNameBox.Clear();
     portTextBox.Clear();
 }
        private void loginBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var user = dc.users.Where(x => x.UserName == UserNameBox.Text &&
                                          x.Password == PasswordBox.Password).Single();

                if (AdminBox.IsChecked == true && EmployeeBox.IsChecked == true)
                {
                    MessageBox.Show("Please only selected one role!");
                }
                else
                {
                    if (AdminBox.IsChecked == true)
                    {
                        if (user.Role == AdminBox.Content.ToString())
                        {
                            Homepage hp = new Homepage();
                            hp.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("U Dont have access to this!");
                            UserNameBox.Clear();
                            PasswordBox.Clear();
                        }
                    }
                    else if (EmployeeBox.IsChecked == true)
                    {
                        if (user.Role == EmployeeBox.Content.ToString())
                        {
                            Homepage hp = new Homepage();
                            hp.Show();
                            this.Hide();
                        }
                        else if (user.Role == "Admin")
                        {
                            Homepage hp = new Homepage();
                            hp.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("U Dont have access to this!");
                            UserNameBox.Clear();
                            PasswordBox.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("u need to check out ur role");
                    }
                }
            }
            catch
            {
                UserNameBox.Clear();
                PasswordBox.Clear();
                MessageBox.Show("Login failed");
            }
        }