//===========================================================================
// Smarclient FPMS Demo Project a sample project for SmartClient technology.
// Smarclient FPMS Demo is designed and implemented bases Microsoft Application Block tech.
// Author: SFPMS Team, Date 2004-11
// Vision 1.0
// Revison History
//=============================================================================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using JSW.Tool;
using JSW.FPMS.Tool;
using JSW.FPMS.Xian.KongZhi;

namespace JSW.FPMS.Xian.ShiTu
{
	/// <summary>
	/// PeiZhiWeiHuForm 的摘要说明。
	/// </summary>
	public class PeiZhiWeiHuForm : System.Windows.Forms.Form
	{
		#region 私有变量区域
		private System.Windows.Forms.GroupBox GB_XinXi;
		private System.Windows.Forms.Label LB_ShuJuZu;
		private System.Windows.Forms.Label LB_ShuJuXiangMing;
		private System.Windows.Forms.TextBox TB_ShuJuXiangMing;
		private System.Windows.Forms.Label LB_ShuJuXiangBieMing;
		private System.Windows.Forms.TextBox TB_ShuJuXiangBieMing;
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label LB_KongJianLeiXing;
		private System.Windows.Forms.Label LB_ZuiDaShuRuChangDu;
		private System.Windows.Forms.TextBox TB_ZuiDaShuRuChangDu;
		private System.Windows.Forms.CheckBox CB_ZhiDu;
		private System.Windows.Forms.Label LB_XianShiShunXu;
		private System.Windows.Forms.TextBox TB_XianShiShunXu;
		private System.Windows.Forms.Label LB_MoRenZhi;
		private System.Windows.Forms.Button BT_QuXiao;
		private System.Windows.Forms.Button BT_QueDing;
		private System.Windows.Forms.Button BT_ShanChu;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private String jibenShuJuJian		=	clsChangLiang.SHUJU_PEIZHIXINXI; 
		private String tianjiaMoShi			=	"数据结构维护/添加数据项";
		private String xiugaiMoShi			=	"数据结构维护/修改数据项";
		private int    id					=	0;
		private String idZFC								=	"id";
		private String shujuzuKJMZFC						=	"ShuJuZuKJM";
		private String shujuzuKJLXZFC						=	"ShuJuZuKJLX";
		private String shujuxiangmingZFC					=	"ShuJuXiangMing";
		private String shujuxiangKJMZFC						=	"ShuJuXiangKJM";
		private String shujuxiangKJLXZFC					=	"ShuJuXiangKJLX";
		private String zuidashuruchangduZFC					=	"ZuiDaShuRuChangDu";
		private String zhiduZFC								=	"ZhiDu";
		private String morenzhiZFC							=	"MoRenZhi";
		private String xianshishunxuZFC						=	"XianShiShunXu";
		private String xitongshujuZFC						=	"XiTongShuJu";
		private System.Windows.Forms.TextBox TB_ShuJuZuLeiXing;
		private System.Windows.Forms.ComboBox CB_KongJianLeiXing;
		private System.Windows.Forms.TextBox TB_ShuJuZuMing;
		private System.Windows.Forms.TextBox TB_MoRenZhi;
		private clsXianKongZhi    kongZhi					=	null;
		#endregion

		#region 保护方法区域
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion

