歌手(全)SQL查詢

This commit is contained in:
jasonchenwork 2025-04-14 11:28:41 +08:00
parent 66fdbb7680
commit 50b2126e5b
6 changed files with 78 additions and 64 deletions

View File

@ -515,10 +515,22 @@ namespace DualScreenDemo
pictureBoxZhuYinSingers.Visible = false;
// 關閉注音搜尋的按鈕顏色
zhuyinSearchButton.BackgroundImage = zhuyinSearchNormalBackground;
FindBopomofoSingers();
// 隱藏與 ZhuYin 歌手相關的所有按鈕
SetZhuYinSingersAndButtonsVisibility(false);
}
private void FindBopomofoSingers(){
string searchText = inputBoxZhuYinSingers.Text;
string query = $"SELECT * FROM ArtistLibrary WHERE `歌手注音` LIKE '{searchText}%' ";
var searchResults = SearchSingers_Mysql(query);
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
}
/// <summary>
/// 創建一個特殊的按鈕,並設定其顯示屬性、事件處理和位置。
@ -584,7 +596,7 @@ namespace DualScreenDemo
ResizeAndPositionControl(inputBoxZhuYinSingers, inputBoxZhuYinCoords.X, inputBoxZhuYinCoords.Y, inputBoxZhuYinCoords.Width, inputBoxZhuYinCoords.Height);
// 設定文本變更事件,當輸入框內容改變時觸發
inputBoxZhuYinSingers.TextChanged += (sender, e) =>
/*inputBoxZhuYinSingers.TextChanged += (sender, e) =>
{
string searchText = inputBoxZhuYinSingers.Text;
@ -598,7 +610,7 @@ namespace DualScreenDemo
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
};
};*/
// 將輸入框加入到窗體的控件集合中
this.Controls.Add(inputBoxZhuYinSingers);

View File

@ -266,9 +266,21 @@ namespace DualScreenDemo
pictureBoxEnglishSingers.Visible = false;
englishSearchButton.BackgroundImage = englishSearchNormalBackground;
FindEnglishSingers();
SetEnglishSingersAndButtonsVisibility(false);
}
private void FindEnglishSingers(){
string searchText = inputBoxEnglishSingers.Text;
string query = $"SELECT * FROM ArtistLibrary WHERE `歌手姓名` LIKE '{searchText}%' ";
var searchResults = SearchSingers_Mysql(query);
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
}
private void InitializeInputBoxEnglishSingers()
{
try
@ -304,19 +316,6 @@ namespace DualScreenDemo
ResizeAndPositionControl(inputBoxEnglishSingers, x, y, width, height);
inputBoxEnglishSingers.TextChanged += (sender, e) =>
{
string searchText = inputBoxEnglishSingers.Text;
var searchResults = allArtists.Where(artist => artist.Name.Replace(" ", "").StartsWith(searchText)).ToList();
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
};
this.Controls.Add(inputBoxEnglishSingers);
}
catch (Exception ex)

View File

@ -118,20 +118,7 @@ namespace DualScreenDemo
ResizeAndPositionControl(handwritingInputBoxForSingers, 366, 373, 541, 62);
this.Controls.Add(handwritingInputBoxForSingers);
handwritingInputBoxForSingers.TextChanged += (sender, e) =>
{
string searchText = handwritingInputBoxForSingers.Text;
var searchResults = allArtists.Where(artist => artist.Name.StartsWith(searchText)).ToList();
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
};
}
private void InitializeCandidateListBoxForSingers()
@ -297,8 +284,20 @@ namespace DualScreenDemo
SetHandWritingForSingersAndButtonsVisibility(false);
handWritingSearchButton.BackgroundImage = handWritingSearchNormalBackground;
FindHandwritingSingers();
this.ResumeLayout();
}
private void FindHandwritingSingers(){
string searchText = handwritingInputBoxForSingers.Text;
string query = $"SELECT * FROM ArtistLibrary WHERE `歌手姓名` LIKE '{searchText}%' ";
var searchResults = SearchSingers_Mysql(query);
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
}
}
}

View File

