public UserFlightSearchWindow(UserLandingWindow landingWindow)
 {
     InitializeComponent();
     m_parent     = landingWindow;
     this.Closed += new EventHandler(FlightSearch_Closed);
     FoundFlightsGrid.ItemsSource = LoadAllFlights(); //Loads all flights available to book, minus any the user has already booked.
     FoundFlightsGrid.Items.Refresh();
     roundTripFlag = false;
     endPage       = false;
 }
        public UserAccountDetailsWindow(UserLandingWindow main)
        {
            InitializeComponent();
            this.Closed += new EventHandler(UserSettings_Closed);
            m_parent     = main;
            CanceledFlightsGrid.ItemsSource = LoadCanceledFlights(); //Loads user's cancelled flights into grid.
            PreviousFlightsGrid.ItemsSource = LoadTakenFlights();    //Load's user's taken flights into grid.

            //Fields the user cannot change are loaded into Labels
            PointsBalanceLabel.Content = App.LoggedInUser.balance.ToString();
            uidLabel.Content           = App.LoggedInUser.uniqueID;

            //Fields the user can change are loaded into TextBoxes
            firstNameTextBox.Text = App.LoggedInUser.firstName.Trim();
            lastNameTextBox.Text  = App.LoggedInUser.lastName.Trim();
            emailTextBox.Text     = App.LoggedInUser.emailAddress.Trim();
            ageTextBox.Text       = App.LoggedInUser.age.ToString().Trim();;
            addressTextBox.Text   = App.LoggedInUser.address.Trim();
            cityTextBox.Text      = App.LoggedInUser.city.Trim();
            phoneTextBox.Text     = App.LoggedInUser.phoneNumber.ToString().Trim();
            USStateBox.Text       = App.LoggedInUser.state.Trim();
            CCTextBox.Text        = App.LoggedInUser.creditCardNumber.ToString().Trim();
        }
コード例 #3
0
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {                                //Called when the Login button is clicked. Checks username and password inputs, and opens the requested window when asked.
            if (usrBox.Text.Length == 1) //length of 1 means you're probably logging in with an employee integer
            {
                if (pwdBox.Text == "alpha")
                {
                    int employeeType = Int32.Parse(usrBox.Text);
                    switch (employeeType)
                    {
                    case 0:
                        LoadEngineer();
                        return;

                    case 1:
                        MarketManager();
                        return;

                    case 2:
                        Accountant();
                        return;

                    case 3:
                        FlightManager();
                        return;

                    default:
                        //Failed to login to employee acct
                        MessageBox.Show("Failed to Log in\nUserID or Password is incorrect", "Error");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("Failed to Log in\nUserID or Password is incorrect", "Error");
                }
            }
            else if (App.UserAccountDict.TryGetValue(usrBox.Text, out App.LoggedInUser))//Checks if a user exists with that UID and stores it in App.LoggedInUser if one exists
            {
                //Check if password match
                using (SHA512 sha512hash = SHA512.Create())
                {
                    byte[] sourcePwdBytes = Encoding.UTF8.GetBytes(pwdBox.Text); //hash can only be done on string of bytes
                    byte[] hashBytes      = sha512hash.ComputeHash(sourcePwdBytes);
                    hashedPwd = BitConverter.ToString(hashBytes).Replace("-", String.Empty);
                }
                if (hashedPwd == App.LoggedInUser.getPwdHash())//Passwords match, so log them in successfully
                {
                    Console.WriteLine("User " + App.LoggedInUser.getUniqueID() + " Logged In Successfully");
                    UserLandingWindow landingWindow = new UserLandingWindow(this);
                    pwdBox.Text = "";     //Cleared so when they logout password doesn't persist for next user
                    landingWindow.Show(); //Load UserLandingWindow
                    this.Hide();
                }
                else
                {   //Wrong Password, don't log them in
                    MessageBox.Show("Failed to Log in\nUserID or Password is incorrect", "Error");
                    Console.WriteLine("User " + App.LoggedInUser.getUniqueID() + " did not log in - PWD hash did not match.");
                    App.LoggedInUser = null; //Clear LoggedInUser to prevent unwanted access
                    pwdBox.Text      = "";   //Clear pwd box
                    return;
                }
            }
            else
            {   //User doesn't exist with that UID, so cannot login
                MessageBox.Show("Failed to Log in\nUser with this ID does not exist. Please double check your ID", "Error");
                Console.WriteLine("User not found with UID " + usrBox.Text);
                pwdBox.Text = "";
                return;
            }
        }