This commit is contained in:
backuppc
2025-07-08 13:29:40 +09:00
parent 8efe357430
commit 0d2da98470
4 changed files with 113 additions and 47 deletions

View File

@@ -122,7 +122,7 @@ namespace VNCServerList.Services
connection.Open();
string sql = @"
INSERT INTO VNC_ServerList ([User], [IP], [Category], [Title],[Description], [Password], [Argument])
VALUES (@User, @IP, @Category, @Description, @Password, @Argument)";
VALUES (@User, @IP, @Category, @Title,@Description, @Password, @Argument)";
using (var command = new SqlCommand(sql, connection))
{
@@ -165,6 +165,33 @@ namespace VNCServerList.Services
}
}
public bool UpdateServerByUserAndIP(string originalUser, string originalIp, VNCServer newServerData)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
string sql = @"
UPDATE VNC_ServerList
SET [IP] = @NewIP, [Category] = @Category, [Title] = @Title, [Description] = @Description,
[Password] = @Password, [Argument] = @Argument
WHERE [User] = @User AND [IP] = @OriginalIP";
using (var command = new SqlCommand(sql, connection))
{
command.Parameters.AddWithValue("@User", originalUser);
command.Parameters.AddWithValue("@OriginalIP", originalIp);
command.Parameters.AddWithValue("@NewIP", newServerData.IP);
command.Parameters.AddWithValue("@Category", (object)newServerData.Category ?? DBNull.Value);
command.Parameters.AddWithValue("@Title", (object)newServerData.Title ?? DBNull.Value);
command.Parameters.AddWithValue("@Description", (object)newServerData.Description ?? DBNull.Value);
command.Parameters.AddWithValue("@Password", (object)newServerData.Password ?? DBNull.Value);
command.Parameters.AddWithValue("@Argument", (object)newServerData.Argument ?? DBNull.Value);
return command.ExecuteNonQuery() > 0;
}
}
}
public bool DeleteServer(string user, string ip)
{
using (var connection = new SqlConnection(_connectionString))