private void ButtonLogin_Click(object sender, RoutedEventArgs e) { int userID = 0; if (!verifySGBDConnection()) { return; } SqlDataAdapter da2 = new SqlDataAdapter(); if (cn.State == ConnectionState.Closed) { cn.Open(); } SqlCommand command = new SqlCommand("SELECT SampleKeeper.getLogin(@nickname, @password)", cn); command.Parameters.AddWithValue("@nickname", txtUsername.Text); command.Parameters.AddWithValue("@password", txtPassword.Password); userID = (int)command.ExecuteScalar(); if (userID != 0) { cn.Close(); SearchWindow win2 = new SearchWindow(txtUsername.Text, userID); win2.Show(); this.Close(); } else { label1.Content = "Wrong Username and/or Password!"; label1.Visibility = Visibility.Visible; } }
private void SearchItemSelected(object sender, RoutedEventArgs e) { SearchWindow win = new SearchWindow(user, userid); win.Show(); this.Close(); }
private void RemoveAlbum(object sender, RoutedEventArgs e) { string catnumber = ""; for (i = 0; i < album_list.Count; i++) { if (album_list[i].nome == c.currentAlbum) { catnumber = album_list[i].catalog_number; } } if (!verifySGBDConnection()) { return; } SqlCommand cmd = new SqlCommand("SampleKeeper.remove_album", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@catalog_number", catnumber); cmd.Connection = cn; try { cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception("Failed to update contact in database. \n ERROR MESSAGE: \n" + ex.Message); } finally { cn.Close(); SearchWindow window = new SearchWindow(user, userid); window.Show(); this.Close(); } }