private void Login(object sender, RoutedEventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox3.Text) || string.IsNullOrWhiteSpace(UserLoginPassword.Password))
     {
         MessageBox.Show("Error! One or more fields are missing!");
     }
     else if (!userNameLoginCheck(textBox3.Text))
     {
         MessageBox.Show("Error! Wrong email!");
     }
     else if (checkForSQLInjection(UserLoginPassword.Password) || checkForSQLInjection(textBox3.Text))
     {
         MessageBox.Show("Invalid password.\n SQL Injection threat.");
     }
     else
     {
         try
         {
             UserSingleton.Create(textBox3.Text, SHA.sha(UserLoginPassword.Password));
             UserSingleton.GetInstance();
             this.Close();
         }
         catch (Exception msg)
         {
             MessageBox.Show(msg.Message);
         }
         //new Server().Login(Email, SHA.sha(Password));
         //currentUser.User = user;
     }
 }
        private void AssignedUsersLoading(object sender, RoutedEventArgs e)
        {
            try
            {
                UserSingleton.GetInstance();
                AllAssignedUsers = new Server().SetAssignedUsers(VoteNum);
                if (AllAssignedUsers != null)
                {
                    AssignedUsersList.ItemsSource   = AllAssignedUsers;
                    AssignedUsersList.SelectedIndex = 0;

                    // AllUsers = AllUsers.Except(AllAssignedUsers).ToList();

                    //foreach (User u in AllAssignedUsers) AllUsers.Remove(u);

                    AllUsers.RemoveAll(a => AllAssignedUsers.Exists(b => a.UserID == b.UserID));

                    UsersList.ItemsSource   = null;
                    UsersList.ItemsSource   = AllUsers;
                    UsersList.SelectedIndex = 0;
                }
            }
            catch (Exception msg)
            {
                LoginWindow window = new LoginWindow();
                window.Owner = Window.GetWindow(this);
                window.ShowDialog();
                UsersLoading(sender, e);
            }
            //Error message
        }
Beispiel #3
0
 private void LogInButton(object sender, RoutedEventArgs e)
 {
     // if (User.userNameLoginCheck(this, UserLoginEmail.Text) == true && User.userPasswordLoginCheck(this, UserLoginPassword.Password) == true)
     // {
     try
     {
         UserSingleton.Create(UserLoginEmail.Text, SHA.sha(UserLoginPassword.Password));
     }
     catch (Exception msg)
     {
         MessageBox.Show(msg.ToString());
     }
     //new Server().Login(Email, SHA.sha(Password));
     //currentUser.User = user;
     try
     {
         UserSingleton.GetInstance();
         this.Close();
     }
     catch (Exception msg)
     {
         MessageBox.Show(msg.Message);
     }
     // }
 }
Beispiel #4
0
 public static void Create(String Email, String Password)
 {
     if (NewUser != null)
     {
         throw new Exception("Object already created");
     }
     instance = new UserSingleton(Email, Password);
 }
 private void UsersLoading(object sender, RoutedEventArgs e)
 {
     try
     {
         UserSingleton.GetInstance();
         AllUsers = new Server().SetUsers();
         if (AllUsers != null)
         {
             UsersList.ItemsSource   = AllUsers;
             UsersList.SelectedIndex = 0;
         }
     }
     catch (Exception msg)
     {
         LoginWindow window = new LoginWindow();
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         UsersLoading(sender, e);
     }
     //Error message
 }
 private void CandidatesLoading(object sender, RoutedEventArgs e)
 {
     try
     {
         UserSingleton UserAdmin   = UserSingleton.GetInstance();
         string        UserAdminID = UserAdmin.GetUserID();
         Candidates = new Server().SetCandidates(VoteNum);
         if (Candidates != null)
         {
             CandudatesList.ItemsSource = Candidates;
         }
         CandudatesList.SelectedIndex = 0;
     }
     catch (Exception msg)
     {
         LoginWindow window = new LoginWindow();
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         CandidatesLoading(sender, e);
     }
 }
Beispiel #7
0
 //UserVotingsList
 private void UserVotingsLoading(string UserID)//()
 {
     try
     {
         UserSingleton UserAdmin   = UserSingleton.GetInstance();
         string        UserAdminID = UserAdmin.GetUserID();
         AllUserVotings = new Server().SetUserPool(UserID);
         if (AllVotings != null)
         {
             UserVotingsList.ItemsSource = AllUserVotings;
         }
         //VotingsList.SelectedIndex = 0;
     }
     catch (Exception msg)
     {
         LoginWindow window = new LoginWindow();
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         UserVotingsLoading(UserID);
     }
     //Error message
 }
Beispiel #8
0
 private void VotingsLoading(object sender, RoutedEventArgs e)
 {
     try
     {
         UserSingleton UserAdmin   = UserSingleton.GetInstance();
         string        UserAdminID = UserAdmin.GetUserID();
         AllVotings = new Server().SetPool(UserAdminID);
         if (AllVotings != null)
         {
             FilteredVotings         = AllVotings;
             VotingsList.ItemsSource = AllVotings;
         }
         //VotingsList.SelectedIndex = 0;
     }
     catch (Exception msg)
     {
         LoginWindow window = new LoginWindow();
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         VotingsLoading(sender, e);
     }
     //Error message
 }