/// <summary>
/// 獲取指定月份指定周數的開始日期
/// </summary>
/// <param name="year">年份</param>
/// <param name="month">月份</param>
/// <param name="index">周數</param>
/// <returns></returns>
private DateTime GetStartDayOfWeeks(int year, int month, int index)
{
if (year < 1600 || year > 9999)
{
MessageBox.Show("年份超限");
return DateTime .MinValue ;
}
if (month < 0 || month > 12)
{
MessageBox.Show("月份錯誤");
return DateTime .MinValue ;
}
if (index < 1)
{
MessageBox.Show("周數錯誤");
return DateTime.MinValue;
}
DateTime startMonth = new DateTime(year, month, 1); //該月第一天
int dayOfWeek = 7;
if (Convert.ToInt32(startMonth.DayOfWeek.ToString("d")) > 0)
dayOfWeek = Convert.ToInt32(startMonth.DayOfWeek.ToString("d")); //該月第一天為星期幾
DateTime startWeek =