计算某年某月工作天数
2006-09-01 18:59
375 查看
using System ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
namespace WebApplication1
...{
/**//// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : Page
...{
protected TextBox TextBox1 ;
private void Page_Load ( object sender , EventArgs e )
...{
this.TextBox1.Text = CalculateWorkingDays ( 2006 , 2 ).ToString ( ) ;
}
private int CalculateWorkingDays ( int Year , int Month )
...{
int count = 0 ;
DateTime [ ] sj = new DateTime[2] ;
int ts = DateTime.DaysInMonth ( Year , Month ) ;
sj [ 0 ] = DateTime.Parse ( Year + "-" + Month + "-1" ) ;
sj [ 1 ] = DateTime.Parse ( Year + "-" + Month + "-" + ts ) ;
for ( DateTime dtTemp = sj [ 0 ] ; dtTemp <= sj [ 1 ] ; dtTemp = dtTemp.AddDays ( 1 ) )
...{
if ( ( dtTemp.DayOfWeek != DayOfWeek.Saturday ) && ( dtTemp.DayOfWeek != DayOfWeek.Sunday ) )
...{
count++ ;
}
}
return count ;
}
Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码
protected override void OnInit ( EventArgs e )
...{
9d7e
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent ( ) ;
base.OnInit ( e ) ;
}
/**//// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent ( )
...{
this.Load += new EventHandler ( this.Page_Load ) ;
}
#endregion
}
}
相关文章推荐
- c++的万年历类,支持显示某月月历与某年年历,支持计算任意两个日期的间隔天数
- 计算某年、某月、某日和某年、某月、某日之间的天数间隔。要求年、月、日通过键盘输入传递到程序中。
- 如何用JS计算某年某月天数(如2015年2月共有28天)
- 作业一:计算某年某月到某年某月的天数
- 1073 计算某年某月的天数
- JavaScript(JS)计算某年某月的天数(月末)
- javascript计算某年某月的天数
- 求用JAVA计算某年某月的天数?(两种方法)
- 怎样得到某年某月的最大天数
- 获取某年某月的工作日天数
- SQL 计算两日期之间的工作天数和过滤工作日(周六、周日)
- 求某年某月的天数
- SQL 查找某年某月的天数
- OJ刷题之某年某月的天数
- 7.(未经评测)某年某月的天数
- 某年某月的天数
- Java-判断某年某月的天数
- C#关于日期 月 天数 和一年有多少周及根据某年某周获取时间段的相关计算
- 获取某年某月的天数
- 打印某年某月的天数