public void updateTableList() { listViewTables.Items.Clear(); welcomeSQLManager.openConnection(databaseName); listOfDatabaseTables = welcomeSQLManager.getDatabaseTables(); welcomeSQLManager.closeConnection(); foreach (string tableName in listOfDatabaseTables) { listViewTables.Items.Add(tableName); } }
public void populateDataGrid() { DataTable dataSet = new DataTable(); Console.WriteLine(tableDatabaseName); jobManagerSQLManager.openConnection(tableDatabaseName); MySqlDataAdapter dataAdapter = new MySqlDataAdapter("select * from " + tableDatabaseName + "." + tableName.ToString() + ";", jobManagerSQLManager.sqlConnect); dataAdapter.Fill(dataSet); jobManagerSQLManager.closeConnection(); SQLTableDataGrid.ItemsSource = dataSet.DefaultView; }
private void buttonLogin_Click(object sender, RoutedEventArgs e) { if (loginUsername.Text.Length == 0) { //If username field is empty errormessage.Text = "Username field cannot be empty."; loginUsername.Focus(); //Set focus to email textBox } else if (loginPassword.Password.Length == 0) { errormessage.Text = "Password field cannot be empty."; loginPassword.Focus(); } else { string username = loginUsername.Text; string password = loginPassword.Password; //Get password as SecureString - gets deleted from memory when not in use MySQLManager loginSQLManager = new MySQLManager(); loginSQLManager.openConnection(loginSQLManager.loginDatabase); //Not sure! Must pass it as PasswordBox for better security? if (loginSQLManager.loginAuth(username, password)) //if auth was succesful { //Connect to users company database and grab all tables loginSQLManager.openConnection(loginSQLManager.userCompanyDatabase); welcome welcomeScreen = new welcome(); welcomeScreen.databaseName = loginSQLManager.userCompanyDatabase; welcomeScreen.updateTableList(); loginSQLManager.closeConnection(); //Switch to welcome screen welcomeScreen.TextBlockName.Text = username; welcomeScreen.Top = this.Top; welcomeScreen.Left = this.Left; welcomeScreen.Show(); Close(); } else //If auth was unsuccesful { errormessage.Text = DateTime.Now.ToString("h:mm:ss tt - ") + "Access denied - username and / or password is incorrect"; } } }