-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormCreateNotice.cs
More file actions
142 lines (129 loc) · 4.58 KB
/
FormCreateNotice.cs
File metadata and controls
142 lines (129 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System;
using System.Drawing;
using System.Windows.Forms;
namespace FormNoticeBoardAndCalendar
{
public class FormCreateNotice : Form
{
private Label lblTitle;
private Label lblAuthor;
private Label lblContent;
private Label lblSchedule;
private TextBox txtTitle;
private TextBox txtAuthor;
private TextBox txtContent;
private DateTimePicker datePicker;
private Button btnSubmit;
private Button btnClose;
private readonly Action<string, string, string,DateTime> onSubmit;
public FormCreateNotice(Action<string, string, string, DateTime> onSubmitCallback)
{
this.onSubmit = onSubmitCallback;
InitializeComponent();
}
private void InitializeComponent()
{
this.Text = "공지사항 작성";
this.ClientSize = new Size(500, 500);
this.StartPosition = FormStartPosition.CenterParent;
this.BackColor = Color.White;
this.Font = new Font("Segoe UI", 10);
lblTitle = new Label()
{
Text = "제목:",
Location = new Point(30, 30),
AutoSize = true
};
txtTitle = new TextBox()
{
Location = new Point(100, 25),
Width = 350,
Height = 30
};
lblAuthor = new Label()
{
Text = "작성자:",
Location = new Point(30, 75),
AutoSize = true
};
txtAuthor = new TextBox()
{
Location = new Point(100, 70),
Width = 200,
Height=30
};
lblContent = new Label()
{
Text = "내용:",
Location = new Point(30, 120),
AutoSize = true
};
txtContent = new TextBox()
{
Location = new Point(100, 115),
Width = 350,
Height = 200,
Multiline = true,
ScrollBars = ScrollBars.Vertical
};
lblSchedule = new Label()
{
Text = "일정 날짜:",
Location = new Point(30, 330),
AutoSize = true
};
datePicker = new DateTimePicker()
{
Location = new Point(120, 325),
Width = 200,
Format = DateTimePickerFormat.Custom,
CustomFormat = "yyyy-MM-dd"
};
btnSubmit = new Button()
{
Text = "공지사항 올리기",
Location = new Point(100, 370),
Width = 150,
Height = 40,
BackColor = Color.LightGreen,
FlatStyle = FlatStyle.Flat
};
btnSubmit.Click += BtnSubmit_Click;
btnClose = new Button()
{
Text = "닫기",
Location = new Point(270, 370),
Width = 100,
Height = 40,
BackColor = Color.LightGray,
FlatStyle = FlatStyle.Flat
};
btnClose.Click += (s, e) => this.Close();
this.Controls.Add(lblTitle);
this.Controls.Add(txtTitle);
this.Controls.Add(lblAuthor);
this.Controls.Add(txtAuthor);
this.Controls.Add(lblContent);
this.Controls.Add(txtContent);
this.Controls.Add(lblSchedule);
this.Controls.Add(datePicker);
this.Controls.Add(btnSubmit);
this.Controls.Add(btnClose);
}
private void BtnSubmit_Click(object sender, EventArgs e)
{
string title = txtTitle.Text.Trim();
string author = txtAuthor.Text.Trim();
string content = txtContent.Text.Trim();
DateTime scheduleDate = datePicker.Value.Date;
if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(author))
{
MessageBox.Show("제목과 작성자를 입력해주세요.", "입력 오류", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// 콜백을 통해 메인폼으로 작성된 내용을 전달
onSubmit?.Invoke(title, author, content,scheduleDate);
this.Close();
}
}
}