		#region 私有方法区域

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.GB_XinXi = new System.Windows.Forms.GroupBox();
			this.TB_ShuJuZuMing = new System.Windows.Forms.TextBox();
			this.TB_MoRenZhi = new System.Windows.Forms.TextBox();
			this.LB_MoRenZhi = new System.Windows.Forms.Label();
			this.TB_XianShiShunXu = new System.Windows.Forms.TextBox();
			this.LB_XianShiShunXu = new System.Windows.Forms.Label();
			this.CB_ZhiDu = new System.Windows.Forms.CheckBox();
			this.TB_ZuiDaShuRuChangDu = new System.Windows.Forms.TextBox();
			this.LB_ZuiDaShuRuChangDu = new System.Windows.Forms.Label();
			this.CB_KongJianLeiXing = new System.Windows.Forms.ComboBox();
			this.LB_KongJianLeiXing = new System.Windows.Forms.Label();
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.TB_ShuJuXiangBieMing = new System.Windows.Forms.TextBox();
			this.LB_ShuJuXiangBieMing = new System.Windows.Forms.Label();
			this.TB_ShuJuXiangMing = new System.Windows.Forms.TextBox();
			this.LB_ShuJuXiangMing = new System.Windows.Forms.Label();
			this.LB_ShuJuZu = new System.Windows.Forms.Label();
			this.BT_QuXiao = new System.Windows.Forms.Button();
			this.BT_QueDing = new System.Windows.Forms.Button();
			this.BT_ShanChu = new System.Windows.Forms.Button();
			this.TB_ShuJuZuLeiXing = new System.Windows.Forms.TextBox();
			this.GB_XinXi.SuspendLayout();
			this.SuspendLayout();
			// 
			// GB_XinXi
			// 
			this.GB_XinXi.Controls.Add(this.TB_ShuJuZuMing);
			this.GB_XinXi.Controls.Add(this.TB_MoRenZhi);
			this.GB_XinXi.Controls.Add(this.LB_MoRenZhi);
			this.GB_XinXi.Controls.Add(this.TB_XianShiShunXu);
			this.GB_XinXi.Controls.Add(this.LB_XianShiShunXu);
			this.GB_XinXi.Controls.Add(this.CB_ZhiDu);
			this.GB_XinXi.Controls.Add(this.TB_ZuiDaShuRuChangDu);
			this.GB_XinXi.Controls.Add(this.LB_ZuiDaShuRuChangDu);
			this.GB_XinXi.Controls.Add(this.CB_KongJianLeiXing);
			this.GB_XinXi.Controls.Add(this.LB_KongJianLeiXing);
			this.GB_XinXi.Controls.Add(this.groupBox1);
			this.GB_XinXi.Controls.Add(this.TB_ShuJuXiangBieMing);
			this.GB_XinXi.Controls.Add(this.LB_ShuJuXiangBieMing);
			this.GB_XinXi.Controls.Add(this.TB_ShuJuXiangMing);
			this.GB_XinXi.Controls.Add(this.LB_ShuJuXiangMing);
			this.GB_XinXi.Controls.Add(this.LB_ShuJuZu);
			this.GB_XinXi.Location = new System.Drawing.Point(8, 8);
			this.GB_XinXi.Name = "GB_XinXi";
			this.GB_XinXi.Size = new System.Drawing.Size(456, 184);
			this.GB_XinXi.TabIndex = 0;
			this.GB_XinXi.TabStop = false;
			// 
			// TB_ShuJuZuMing
			// 
			this.TB_ShuJuZuMing.Enabled = false;
			this.TB_ShuJuZuMing.Location = new System.Drawing.Point(72, 16);
			this.TB_ShuJuZuMing.MaxLength = 20;
			this.TB_ShuJuZuMing.Name = "TB_ShuJuZuMing";
			this.TB_ShuJuZuMing.Size = new System.Drawing.Size(136, 21);
			this.TB_ShuJuZuMing.TabIndex = 17;
			this.TB_ShuJuZuMing.Text = "";
			// 
			// TB_MoRenZhi
			// 
			this.TB_MoRenZhi.Location = new System.Drawing.Point(304, 120);
			this.TB_MoRenZhi.MaxLength = 20;
			this.TB_MoRenZhi.Name = "TB_MoRenZhi";
			this.TB_MoRenZhi.Size = new System.Drawing.Size(136, 21);
			this.TB_MoRenZhi.TabIndex = 16;
			this.TB_MoRenZhi.Text = "";
			// 
			// LB_MoRenZhi
			// 
			this.LB_MoRenZhi.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_MoRenZhi.Location = new System.Drawing.Point(216, 120);
			this.LB_MoRenZhi.Name = "LB_MoRenZhi";
			this.LB_MoRenZhi.Size = new System.Drawing.Size(88, 21);
			this.LB_MoRenZhi.TabIndex = 15;
			this.LB_MoRenZhi.Text = "默认值";
			this.LB_MoRenZhi.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// TB_XianShiShunXu
			// 
			this.TB_XianShiShunXu.Location = new System.Drawing.Point(72, 120);
			this.TB_XianShiShunXu.MaxLength = 20;
			this.TB_XianShiShunXu.Name = "TB_XianShiShunXu";
			this.TB_XianShiShunXu.Size = new System.Drawing.Size(136, 21);
			this.TB_XianShiShunXu.TabIndex = 14;
			this.TB_XianShiShunXu.Text = "";
			// 
			// LB_XianShiShunXu
			// 
			this.LB_XianShiShunXu.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_XianShiShunXu.Location = new System.Drawing.Point(8, 120);
			this.LB_XianShiShunXu.Name = "LB_XianShiShunXu";
			this.LB_XianShiShunXu.Size = new System.Drawing.Size(64, 21);
			this.LB_XianShiShunXu.TabIndex = 13;
			this.LB_XianShiShunXu.Text = "显示顺序";
			this.LB_XianShiShunXu.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// CB_ZhiDu
			// 
			this.CB_ZhiDu.Location = new System.Drawing.Point(16, 152);
			this.CB_ZhiDu.Name = "CB_ZhiDu";
			this.CB_ZhiDu.TabIndex = 12;
			this.CB_ZhiDu.Text = "是否只读";
			// 
			// TB_ZuiDaShuRuChangDu
			// 
			this.TB_ZuiDaShuRuChangDu.Location = new System.Drawing.Point(304, 88);
			this.TB_ZuiDaShuRuChangDu.MaxLength = 20;
			this.TB_ZuiDaShuRuChangDu.Name = "TB_ZuiDaShuRuChangDu";
			this.TB_ZuiDaShuRuChangDu.Size = new System.Drawing.Size(136, 21);
			this.TB_ZuiDaShuRuChangDu.TabIndex = 11;
			this.TB_ZuiDaShuRuChangDu.Text = "";
			// 
			// LB_ZuiDaShuRuChangDu
			// 
			this.LB_ZuiDaShuRuChangDu.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_ZuiDaShuRuChangDu.Location = new System.Drawing.Point(216, 88);
			this.LB_ZuiDaShuRuChangDu.Name = "LB_ZuiDaShuRuChangDu";
			this.LB_ZuiDaShuRuChangDu.Size = new System.Drawing.Size(88, 21);
			this.LB_ZuiDaShuRuChangDu.TabIndex = 10;
			this.LB_ZuiDaShuRuChangDu.Text = "最大输入长度";
			this.LB_ZuiDaShuRuChangDu.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// CB_KongJianLeiXing
			// 
			this.CB_KongJianLeiXing.ItemHeight = 12;
			this.CB_KongJianLeiXing.Items.AddRange(new object[] {
																	"字符数据类型",
																	"日期数据类型",
																	"浮点数据类型",
																	"整形数据类型"});
			this.CB_KongJianLeiXing.Location = new System.Drawing.Point(72, 88);
			this.CB_KongJianLeiXing.Name = "CB_KongJianLeiXing";
			this.CB_KongJianLeiXing.Size = new System.Drawing.Size(136, 20);
			this.CB_KongJianLeiXing.TabIndex = 9;
			this.CB_KongJianLeiXing.SelectedValueChanged += new System.EventHandler(this.CB_KongJianLeiXing_SelectedValueChanged);
			// 
			// LB_KongJianLeiXing
			// 
			this.LB_KongJianLeiXing.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_KongJianLeiXing.Location = new System.Drawing.Point(8, 88);
			this.LB_KongJianLeiXing.Name = "LB_KongJianLeiXing";
			this.LB_KongJianLeiXing.Size = new System.Drawing.Size(64, 21);
			this.LB_KongJianLeiXing.TabIndex = 8;
			this.LB_KongJianLeiXing.Text = "控件类型";
			this.LB_KongJianLeiXing.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// groupBox1
			// 
			this.groupBox1.Location = new System.Drawing.Point(8, 40);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(440, 8);
			this.groupBox1.TabIndex = 7;
			this.groupBox1.TabStop = false;
			// 
			// TB_ShuJuXiangBieMing
			// 
			this.TB_ShuJuXiangBieMing.Location = new System.Drawing.Point(304, 56);
			this.TB_ShuJuXiangBieMing.MaxLength = 20;
			this.TB_ShuJuXiangBieMing.Name = "TB_ShuJuXiangBieMing";
			this.TB_ShuJuXiangBieMing.Size = new System.Drawing.Size(136, 21);
			this.TB_ShuJuXiangBieMing.TabIndex = 6;
			this.TB_ShuJuXiangBieMing.Text = "";
			// 
			// LB_ShuJuXiangBieMing
			// 
			this.LB_ShuJuXiangBieMing.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_ShuJuXiangBieMing.Location = new System.Drawing.Point(216, 56);
			this.LB_ShuJuXiangBieMing.Name = "LB_ShuJuXiangBieMing";
			this.LB_ShuJuXiangBieMing.Size = new System.Drawing.Size(88, 21);
			this.LB_ShuJuXiangBieMing.TabIndex = 5;
			this.LB_ShuJuXiangBieMing.Text = "数据项别名";
			this.LB_ShuJuXiangBieMing.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// TB_ShuJuXiangMing
			// 
			this.TB_ShuJuXiangMing.Location = new System.Drawing.Point(72, 56);
			this.TB_ShuJuXiangMing.MaxLength = 20;
			this.TB_ShuJuXiangMing.Name = "TB_ShuJuXiangMing";
			this.TB_ShuJuXiangMing.Size = new System.Drawing.Size(136, 21);
			this.TB_ShuJuXiangMing.TabIndex = 4;
			this.TB_ShuJuXiangMing.Text = "";
			// 
			// LB_ShuJuXiangMing
			// 
			this.LB_ShuJuXiangMing.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_ShuJuXiangMing.Location = new System.Drawing.Point(8, 56);
			this.LB_ShuJuXiangMing.Name = "LB_ShuJuXiangMing";
			this.LB_ShuJuXiangMing.Size = new System.Drawing.Size(64, 21);
			this.LB_ShuJuXiangMing.TabIndex = 3;
			this.LB_ShuJuXiangMing.Text = "数据项名";
			this.LB_ShuJuXiangMing.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// LB_ShuJuZu
			// 
			this.LB_ShuJuZu.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.LB_ShuJuZu.Location = new System.Drawing.Point(8, 16);
			this.LB_ShuJuZu.Name = "LB_ShuJuZu";
			this.LB_ShuJuZu.Size = new System.Drawing.Size(64, 21);
			this.LB_ShuJuZu.TabIndex = 1;
			this.LB_ShuJuZu.Text = "数据组";
			this.LB_ShuJuZu.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// BT_QuXiao
			// 
			this.BT_QuXiao.Location = new System.Drawing.Point(376, 200);
			this.BT_QuXiao.Name = "BT_QuXiao";
			this.BT_QuXiao.TabIndex = 10;
			this.BT_QuXiao.Text = "取消";
			this.BT_QuXiao.Click += new System.EventHandler(this.BT_QuXiao_Click);
			// 
			// BT_QueDing
			// 
			this.BT_QueDing.Location = new System.Drawing.Point(216, 200);
			this.BT_QueDing.Name = "BT_QueDing";
			this.BT_QueDing.Size = new System.Drawing.Size(72, 23);
			this.BT_QueDing.TabIndex = 9;
			this.BT_QueDing.Text = "确定";
			this.BT_QueDing.Click += new System.EventHandler(this.BT_QueDing_Click);
			// 
			// BT_ShanChu
			// 
			this.BT_ShanChu.Location = new System.Drawing.Point(296, 200);
			this.BT_ShanChu.Name = "BT_ShanChu";
			this.BT_ShanChu.TabIndex = 8;
			this.BT_ShanChu.Text = "删除";
			this.BT_ShanChu.Click += new System.EventHandler(this.BT_ShanChu_Click);
			// 
			// TB_ShuJuZuLeiXing
			// 
			this.TB_ShuJuZuLeiXing.Location = new System.Drawing.Point(72, 88);
			this.TB_ShuJuZuLeiXing.MaxLength = 20;
			this.TB_ShuJuZuLeiXing.Name = "TB_ShuJuZuLeiXing";
			this.TB_ShuJuZuLeiXing.Size = new System.Drawing.Size(136, 21);
			this.TB_ShuJuZuLeiXing.TabIndex = 17;
			this.TB_ShuJuZuLeiXing.Text = "";
			// 
			// PeiZhiWeiHuForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(472, 229);
			this.Controls.Add(this.BT_QuXiao);
			this.Controls.Add(this.BT_QueDing);
			this.Controls.Add(this.BT_ShanChu);
			this.Controls.Add(this.GB_XinXi);
			this.Location = new System.Drawing.Point(450, 400);
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(480, 256);
			this.MinimumSize = new System.Drawing.Size(480, 256);
			this.Name = "PeiZhiWeiHuForm";
			this.GB_XinXi.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 获得相应的数据
		/// </summary>
		/// <param name="ShuJuJian">数据种类键值</param>
		/// <returns>数据</returns>
		private String HuoDeShuJu(Hashtable ShuJu,string ShuJuJian) 
		{
			//是否有该键值
			if(!ShuJu.ContainsKey(ShuJuJian)) 
			{
				return null;
			}
			//获得相应的值
			IDictionaryEnumerator jiHe = ShuJu.GetEnumerator();			
			while ( jiHe.MoveNext() )
			{
				if(jiHe.Key.Equals(ShuJuJian) )
				{
					break;					
				}
			}	
			//返回数据
			return (jiHe.Value.ToString() ); 

		}	

