using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CommonFunction
{
	/// <summary>
	/// operDate 的摘要说明。
	/// </summary>
	public class operDate : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.TextBox txtCurDate;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.TextBox txtYear;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Button btnCurTime;
		protected System.Web.UI.WebControls.TextBox txtCurTime;
		protected System.Web.UI.WebControls.Button btnGetYear;
		protected System.Web.UI.WebControls.Button btnGetAgo;
		protected System.Web.UI.WebControls.TextBox txtAgoDate;
		protected System.Web.UI.WebControls.Button btnGetDate;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN：该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnGetDate.Click += new System.EventHandler(this.btnGetDate_Click);
			this.btnCurTime.Click += new System.EventHandler(this.btnCurTime_Click);
			this.btnGetYear.Click += new System.EventHandler(this.btnGetYear_Click);
			this.btnGetAgo.Click += new System.EventHandler(this.btnGetAgo_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnGetDate_Click(object sender, System.EventArgs e)
		{
			txtCurDate.Text = DateTime.Now.ToShortDateString();
		}

		private void btnCurTime_Click(object sender, System.EventArgs e)
		{
			txtCurTime.Text = DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" +DateTime.Now.Day.ToString() + " " 
				+ DateTime.Now.Hour.ToString() + ":" +DateTime.Now.Minute.ToString() + ":" +DateTime.Now.Second.ToString();
		}

		private void btnGetYear_Click(object sender, System.EventArgs e)
		{
			txtYear.Text = DateTime.Now.Year.ToString();
		}

		private void btnGetAgo_Click(object sender, System.EventArgs e)
		{
			txtAgoDate.Text = DateTime.Now.AddDays(-1).ToShortDateString();
		}
	}
}
