程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 根據當前時間獲取本周,下周,上周日期

根據當前時間獲取本周,下周,上周日期

編輯:C#入門知識

實現點擊按鈕更改周,並獲取本周,上周,下周對應的具體日期

借鑒了一些網上的方法

         
         
         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);
   更改周 按鈕事件
          
                   
           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 =                      }

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved