Exemplo n.º 1
0
 /// <summary>
 /// When the main menu button is selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnMainMenu_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         mainMenu.Show();
         this.Close();
     }
     catch (Exception ex)
     {
         ex.Log();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// When the window exits
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnExit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         uiUpdateTimer.Stop();
         uiUpdateTimer.Dispose();
         mainMenu.Show();
         Close();
     }
     catch (Exception ex)
     {
         ex.Log();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Will attempt to log the user in on button press
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            string username = txtUsername.Text;
            int    age      = 0;

            try
            {
                if (!int.TryParse(txtAge.Text, out age))
                {
                    throw new ArgumentException();
                }
                if (age > 0)
                {
                    if (Controllers.UserManager.LoginUser(username, age).Status == Utilities.OperationStatus.Success)
                    {
                        Console.WriteLine("The user was logged into the application!");
                        MainMenuWindow mainMenu = new MainMenuWindow(this);
                        mainMenu.Show();
                        this.Hide();
                    }
                    else
                    {
                        // Alert the user that they could not be loged in
                        Console.WriteLine("The user could not be logged into the application!");
                    }
                }
                else
                {
                    Console.WriteLine("The user entered an invalid age <= 0.");
                    ErrorOutput.Visibility = Visibility.Visible;
                    tbkErrorOutput.Text    = "ERROR: Invalid user data, please enter a value above 0.";
                }
            }
            catch (ArgumentException argEx)
            {
                // Tell the user they entered invalid data
                ErrorOutput.Visibility = Visibility.Visible;
                tbkErrorOutput.Text    = "ERROR: Invalid user data, please use only numeric values for your age.";
            }
            catch (Exception ex)
            {
                ErrorOutput.Visibility = Visibility.Visible;
                tbkErrorOutput.Text    = "ERROR: Unknown System Error. Please see error log.";
                ex.Log();
            }
        }