コード例 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = this.tbUsernam.Text.ToLower();
            string password = this.pbPassword.Password;

            List <User> users = new List <User>();

            try
            {
                users = _loginService.Login(username, password);
                User user = users.Single(s => s.Username.ToLower() == username);
                if (user.IsAdmin == false)
                {
                    ManageMechanics manageMechanics = new ManageMechanics();
                    List <Mechanic> mechanics       = manageMechanics.AllMechanics();
                    Mechanic        mechanic        = mechanics.Single(x => x.IdNumber == user.MechanicId);

                    MechanicHome mechanicHomePage = new MechanicHome(mechanic);

                    this.NavigationService.Navigate(mechanicHomePage);
                }
                else
                {
                    AdminHome adminHomePage = new AdminHome();

                    this.NavigationService.Navigate(adminHomePage);
                }
            }
            catch
            {
                MessageBox.Show(_errorMsg);
                this.tbUsernam.Clear();
                this.pbPassword.Clear();
            }
        }
コード例 #2
0
        private void goBackButton_Click(object sender, RoutedEventArgs e)
        {
            MechanicHome mechanicHome = new MechanicHome(Mechanic);

            this.NavigationService.Navigate(mechanicHome);
        }