歌手查詢SQL函式創建
This commit is contained in:
parent
79d166e084
commit
435d668205
@ -81,7 +81,42 @@ namespace DualScreenDemo{
|
|||||||
return searchResults;
|
return searchResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Artist> SearchSingers_Mysql(string query){
|
||||||
|
List<Artist> searchResults = new List<Artist>();
|
||||||
|
Console.WriteLine(query);
|
||||||
|
string connectionString = "Server=192.168.22.170;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||||
|
|
||||||
|
using (var connection = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
Console.WriteLine("MyDB 連線成功!");
|
||||||
|
|
||||||
|
using (var command = new MySqlCommand(query, connection))
|
||||||
|
{
|
||||||
|
|
||||||
|
using (var reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
string artist = reader["歌手姓名"].ToString();
|
||||||
|
string phonetic = reader["歌手注音"].ToString();
|
||||||
|
string category = reader["歌手分類"].ToString();
|
||||||
|
string strokesStr = reader["歌手筆畫"].ToString();
|
||||||
|
if (double.TryParse(strokesStr, out double strokesDouble))
|
||||||
|
{
|
||||||
|
int strokes = (int)Math.Round(strokesDouble);
|
||||||
|
searchResults.Add(new Artist(artist, phonetic, category, strokes));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection.Close();
|
||||||
|
Console.WriteLine("MyDB 連線已關閉!");
|
||||||
|
}
|
||||||
|
return searchResults;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1122,104 +1122,7 @@ namespace DualScreenDemo
|
|||||||
MessageBox.Show("Show All button clicked!");
|
MessageBox.Show("Show All button clicked!");
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
private void SetPictureBoxArtistSearchAndButtonsVisibility(bool isVisible)
|
|
||||||
{
|
|
||||||
System.Action action = () =>
|
|
||||||
{
|
|
||||||
SuspendLayout();
|
|
||||||
|
|
||||||
|
|
||||||
pictureBoxArtistSearch.Visible = isVisible;
|
|
||||||
|
|
||||||
|
|
||||||
if (isVisible) pictureBoxArtistSearch.BringToFront();
|
|
||||||
|
|
||||||
|
|
||||||
modifyButtonArtistSearch.Visible = isVisible;
|
|
||||||
closeButtonArtistSearch.Visible = isVisible;
|
|
||||||
|
|
||||||
|
|
||||||
if (isVisible)
|
|
||||||
{
|
|
||||||
modifyButtonArtistSearch.BringToFront();
|
|
||||||
closeButtonArtistSearch.BringToFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (Button button in numberButtonsArtistSearch)
|
|
||||||
{
|
|
||||||
button.Visible = isVisible;
|
|
||||||
|
|
||||||
if (isVisible)
|
|
||||||
button.BringToFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
inputBoxArtistSearch.Visible = isVisible;
|
|
||||||
if (isVisible) inputBoxArtistSearch.BringToFront();
|
|
||||||
|
|
||||||
ResumeLayout();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.InvokeRequired)
|
|
||||||
{
|
|
||||||
this.Invoke(action);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
private void SetPictureBoxWordCountAndButtonsVisibility(bool isVisible)
|
|
||||||
{
|
|
||||||
System.Action action = () =>
|
|
||||||
{
|
|
||||||
SuspendLayout();
|
|
||||||
|
|
||||||
|
|
||||||
pictureBoxWordCount.Visible = isVisible;
|
|
||||||
|
|
||||||
|
|
||||||
if (isVisible) pictureBoxWordCount.BringToFront();
|
|
||||||
|
|
||||||
|
|
||||||
modifyButtonWordCount.Visible = isVisible;
|
|
||||||
closeButtonWordCount.Visible = isVisible;
|
|
||||||
|
|
||||||
|
|
||||||
if (isVisible)
|
|
||||||
{
|
|
||||||
modifyButtonWordCount.BringToFront();
|
|
||||||
closeButtonWordCount.BringToFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (Button button in numberButtonsWordCount)
|
|
||||||
{
|
|
||||||
button.Visible = isVisible;
|
|
||||||
|
|
||||||
if (isVisible)
|
|
||||||
button.BringToFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
inputBoxWordCount.Visible = isVisible;
|
|
||||||
if (isVisible) inputBoxWordCount.BringToFront();
|
|
||||||
|
|
||||||
ResumeLayout();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.InvokeRequired)
|
|
||||||
{
|
|
||||||
this.Invoke(action);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private void ConfigureButton(Button button, int posX, int posY, int width, int height,
|
private void ConfigureButton(Button button, int posX, int posY, int width, int height,
|
||||||
Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage,
|
Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage,
|
||||||
EventHandler clickEventHandler)
|
EventHandler clickEventHandler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user