		/// <summary>
		/// 数据合法性检测
		/// </summary>
		private bool ShuJuJianCe() 
		{	
			try 
			{
				if(this.TB_ShuJuXiangMing.Text.Length == 0 ) 
				{
					throw new Exception("数据项名称不能为空");
				}
				if(this.TB_ShuJuXiangBieMing.Text.Length == 0 ) 
				{	
					throw new Exception("数据项别名不能为空");
				}
				else //数值检测
				{
					//检查是否合法的数据项别名
					string diyiwei = TB_ShuJuXiangBieMing.Text.Trim().Substring(0,1);
					bool shifouHeFa = false;
					try 
					{

						double ceshi = Convert.ToDouble(diyiwei);												
					}
					catch(Exception e) 
					{
						//合法的数据，不是数值
						e = null;
						shifouHeFa = true;
					}
					//不是合法数据
					if(!shifouHeFa) 
					{
						throw new Exception("数据项别名必须以字符开头");
					}

					


				}
				if(this.CB_KongJianLeiXing.Text.Length == 0) 
				{
					throw new Exception("数据项控件类型不能为空");
					
				}
				//最大输入长度数据验证
				if(this.TB_ZuiDaShuRuChangDu.Text.Length==0) 
				{
					throw new Exception("最大输入长度不能为空");
				}
				else 
				{
					try 
					{
						int lingshi = Convert.ToInt16(this.TB_ZuiDaShuRuChangDu.Text); 
					}
					catch(Exception e) 
					{
						throw new Exception("最大输入长度必须为整形数据");
					}
				}
				// 显示顺序数据验证
				if(this.TB_XianShiShunXu.Text.Length==0) 
				{
					throw new Exception("显示顺序不能为空");
				}
				else 
				{
					try 
					{
						int lingshi = Convert.ToInt16(this.TB_XianShiShunXu.Text); 
					}
					catch(Exception e) 
					{
						throw new Exception("显示顺序必须为整形数据");
					}
				}
				//默认值检验
				String leixingZhi	= CB_KongJianLeiXing.Text;
				String morenZhi		= this.TB_MoRenZhi.Text.Trim();

				if(leixingZhi.Length > 0 ) 
				{
					try 
					{
						
						if(morenZhi.Length<=0) 
						{
							return true;
						}
						//如果是日期的默认值检测
						if(leixingZhi.Equals(clsChangLiang.SHUJU_LEIXING_RIQI)) 
						{
							try 
							{
								Convert.ToDateTime(	morenZhi);
							}
							catch(Exception e) //日期数据错误
							{
								throw new Exception("默认值日期数据错误");
							}
						}
						if(leixingZhi.Equals(clsChangLiang.SHUJU_LEIXING_FUDIAN))
						{
							try 
							{
								Convert.ToSingle(morenZhi);
							}
							catch(Exception e) //浮点数据错误
							{
								throw new Exception("默认值浮点错误");
							}
						}
					}
					catch(Exception e) 
					{
						throw e;
					}
				}			
			}
			catch(Exception e) 
			{

				MessageBox.Show(this,e.Message,"数据合法性检测");

				return false;
			}

			return true;
		}

