コード例 #1
0
 private void BtnLogout_OnClick(object sender, RoutedEventArgs e)
 {
     MainWindow mainWindow = new MainWindow();
     this.Close();
     mainWindow.ShowDialog();
 }
コード例 #2
0
        private void SubmitRegistration(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(this.TxtUsername.Text)
                || String.IsNullOrEmpty(this.TxtEmail.Text)
                || String.IsNullOrEmpty(this.TxtPassword.Password))
            {
                MessageBox.Show("Username, email and password can not be empty!");
            }
            else if (this.TxtPassword.Password != this.TxtConfirmPassword.Password)
            {
                MessageBox.Show("Passwords are not the same!");
            }
            else
            {
                UserSet userToAdd = new UserSet();
                userToAdd.Username = this.TxtUsername.Text;
                userToAdd.Email = this.TxtEmail.Text;
                userToAdd.PasswordHash = DataAccess.PasswordHash.HashPassword(this.TxtPassword.Password);

                if (!String.IsNullOrEmpty(this.TxtCreditCardNumber.Text))
                {
                    userToAdd.CreditCardNumberHash = DataAccess.PasswordHash.HashPassword(this.TxtCreditCardNumber.Text);
                }
                if (!String.IsNullOrEmpty(this.TxtAddress.Text))
                {
                    userToAdd.Address = this.TxtAddress.Text;
                }
                if (!String.IsNullOrEmpty(this.TxtZipCode.Text))
                {
                    userToAdd.Address = this.TxtZipCode.Text;
                }
                if (!String.IsNullOrEmpty(this.TxtFirstName.Text))
                {
                    userToAdd.Address = this.TxtFirstName.Text;
                }
                if (!String.IsNullOrEmpty(this.TxtLastName.Text))
                {
                    userToAdd.Address = this.TxtLastName.Text;
                }
                if (!String.IsNullOrEmpty(this.TxtTicketId.Text))
                {
                    userToAdd.Address = this.TxtTicketId.Text;
                }
                if (!String.IsNullOrEmpty(this.TxtDiscountcardId.Text))
                {
                    userToAdd.Address = this.TxtDiscountcardId.Text;
                }
                if (DataAccess.DataAccess.AddUser(userToAdd))
                {
                    MessageBox.Show("Registration successful! Use your username and password to login.");
                    MainWindow mainWindow = new MainWindow();
                    this.Close();
                    mainWindow.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Oops, something went wrong in your registration!");
                }
            }
        }