Click the button to change the week and obtain the specific date of the week, last week, and next week.
Some online methods are used for reference.
DateTime beginDate = getWeekUpOfDate(DateTime.Now, DayOfWeek.Monday, ); DateTime endDate = getWeekUpOfDate(DateTime.Now, DayOfWeek.Sunday, ); DateTime getWeekUpOfDate(DateTime dt, DayOfWeek weekday, wd1 = ( wd2 = ( wd2 == wd1 ? dt.AddDays( * Number) : dt.AddDays( * Number - wd2 + wd1);
Change weekly button event btnThisWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday,); btnLastWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,-); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday,); btnNextWeek_Click (beginDate = getWeekUpOfDate (DateTime. now, DayOfWeek. monday,); endDate = getWeekUpOfDate (DateTime. now, DayOfWeek. sunday ,);
DateTime beginTime = DateTime endTime = DateTime[] times = GetDateTime(beginTime, endTime); (times.Length > TextBox1.Text= times[].ToShortDateString(); TextBox2.Text = times[].ToShortDateString(); TextBox3.Text = times[].ToShortDateString(); TextBox4.Text = times[].ToShortDateString(); TextBox5.Text = times[].ToShortDateString(); TextBox6.Text = times[].ToShortDateString(); TextBox7.Text = times[].ToShortDateString(); }
List<DateTime> timeList = List<DateTime> (; beginTime <= endTime; beginTime = beginTime.AddDays()) DateTime[] times = }