		/// <summary>
		/// 
		/// </summary>		
		private void ChuShiHua(clsXianKongZhi KongZhi,Hashtable ShuJu,bool DiaoKan) 
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();	
			kongZhi = KongZhi;
			//更新数据模式														
			this.Text = xiugaiMoShi;
			this.id =	Convert.ToInt16(this.HuoDeShuJu(ShuJu,this.idZFC));
			this.TB_ShuJuXiangMing.Text			= this.HuoDeShuJu(ShuJu,this.shujuxiangmingZFC);
			this.TB_ShuJuXiangBieMing.Text		= this.HuoDeShuJu(ShuJu,this.shujuxiangKJMZFC); 			
			this.TB_ZuiDaShuRuChangDu.Text		= this.HuoDeShuJu(ShuJu,this.zuidashuruchangduZFC);
			this.TB_XianShiShunXu.Text			= this.HuoDeShuJu(ShuJu,this.xianshishunxuZFC);
			this.TB_MoRenZhi.Text				= this.HuoDeShuJu(ShuJu,this.morenzhiZFC);
			this.CB_KongJianLeiXing.Text		= this.HuoDeShuJu(ShuJu,this.shujuxiangKJLXZFC);
			string shujuZu						=  this.HuoDeShuJu(ShuJu,this.shujuzuKJMZFC);
			if(shujuZu.Equals("XinXiZu"))
			{
				this.TB_ShuJuZuMing.Text		= "信息组";
			}
			else 
			{
				this.TB_ShuJuZuMing.Text		= "反馈组";
			}
			this.CB_KongJianLeiXing.Text		=  this.HuoDeShuJu(ShuJu,this.shujuzuKJLXZFC);
			string zhiDu						=  this.HuoDeShuJu(ShuJu,this.zhiduZFC);
			if(zhiDu.Equals("Y")) 
			{
				this.CB_ZhiDu.Checked=true;
			}
			else 
			{
				this.CB_ZhiDu.Checked=false;
			}
			string xitongShuJu = this.HuoDeShuJu(ShuJu,this.xitongshujuZFC);
			if(xitongShuJu.Equals("Y"))
			{				
				this.CB_KongJianLeiXing.Enabled=false;
				this.TB_ShuJuXiangMing.Enabled=false;
				this.TB_ShuJuXiangBieMing.Enabled=false;
				this.CB_ZhiDu.Enabled=false;
				this.BT_ShanChu.Enabled=false;
				this.BT_ShanChu.Enabled=false;
			}

