類別(全)SQL查詢

This commit is contained in:
jasonchenwork 2025-04-14 16:12:49 +08:00
parent 9fc07f5a15
commit dd07cd6f52
9 changed files with 45 additions and 24 deletions

View File

@ -11,10 +11,12 @@ namespace DualScreenDemo
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground; nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaActiveBackground; chinaSongsButton.BackgroundImage = chinaActiveBackground;
chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1")) /*chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("F1"); // Set the query for SQL to filter by genre "F1"
var chinaSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = chinaSongs; currentSongList = chinaSongs;
totalPages = (int)Math.Ceiling((double)chinaSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)chinaSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("A1"); // Set the query for SQL to filter by genre "F1"
var loveDuetSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = loveDuetSongs; currentSongList = loveDuetSongs;
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1")) /*medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("C1"); // Set the query for SQL to filter by genre "F1"
var medleyDanceSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = medleyDanceSongs; currentSongList = medleyDanceSongs;
totalPages = (int)Math.Ceiling((double)medleyDanceSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)medleyDanceSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1")) /*ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("D1"); // Set the query for SQL to filter by genre "F1"
var ninetiesSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = ninetiesSongs; currentSongList = ninetiesSongs;
totalPages = (int)Math.Ceiling((double)ninetiesSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)ninetiesSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1")) /*nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("E1"); // Set the query for SQL to filter by genre "F1"
var nostalgicSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = nostalgicSongs; currentSongList = nostalgicSongs;
totalPages = (int)Math.Ceiling((double)nostalgicSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)nostalgicSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1")) /*talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("B1"); // Set the query for SQL to filter by genre "F1"
var talentShowSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = talentShowSongs; currentSongList = talentShowSongs;
totalPages = (int)Math.Ceiling((double)talentShowSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)talentShowSongs.Count / itemsPerPage);

View File

@ -12,9 +12,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1")) /*vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("G1"); // Set the query for SQL to filter by genre "F1"
var vietnameseSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = vietnameseSongs; currentSongList = vietnameseSongs;
totalPages = (int)Math.Ceiling((double)vietnameseSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)vietnameseSongs.Count / itemsPerPage);

View File

@ -177,9 +177,11 @@ namespace DualScreenDemo
chinaSongsButton.BackgroundImage = chinaNormalBackground; chinaSongsButton.BackgroundImage = chinaNormalBackground;
loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList(); .ToList();*/
string query = SetQueryforSQL("A1");
var loveDuetSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
currentSongList = loveDuetSongs; currentSongList = loveDuetSongs;
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);
@ -248,5 +250,10 @@ namespace DualScreenDemo
} }
private string SetQueryforSQL(string contains){
string query = $"SELECT * FROM SongLibrary WHERE `分類` LIKE '%{contains}%' ORDER BY `點播次數` DESC";
return query;
}
} }
} }

View File

@ -189,13 +189,13 @@ namespace DualScreenDemo
private List<SongData> yingWenSongs2; private List<SongData> yingWenSongs2;
private List<SongData> riYuSongs2; private List<SongData> riYuSongs2;
private List<SongData> hanYuSongs2; private List<SongData> hanYuSongs2;
private List<SongData> loveDuetSongs; //private List<SongData> loveDuetSongs;
private List<SongData> talentShowSongs; //private List<SongData> talentShowSongs;
private List<SongData> medleyDanceSongs; //private List<SongData> medleyDanceSongs;
private List<SongData> ninetiesSongs; //private List<SongData> ninetiesSongs;
private List<SongData> nostalgicSongs; //private List<SongData> nostalgicSongs;
private List<SongData> chinaSongs; //private List<SongData> chinaSongs;
private List<SongData> vietnameseSongs; //private List<SongData> vietnameseSongs;
public static List<SongData> userRequestedSongs; public static List<SongData> userRequestedSongs;
public static List<SongData> playedSongsHistory; public static List<SongData> playedSongsHistory;
public static List<PlayState> playStates; public static List<PlayState> playStates;