private void saveWLAN() { if (currentWLAN == null) { if (!(wifi_checkbox.IsChecked ?? false)) { return; } currentWLAN = new WirelessLAN( -1, selectedProject, "WIFI_" + selectedProject.ProjectID.ToString(), wifi_password.Password ); createWLAN(); } else if (!(wifi_checkbox.IsChecked ?? false)) { destroyWLAN(); } else { if (currentWLAN.PasswordHash != wifi_password.Password) { currentWLAN.PasswordHash = wifi_password.Password; updateWLAN(); } } }
private void loadWLANs() { cn = Helpers.getSGBDConnection(); if (!Helpers.verifySGBDConnection(cn)) { throw new Exception("Cannot connect to database"); } SqlCommand cmd = new SqlCommand("SELECT * FROM DML.WLAN_INFO (@ProjectID)", cn); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@ProjectID", selectedProject.ProjectID); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); currentWLAN = new WirelessLAN( int.Parse(reader["NetResID"].ToString()), selectedProject, reader["SSID"].ToString(), reader["PasswordHash"].ToString() ); see_more.Visibility = Visibility.Visible; wifi_checkbox.IsChecked = true; wifi_ssid.Content = "SSID : " + currentWLAN.SSID; wifi_password.Password = currentWLAN.PasswordHash; wifi_password.IsEnabled = true; } cn.Close(); }
private void project_button_Checked(object sender, RoutedEventArgs e) { try { // Check selected project checkProject(); // Clear all fields and disable buttons currentWLAN = null; request_vm_button.IsEnabled = true; request_network_button.IsEnabled = true; deliver_button.IsEnabled = true; os_list.IsEnabled = true; wifi_checkbox.IsEnabled = true; socket_list.IsEnabled = true; // Clear active requisitions data and load the active requisitions for selected project ActiveRequisitionsData.Clear(); wifi_checkbox.IsChecked = false; see_more.Visibility = Visibility.Hidden; wifi_password.Password = ""; wifi_ssid.Content = ""; LoadProjectActiveRequisitions(); loadWLANs(); } catch (SqlException exc) { Helpers.ShowCustomDialogBox(exc); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }