using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace yinLouSys
{
	/// <summary>
	/// selectDate 的摘要说明。
	/// </summary>
	public class selectDate : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MonthCalendar monthCalendar1;
        private System.Windows.Forms.Button button1;
        private Button button3;
        private int leftPx;
        private int topPx;
        private Form _frmParent;

        private int _isClear = 1;  //是否可以清空日期1可以，0不可以

        public int IsClear
        {
            get { return _isClear; }
            set { _isClear = value; }
        }

        public Form FrmParent
        {
            get { return _frmParent; }
            set { _frmParent = value; }
        }

		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public selectDate(int l,int t)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
            leftPx=l;
            topPx = t;

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
            this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
            this.button1 = new System.Windows.Forms.Button();
            this.button3 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // monthCalendar1
            // 
            this.monthCalendar1.Location = new System.Drawing.Point(0, 0);
            this.monthCalendar1.Name = "monthCalendar1";
            this.monthCalendar1.TabIndex = 0;
            this.monthCalendar1.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar1_DateSelected);
            // 
            // button1
            // 
            this.button1.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button1.ForeColor = System.Drawing.Color.DarkSlateBlue;
            this.button1.Location = new System.Drawing.Point(223, 127);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(40, 20);
            this.button1.TabIndex = 1;
            this.button1.Text = "关闭";
            this.button1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            this.button1.UseVisualStyleBackColor = false;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // button3
            // 
            this.button3.BackColor = System.Drawing.SystemColors.ButtonFace;
            this.button3.Cursor = System.Windows.Forms.Cursors.Hand;
            this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
            this.button3.ForeColor = System.Drawing.Color.DarkSlateBlue;
            this.button3.Location = new System.Drawing.Point(177, 127);
            this.button3.Name = "button3";
            this.button3.Size = new System.Drawing.Size(40, 20);
            this.button3.TabIndex = 3;
            this.button3.Text = "清空";
            this.button3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            this.button3.UseVisualStyleBackColor = false;
            this.button3.Click += new System.EventHandler(this.button3_Click);
            // 
            // selectDate
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
            this.ClientSize = new System.Drawing.Size(267, 150);
            this.Controls.Add(this.button3);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.monthCalendar1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Name = "selectDate";
            this.ShowInTaskbar = false;
            this.Text = "选择日期";
            this.Leave += new System.EventHandler(this.selectDate_Leave);
            this.Load += new System.EventHandler(this.selectDate_Load);
            this.ResumeLayout(false);

		}
		#endregion

		private void button2_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void button1_Click(object sender, System.EventArgs e)
		{			
            //string bb=this.monthCalendar1.SelectionEnd.ToString("yyyy-MM-dd");
            //StuSignUp._strDate=bb;
			
            //this.Dispose();
            //this.Visible=false;
            this.Close();
		}

      

        private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
        {
            frmMain._strDate = monthCalendar1.SelectionEnd.ToString("yyyy-MM-dd");
            this.Close();

        }

        private void selectDate_Load(object sender, EventArgs e)
        {
            this.Top = topPx;
            this.Left = leftPx;
           // StuSignUp._strDate = "";
            if (frmMain._strDate != "")
            {
               // monthCalendar1.SelectionStart = Convert.ToDateTime(StuSignUp._strDate);
                monthCalendar1.SetDate(Convert.ToDateTime(frmMain._strDate));
            }

            button3.Visible = _isClear == 1;
           
        }

        private void selectDate_Leave(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            frmMain._strDate = "";
            this.Close();
        }
	}
}
