www.pudn.com > PlanBoard.rar > UC_AddPlan.cs


using System; 
using System.Collections; 
using System.ComponentModel; 
using System.Drawing; 
using System.Data; 
using System.Windows.Forms; 
 
namespace PlanBoard 
{ 
	///  
	/// UC_AddPlan 的摘要说明。 
	///  
	public class UC_AddPlan : System.Windows.Forms.UserControl 
	{ 
		private System.Windows.Forms.Label label1; 
		private System.Windows.Forms.Label label2; 
		private System.Windows.Forms.Label label3; 
		private System.Windows.Forms.Label label4; 
		private System.Windows.Forms.Label label5; 
		private System.Windows.Forms.Label label6; 
		private System.Windows.Forms.Panel panel1; 
		private System.Windows.Forms.Label label7; 
		private System.Windows.Forms.CheckBox ccb_Finished; 
		private System.Windows.Forms.Label label8; 
		private System.Windows.Forms.Button btn_Add; 
		private System.Windows.Forms.TextBox txt_Item; 
		private System.Windows.Forms.TextBox txt_Desc; 
		private System.Windows.Forms.TextBox txt_Remarks; 
		private System.Windows.Forms.DateTimePicker dtp_DateBegin; 
		private System.Windows.Forms.DateTimePicker dtp_DateEnd; 
		private System.Windows.Forms.DateTimePicker dtp_PlanDate; 
		private System.Windows.Forms.ComboBox cbb_Level; 
		private System.Windows.Forms.DateTimePicker dtp_FinishDate; 
		private System.Windows.Forms.Button btn_Cancel; 
		///   
		/// 必需的设计器变量。 
		///  
		private System.ComponentModel.Container components = null; 
 
		public Form1 Parent_Form = null; 
 
		public UC_AddPlan() 
		{ 
			// 该调用是 Windows.Forms 窗体设计器所必需的。 
			InitializeComponent(); 
		} 
 
