From c07696d8f7923c5cce25553945a0f35bbb9c79dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=A0=EA=B7=9C?= Date: Sun, 6 Jun 2021 04:11:00 +0900 Subject: [PATCH] clear addSchedule --- Server/Classes/Database.cs | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/Server/Classes/Database.cs b/Server/Classes/Database.cs index 72a23fc..e22e4d4 100644 --- a/Server/Classes/Database.cs +++ b/Server/Classes/Database.cs @@ -132,25 +132,20 @@ public static bool Register(Employee employee) // 일정 public static bool AddSchedule(Schedule schedule) { + + DateTime Start = schedule.start; + DateTime End = schedule.end; MySqlCommand cmd = new MySqlCommand( "INSERT INTO schedule VALUES (@author, @title, @start, @end, @scope, @contents);", con); - using(MemoryStream ms = new MemoryStream()) - { - MySqlParameter start = new MySqlParameter("@start", MySqlDbType.DateTime, (int)ms.Length); - MySqlParameter end = new MySqlParameter("@end", MySqlDbType.DateTime, (int)ms.Length); - MySqlParameter contents = new MySqlParameter("@contents", MySqlDbType.LongText, (int)ms.Length); - start.Value = schedule.start; // MetroDateTime 연결할 것 - end.Value = schedule.end; // MetroDateTime 연결할 것 - contents.Value = schedule.contents; - - cmd.Parameters.AddWithValue("@author", schedule.author); - cmd.Parameters.AddWithValue("@title", schedule.title); - cmd.Parameters.Add(start); - cmd.Parameters.Add(end); - cmd.Parameters.AddWithValue("@scope", schedule.scope); - cmd.Parameters.Add(contents); - } + + cmd.Parameters.AddWithValue("@author", schedule.author); + cmd.Parameters.AddWithValue("@title", schedule.title); + cmd.Parameters.Add("@start", MySqlDbType.DateTime, 50).Value = Start; + cmd.Parameters.Add("@end", MySqlDbType.DateTime, 50).Value = End; + cmd.Parameters.AddWithValue("@scope", schedule.scope); + cmd.Parameters.AddWithValue("@contents", schedule.contents); + try { cmd.ExecuteNonQuery();