Exemplo n.º 1
0
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            LogicHandler l = new LogicHandler();

            var username = TbUsername.Text;
            var password = TbPassword.Text;

            var loggedUser = l.loginUser(username, password);
            var loggedBoss = l.loginBoss(username, password);

            if (loggedUser != null && source == 2) //source, chef eller vanlig användare
            {
                MainWindow.main.Status = loggedUser.Username;
                MainWindow.main.btnLogOut.Visibility = Visibility.Visible;
                MainWindow.main.BtnLogIn.Visibility  = Visibility.Hidden;
                this.Close();
            }
            else if (loggedBoss != null && source == 1)
            {
                var isBoss = String.Format(loggedBoss.Username + " (Chef)");
                MainWindow.main.BossStatus = isBoss;
                MainWindow.main.btnLogOutChef.Visibility = Visibility.Visible;
                MainWindow.main.btnLogInChef.Visibility  = Visibility.Hidden;
                this.Close();
            }
            else
            {
                lbError.Content = "Misslyckad inloggning! Försök igen tack å hej";
            }
        }