您的位置:首页 > 移动开发 > Objective-C

计算某年某月工作天数

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


    }


}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息