private void Register_Click(object sender, RoutedEventArgs e)
 {
     //TODO:fix it
     if (Pass.Password == ConfPass.Password)
     {
         if (FR.FR_Imp.GetFR().CheckIfGuestExists(User.Text) ||
             FR.FR_Imp.GetFR().CheckIfHostExists(User.Text))
         {
             MessageBox.Show("There is already an account by that name!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         if (User.Text.ToLower() == "admin")
         {
             MessageBox.Show("Invalid username!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         int key = Configuration.GuestKey;
         FR_Imp.GetFR().WriteGuestToFile(User.Text, Pass.Password, key);
         MessageBox.Show("You have been registered!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Hide();
         var createWin = new GuestMenu(User.Text, key);
         createWin.Closed += (s, args) => Close();
         createWin.Show();
         return;
     }
     //TODO: לעשות שאי שיוון בי הטקסטבוקסים יותרע בתווית
     MessageBox.Show("Password and confirmation must match!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
 }
Beispiel #2
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            if (FR.FR_Imp.GetFR().GuestCompareToPasswordInFile(UserTextBox.Text.ToLower(), PassBox.Password))
            {
                UserName = UserTextBox.Text;
                Hide();
                var createWin = new GuestMenu(UserName, FR.FR_Imp.GetFR().GetGuestKey(UserName));
                createWin.Closed += (s, args) =>
                {
                    ClearButton_Click(null, null);
                    Show();
                };
                createWin.Show();
            }

            else if (FR.FR_Imp.GetFR().HostCompareToPasswordInFile(UserTextBox.Text.ToLower(), PassBox.Password))
            {
                UserName = UserTextBox.Text;
                Hide();
                var createWin = new HostMenu(new BE.Host()
                {
                    PhoneNumber       = FR.FR_Imp.GetFR().GetHostPhoneNumber(UserName),
                    PrivateName       = FR.FR_Imp.GetFR().GetHostPrivateName(UserName),
                    FamilyName        = FR.FR_Imp.GetFR().GetHostFamilyName(UserName),
                    MailAddress       = FR.FR_Imp.GetFR().GetHostMailAddress(UserName),
                    HostKey           = FR.FR_Imp.GetFR().GetHostKey(UserName),
                    BankBranchDetails = new BE.BankBranch()
                });
                createWin.Closed += (s, args) =>
                {
                    ClearButton_Click(null, null);
                    Show();
                };
                createWin.Show();
            }

            else if (FR.FR_Imp.GetFR().AdminCompareToPasswordInFile(UserTextBox.Text.ToLower(), PassBox.Password))
            {
                UserName = "******";
                Hide();
                var createWin = new AdminWindow();
                createWin.Closed += (s, args) =>
                {
                    ClearButton_Click(null, null);
                    Show();
                };
                createWin.Show();
            }
            else
            {
                System.Media.SystemSounds.Hand.Play();
                WrongLabel.Visibility = Visibility.Visible;
            }
        }