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 1/2] 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(); From a4c0104b451614c45a5e5e7bc67f7ef2aa50e3ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=A0=EA=B7=9C?= Date: Mon, 7 Jun 2021 03:01:39 +0900 Subject: [PATCH 2/2] add target in schedule --- OSTLibrary/Classes/Schedule.cs | 6 +++--- Server/Classes/Database.cs | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OSTLibrary/Classes/Schedule.cs b/OSTLibrary/Classes/Schedule.cs index 2ea4b0f..acd8eba 100644 --- a/OSTLibrary/Classes/Schedule.cs +++ b/OSTLibrary/Classes/Schedule.cs @@ -10,10 +10,9 @@ public class Schedule public DateTime end; public string scope; public string contents; + public string target; - - - public Schedule(int author, string title, DateTime start, DateTime end,string scope, string contents) + public Schedule(int author, string title, DateTime start, DateTime end,string scope, string contents, string target) { this.author = author; this.title = title; @@ -21,6 +20,7 @@ public Schedule(int author, string title, DateTime start, DateTime end,string sc this.end = end; this.scope = scope; this.contents = contents; + this.target = target; } } } diff --git a/Server/Classes/Database.cs b/Server/Classes/Database.cs index e22e4d4..c9c938a 100644 --- a/Server/Classes/Database.cs +++ b/Server/Classes/Database.cs @@ -136,7 +136,7 @@ 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);", + "INSERT INTO schedule VALUES (@author, @title, @start, @end, @scope, @contents, @target);", con); cmd.Parameters.AddWithValue("@author", schedule.author); @@ -145,7 +145,8 @@ public static bool AddSchedule(Schedule schedule) cmd.Parameters.Add("@end", MySqlDbType.DateTime, 50).Value = End; cmd.Parameters.AddWithValue("@scope", schedule.scope); cmd.Parameters.AddWithValue("@contents", schedule.contents); - + cmd.Parameters.AddWithValue("@target", schedule.target); + try { cmd.ExecuteNonQuery(); @@ -175,7 +176,8 @@ public static List GetSchedule(Employee emp) rdr.GetDateTime("start"), rdr.GetDateTime("end"), rdr.GetString("scope"), - rdr.GetString("contents"))); + rdr.GetString("contents"), + rdr.GetString("target"))); } } return schedules;