@ -168,8 +168,26 @@ namespace DualScreenDemo
{
pictureBoxPinYinSingers.Visible = false;
pinyinSearchButton.BackgroundImage = pinyinSearchNormalBackground;
FindPinYinSingers();
SetPinYinSingersAndButtonsVisibility(false);
}
private void FindPinYinSingers(){
string searchText = inputBoxPinYinSingers.Text;
// 在這裡添加搜尋歌曲的邏輯
// 例如:根據輸入框的內容搜尋歌曲
string query = $"SELECT * FROM SongLibrary WHERE `歌星A拼音` LIKE '{searchText}%' OR `歌星B拼音` LIKE '{searchText}%' ";
var searchResults = SearchSongs_Mysql(query);
// 重置分頁
currentPage = 0;
currentSongList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
// 更新多頁面面板的內容
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(currentSongList);
}
private void InitializeInputBoxPinYinSingers()
{
@ -206,7 +224,7 @@ namespace DualScreenDemo
ResizeAndPositionControl(inputBoxPinYinSingers, x, y, width, height);
inputBoxPinYinSingers.TextChanged += (sender, e) =>
/*inputBoxPinYinSingers.TextChanged += (sender, e) =>
{
string searchText = inputBoxPinYinSingers.Text;
var searchResults = allSongs.Where(song => song.ArtistAPinyin.Replace(" ", "").StartsWith(searchText))
@ -218,19 +236,7 @@ namespace DualScreenDemo
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(currentSongList);
/////////////////////////////////////////////////////////////////
/*string searchText = inputBoxPinYinSingers.Text;
var searchResults = allArtists.Where(artist => artist.Name.Replace(" ", "").StartsWith(searchText)).ToList();
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);*/
};
};*/
this.Controls.Add(inputBoxPinYinSingers);
}

View File

@ -532,11 +532,26 @@ namespace DualScreenDemo
// 隱藏 WordCount 歌手圖片框
pictureBoxWordCountSingers.Visible = false;
wordCountSearchButton.BackgroundImage = wordCountSearchNormalBackground;
FindWordCountSingers();
// 隱藏與 WordCount 歌手相關的所有按鈕
SetWordCountSingersAndButtonsVisibility(false);
}
private void FindWordCountSingers(){
string searchText = inputBoxWordCountSingers.Text; // 取得輸入內容
if (int.TryParse(searchText, out int length))
{
//var searchResults = allArtists.Where(artist => artist.Name.Length == length).ToList();
string query = $"SELECT * FROM ArtistLibrary WHERE CHAR_LENGTH(歌手姓名) = {length} ";
var searchResults = SearchSingers_Mysql(query);
// 設定當前頁數為 0並加載搜索結果
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
}
}
/// <summary>
/// 創建一個特殊的按鈕,並設定其顯示屬性、事件處理和位置。
@ -600,24 +615,7 @@ namespace DualScreenDemo
// 調整和定位輸入框的位置及大小
ResizeAndPositionControl(inputBoxWordCountSingers, inputBoxWordCountCoords.X, inputBoxWordCountCoords.Y, inputBoxWordCountCoords.Width, inputBoxWordCountCoords.Height);
// 設定文本變更事件,當輸入框內容改變時觸發
inputBoxWordCountSingers.TextChanged += (sender, e) =>
{
string searchText = inputBoxWordCountSingers.Text; // 取得輸入內容
if (int.TryParse(searchText, out int length))
{
var searchResults = allArtists.Where(artist => artist.Name.Length == length).ToList();
// 設定當前頁數為 0並加載搜索結果
currentPage = 0;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSingers(currentArtistList);
}
};
// 將輸入框加入到窗體的控件集合中
this.Controls.Add(inputBoxWordCountSingers);
}

View File

@ -309,7 +309,7 @@ namespace DualScreenDemo
string searchText = inputBoxZhuYinSongs.Text;
// 在這裡添加搜尋歌曲的邏輯
// 例如:根據輸入框的內容搜尋歌曲
string query = $"SELECT * FROM SongLibrary WHERE `歌曲注音` = '{searchText}' ";
string query = $"SELECT * FROM SongLibrary WHERE `歌曲注音` LIKE '{searchText}%' ";
var searchResults = SearchSongs_Mysql(query);
// 重置分頁