diff --git a/Client/Forms/ControlSchedule.cs b/Client/Forms/ControlSchedule.cs index 976d94e..c9b6d63 100644 --- a/Client/Forms/ControlSchedule.cs +++ b/Client/Forms/ControlSchedule.cs @@ -20,13 +20,13 @@ public ControlSchedule(Schedule schedule) { InitializeComponent(); - if (schedule.range == "회사 전체") + if (schedule.scope == "회사 전체") picRangeColor.Image = Resources.lavendar; - else if (schedule.range == "본부 전체") + else if (schedule.scope == "본부 전체") picRangeColor.Image = Resources.light_blue; - else if (schedule.range == "팀 전체") + else if (schedule.scope == "팀 전체") picRangeColor.Image = Resources.light_green; - else if (schedule.range == "개인") + else if (schedule.scope == "개인") picRangeColor.Image = Resources.gold; lblSche_Name.Text = schedule.title; @@ -38,7 +38,6 @@ public ControlSchedule(Schedule schedule) private void picContent_Click(object sender, EventArgs e) { //'+' 아이콘 클릭 시 일정 내용 메세지박스로 출력 - //MessageBox.Show(); MessageBox.Show(ctent, "스케줄 내용", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -46,6 +45,16 @@ private void picDelete_Click(object sender, EventArgs e) { //클릭 시 스케줄 수동 삭제 //기간 만기 시 자동삭제는 어디서해야할까? + var result = MessageBox.Show( + "일정을 삭제하시겠습니까?", + "Caption", + MessageBoxButtons.OKCancel, + MessageBoxIcon.Question + ); + if(result == DialogResult.OK) + { + //컨트롤 삭제 코드 + } } } } diff --git a/Client/Forms/FormLogin.cs b/Client/Forms/FormLogin.cs index daa199c..96178bc 100644 --- a/Client/Forms/FormLogin.cs +++ b/Client/Forms/FormLogin.cs @@ -192,6 +192,7 @@ public void EndLogin(Packet packet) // 나에 대한 채팅방 정보들과 다른 사원들의 정보를 저장 Program.rooms = p.rooms; Program.employees = p.employees; + Program.schedules = p.schedules; // 로그인 창 닫기 BeginInvoke(new MethodInvoker(() => Close())); diff --git a/Client/Forms/FormMain.cs b/Client/Forms/FormMain.cs index 4935b66..00c7c31 100644 --- a/Client/Forms/FormMain.cs +++ b/Client/Forms/FormMain.cs @@ -16,7 +16,7 @@ public partial class FormMain : MetroForm { Dictionary formChats; // 켜져있는 채팅방들 Dictionary roomCards; // 나의 채팅방 카드들 - Dictionary scheduleCards; //나의 스케줄 카드들 + Dictionary scheduleCards; //나의 스케줄 카드들 public FormMain() { @@ -52,10 +52,15 @@ private void FormMain_Shown(object sender, EventArgs e) // 채팅 관련 컨트롤들 배열 초기화 formChats = new Dictionary(); roomCards = new Dictionary(); + // 스케줄 관련 컨트롤들 배열 초기화 + scheduleCards = new Dictionary(); // 최초 룸 모두 추가 Program.rooms.ForEach(AddRoomCard); + // 최초 스케줄 모두 추가 (여기서 에러 발생) + Program.schedules.ForEach(AddScheduleCard); + // 룸 받기 콜백 if (!Program.callback.ContainsKey(PacketType.Room)) Program.callback.Add(PacketType.Room, ReceiveRoom); @@ -64,6 +69,10 @@ private void FormMain_Shown(object sender, EventArgs e) if (!Program.callback.ContainsKey(PacketType.Chat)) Program.callback.Add(PacketType.Chat, ReceiveChat); + // 스케줄 받기 콜백 + if (!Program.callback.ContainsKey(PacketType.Schedule)) + Program.callback.Add(PacketType.Schedule, ReceiveSchedule); + // 사원 정보 받고 트리뷰 처리 foreach (Employee emp in Program.employees.Values) { @@ -256,11 +265,11 @@ void AddRoomCard(Room room) pnlChat.Controls.Add(cardRoom); roomCards.Add(room.id, cardRoom); } - void AddScheduleCard(Schedule schedule) + void AddScheduleCard(Schedule schedule) //스케줄카드 생성 { ControlSchedule Cardschedule = new ControlSchedule(schedule); - //scheduleCards.Add(, Cardschedule); + scheduleCards.Add(Program.employee.id, Cardschedule); } void ReceiveRoom(Packet p) { @@ -301,7 +310,7 @@ void ReceiveChat(Packet p) } } } - void ReceiveSchedule(Packet p) + void ReceiveSchedule(Packet p) //스케줄카드로 받아와 저장 { SchedulePacket sp = p as SchedulePacket; diff --git a/Client/Panels/PanelSchedule.Designer.cs b/Client/Panels/PanelSchedule.Designer.cs index 25a4f74..0125b5f 100644 --- a/Client/Panels/PanelSchedule.Designer.cs +++ b/Client/Panels/PanelSchedule.Designer.cs @@ -99,7 +99,6 @@ private void InitializeComponent() this.tleSubmit.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.tleSubmit.Cursor = System.Windows.Forms.Cursors.Hand; - this.tleSubmit.Enabled = false; this.tleSubmit.Location = new System.Drawing.Point(0, 522); this.tleSubmit.Name = "tleSubmit"; this.tleSubmit.Size = new System.Drawing.Size(360, 48); @@ -148,11 +147,6 @@ private void InitializeComponent() // this.cmbScope.FormattingEnabled = true; this.cmbScope.ItemHeight = 23; - this.cmbScope.Items.AddRange(new object[] { - "회사 전체", - "본부 전체", - "팀 전체", - "개인"}); this.cmbScope.Location = new System.Drawing.Point(60, 206); this.cmbScope.Name = "cmbScope"; this.cmbScope.Size = new System.Drawing.Size(240, 29); diff --git a/Client/Panels/PanelSchedule.cs b/Client/Panels/PanelSchedule.cs index 507a23d..b2a08d6 100644 --- a/Client/Panels/PanelSchedule.cs +++ b/Client/Panels/PanelSchedule.cs @@ -37,12 +37,14 @@ private void picClose_Click(object sender, EventArgs e) private void tleSubmit_Click(object sender, EventArgs e) { + // Panel -> Client.cs(Server) try { Program.Send(new SchedulePacket(new Schedule(Program.employee.id, txtTitle.Text, dtpStart.Value, dtpEnd.Value, cmbScope.SelectedItem as string, txtContent.Text))); } catch (FormatException) { } + Swipe(false); } } } \ No newline at end of file diff --git a/OSTLibrary/Classes/Schedule.cs b/OSTLibrary/Classes/Schedule.cs index df9ea54..2ea4b0f 100644 --- a/OSTLibrary/Classes/Schedule.cs +++ b/OSTLibrary/Classes/Schedule.cs @@ -8,18 +8,18 @@ public class Schedule public string title; public DateTime start; public DateTime end; - public string range; + public string scope; public string contents; - public Schedule(int author, string title, DateTime start, DateTime end,string range, string contents) + public Schedule(int author, string title, DateTime start, DateTime end,string scope, string contents) { this.author = author; this.title = title; this.start = start; this.end = end; - this.range = range; + this.scope = scope; this.contents = contents; } } diff --git a/OSTLibrary/Networks/LoginPacket.cs b/OSTLibrary/Networks/LoginPacket.cs index 9f6f32b..37ef8d8 100644 --- a/OSTLibrary/Networks/LoginPacket.cs +++ b/OSTLibrary/Networks/LoginPacket.cs @@ -10,6 +10,7 @@ public class LoginPacket : Packet { public Dictionary employees; public List rooms; + public List schedules; public bool success = false; @@ -20,13 +21,14 @@ public LoginPacket(int empId, string password) employees = new Dictionary(); employees.Add(0, new Employee(empId, password)); } - public LoginPacket(bool success, Dictionary employees, List rooms) + public LoginPacket(bool success, Dictionary employees, List rooms, List schedules) { type = PacketType.Login; this.success = success; this.employees = employees; this.rooms = rooms; + this.schedules = schedules; } } } diff --git a/Server/Classes/Client.cs b/Server/Classes/Client.cs index c11447d..379517b 100644 --- a/Server/Classes/Client.cs +++ b/Server/Classes/Client.cs @@ -140,7 +140,9 @@ public void Recieve() room.lastChat = Database.GetLastChat(room); } - p = new LoginPacket(true, Program.employees, myRooms); + List mySchedule = Database.GetSchedule(emp); + + p = new LoginPacket(true, Program.employees, myRooms, mySchedule); } Thread.Sleep(200); // 클라이언트 스피너 보기 위함 @@ -245,7 +247,14 @@ public void Recieve() } else if(packet.type == PacketType.Schedule) { + // Panel(Client) -> Client.cs(Server) -> DB add SchedulePacket sp = packet as SchedulePacket; + if (Database.AddSchedule(sp.schedules[0])) + { + Log("Schedule", "스케줄 DB 저장 성공"); + } + else + Log("Schedule", "스케줄 DB 저장 실패"); } diff --git a/Server/Classes/Database.cs b/Server/Classes/Database.cs index 77f498e..2e4f1ef 100644 --- a/Server/Classes/Database.cs +++ b/Server/Classes/Database.cs @@ -148,7 +148,7 @@ public static bool AddSchedule(Schedule schedule) cmd.Parameters.AddWithValue("@title", schedule.title); cmd.Parameters.Add(start); cmd.Parameters.Add(end); - cmd.Parameters.AddWithValue("@scope", schedule.range); + cmd.Parameters.AddWithValue("@scope", schedule.scope); cmd.Parameters.Add(contents); } try @@ -166,12 +166,12 @@ public static List GetSchedule(Employee emp) { List schedules = new List(); - string sql = $"SELECT author, title, start, end, range, contents FROM employee WHERE id={emp}"; + string sql = $"SELECT author, title, start, end, range, contents FROM schedule WHERE author={emp.id}"; MySqlCommand cmd = new MySqlCommand(sql, con); using (MySqlDataReader rdr = cmd.ExecuteReader()) { - if (rdr.Read()) + while (rdr.Read()) { using (MemoryStream ms = new MemoryStream()) schedules.Add(new Schedule( diff --git a/Server/Program.cs b/Server/Program.cs index b3ca321..feb9253 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -15,6 +15,7 @@ class Program public static Dictionary clients; // 로그인 후 클라이언트들 public static Dictionary employees; // 사원들 정보 + public static Dictionary schedules; // 스케줄 정보들 public static Dictionary> roomEmps; // 각 룸에 있는 접속된 사원 번호 static void Main(string[] args) @@ -24,6 +25,7 @@ static void Main(string[] args) clients = new Dictionary(); unloginedClients = new List(); roomEmps = new Dictionary>(); + schedules = new Dictionary(); // 데이터 베이스 접속 if (Database.Connect())