Skip to content

Commit

Permalink
some edit
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseop-choung committed Jun 5, 2021
1 parent 2848870 commit e05b258
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 23 deletions.
19 changes: 14 additions & 5 deletions Client/Forms/ControlSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,14 +38,23 @@ public ControlSchedule(Schedule schedule)
private void picContent_Click(object sender, EventArgs e)
{
//'+' ์•„์ด์ฝ˜ ํด๋ฆญ ์‹œ ์ผ์ • ๋‚ด์šฉ ๋ฉ”์„ธ์ง€๋ฐ•์Šค๋กœ ์ถœ๋ ฅ
//MessageBox.Show();
MessageBox.Show(ctent, "์Šค์ผ€์ค„ ๋‚ด์šฉ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

private void picDelete_Click(object sender, EventArgs e)
{
//ํด๋ฆญ ์‹œ ์Šค์ผ€์ค„ ์ˆ˜๋™ ์‚ญ์ œ
//๊ธฐ๊ฐ„ ๋งŒ๊ธฐ ์‹œ ์ž๋™์‚ญ์ œ๋Š” ์–ด๋””์„œํ•ด์•ผํ• ๊นŒ?
var result = MessageBox.Show(
"์ผ์ •์„ ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?",
"Caption",
MessageBoxButtons.OKCancel,
MessageBoxIcon.Question
);
if(result == DialogResult.OK)
{
//์ปจํŠธ๋กค ์‚ญ์ œ ์ฝ”๋“œ
}
}
}
}
1 change: 1 addition & 0 deletions Client/Forms/FormLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
17 changes: 13 additions & 4 deletions Client/Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class FormMain : MetroForm
{
Dictionary<string, FormRoom> formChats; // ์ผœ์ ธ์žˆ๋Š” ์ฑ„ํŒ…๋ฐฉ๋“ค
Dictionary<string, ControlRoomCard> roomCards; // ๋‚˜์˜ ์ฑ„ํŒ…๋ฐฉ ์นด๋“œ๋“ค
Dictionary<string, ControlSchedule> scheduleCards; //๋‚˜์˜ ์Šค์ผ€์ค„ ์นด๋“œ๋“ค
Dictionary<int, ControlSchedule> scheduleCards; //๋‚˜์˜ ์Šค์ผ€์ค„ ์นด๋“œ๋“ค

public FormMain()
{
Expand Down Expand Up @@ -52,10 +52,15 @@ private void FormMain_Shown(object sender, EventArgs e)
// ์ฑ„ํŒ… ๊ด€๋ จ ์ปจํŠธ๋กค๋“ค ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”
formChats = new Dictionary<string, FormRoom>();
roomCards = new Dictionary<string, ControlRoomCard>();
// ์Šค์ผ€์ค„ ๊ด€๋ จ ์ปจํŠธ๋กค๋“ค ๋ฐฐ์—ด ์ดˆ๊ธฐํ™”
scheduleCards = new Dictionary<int, ControlSchedule>();

// ์ตœ์ดˆ ๋ฃธ ๋ชจ๋‘ ์ถ”๊ฐ€
Program.rooms.ForEach(AddRoomCard);

// ์ตœ์ดˆ ์Šค์ผ€์ค„ ๋ชจ๋‘ ์ถ”๊ฐ€ (์—ฌ๊ธฐ์„œ ์—๋Ÿฌ ๋ฐœ์ƒ)
Program.schedules.ForEach(AddScheduleCard);

// ๋ฃธ ๋ฐ›๊ธฐ ์ฝœ๋ฐฑ
if (!Program.callback.ContainsKey(PacketType.Room))
Program.callback.Add(PacketType.Room, ReceiveRoom);
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -301,7 +310,7 @@ void ReceiveChat(Packet p)
}
}
}
void ReceiveSchedule(Packet p)
void ReceiveSchedule(Packet p) //์Šค์ผ€์ค„์นด๋“œ๋กœ ๋ฐ›์•„์™€ ์ €์žฅ
{
SchedulePacket sp = p as SchedulePacket;

Expand Down
6 changes: 0 additions & 6 deletions Client/Panels/PanelSchedule.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Client/Panels/PanelSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
6 changes: 3 additions & 3 deletions OSTLibrary/Classes/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 3 additions & 1 deletion OSTLibrary/Networks/LoginPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class LoginPacket : Packet
{
public Dictionary<int, Employee> employees;
public List<Room> rooms;
public List<Schedule> schedules;

public bool success = false;

Expand All @@ -20,13 +21,14 @@ public LoginPacket(int empId, string password)
employees = new Dictionary<int, Employee>();
employees.Add(0, new Employee(empId, password));
}
public LoginPacket(bool success, Dictionary<int, Employee> employees, List<Room> rooms)
public LoginPacket(bool success, Dictionary<int, Employee> employees, List<Room> rooms, List<Schedule> schedules)
{
type = PacketType.Login;

this.success = success;
this.employees = employees;
this.rooms = rooms;
this.schedules = schedules;
}
}
}
11 changes: 10 additions & 1 deletion Server/Classes/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public void Recieve()
room.lastChat = Database.GetLastChat(room);
}

p = new LoginPacket(true, Program.employees, myRooms);
List<Schedule> mySchedule = Database.GetSchedule(emp);

p = new LoginPacket(true, Program.employees, myRooms, mySchedule);
}

Thread.Sleep(200); // ํด๋ผ์ด์–ธํŠธ ์Šคํ”ผ๋„ˆ ๋ณด๊ธฐ ์œ„ํ•จ
Expand Down Expand Up @@ -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 ์ €์žฅ ์‹คํŒจ");

}

Expand Down
6 changes: 3 additions & 3 deletions Server/Classes/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -166,12 +166,12 @@ public static List<Schedule> GetSchedule(Employee emp)
{
List<Schedule> schedules = new List<Schedule>();

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(
Expand Down
2 changes: 2 additions & 0 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Program

public static Dictionary<int, Client> clients; // ๋กœ๊ทธ์ธ ํ›„ ํด๋ผ์ด์–ธํŠธ๋“ค
public static Dictionary<int, Employee> employees; // ์‚ฌ์›๋“ค ์ •๋ณด
public static Dictionary<int, Schedule> schedules; // ์Šค์ผ€์ค„ ์ •๋ณด๋“ค
public static Dictionary<string, List<int>> roomEmps; // ๊ฐ ๋ฃธ์— ์žˆ๋Š” ์ ‘์†๋œ ์‚ฌ์› ๋ฒˆํ˜ธ

static void Main(string[] args)
Expand All @@ -24,6 +25,7 @@ static void Main(string[] args)
clients = new Dictionary<int, Client>();
unloginedClients = new List<Client>();
roomEmps = new Dictionary<string, List<int>>();
schedules = new Dictionary<int, Schedule>();

// ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ์ ‘์†
if (Database.Connect())
Expand Down

0 comments on commit e05b258

Please sign in to comment.