SQL指令修改(歌星轉歌曲)
This commit is contained in:
parent
533cc9eb4a
commit
9f517c54d4
@ -1969,11 +1969,9 @@ public class MultiPagePanel : Panel
|
|||||||
|
|
||||||
artistLabel.Click += (sender, e) =>
|
artistLabel.Click += (sender, e) =>
|
||||||
{
|
{
|
||||||
string searchText = artistLabel.Text; // 取得輸入內容
|
string searchText = artistLabel.Text; // 取得輸入內容
|
||||||
|
string query = $"SELECT * FROM SongLibrary WHERE `歌星 A` = '{searchText}' OR `歌星 B` = '{searchText}'";
|
||||||
// 根據輸入的注音篩選歌曲清單
|
List<SongData> searchResults = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
var searchResults = PrimaryForm.Instance.allSongs.Where(song => song.ArtistA.StartsWith(searchText) || song.ArtistB.StartsWith(searchText)).ToList();
|
|
||||||
|
|
||||||
// 重置分頁
|
// 重置分頁
|
||||||
PrimaryForm.Instance.currentPage = 0;
|
PrimaryForm.Instance.currentPage = 0;
|
||||||
currentSongList = searchResults;
|
currentSongList = searchResults;
|
||||||
|
@ -546,18 +546,19 @@ namespace DualScreenDemo
|
|||||||
/// 查詢歌曲(字數查詢),連接資料庫並執行 SQL 查詢。
|
/// 查詢歌曲(字數查詢),連接資料庫並執行 SQL 查詢。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void FindWordCountSongs(){
|
private void FindWordCountSongs(){
|
||||||
|
string searchText = inputBoxWordCountSongs.Text;
|
||||||
// 在這裡添加搜尋歌曲的邏輯
|
// 在這裡添加搜尋歌曲的邏輯
|
||||||
// 例如:根據輸入框的內容搜尋歌曲
|
// 例如:根據輸入框的內容搜尋歌曲
|
||||||
string query = "SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = @searchLength ";
|
string query;
|
||||||
string searchText = inputBoxWordCountSongs.Text;
|
|
||||||
if (int.TryParse(searchText, out int length))
|
if (int.TryParse(searchText, out int length))
|
||||||
{
|
{
|
||||||
query= $"SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = {length} ";
|
query = $"SELECT * FROM SongLibrary WHERE CHAR_LENGTH(歌曲名稱) = {length} ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 處理輸入錯誤,例如顯示提示訊息
|
// 處理輸入錯誤,例如顯示提示訊息
|
||||||
//MessageBox.Show("請輸入正確的數字!");
|
//MessageBox.Show("請輸入正確的數字!");
|
||||||
|
query = string.Empty; // 清空查詢
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<SongData> searchResults = SearchSongs_Mysql(query);
|
List<SongData> searchResults = SearchSongs_Mysql(query);
|
||||||
|
@ -146,7 +146,7 @@ namespace DualScreenDemo
|
|||||||
public List<SongData> SearchSongs_Mysql(string query)
|
public List<SongData> SearchSongs_Mysql(string query)
|
||||||
{
|
{
|
||||||
List<SongData> searchResults = new List<SongData>();
|
List<SongData> searchResults = new List<SongData>();
|
||||||
|
Console.WriteLine(query);
|
||||||
string connectionString = "Server=192.168.22.170;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
string connectionString = "Server=192.168.22.170;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||||
|
|
||||||
using (var connection = new MySqlConnection(connectionString))
|
using (var connection = new MySqlConnection(connectionString))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user