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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
參照

namespace _103303058_0518_01
{
public enum Sport
{
NONE,
BASEBALL,
TENNIS,
FOOTBALL,
BASKETBALL,
};


public class C_Person
{
public string Name = "未輸入"; //在每個變數前說明私密於否
public Sport Favorate_Sport = Sport.NONE;

private int m_PermitHolidays = 0;
private int m_YearofExperience = 0;
private int m_Holidays = 0;

public int YearofExperience
{
get
{
return m_YearofExperience;
}

set
{
if (value > 40)
{
m_YearofExperience = 40;
}
else if (value <= 1)
{
m_YearofExperience = 1;
}
else
{
m_YearofExperience = value;
}




if (m_YearofExperience <= 1)
{
m_PermitHolidays = 1;
}
else if (m_YearofExperience <= 5 )
{
m_PermitHolidays = 3;
}
else if (m_YearofExperience <= 10 )
{
m_PermitHolidays = 5;
}
else if (m_YearofExperience <= 20 )
{
m_PermitHolidays = 14;
}
else
{
m_PermitHolidays = 21;
}


}
}





public int PromitHolidays
{
get
{
return m_PermitHolidays;
}


}

public int Holidays
{
get
{
return m_Holidays;
}
set
{
if (value > m_PermitHolidays)
{
m_Holidays = m_PermitHolidays;
}
else
{
m_Holidays = value;
}
}

}
}
}





設計者

/// <summary>
/// 設計工具所需的變數。
private C_Person David;
/// </summary>



namespace _103303058_0525_01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
David = new C_Person();
groupBox1.Visible = false;


textBox_Name.Text = David.Name;


}

private void button1_Click(object sender, EventArgs e)
{
string str="";

if (textBox_Days.Text == "" || textBox_Year.Text == "")
{
MessageBox.Show("請輸入年資或欲請假天數", "錯誤", MessageBoxButtons.OK);
}
else
{
David.YearofExperience = Convert.ToInt32(textBox_Year.Text);
David.Holidays = Convert.ToInt32(textBox_Days.Text);


if (David.PromitHolidays - David.Holidays > 0)
{
str += "您有" + Convert.ToInt32(David.PromitHolidays) + "天可以請"+"\n此次請假過後還剩" + Convert.ToInt32(David.PromitHolidays - David.Holidays) + "天可以請喔";

}
else
{ str += "您之後就沒有假可以請了喔"; }

MessageBox.Show(str, "請假", MessageBoxButtons.OK);
groupBox1.Visible = true;


}


}

private void button2_Click(object sender, EventArgs e)
{
string days = "您請假的日期為"+ monthCalendar1.SelectionRange.Start.ToShortDateString()+ "到";
int i = David.Holidays;

days += monthCalendar1.SelectionEnd.AddDays(i-1).ToShortDateString();


MessageBox.Show(days , "請假",MessageBoxButtons.OK);


}
}
}