예제 #1
0
 private void DefaultUser()
 {
     try
     {
         if ((Factory.Default.GetUsersRepository().Items.Count() == 1) && (StudySession.Default.CurrentUserID == 0) && (Factory.Default.GetUsersRepository().Items.ToList()[0].Password == null))
         {
             StudySession.Default.CurrentUserID = Factory.Default.GetUsersRepository().Items.ToList()[0].ID;
             StartWin sw = new StartWin();
             sw.Show();
             this.Close();
         }
     }
     catch
     {
         MessageBox.Show("An error occured. Last action was not performed.");
     }
 }
예제 #2
0
 private void OkButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var u = (User)userListBox.SelectedItem;
         if ((u != null && u.Password == null) || (Convert.ToBase64String(MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(passwordBox.Password))) == u.Password))
         {
             StudySession.Default.CurrentUserID = u.ID;
             StartWin sw = new StartWin();
             sw.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Incorrect password.");
         }
     }
     catch
     {
         MessageBox.Show("Profile was not selected.");
     }
 }