新增點播次數
This commit is contained in:
parent
a4940126aa
commit
91fad6df31
@ -1564,6 +1564,12 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
|||||||
PrimaryForm.PrintPlayingSongList();
|
PrimaryForm.PrintPlayingSongList();
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Console.WriteLine($"[6] 更新下一首與印出列表花費: {stopwatch.ElapsedMilliseconds} ms");
|
Console.WriteLine($"[6] 更新下一首與印出列表花費: {stopwatch.ElapsedMilliseconds} ms");
|
||||||
|
|
||||||
|
// 點播次數+1
|
||||||
|
stopwatch.Restart();
|
||||||
|
PrimaryForm.Instance.AddSongCount(songData.SongNumber);
|
||||||
|
stopwatch.Stop();
|
||||||
|
Console.WriteLine($"[7] 新增點播次數花費: {stopwatch.ElapsedMilliseconds} ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -177,6 +177,33 @@ namespace DualScreenDemo{
|
|||||||
File.AppendAllText(logFilePath, data);
|
File.AppendAllText(logFilePath, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddSongCount(string id){
|
||||||
|
string query = $"UPDATE songs SET song_counts = song_counts+1 WHERE id = '{id}';";
|
||||||
|
Console.WriteLine(query);
|
||||||
|
string connectionString = "Server=192.168.11.4;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))
|
||||||
|
{
|
||||||
|
int rowsAffected = command.ExecuteNonQuery();
|
||||||
|
if (rowsAffected > 0)
|
||||||
|
{
|
||||||
|
Console.WriteLine("新增成功!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("新增失敗(點播次數沒有新增)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
connection.Close();
|
||||||
|
Console.WriteLine("MyDB 連線已關閉!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user