		///   
		/// 清理所有正在使用的资源。 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region 组件设计器生成的代码 
		///   
		/// 设计器支持所需的方法 - 不要使用代码编辑器  
		/// 修改此方法的内容。 
		///  
		private void InitializeComponent() 
		{ 
			this.label1 = new System.Windows.Forms.Label(); 
			this.label2 = new System.Windows.Forms.Label(); 
			this.label3 = new System.Windows.Forms.Label(); 
			this.label4 = new System.Windows.Forms.Label(); 
			this.label5 = new System.Windows.Forms.Label(); 
			this.label6 = new System.Windows.Forms.Label(); 
			this.panel1 = new System.Windows.Forms.Panel(); 
			this.ccb_Finished = new System.Windows.Forms.CheckBox(); 
			this.dtp_FinishDate = new System.Windows.Forms.DateTimePicker(); 
			this.dtp_PlanDate = new System.Windows.Forms.DateTimePicker(); 
			this.label7 = new System.Windows.Forms.Label(); 
			this.txt_Item = new System.Windows.Forms.TextBox(); 
			this.txt_Desc = new System.Windows.Forms.TextBox(); 
			this.txt_Remarks = new System.Windows.Forms.TextBox(); 
			this.dtp_DateBegin = new System.Windows.Forms.DateTimePicker(); 
			this.dtp_DateEnd = new System.Windows.Forms.DateTimePicker(); 
			this.btn_Add = new System.Windows.Forms.Button(); 
			this.cbb_Level = new System.Windows.Forms.ComboBox(); 
			this.label8 = new System.Windows.Forms.Label(); 
			this.btn_Cancel = new System.Windows.Forms.Button(); 
			this.panel1.SuspendLayout(); 
			this.SuspendLayout(); 
			//  
			// label1 
			//  
			this.label1.Location = new System.Drawing.Point(72, 72); 
			this.label1.Name = "label1"; 
			this.label1.Size = new System.Drawing.Size(80, 16); 
			this.label1.TabIndex = 0; 
			this.label1.Text = "名称:"; 
			//  
			// label2 
			//  
			this.label2.Location = new System.Drawing.Point(72, 168); 
			this.label2.Name = "label2"; 
			this.label2.Size = new System.Drawing.Size(80, 16); 
			this.label2.TabIndex = 4; 
			this.label2.Text = "描述:"; 
			//  
			// label3 
			//  
			this.label3.Location = new System.Drawing.Point(72, 104); 
			this.label3.Name = "label3"; 
			this.label3.Size = new System.Drawing.Size(80, 16); 
			this.label3.TabIndex = 1; 
			this.label3.Text = "开始日期:"; 
			//  
			// label4 
			//  
			this.label4.Location = new System.Drawing.Point(72, 296); 
			this.label4.Name = "label4"; 
			this.label4.Size = new System.Drawing.Size(80, 16); 
			this.label4.TabIndex = 5; 
			this.label4.Text = "备注:"; 
			//  
			// label5 
			//  
			this.label5.Location = new System.Drawing.Point(72, 136); 
			this.label5.Name = "label5"; 
			this.label5.Size = new System.Drawing.Size(80, 16); 
			this.label5.TabIndex = 3; 
			this.label5.Text = "优先级:"; 
			//  
			// label6 
			//  
			this.label6.Location = new System.Drawing.Point(8, 16); 
			this.label6.Name = "label6"; 
			this.label6.Size = new System.Drawing.Size(80, 16); 
			this.label6.TabIndex = 6; 
			this.label6.Text = "计划日期:"; 
			//  
			// panel1 
			//  
			this.panel1.Controls.Add(this.ccb_Finished); 
			this.panel1.Controls.Add(this.dtp_FinishDate); 
			this.panel1.Controls.Add(this.dtp_PlanDate); 
			this.panel1.Controls.Add(this.label7); 
			this.panel1.Controls.Add(this.label6); 
			this.panel1.Location = new System.Drawing.Point(64, 368); 
			this.panel1.Name = "panel1"; 
			this.panel1.Size = new System.Drawing.Size(536, 72); 
			this.panel1.TabIndex = 6; 
			this.panel1.Visible = false; 
			//  
			// ccb_Finished 
			//  
			this.ccb_Finished.Location = new System.Drawing.Point(16, 48); 
			this.ccb_Finished.Name = "ccb_Finished"; 
			this.ccb_Finished.TabIndex = 16; 
			this.ccb_Finished.Text = "是否已完成"; 
			//  
			// dtp_FinishDate 
			//  
			this.dtp_FinishDate.CustomFormat = "yyyy-MM-dd"; 
			this.dtp_FinishDate.Location = new System.Drawing.Point(376, 16); 
			this.dtp_FinishDate.Name = "dtp_FinishDate"; 
			this.dtp_FinishDate.Size = new System.Drawing.Size(120, 21); 
			this.dtp_FinishDate.TabIndex = 15; 
			//  
			// dtp_PlanDate 
			//  
			this.dtp_PlanDate.CustomFormat = "yyyy-MM-dd"; 
			this.dtp_PlanDate.Location = new System.Drawing.Point(88, 16); 
			this.dtp_PlanDate.Name = "dtp_PlanDate"; 
			this.dtp_PlanDate.Size = new System.Drawing.Size(120, 21); 
			this.dtp_PlanDate.TabIndex = 14; 
			//  
			// label7 
			//  
			this.label7.Location = new System.Drawing.Point(296, 16); 
			this.label7.Name = "label7"; 
			this.label7.Size = new System.Drawing.Size(80, 16); 
			this.label7.TabIndex = 7; 
			this.label7.Text = "完成日期:"; 
			//  
			// txt_Item 
			//  
			this.txt_Item.Location = new System.Drawing.Point(152, 72); 
			this.txt_Item.Name = "txt_Item"; 
			this.txt_Item.Size = new System.Drawing.Size(432, 21); 
			this.txt_Item.TabIndex = 8; 
			this.txt_Item.Text = ""; 
			//  
			// txt_Desc 
			//  
			this.txt_Desc.Location = new System.Drawing.Point(152, 168); 
			this.txt_Desc.Multiline = true; 
			this.txt_Desc.Name = "txt_Desc"; 
			this.txt_Desc.Size = new System.Drawing.Size(432, 112); 
			this.txt_Desc.TabIndex = 12; 
			this.txt_Desc.Text = ""; 
			//  
			// txt_Remarks 
			//  
			this.txt_Remarks.Location = new System.Drawing.Point(152, 296); 
			this.txt_Remarks.Multiline = true; 
			this.txt_Remarks.Name = "txt_Remarks"; 
			this.txt_Remarks.Size = new System.Drawing.Size(432, 56); 
			this.txt_Remarks.TabIndex = 13; 
			this.txt_Remarks.Text = ""; 
			//  
			// dtp_DateBegin 
			//  
			this.dtp_DateBegin.Location = new System.Drawing.Point(152, 104); 
			this.dtp_DateBegin.Name = "dtp_DateBegin"; 
			this.dtp_DateBegin.Size = new System.Drawing.Size(120, 21); 
			this.dtp_DateBegin.TabIndex = 9; 
			//  
			// dtp_DateEnd 
			//  
			this.dtp_DateEnd.CustomFormat = "yyyy-MM-dd"; 
			this.dtp_DateEnd.Location = new System.Drawing.Point(440, 104); 
			this.dtp_DateEnd.Name = "dtp_DateEnd"; 
			this.dtp_DateEnd.Size = new System.Drawing.Size(120, 21); 
			this.dtp_DateEnd.TabIndex = 10; 
			//  
			// btn_Add 
			//  
			this.btn_Add.Location = new System.Drawing.Point(416, 440); 
			this.btn_Add.Name = "btn_Add"; 
			this.btn_Add.TabIndex = 17; 
			this.btn_Add.Text = "添加"; 
			this.btn_Add.Click += new System.EventHandler(this.btn_Add_Click); 
			//  
			// cbb_Level 
			//  
			this.cbb_Level.Items.AddRange(new object[] { 
														   "重要紧急", 
														   "重要不紧急", 
														   "不重要紧急", 
														   "不重要不紧急"}); 
			this.cbb_Level.Location = new System.Drawing.Point(152, 136); 
			this.cbb_Level.Name = "cbb_Level"; 
			this.cbb_Level.Size = new System.Drawing.Size(112, 20); 
			this.cbb_Level.TabIndex = 11; 
			this.cbb_Level.Text = "重要紧急"; 
			//  
			// label8 
			//  
			this.label8.Location = new System.Drawing.Point(360, 104); 
			this.label8.Name = "label8"; 
			this.label8.Size = new System.Drawing.Size(80, 16); 
			this.label8.TabIndex = 2; 
			this.label8.Text = "截止日期:"; 
			//  
			// btn_Cancel 
			//  
			this.btn_Cancel.Location = new System.Drawing.Point(512, 440); 
			this.btn_Cancel.Name = "btn_Cancel"; 
			this.btn_Cancel.TabIndex = 18; 
			this.btn_Cancel.Text = "取消"; 
			this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click); 
			//  
			// UC_AddPlan 
			//  
			this.Controls.Add(this.btn_Cancel); 
			this.Controls.Add(this.label8); 
			this.Controls.Add(this.cbb_Level); 
			this.Controls.Add(this.btn_Add); 
			this.Controls.Add(this.dtp_DateEnd); 
			this.Controls.Add(this.dtp_DateBegin); 
			this.Controls.Add(this.txt_Remarks); 
			this.Controls.Add(this.txt_Desc); 
			this.Controls.Add(this.txt_Item); 
			this.Controls.Add(this.panel1); 
			this.Controls.Add(this.label5); 
			this.Controls.Add(this.label4); 
			this.Controls.Add(this.label3); 
			this.Controls.Add(this.label2); 
			this.Controls.Add(this.label1); 
			this.Name = "UC_AddPlan"; 
			this.Size = new System.Drawing.Size(672, 512); 
			this.panel1.ResumeLayout(false); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		private void btn_Add_Click(object sender, System.EventArgs e) 
		{ 
			if(txt_Item.Text == "") 
			{ 
				Global.Message("计划名称不能为空!"); 
				return; 
			} 
			else 
			{ 
				foreach(PlanInfo p in Global.PLAN_LIST.Plan_List) 
				{ 
					if(p.Item == txt_Item.Text) 
					{ 
						Global.Message("该计划名称与已有的计划重复!"); 
						return; 
					} 
				} 
			} 
 
			PlanInfo info = new PlanInfo(); 
			info.Item = txt_Item.Text; 
			info.Desc = txt_Desc.Text; 
			info.DateBegin = dtp_DateBegin.Value; 
			info.DateEnd = dtp_DateEnd.Value; 
			info.PlanDate = DateTime.Today; 
			info.FinishDate = Global.DATE_NULL; 
			info.Remarks = txt_Remarks.Text; 
			info.Finished = false; 
			info.Level = Global.ToLevel(cbb_Level.Text); 
 
			Global.PLAN_LIST.Plan_List.Add(info); 
			Global.SaveConfig(); 
			//Global.configEnable = false; 
 
			this.Visible = false; 
			Parent_Form.ReturnParent(this); 
		} 
 
		private void btn_Cancel_Click(object sender, System.EventArgs e) 
		{ 
			this.Visible = false; 
			Parent_Form.ReturnParent(this); 
		} 
	} 
}