/* * Navigation links and keeps window size consistent among windows */ private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (((ListViewItem)((ListView)sender).SelectedItem).Name) { case "Home": MainWindow main = new MainWindow(username); main.Height = this.ActualHeight; main.Width = this.ActualWidth; main.Top = this.Top; main.Left = this.Left; main.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { main.WindowState = System.Windows.WindowState.Maximized; } main.Show(); this.Close(); break; case "Events": EventScreen events = new EventScreen(username); events.Height = this.ActualHeight; events.Width = this.ActualWidth; events.Top = this.Top; events.Left = this.Left; events.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { events.WindowState = System.Windows.WindowState.Maximized; } events.Show(); this.Close(); break; case "Friends": FriendScreen friend = new FriendScreen(username); friend.Height = this.ActualHeight; friend.Width = this.ActualWidth; friend.Top = this.Top; friend.Left = this.Left; friend.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { friend.WindowState = System.Windows.WindowState.Maximized; } friend.Show(); this.Close(); break; case "Memories": MemoriesScreen memories = new MemoriesScreen(username); memories.Height = this.ActualHeight; memories.Width = this.ActualWidth; memories.Top = this.Top; memories.Left = this.Left; memories.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { memories.WindowState = System.Windows.WindowState.Maximized; } memories.Show(); this.Close(); break; case "Discover": DiscoverScreen discover = new DiscoverScreen(username); discover.Height = this.ActualHeight; discover.Width = this.ActualWidth; discover.Top = this.Top; discover.Left = this.Left; discover.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { discover.WindowState = System.Windows.WindowState.Maximized; } discover.Show(); this.Close(); break; case "Settings": SettingsScreen settings = new SettingsScreen(username); settings.Height = this.ActualHeight; settings.Width = this.ActualWidth; settings.Top = this.Top; settings.Left = this.Left; settings.WindowStartupLocation = this.WindowStartupLocation; if (this.WindowState == System.Windows.WindowState.Maximized) { settings.WindowState = System.Windows.WindowState.Maximized; } settings.Show(); this.Close(); break; case "Logout": LoginScreen login = new LoginScreen(); login.Show(); this.Close(); break; default: break; } }
/* * deletes account and all everything associated with it */ private void deleteAccount(object sender, RoutedEventArgs e) { if (currentPassword.Equals(confirmPassword.Password) && username.Equals(confirmUsername.Text)) { String CmdString = string.Empty; using (SqlConnection cnn = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=LoginDB; Integrated Security=True;")) { cnn.Open(); CmdString = "DELETE FROM Users WHERE UserName = @username"; SqlCommand cmd = new SqlCommand(CmdString, cnn); // values are retrieve from variables defined in program cmd.Parameters.AddWithValue("@username", username); cmd.ExecuteNonQuery(); } CmdString = string.Empty; using (SqlConnection cnn = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=LoginDB; Integrated Security=True;")) { cnn.Open(); CmdString = "DELETE FROM BucketList WHERE UserName = @username"; SqlCommand cmd = new SqlCommand(CmdString, cnn); // values are retrieve from variables defined in program cmd.Parameters.AddWithValue("@username", username); cmd.ExecuteNonQuery(); } CmdString = string.Empty; using (SqlConnection cnn = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=LoginDB; Integrated Security=True;")) { cnn.Open(); CmdString = "DELETE FROM Friends WHERE UserName = @username"; SqlCommand cmd = new SqlCommand(CmdString, cnn); // values are retrieve from variables defined in program cmd.Parameters.AddWithValue("@username", username); cmd.ExecuteNonQuery(); } CmdString = string.Empty; using (SqlConnection cnn = new SqlConnection(@"Data Source=(localdb)\MSSQLLocalDB; Initial Catalog=LoginDB; Integrated Security=True;")) { cnn.Open(); CmdString = "DELETE FROM Image WHERE UserName = @username"; SqlCommand cmd = new SqlCommand(CmdString, cnn); // values are retrieve from variables defined in program cmd.Parameters.AddWithValue("@username", username); cmd.ExecuteNonQuery(); } LoginScreen login = new LoginScreen(); login.Show(); this.Close(); } else { MessageBox.Show("Credentials Incorrect"); } }