			//调看界面
			if(DiaoKan) 
			{
				this.TB_ShuJuZuMing.Enabled=false;
				this.TB_ShuJuXiangMing.Enabled=false;
				this.TB_ShuJuXiangBieMing.Enabled=false;
				this.TB_ShuJuZuLeiXing.Enabled=false;
				this.TB_MoRenZhi.Enabled=false;
				this.TB_XianShiShunXu.Enabled=false;
				this.TB_ZuiDaShuRuChangDu.Enabled=false;
				this.CB_KongJianLeiXing.Enabled=false;
				this.CB_ZhiDu.Enabled=false;
				this.BT_ShanChu.Visible=false;
				this.BT_QueDing.Visible=false;
			}
		}

		#region 事件响应区域		
		/// <summary>
		/// 确定按钮单击响应事件
		/// </summary>
		private void BT_QueDing_Click(object sender, System.EventArgs e)
		{		
			//数据检测
			if(!ShuJuJianCe()) 
			{
				return ;
			}
			//数据维护操作
			try
			{				
				kongZhi.ShuJuWeiHu(jibenShuJuJian,clsChangLiang.SHUJU_XIUGAI,idZFC,GouZaoShuJu()); 
				this.Dispose(); 
			}
			catch(Exception genException) 
			{
				clsRiZhiChuLi.JiLuRiZhi(genException.Message);
				if(DialogResult.No == MessageBox.Show(this,
					"出现错误，你是否继续操作！参考日志，获得该错误的详细信息","提示信息",MessageBoxButtons.YesNo))
				{
					this.Close(); 
				}

			}
		
		}
		
