Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
e0ee54c29c | |||
94c043045c |
13
App.config
13
App.config
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
|
|
||||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||||
</configSections>
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
@ -15,11 +15,11 @@
|
|||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
|
<bindingRedirect oldVersion="0.0.0.0-6.0.2.0" newVersion="6.0.2.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
|
||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity name="SQLitePCLRaw.core" publicKeyToken="1488e028ca7ab535" culture="neutral" />
|
<assemblyIdentity name="SQLitePCLRaw.core" publicKeyToken="1488e028ca7ab535" culture="neutral" />
|
||||||
@ -33,10 +33,5 @@
|
|||||||
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
|
||||||
</providers>
|
</providers>
|
||||||
</entityFramework>
|
</entityFramework>
|
||||||
<system.data>
|
|
||||||
<DbProviderFactories>
|
|
||||||
<remove invariant="System.Data.SQLite.EF6" />
|
|
||||||
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
|
|
||||||
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
|
|
||||||
</system.data>
|
|
||||||
</configuration>
|
</configuration>
|
@ -8,7 +8,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SQLite; // 確保添加了這個命名空間
|
//using System.Data.SQLite; // 確保添加了這個命名空間
|
||||||
//using System.Data.SqlClient; // 对于SQL Server
|
//using System.Data.SqlClient; // 对于SQL Server
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@ -32,6 +32,7 @@ using ExcelDataReader;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using MySqlConnector;
|
||||||
using Karaoke_Kingpin.Models;
|
using Karaoke_Kingpin.Models;
|
||||||
using Karaoke_Kingpin.Converters;
|
using Karaoke_Kingpin.Converters;
|
||||||
namespace Karaoke_Kingpin.Controller
|
namespace Karaoke_Kingpin.Controller
|
||||||
@ -661,81 +662,56 @@ namespace Karaoke_Kingpin.Controller
|
|||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
static extern bool FreeConsole();
|
static extern bool FreeConsole();
|
||||||
private void LoadSongsFromDatabase()
|
private void LoadSongsFromDatabase()
|
||||||
{
|
{
|
||||||
string connectionString = @"Data Source=KSongDatabase.db;"; // SQLite连接字符串
|
using (MyDB db = new MyDB()) // MyDB 改為 SongDB
|
||||||
string query = "SELECT * FROM SongLibrary";
|
|
||||||
|
|
||||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
{
|
||||||
SQLiteCommand command = new SQLiteCommand(query, connection);
|
string sql = "SELECT * FROM SongLibrary;";
|
||||||
try
|
DataTable result = db.Select(sql, null);
|
||||||
|
|
||||||
|
_songs = new ObservableCollection<SongData>();
|
||||||
|
|
||||||
|
foreach (DataRow row in result.Rows)
|
||||||
{
|
{
|
||||||
connection.Open();
|
var song = new SongData(
|
||||||
SQLiteDataReader reader = command.ExecuteReader();
|
row["歌曲編號"].ToString(),
|
||||||
|
row["歌曲名稱"].ToString(),
|
||||||
_songs = new ObservableCollection<SongData>();
|
row["歌星 A"].ToString(),
|
||||||
while (reader.Read())
|
row["歌星 B"].ToString(),
|
||||||
{
|
row["路徑 1"].ToString(),
|
||||||
//int? dbAdjust = null; // 使用可空的整数类型
|
row["路徑 2"].ToString(),
|
||||||
|
row["歌曲檔名"].ToString(),
|
||||||
//// 在尝试转换之前,检查字段是否为空
|
row.IsNull("新增日期") ? DateTime.Now.ToString("yyyy/MM/dd") : Convert.ToDateTime(row["新增日期"]).ToString("yyyy/MM/dd"),
|
||||||
//if (!reader.IsDBNull(reader.GetOrdinal("DB加減")) && !string.IsNullOrWhiteSpace(reader["DB加減"].ToString()))
|
row["分類"].ToString(),
|
||||||
//{
|
row["歌曲注音"].ToString(),
|
||||||
// dbAdjust = Convert.ToInt32(reader["DB加減"]);
|
row["歌曲拼音"].ToString(),
|
||||||
//}
|
row["語別"].ToString(),
|
||||||
|
row.IsNull("點播次數") ? 0 : Convert.ToInt32(row["點播次數"]),
|
||||||
int songNameLength = 0;
|
row["版權01"].ToString(),
|
||||||
|
row["版權02"].ToString(),
|
||||||
if (!int.TryParse(reader["歌名字數"].ToString(), out songNameLength))
|
row["版權03"].ToString(),
|
||||||
{
|
row["版權04"].ToString(),
|
||||||
System.Diagnostics.Debug.WriteLine($"歌名字數 conversion failed for value {reader["歌名字數"].ToString()}");
|
row["版權05"].ToString(),
|
||||||
}
|
row["版權06"].ToString(),
|
||||||
|
row.IsNull("狀態") ? 0 : Convert.ToInt32(row["狀態"]),
|
||||||
var song = new SongData(
|
row.IsNull("歌名字數") ? 0 : Convert.ToInt32(row["歌名字數"]),
|
||||||
reader["歌曲編號"].ToString(),
|
row.IsNull("人聲") ? 0 : Convert.ToInt32(row["人聲"]),
|
||||||
reader["歌曲名稱"].ToString(),
|
row.IsNull("狀態2") ? 0 : Convert.ToInt32(row["狀態2"]),
|
||||||
reader["歌星 A"].ToString(),
|
row["情境"].ToString(),
|
||||||
reader["歌星 B"].ToString(),
|
row["歌星A注音"].ToString(),
|
||||||
reader["路徑 1"].ToString(),
|
row["歌星B注音"].ToString(),
|
||||||
reader["路徑 2"].ToString(),
|
row["歌星A分類"].ToString(),
|
||||||
reader["歌曲檔名"].ToString(),
|
row["歌星B分類"].ToString(),
|
||||||
reader.IsDBNull(reader.GetOrdinal("新增日期")) ? DateTime.Now.ToString("yyyy/MM/dd") : Convert.ToDateTime(reader["新增日期"]).ToString("yyyy/MM/dd"),
|
row["歌星A簡體"].ToString(),
|
||||||
reader["分類"].ToString(),
|
row["歌星B簡體"].ToString(),
|
||||||
reader["歌曲注音"].ToString(),
|
row["歌名簡體"].ToString(),
|
||||||
reader["歌曲拼音"].ToString(),
|
row["歌星A拼音"].ToString(),
|
||||||
reader["語別"].ToString(),
|
row["歌星B拼音"].ToString()
|
||||||
reader.IsDBNull(reader.GetOrdinal("點播次數")) ? 0 : Convert.ToInt32(reader["點播次數"]),
|
);
|
||||||
reader["版權01"].ToString(),
|
_songs.Add(song);
|
||||||
reader["版權02"].ToString(),
|
|
||||||
reader["版權03"].ToString(),
|
|
||||||
reader["版權04"].ToString(),
|
|
||||||
reader["版權05"].ToString(),
|
|
||||||
reader["版權06"].ToString(),
|
|
||||||
reader.IsDBNull(reader.GetOrdinal("狀態")) ? 0 : Convert.ToInt32(reader["狀態"]),
|
|
||||||
reader.IsDBNull(reader.GetOrdinal("歌名字數")) ? 0 : Convert.ToInt32(reader["歌名字數"]),
|
|
||||||
reader.IsDBNull(reader.GetOrdinal("人聲")) ? 0 : Convert.ToInt32(reader["人聲"]),
|
|
||||||
reader.IsDBNull(reader.GetOrdinal("狀態2")) ? 0 : Convert.ToInt32(reader["狀態2"]),
|
|
||||||
reader["情境"].ToString(),
|
|
||||||
reader["歌星A注音"].ToString(),
|
|
||||||
reader["歌星B注音"].ToString(),
|
|
||||||
reader["歌星A分類"].ToString(),
|
|
||||||
reader["歌星B分類"].ToString(),
|
|
||||||
reader["歌星A簡體"].ToString(),
|
|
||||||
reader["歌星B簡體"].ToString(),
|
|
||||||
reader["歌名簡體"].ToString(),
|
|
||||||
reader["歌星A拼音"].ToString(),
|
|
||||||
reader["歌星B拼音"].ToString()
|
|
||||||
);
|
|
||||||
_songs.Add(song);
|
|
||||||
}
|
|
||||||
SongsDataGrid.ItemsSource = _songs; // 确保这里没有错误,你的 XAML 定义了 SongsDataGrid 控件
|
|
||||||
reader.Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.Windows.MessageBox.Show("數據庫操作失敗: " + ex.Message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SongsDataGrid.ItemsSource = _songs; // 確保 XAML 定義了 SongsDataGrid 控件
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -936,178 +912,107 @@ namespace Karaoke_Kingpin.Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSongFromDatabase(string songNumber)
|
private void DeleteSongFromDatabase(string songNumber){
|
||||||
{
|
using (MyDB db = new MyDB())
|
||||||
string connectionString = @"Data Source=KSongDatabase.db;";
|
|
||||||
|
|
||||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
{
|
||||||
string query = "DELETE FROM SongLibrary WHERE 歌曲編號 = @SongNumber";
|
string deleteQuery = "DELETE FROM SongLibrary WHERE 歌曲編號 = @SongNumber";
|
||||||
|
|
||||||
using (SQLiteCommand command = new SQLiteCommand(query, connection))
|
MySqlParameter[] parameters = {new MySqlParameter("@SongNumber", songNumber)};
|
||||||
{
|
|
||||||
command.Parameters.AddWithValue("@SongNumber", songNumber);
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
int rowsAffected = command.ExecuteNonQuery();
|
int rowsAffected = db.ExecuteNonQuery(deleteQuery, parameters);
|
||||||
if (rowsAffected > 0)
|
|
||||||
{
|
if (rowsAffected > 0){
|
||||||
Console.WriteLine($"Song with SongNumber: {songNumber} successfully deleted.");
|
Console.WriteLine($"歌曲編號 {songNumber} 刪除成功!");
|
||||||
}
|
}else{
|
||||||
else
|
Console.WriteLine($"刪除歌曲編號 {songNumber} 失敗,可能該歌曲不存在。");
|
||||||
{
|
|
||||||
Console.WriteLine($"Failed to delete song with SongNumber: {songNumber}.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSongToDatabase(SongData song)
|
|
||||||
{
|
|
||||||
string connectionString = @"Data Source=KSongDatabase.db;";
|
|
||||||
string query = "INSERT INTO SongLibrary (歌曲編號, 歌曲名稱, [歌星 A], [歌星 B], [路徑 1], [路徑 2], 歌曲檔名, 新增日期, 分類, 歌曲注音, 歌曲拼音, 語別, 點播次數, 版權01, 版權02, 版權03, 版權04, 版權05, 版權06, 狀態, 歌名字數, 人聲, 狀態2, 情境, 歌星A注音, 歌星B注音, 歌星A分類, 歌星B分類, 歌星A簡體, 歌星B簡體, 歌名簡體) " +
|
|
||||||
"VALUES (@SongNumber, @Song, @ArtistA, @ArtistB, @SongFilePathHost1, @SongFilePathHost2, @SongFileName, @AddedTime, @Category, @PhoneticNotation, @PinyinNotation, @LanguageType, @Plays, @Copyright01, @Copyright02, @Copyright03, @Copyright04, @Copyright05, @Copyright06, @Status, @SongNameLength, @Vocal, @Status2, @Situation, @ArtistAPhonetic, @ArtistBPhonetic, @ArtistACategory, @ArtistBCategory, @ArtistASimplified, @ArtistBSimplified, @SongSimplified)";
|
|
||||||
|
|
||||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
|
||||||
SQLiteCommand command = new SQLiteCommand(query, connection);
|
|
||||||
command.Parameters.AddWithValue("@SongNumber", song.SongNumber);
|
|
||||||
command.Parameters.AddWithValue("@Song", song.Song);
|
|
||||||
command.Parameters.AddWithValue("@ArtistA", song.ArtistA);
|
|
||||||
command.Parameters.AddWithValue("@ArtistB", song.ArtistB);
|
|
||||||
command.Parameters.AddWithValue("@SongFilePathHost1", song.SongFilePathHost1);
|
|
||||||
command.Parameters.AddWithValue("@SongFilePathHost2", song.SongFilePathHost2);
|
|
||||||
command.Parameters.AddWithValue("@SongFileName", song.SongFileName);
|
|
||||||
// Convert the date format from "yyyy/MM/dd" to "yyyy-MM-dd"
|
|
||||||
string addedTimeFormatted = song.AddedTime;
|
|
||||||
DateTime parsedDate;
|
|
||||||
if (DateTime.TryParseExact(addedTimeFormatted, "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate))
|
|
||||||
{
|
|
||||||
addedTimeFormatted = parsedDate.ToString("yyyy-MM-dd");
|
|
||||||
}
|
|
||||||
command.Parameters.AddWithValue("@AddedTime", addedTimeFormatted);
|
|
||||||
command.Parameters.AddWithValue("@Category", song.Category);
|
|
||||||
command.Parameters.AddWithValue("@PhoneticNotation", song.PhoneticNotation);
|
|
||||||
command.Parameters.AddWithValue("@PinyinNotation", song.PinyinNotation);
|
|
||||||
command.Parameters.AddWithValue("@LanguageType", song.LanguageType);
|
|
||||||
command.Parameters.AddWithValue("@Plays", song.Plays);
|
|
||||||
command.Parameters.AddWithValue("@Copyright01", song.Copyright01);
|
|
||||||
command.Parameters.AddWithValue("@Copyright02", song.Copyright02);
|
|
||||||
command.Parameters.AddWithValue("@Copyright03", song.Copyright03);
|
|
||||||
command.Parameters.AddWithValue("@Copyright04", song.Copyright04);
|
|
||||||
command.Parameters.AddWithValue("@Copyright05", song.Copyright05);
|
|
||||||
command.Parameters.AddWithValue("@Copyright06", song.Copyright06);
|
|
||||||
command.Parameters.AddWithValue("@Status", song.Status);
|
|
||||||
command.Parameters.AddWithValue("@SongNameLength", song.SongNameLength);
|
|
||||||
command.Parameters.AddWithValue("@Vocal", song.Vocal);
|
|
||||||
command.Parameters.AddWithValue("@Status2", song.Status2);
|
|
||||||
command.Parameters.AddWithValue("@Situation", song.Situation);
|
|
||||||
command.Parameters.AddWithValue("@ArtistAPhonetic", song.ArtistAPhonetic);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBPhonetic", song.ArtistBPhonetic);
|
|
||||||
command.Parameters.AddWithValue("@ArtistACategory", song.ArtistACategory);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBCategory", song.ArtistBCategory);
|
|
||||||
command.Parameters.AddWithValue("@ArtistASimplified", song.ArtistASimplified);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBSimplified", song.ArtistBSimplified);
|
|
||||||
command.Parameters.AddWithValue("@SongSimplified", song.SongSimplified);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
command.ExecuteNonQuery();
|
|
||||||
System.Windows.MessageBox.Show("Song saved successfully to the database.");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.Windows.MessageBox.Show("Failed to save song to the database: " + ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the song to the ObservableCollection if it's not already in it
|
|
||||||
var existingSong = _songs.FirstOrDefault(s => s.SongNumber == song.SongNumber);
|
|
||||||
if (existingSong == null)
|
|
||||||
{
|
|
||||||
_songs.Add(song);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Update the existing song in the ObservableCollection
|
|
||||||
int index = _songs.IndexOf(existingSong);
|
|
||||||
_songs[index] = song;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _SaveSongToDatabase(SongData song)
|
private void _SaveSongToDatabase(SongData song)
|
||||||
{
|
{
|
||||||
string connectionString = @"Data Source=KSongDatabase.db;";
|
using (MyDB db = new MyDB())
|
||||||
string query = "INSERT INTO SongLibrary (歌曲編號, 歌曲名稱, [歌星 A], [歌星 B], [路徑 1], [路徑 2], 歌曲檔名, 新增日期, 分類, 歌曲注音, 歌曲拼音, 語別, 點播次數, 版權01, 版權02, 版權03, 版權04, 版權05, 版權06, 狀態, 歌名字數, 人聲, 狀態2, 情境, 歌星A注音, 歌星B注音, 歌星A分類, 歌星B分類, 歌星A簡體, 歌星B簡體, 歌名簡體) " +
|
|
||||||
"VALUES (@SongNumber, @Song, @ArtistA, @ArtistB, @SongFilePathHost1, @SongFilePathHost2, @SongFileName, @AddedTime, @Category, @PhoneticNotation, @PinyinNotation, @LanguageType, @Plays, @Copyright01, @Copyright02, @Copyright03, @Copyright04, @Copyright05, @Copyright06, @Status, @SongNameLength, @Vocal, @Status2, @Situation, @ArtistAPhonetic, @ArtistBPhonetic, @ArtistACategory, @ArtistBCategory, @ArtistASimplified, @ArtistBSimplified, @SongSimplified)";
|
|
||||||
|
|
||||||
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
|
|
||||||
{
|
{
|
||||||
SQLiteCommand command = new SQLiteCommand(query, connection);
|
string query = @"INSERT INTO SongLibrary
|
||||||
command.Parameters.AddWithValue("@SongNumber", song.SongNumber);
|
(`歌曲編號`, `歌曲名稱`, `歌星 A`, `歌星 B`, `路徑 1`, `路徑 2`, `歌曲檔名`, `新增日期`, `分類`, `歌曲注音`, `歌曲拼音`, `語別`, `點播次數`,
|
||||||
command.Parameters.AddWithValue("@Song", song.Song);
|
`版權01`, `版權02`, `版權03`, `版權04`, `版權05`, `版權06`, `狀態`, `歌名字數`, `人聲`, `狀態2`, `情境`, `歌星A注音`, `歌星B注音`,
|
||||||
command.Parameters.AddWithValue("@ArtistA", song.ArtistA);
|
`歌星A分類`, `歌星B分類`, `歌星A簡體`, `歌星B簡體`, `歌名簡體`)
|
||||||
command.Parameters.AddWithValue("@ArtistB", song.ArtistB);
|
VALUES
|
||||||
command.Parameters.AddWithValue("@SongFilePathHost1", song.SongFilePathHost1);
|
(@SongNumber, @Song, @ArtistA, @ArtistB, @SongFilePathHost1, @SongFilePathHost2, @SongFileName, @AddedTime, @Category, @PhoneticNotation,
|
||||||
command.Parameters.AddWithValue("@SongFilePathHost2", song.SongFilePathHost2);
|
@PinyinNotation, @LanguageType, @Plays, @Copyright01, @Copyright02, @Copyright03, @Copyright04, @Copyright05, @Copyright06,
|
||||||
command.Parameters.AddWithValue("@SongFileName", song.SongFileName);
|
@Status, @SongNameLength, @Vocal, @Status2, @Situation, @ArtistAPhonetic, @ArtistBPhonetic, @ArtistACategory, @ArtistBCategory,
|
||||||
// Convert the date format from "yyyy/MM/dd" to "yyyy-MM-dd"
|
@ArtistASimplified, @ArtistBSimplified, @SongSimplified)
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
`歌曲名稱` = VALUES(`歌曲名稱`), `歌星 A` = VALUES(`歌星 A`), `歌星 B` = VALUES(`歌星 B`),
|
||||||
|
`路徑 1` = VALUES(`路徑 1`), `路徑 2` = VALUES(`路徑 2`), `歌曲檔名` = VALUES(`歌曲檔名`),
|
||||||
|
`分類` = VALUES(`分類`), `歌曲注音` = VALUES(`歌曲注音`), `歌曲拼音` = VALUES(`歌曲拼音`),
|
||||||
|
`語別` = VALUES(`語別`), `點播次數` = VALUES(`點播次數`), `版權01` = VALUES(`版權01`),
|
||||||
|
`版權02` = VALUES(`版權02`), `版權03` = VALUES(`版權03`), `版權04` = VALUES(`版權04`),
|
||||||
|
`版權05` = VALUES(`版權05`), `版權06` = VALUES(`版權06`), `狀態` = VALUES(`狀態`),
|
||||||
|
`歌名字數` = VALUES(`歌名字數`), `人聲` = VALUES(`人聲`), `狀態2` = VALUES(`狀態2`),
|
||||||
|
`情境` = VALUES(`情境`), `歌星A注音` = VALUES(`歌星A注音`), `歌星B注音` = VALUES(`歌星B注音`),
|
||||||
|
`歌星A分類` = VALUES(`歌星A分類`), `歌星B分類` = VALUES(`歌星B分類`), `歌星A簡體` = VALUES(`歌星A簡體`),
|
||||||
|
`歌星B簡體` = VALUES(`歌星B簡體`), `歌名簡體` = VALUES(`歌名簡體`);";
|
||||||
|
|
||||||
|
// 轉換日期格式(yyyy/MM/dd → yyyy-MM-dd)
|
||||||
string addedTimeFormatted = song.AddedTime;
|
string addedTimeFormatted = song.AddedTime;
|
||||||
DateTime parsedDate;
|
if (DateTime.TryParseExact(addedTimeFormatted, "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime parsedDate))
|
||||||
if (DateTime.TryParseExact(addedTimeFormatted, "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate))
|
|
||||||
{
|
{
|
||||||
addedTimeFormatted = parsedDate.ToString("yyyy-MM-dd");
|
addedTimeFormatted = parsedDate.ToString("yyyy-MM-dd");
|
||||||
}
|
}
|
||||||
command.Parameters.AddWithValue("@AddedTime", addedTimeFormatted);
|
|
||||||
command.Parameters.AddWithValue("@Category", song.Category);
|
|
||||||
command.Parameters.AddWithValue("@PhoneticNotation", song.PhoneticNotation);
|
|
||||||
command.Parameters.AddWithValue("@PinyinNotation", song.PinyinNotation);
|
|
||||||
command.Parameters.AddWithValue("@LanguageType", song.LanguageType);
|
|
||||||
command.Parameters.AddWithValue("@Plays", song.Plays);
|
|
||||||
command.Parameters.AddWithValue("@Copyright01", song.Copyright01);
|
|
||||||
command.Parameters.AddWithValue("@Copyright02", song.Copyright02);
|
|
||||||
command.Parameters.AddWithValue("@Copyright03", song.Copyright03);
|
|
||||||
command.Parameters.AddWithValue("@Copyright04", song.Copyright04);
|
|
||||||
command.Parameters.AddWithValue("@Copyright05", song.Copyright05);
|
|
||||||
command.Parameters.AddWithValue("@Copyright06", song.Copyright06);
|
|
||||||
command.Parameters.AddWithValue("@Status", song.Status);
|
|
||||||
command.Parameters.AddWithValue("@SongNameLength", song.SongNameLength);
|
|
||||||
command.Parameters.AddWithValue("@Vocal", song.Vocal);
|
|
||||||
command.Parameters.AddWithValue("@Status2", song.Status2);
|
|
||||||
command.Parameters.AddWithValue("@Situation", song.Situation);
|
|
||||||
command.Parameters.AddWithValue("@ArtistAPhonetic", song.ArtistAPhonetic);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBPhonetic", song.ArtistBPhonetic);
|
|
||||||
command.Parameters.AddWithValue("@ArtistACategory", song.ArtistACategory);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBCategory", song.ArtistBCategory);
|
|
||||||
command.Parameters.AddWithValue("@ArtistASimplified", song.ArtistASimplified);
|
|
||||||
command.Parameters.AddWithValue("@ArtistBSimplified", song.ArtistBSimplified);
|
|
||||||
command.Parameters.AddWithValue("@SongSimplified", song.SongSimplified);
|
|
||||||
|
|
||||||
try
|
// 設定參數
|
||||||
{
|
MySqlParameter[] parameters = {
|
||||||
connection.Open();
|
new MySqlParameter("@SongNumber", song.SongNumber),
|
||||||
command.ExecuteNonQuery();
|
new MySqlParameter("@Song", song.Song),
|
||||||
//System.Windows.MessageBox.Show("Song saved successfully to the database.");
|
new MySqlParameter("@ArtistA", song.ArtistA),
|
||||||
}
|
new MySqlParameter("@ArtistB", song.ArtistB),
|
||||||
catch (Exception ex)
|
new MySqlParameter("@SongFilePathHost1", song.SongFilePathHost1),
|
||||||
{
|
new MySqlParameter("@SongFilePathHost2", song.SongFilePathHost2),
|
||||||
System.Windows.MessageBox.Show("Failed to save song to the database: " + ex.Message);
|
new MySqlParameter("@SongFileName", song.SongFileName),
|
||||||
}
|
new MySqlParameter("@AddedTime", addedTimeFormatted),
|
||||||
|
new MySqlParameter("@Category", song.Category),
|
||||||
|
new MySqlParameter("@PhoneticNotation", song.PhoneticNotation),
|
||||||
|
new MySqlParameter("@PinyinNotation", song.PinyinNotation),
|
||||||
|
new MySqlParameter("@LanguageType", song.LanguageType),
|
||||||
|
new MySqlParameter("@Plays", song.Plays),
|
||||||
|
new MySqlParameter("@Copyright01", song.Copyright01),
|
||||||
|
new MySqlParameter("@Copyright02", song.Copyright02),
|
||||||
|
new MySqlParameter("@Copyright03", song.Copyright03),
|
||||||
|
new MySqlParameter("@Copyright04", song.Copyright04),
|
||||||
|
new MySqlParameter("@Copyright05", song.Copyright05),
|
||||||
|
new MySqlParameter("@Copyright06", song.Copyright06),
|
||||||
|
new MySqlParameter("@Status", song.Status),
|
||||||
|
new MySqlParameter("@SongNameLength", song.SongNameLength),
|
||||||
|
new MySqlParameter("@Vocal", song.Vocal),
|
||||||
|
new MySqlParameter("@Status2", song.Status2),
|
||||||
|
new MySqlParameter("@Situation", song.Situation),
|
||||||
|
new MySqlParameter("@ArtistAPhonetic", song.ArtistAPhonetic),
|
||||||
|
new MySqlParameter("@ArtistBPhonetic", song.ArtistBPhonetic),
|
||||||
|
new MySqlParameter("@ArtistACategory", song.ArtistACategory),
|
||||||
|
new MySqlParameter("@ArtistBCategory", song.ArtistBCategory),
|
||||||
|
new MySqlParameter("@ArtistASimplified", song.ArtistASimplified),
|
||||||
|
new MySqlParameter("@ArtistBSimplified", song.ArtistBSimplified),
|
||||||
|
new MySqlParameter("@SongSimplified", song.SongSimplified),
|
||||||
|
};
|
||||||
|
|
||||||
|
int affectedRows = db.ExecuteNonQuery(query, parameters);
|
||||||
|
Console.WriteLine($"影響的行數: {affectedRows}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the song to the ObservableCollection if it's not already in it
|
// 更新 ObservableCollection
|
||||||
var existingSong = _songs.FirstOrDefault(s => s.SongNumber == song.SongNumber);
|
var existingSong = _songs.FirstOrDefault(s => s.SongNumber == song.SongNumber);
|
||||||
if (existingSong == null)
|
if (existingSong == null)
|
||||||
{
|
{
|
||||||
_songs.Add(song);
|
_songs.Add(song);
|
||||||
|
Console.WriteLine($"加入一筆: {song.SongNumber}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update the existing song in the ObservableCollection
|
|
||||||
int index = _songs.IndexOf(existingSong);
|
int index = _songs.IndexOf(existingSong);
|
||||||
_songs[index] = song;
|
_songs[index] = song;
|
||||||
|
Console.WriteLine($"修改一筆: {song.SongNumber}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoveSongButton_Click(object sender, RoutedEventArgs e)
|
private void LoveSongButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
@ -21,9 +21,9 @@ namespace Karaoke_Kingpin.Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// MainWindow.xaml 的互動邏輯
|
/// MainWindow.xaml 的互動邏輯
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class Login : Window
|
||||||
{
|
{
|
||||||
public MainWindow()
|
public Login()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="packages\EntityFramework.6.5.1\build\EntityFramework.props" Condition="Exists('packages\EntityFramework.6.5.1\build\EntityFramework.props')" />
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -51,14 +50,8 @@
|
|||||||
<Reference Include="ChnCharInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18f031bd02e5e291, processorArchitecture=MSIL">
|
<Reference Include="ChnCharInfo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18f031bd02e5e291, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.International.Converters.PinYinConverter.1.0.0\lib\ChnCharInfo.dll</HintPath>
|
<HintPath>packages\Microsoft.International.Converters.PinYinConverter.1.0.0\lib\ChnCharInfo.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
<Reference Include="EPPlus, Version=8.0.1.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\EntityFramework.6.5.1\lib\net45\EntityFramework.dll</HintPath>
|
<HintPath>packages\EPPlus.8.0.1\lib\net462\EPPlus.dll</HintPath>
|
||||||
</Reference>
|
|
||||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\EntityFramework.6.5.1\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="EPPlus, Version=7.7.0.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\EPPlus.7.7.0\lib\net462\EPPlus.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="EPPlus.Interfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=a694d7f3b0907a61, processorArchitecture=MSIL">
|
<Reference Include="EPPlus.Interfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=a694d7f3b0907a61, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\EPPlus.Interfaces.8.0.0\lib\net462\EPPlus.Interfaces.dll</HintPath>
|
<HintPath>packages\EPPlus.Interfaces.8.0.0\lib\net462\EPPlus.Interfaces.dll</HintPath>
|
||||||
@ -78,8 +71,8 @@
|
|||||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.9.0.3\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.9.0.3\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Data.Sqlite, Version=9.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Bcl.Cryptography, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Data.Sqlite.Core.9.0.3\lib\netstandard2.0\Microsoft.Data.Sqlite.dll</HintPath>
|
<HintPath>packages\Microsoft.Bcl.Cryptography.9.0.3\lib\net462\Microsoft.Bcl.Cryptography.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.3, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.3, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.9.0.3\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
<HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.9.0.3\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||||
@ -105,31 +98,16 @@
|
|||||||
<Reference Include="Pinyin4net, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Pinyin4net, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\pinyin4net.1.0.0\lib\net40\Pinyin4net.dll</HintPath>
|
<HintPath>packages\pinyin4net.1.0.0\lib\net40\Pinyin4net.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SQLitePCLRaw.batteries_v2, Version=2.1.11.2622, Culture=neutral, PublicKeyToken=8226ea5df37bcae9, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\SQLitePCLRaw.bundle_e_sqlite3.2.1.11\lib\net461\SQLitePCLRaw.batteries_v2.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SQLitePCLRaw.core, Version=2.1.11.2622, Culture=neutral, PublicKeyToken=1488e028ca7ab535, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\SQLitePCLRaw.core.2.1.11\lib\netstandard2.0\SQLitePCLRaw.core.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SQLitePCLRaw.provider.dynamic_cdecl, Version=2.1.11.2622, Culture=neutral, PublicKeyToken=b68184102cba0b3b, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\SQLitePCLRaw.provider.dynamic_cdecl.2.1.11\lib\netstandard2.0\SQLitePCLRaw.provider.dynamic_cdecl.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.5.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
<HintPath>packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.configuration" />
|
<Reference Include="System.configuration" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Data.SQLite.EF6, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Data.SQLite.Linq, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
|
||||||
<HintPath>packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Diagnostics.DiagnosticSource.9.0.3\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
<HintPath>packages\System.Diagnostics.DiagnosticSource.9.0.3\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -137,9 +115,25 @@
|
|||||||
<Reference Include="System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Drawing.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Drawing.Common.9.0.3\lib\net462\System.Drawing.Common.dll</HintPath>
|
<HintPath>packages\System.Drawing.Common.9.0.3\lib\net462\System.Drawing.Common.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Formats.Asn1, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Formats.Asn1.9.0.3\lib\net462\System.Formats.Asn1.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.IO.Compression" />
|
<Reference Include="System.IO.Compression" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Memory, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Memory.4.6.2\lib\net462\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Numerics" />
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.1.1\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Security" />
|
<Reference Include="System.Security" />
|
||||||
|
<Reference Include="System.Security.Cryptography.Xml, Version=9.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>packages\System.Security.Cryptography.Xml.9.0.3\lib\net462\System.Security.Cryptography.Xml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Text.Encoding.CodePages, Version=9.0.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Text.Encoding.CodePages, Version=9.0.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\System.Text.Encoding.CodePages.9.0.3\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
|
<HintPath>packages\System.Text.Encoding.CodePages.9.0.3\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -169,11 +163,12 @@
|
|||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="Converters\ImagePathConverter.cs" />
|
<Compile Include="Converters\ImagePathConverter.cs" />
|
||||||
<Compile Include="Models\SongData.cs" />
|
<Compile Include="Models\SongData.cs" />
|
||||||
|
<Compile Include="Models\MyDB.cs" />
|
||||||
<Page Include="Views\Index.xaml">
|
<Page Include="Views\Index.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\MainWindow.xaml">
|
<Page Include="Views\Login.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
@ -183,7 +178,7 @@
|
|||||||
<Compile Include="Converters\BitmapToImageSourceConverter.cs" />
|
<Compile Include="Converters\BitmapToImageSourceConverter.cs" />
|
||||||
<Compile Include="Controller\Index.cs" />
|
<Compile Include="Controller\Index.cs" />
|
||||||
<Compile Include="Controller\MainViewModel.cs" />
|
<Compile Include="Controller\MainViewModel.cs" />
|
||||||
<Compile Include="Controller\MainWindow.cs">
|
<Compile Include="Controller\Login.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -229,10 +224,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ErrorText>此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原,以下載該套件。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的檔案是 {0}。</ErrorText>
|
<ErrorText>此專案參考這部電腦上所缺少的 NuGet 套件。請啟用 NuGet 套件還原,以下載該套件。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的檔案是 {0}。</ErrorText>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Error Condition="!Exists('packages\EntityFramework.6.5.1\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.5.1\build\EntityFramework.props'))" />
|
<Error Condition="!Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
|
||||||
<Error Condition="!Exists('packages\EntityFramework.6.5.1\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\EntityFramework.6.5.1\build\EntityFramework.targets'))" />
|
|
||||||
<Error Condition="!Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
|
|
||||||
</Target>
|
</Target>
|
||||||
<Import Project="packages\EntityFramework.6.5.1\build\EntityFramework.targets" Condition="Exists('packages\EntityFramework.6.5.1\build\EntityFramework.targets')" />
|
<Import Project="packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
|
||||||
<Import Project="packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
|
|
||||||
</Project>
|
</Project>
|
59
Models/MyDB.cs
Normal file
59
Models/MyDB.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using MySqlConnector;
|
||||||
|
|
||||||
|
namespace Karaoke_Kingpin.Models
|
||||||
|
{
|
||||||
|
public class MyDB : IDisposable
|
||||||
|
{
|
||||||
|
private readonly string connectionString = "Server=192.168.22.170;Port=3306;Database=Karaoke-Kingpin;User=Karaoke-Kingpin;Password=ESM7yTPMnavFmbBH;";
|
||||||
|
private MySqlConnection conn;
|
||||||
|
|
||||||
|
public MyDB()
|
||||||
|
{
|
||||||
|
conn = new MySqlConnection(connectionString);
|
||||||
|
conn.Open();
|
||||||
|
Console.WriteLine("MyDB 連線成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (conn != null)
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
Console.WriteLine("MyDB 連線已關閉!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SELECT 方法
|
||||||
|
public DataTable Select(string query, MySqlParameter[] parameters)
|
||||||
|
{
|
||||||
|
using (var cmd = new MySqlCommand(query, conn))
|
||||||
|
{
|
||||||
|
if (parameters != null)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddRange(parameters);
|
||||||
|
}
|
||||||
|
using (var adapter = new MySqlDataAdapter(cmd))
|
||||||
|
{
|
||||||
|
DataTable result = new DataTable();
|
||||||
|
adapter.Fill(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// INSERT / UPDATE / DELETE 方法
|
||||||
|
public int ExecuteNonQuery(string query, MySqlParameter[] parameters)
|
||||||
|
{
|
||||||
|
using (var cmd = new MySqlCommand(query, conn))
|
||||||
|
{
|
||||||
|
if (parameters != null)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddRange(parameters);
|
||||||
|
}
|
||||||
|
return cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Karaoke_Kingpin.Models
|
namespace Karaoke_Kingpin.Models
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:Karaoke_Kingpin.Controller"
|
xmlns:local="clr-namespace:Karaoke_Kingpin.Controller"
|
||||||
xmlns:converters="clr-namespace:Karaoke_Kingpin.Converters"
|
xmlns:converters="clr-namespace:Karaoke_Kingpin.Converters"
|
||||||
StartupUri="Views\MainWindow.xaml">
|
StartupUri="Views\login.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Window x:Class="Karaoke_Kingpin.Controller.MainWindow"
|
<Window x:Class="Karaoke_Kingpin.Controller.Login"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
@ -2,15 +2,13 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Chinese" version="0.5.0" targetFramework="net481" />
|
<package id="Chinese" version="0.5.0" targetFramework="net481" />
|
||||||
<package id="ChineseConverter" version="1.0.0" targetFramework="net481" />
|
<package id="ChineseConverter" version="1.0.0" targetFramework="net481" />
|
||||||
<package id="EntityFramework" version="6.5.1" targetFramework="net48" />
|
<package id="EPPlus" version="8.0.1" targetFramework="net48" />
|
||||||
<package id="EPPlus" version="7.7.0" targetFramework="net48" />
|
|
||||||
<package id="EPPlus.Interfaces" version="8.0.0" targetFramework="net48" />
|
<package id="EPPlus.Interfaces" version="8.0.0" targetFramework="net48" />
|
||||||
<package id="EPPlus.System.Drawing" version="8.0.0" targetFramework="net48" />
|
<package id="EPPlus.System.Drawing" version="8.0.0" targetFramework="net48" />
|
||||||
<package id="ExcelDataReader" version="3.7.0" targetFramework="net48" />
|
<package id="ExcelDataReader" version="3.7.0" targetFramework="net48" />
|
||||||
<package id="ExcelDataReader.DataSet" version="3.7.0" targetFramework="net48" />
|
<package id="ExcelDataReader.DataSet" version="3.7.0" targetFramework="net48" />
|
||||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="9.0.3" targetFramework="net48" />
|
<package id="Microsoft.Bcl.AsyncInterfaces" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="Microsoft.Data.Sqlite" version="9.0.3" targetFramework="net48" />
|
<package id="Microsoft.Bcl.Cryptography" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="Microsoft.Data.Sqlite.Core" version="9.0.3" targetFramework="net48" />
|
|
||||||
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="9.0.3" targetFramework="net48" />
|
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="9.0.3" targetFramework="net48" />
|
<package id="Microsoft.Extensions.Logging.Abstractions" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="Microsoft.International.Converters.PinYinConverter" version="1.0.0" targetFramework="net481" />
|
<package id="Microsoft.International.Converters.PinYinConverter" version="1.0.0" targetFramework="net481" />
|
||||||
@ -20,18 +18,16 @@
|
|||||||
<package id="NStandard" version="0.90.0" targetFramework="net48" />
|
<package id="NStandard" version="0.90.0" targetFramework="net48" />
|
||||||
<package id="pinyin4net" version="1.0.0" targetFramework="net481" />
|
<package id="pinyin4net" version="1.0.0" targetFramework="net481" />
|
||||||
<package id="SamOatesGames.ModernUI.Xceed.Toolkit" version="1.0.1905191936" targetFramework="net481" />
|
<package id="SamOatesGames.ModernUI.Xceed.Toolkit" version="1.0.1905191936" targetFramework="net481" />
|
||||||
<package id="SQLitePCLRaw.bundle_e_sqlite3" version="2.1.11" targetFramework="net48" />
|
<package id="System.Buffers" version="4.6.1" targetFramework="net48" />
|
||||||
<package id="SQLitePCLRaw.core" version="2.1.11" targetFramework="net48" />
|
|
||||||
<package id="SQLitePCLRaw.lib.e_sqlite3" version="2.1.11" targetFramework="net48" />
|
|
||||||
<package id="SQLitePCLRaw.provider.dynamic_cdecl" version="2.1.11" targetFramework="net48" />
|
|
||||||
<package id="Stub.System.Data.SQLite.Core.NetFramework" version="1.0.119.0" targetFramework="net48" />
|
|
||||||
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net481" />
|
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net481" />
|
||||||
<package id="System.Data.SQLite" version="1.0.119.0" targetFramework="net48" />
|
|
||||||
<package id="System.Data.SQLite.Core" version="1.0.119.0" targetFramework="net48" />
|
|
||||||
<package id="System.Data.SQLite.EF6" version="1.0.119.0" targetFramework="net48" />
|
|
||||||
<package id="System.Data.SQLite.Linq" version="1.0.119.0" targetFramework="net48" />
|
|
||||||
<package id="System.Diagnostics.DiagnosticSource" version="9.0.3" targetFramework="net48" />
|
<package id="System.Diagnostics.DiagnosticSource" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="System.Drawing.Common" version="9.0.3" targetFramework="net48" />
|
<package id="System.Drawing.Common" version="9.0.3" targetFramework="net48" />
|
||||||
|
<package id="System.Formats.Asn1" version="9.0.3" targetFramework="net48" />
|
||||||
|
<package id="System.Memory" version="4.6.2" targetFramework="net48" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.6.1" targetFramework="net48" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.1" targetFramework="net48" />
|
||||||
|
<package id="System.Security.Cryptography.Xml" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="System.Text.Encoding.CodePages" version="9.0.3" targetFramework="net48" />
|
<package id="System.Text.Encoding.CodePages" version="9.0.3" targetFramework="net48" />
|
||||||
<package id="System.Threading.Tasks.Extensions" version="4.6.2" targetFramework="net48" />
|
<package id="System.Threading.Tasks.Extensions" version="4.6.2" targetFramework="net48" />
|
||||||
|
<package id="System.ValueTuple" version="4.6.1" targetFramework="net48" />
|
||||||
</packages>
|
</packages>
|
Reference in New Issue
Block a user