		/// <summary>
		/// 删除按钮单击响应事件
		/// </summary>
		private void BT_ShanChu_Click(object sender, System.EventArgs e)
		{
			//提示
			if(this.id > 0 && DialogResult.Yes != MessageBox.Show(this,
				"确认删除本条数据?","提示信息",MessageBoxButtons.YesNo))
			{
				return;
			}
			//数据检测
			if(!ShuJuJianCe())
			{
				return ;
			}
			//数据维护操作
			try 
			{
				if(this.id <= 0 ) //添加数据模式
				{
					
					kongZhi.ShuJuWeiHu(jibenShuJuJian,clsChangLiang.SHUJU_TIANJIA,idZFC,true,GouZaoShuJu()); 
					
				} 
				else //删除数据模式
				{
					kongZhi.ShuJuWeiHu(jibenShuJuJian,clsChangLiang.SHUJU_SHANCHU,idZFC,GouZaoShuJu()); 
				}
				this.Close();
			}
			catch(Exception genException) 
			{
				clsRiZhiChuLi.JiLuRiZhi(genException.Message);
				if(DialogResult.Yes != MessageBox.Show(this,
					"出现错误，你是否继续操作！参考日志，获得该错误的详细信息","提示信息",MessageBoxButtons.YesNo))
				{
					this.Close(); 
				}

			}
			
		}
		/// <summary>
		/// 取消按钮单击响应事件
		/// </summary>
		private void BT_QuXiao_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		/// <summary>
		/// 构造数据HashTable
		/// </summary>
		/// <returns></returns>
		private Hashtable GouZaoShuJu() 
		{
			Hashtable HT = new Hashtable();
			HT.Add(this.idZFC,Convert.ToString(this.id));
			string shujuzuKJM = "XinXiZu";
			if(this.TB_ShuJuZuMing.Text.Equals("反馈组")) 
			{
				shujuzuKJM="FanKuiZu";
			}
			HT.Add(this.shujuzuKJMZFC,shujuzuKJM);
			HT.Add(this.shujuzuKJLXZFC,"GB"); 
			HT.Add(this.shujuxiangmingZFC,this.TB_ShuJuXiangMing.Text);
			HT.Add(this.shujuxiangKJMZFC,this.TB_ShuJuXiangBieMing.Text);
			HT.Add(this.shujuxiangKJLXZFC,this.CB_KongJianLeiXing.Text);
			HT.Add(this.zuidashuruchangduZFC,this.TB_ZuiDaShuRuChangDu.Text);			
			HT.Add(this.xianshishunxuZFC,this.TB_XianShiShunXu.Text); 
			HT.Add(this.morenzhiZFC,this.TB_MoRenZhi.Text);
			string zhiDu = "N";
			if(this.CB_ZhiDu.Checked)
			{
				zhiDu = "Y";
			}
			HT.Add(this.zhiduZFC,zhiDu);
			
			return HT;
		}
		/// <summary>
		/// 
		/// </summary>
		private void CB_KongJianLeiXing_SelectedValueChanged(object sender, System.EventArgs e)
		{
			String Zhi = this.CB_KongJianLeiXing.Text.Trim();
			if(Zhi.Length > 0 ) 
			{
				if(Zhi.Equals(clsChangLiang.SHUJU_LEIXING_RIQI)) 
				{
					this.TB_ZuiDaShuRuChangDu.Text="10";
					this.TB_ZuiDaShuRuChangDu.Enabled=false;
					return;
				}
				this.TB_ZuiDaShuRuChangDu.Enabled=true;
			}			
		}
		#endregion

		#endregion

		#region 公有方法区域
		/// <summary>
		/// 维护已经有的数据
		/// </summary>
		/// <param name="KongZhi">界面控制</param>
		/// <param name="ShuJu">数据</param>			
		public PeiZhiWeiHuForm(clsXianKongZhi KongZhi,Hashtable ShuJu) 
		{
			ChuShiHua(KongZhi,ShuJu,false);
		}

		
		/// <summary>
		/// 维护已有的数据
		/// </summary>
		/// <param name="KongZhi">界面控制</param>
		/// <param name="ShuJu">数据</param>	
		/// <param name="DiaoKan">是否是调看</param>
		public PeiZhiWeiHuForm(clsXianKongZhi KongZhi,Hashtable ShuJu,bool DiaoKan)
		{
			
			ChuShiHua(KongZhi,ShuJu,DiaoKan); 
		}
		
		/// <summary>
		/// 构造器，新的数据
		/// </summary>
		/// <param name="KongZhi"></param>
		public PeiZhiWeiHuForm(clsXianKongZhi KongZhi) 
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			kongZhi = KongZhi;
			//添加数据模式
			this.Text = tianjiaMoShi;
			this.BT_QueDing.Visible=false;
			this.BT_ShanChu.Text = "确定";
			this.TB_ShuJuZuMing.Text			= "信息组";

		}
		#endregion
		
		
	}
}
