//===========================================================================
// 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 System.Data;
using Microsoft.ApplicationBlocks.ApplicationUpdater;
using Microsoft.ApplicationBlocks.SmartClient.Offline;
using JSW.Tool; 
using JSW.FPMS.Tool;
using JSW.FPMS.Xiang.KongZhi;

namespace JSW.FPMS.Xiang.ShiTu
{
	/// <summary>
	/// clsXuQiuChaXunForm 应用程序主界面，响应用户UI操作
	/// MVC中的Viewer角色
	/// </summary>
	public class XuQiuChaXunForm : System.Windows.Forms.Form
	{
		#region 成员变量区域

		private System.Windows.Forms.Button BT_XuQiuLuRu;
		private System.Windows.Forms.GroupBox GB_JieGuo;
		private System.Windows.Forms.DataGrid DG_XuQiu;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem9;
		private System.Windows.Forms.MainMenu MM_CaiDan;
		private System.Windows.Forms.MenuItem MMI_GongNeng;
		private System.Windows.Forms.MenuItem MMI_XuQiuLuRu;
		private System.Windows.Forms.MenuItem MMI_TuiChu;
		private System.Windows.Forms.MenuItem MMI_BangZhuBT;
		private System.Windows.Forms.MenuItem MMI_BangZhu;
		private System.Windows.Forms.MenuItem MMI_GuanYu;
		private System.Windows.Forms.StatusBar SB_ZhuangTai;
		private System.ComponentModel.IContainer components;


		//界面控制器
		private clsXuQiuChaXunKongZhi jiemianKongZhi = null;
		private System.Windows.Forms.DataGridTableStyle DGTS_XiuQiu;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_CaiJiShiJian;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_TiChuRen;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_YuFuBianMa;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_XuQiuLeiBie;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_DaFuRen;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_DaFuShiJian;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_XinXiDianBianHao;
		private System.Windows.Forms.DataGridTextBoxColumn DGTSTB_XuQiuManYiDu;
		private System.Windows.Forms.Button BT_ShuanXin;
		private System.Windows.Forms.MenuItem MMI_ShuaXin;
		private System.Windows.Forms.Button BT_DiaoKan;
		private System.Windows.Forms.Timer TM_ShuJuGengXin;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem MMI_ShangXian;
		private System.Windows.Forms.MenuItem MMI_LiXian;
		private System.Windows.Forms.PictureBox pictureBox1;

		//
		private DataSet xuqiuChaXun = null;

		#endregion
		
		#region 私有方法区域
		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container();
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(XuQiuChaXunForm));
			this.BT_XuQiuLuRu = new System.Windows.Forms.Button();
			this.GB_JieGuo = new System.Windows.Forms.GroupBox();
			this.DG_XuQiu = new System.Windows.Forms.DataGrid();
			this.DGTS_XiuQiu = new System.Windows.Forms.DataGridTableStyle();
			this.DGTSTB_CaiJiShiJian = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_TiChuRen = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_YuFuBianMa = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_XuQiuLeiBie = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_DaFuRen = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_DaFuShiJian = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_XinXiDianBianHao = new System.Windows.Forms.DataGridTextBoxColumn();
			this.DGTSTB_XuQiuManYiDu = new System.Windows.Forms.DataGridTextBoxColumn();
			this.MM_CaiDan = new System.Windows.Forms.MainMenu();
			this.MMI_GongNeng = new System.Windows.Forms.MenuItem();
			this.MMI_ShuaXin = new System.Windows.Forms.MenuItem();
			this.MMI_XuQiuLuRu = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.MMI_TuiChu = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.MMI_ShangXian = new System.Windows.Forms.MenuItem();
			this.MMI_LiXian = new System.Windows.Forms.MenuItem();
			this.MMI_BangZhuBT = new System.Windows.Forms.MenuItem();
			this.MMI_BangZhu = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.MMI_GuanYu = new System.Windows.Forms.MenuItem();
			this.SB_ZhuangTai = new System.Windows.Forms.StatusBar();
			this.BT_ShuanXin = new System.Windows.Forms.Button();
			this.BT_DiaoKan = new System.Windows.Forms.Button();
			this.TM_ShuJuGengXin = new System.Windows.Forms.Timer(this.components);
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.GB_JieGuo.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.DG_XuQiu)).BeginInit();
			this.SuspendLayout();
			// 
			// BT_XuQiuLuRu
			// 
			this.BT_XuQiuLuRu.Location = new System.Drawing.Point(88, 16);
			this.BT_XuQiuLuRu.Name = "BT_XuQiuLuRu";
			this.BT_XuQiuLuRu.TabIndex = 10;
			this.BT_XuQiuLuRu.Text = "需求录入";
			this.BT_XuQiuLuRu.Click += new System.EventHandler(this.BT_XuQiuLuRu_Click);
			// 
			// GB_JieGuo
			// 
			this.GB_JieGuo.Controls.Add(this.DG_XuQiu);
			this.GB_JieGuo.Location = new System.Drawing.Point(8, 48);
			this.GB_JieGuo.Name = "GB_JieGuo";
			this.GB_JieGuo.Size = new System.Drawing.Size(592, 304);
			this.GB_JieGuo.TabIndex = 14;
			this.GB_JieGuo.TabStop = false;
			// 
			// DG_XuQiu
			// 
			this.DG_XuQiu.CaptionVisible = false;
			this.DG_XuQiu.DataMember = "";
			this.DG_XuQiu.Dock = System.Windows.Forms.DockStyle.Fill;
			this.DG_XuQiu.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.DG_XuQiu.Location = new System.Drawing.Point(3, 17);
			this.DG_XuQiu.Name = "DG_XuQiu";
			this.DG_XuQiu.Size = new System.Drawing.Size(586, 284);
			this.DG_XuQiu.TabIndex = 0;
			this.DG_XuQiu.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
																								 this.DGTS_XiuQiu});
			this.DG_XuQiu.DoubleClick += new System.EventHandler(this.DG_XuQiu_DoubleClick);
			// 
			// DGTS_XiuQiu
			// 
			this.DGTS_XiuQiu.DataGrid = this.DG_XuQiu;
			this.DGTS_XiuQiu.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
																										  this.DGTSTB_CaiJiShiJian,
																										  this.DGTSTB_TiChuRen,
																										  this.DGTSTB_YuFuBianMa,
																										  this.DGTSTB_XuQiuLeiBie,
																										  this.DGTSTB_DaFuRen,
																										  this.DGTSTB_DaFuShiJian,
																										  this.DGTSTB_XinXiDianBianHao,
																										  this.DGTSTB_XuQiuManYiDu});
			this.DGTS_XiuQiu.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.DGTS_XiuQiu.MappingName = "XuQiu";
			// 
			// DGTSTB_CaiJiShiJian
			// 
			this.DGTSTB_CaiJiShiJian.Format = "yyyy-MM-dd";
			this.DGTSTB_CaiJiShiJian.FormatInfo = null;
			this.DGTSTB_CaiJiShiJian.HeaderText = "采集时间";
			this.DGTSTB_CaiJiShiJian.MappingName = "CaiJiShiJian";
			this.DGTSTB_CaiJiShiJian.NullText = "";
			this.DGTSTB_CaiJiShiJian.Width = 75;
			// 
			// DGTSTB_TiChuRen
			// 
			this.DGTSTB_TiChuRen.Format = "";
			this.DGTSTB_TiChuRen.FormatInfo = null;
			this.DGTSTB_TiChuRen.HeaderText = "提出人";
			this.DGTSTB_TiChuRen.MappingName = "TiChuRen";
			this.DGTSTB_TiChuRen.NullText = "";
			this.DGTSTB_TiChuRen.Width = 75;
			// 
			// DGTSTB_YuFuBianMa
			// 
			this.DGTSTB_YuFuBianMa.Format = "";
			this.DGTSTB_YuFuBianMa.FormatInfo = null;
			this.DGTSTB_YuFuBianMa.HeaderText = "育妇编码";
			this.DGTSTB_YuFuBianMa.MappingName = "YuFuBianMa";
			this.DGTSTB_YuFuBianMa.NullText = "";
			this.DGTSTB_YuFuBianMa.Width = 75;
			// 
			// DGTSTB_XuQiuLeiBie
			// 
			this.DGTSTB_XuQiuLeiBie.Format = "";
			this.DGTSTB_XuQiuLeiBie.FormatInfo = null;
			this.DGTSTB_XuQiuLeiBie.HeaderText = "需求类别";
			this.DGTSTB_XuQiuLeiBie.MappingName = "XuQiuLeiBie";
			this.DGTSTB_XuQiuLeiBie.NullText = "";
			this.DGTSTB_XuQiuLeiBie.Width = 75;
			// 
			// DGTSTB_DaFuRen
			// 
			this.DGTSTB_DaFuRen.Format = "";
			this.DGTSTB_DaFuRen.FormatInfo = null;
			this.DGTSTB_DaFuRen.HeaderText = "答复人";
			this.DGTSTB_DaFuRen.MappingName = "DaFuRen";
			this.DGTSTB_DaFuRen.NullText = "";
			this.DGTSTB_DaFuRen.Width = 75;
			// 
			// DGTSTB_DaFuShiJian
			// 
			this.DGTSTB_DaFuShiJian.Format = "yyyy-MM-dd";
			this.DGTSTB_DaFuShiJian.FormatInfo = null;
			this.DGTSTB_DaFuShiJian.HeaderText = "答复时间";
			this.DGTSTB_DaFuShiJian.MappingName = "DaFuShiJian";
			this.DGTSTB_DaFuShiJian.NullText = "";
			this.DGTSTB_DaFuShiJian.Width = 75;
			// 
			// DGTSTB_XinXiDianBianHao
			// 
			this.DGTSTB_XinXiDianBianHao.Format = "";
			this.DGTSTB_XinXiDianBianHao.FormatInfo = null;
			this.DGTSTB_XinXiDianBianHao.HeaderText = "信息点编号";
			this.DGTSTB_XinXiDianBianHao.MappingName = "XinXiDianBianHao";
			this.DGTSTB_XinXiDianBianHao.NullText = "";
			this.DGTSTB_XinXiDianBianHao.Width = 75;
			// 
			// DGTSTB_XuQiuManYiDu
			// 
			this.DGTSTB_XuQiuManYiDu.Format = "";
			this.DGTSTB_XuQiuManYiDu.FormatInfo = null;
			this.DGTSTB_XuQiuManYiDu.HeaderText = "需求满意度";
			this.DGTSTB_XuQiuManYiDu.MappingName = "XuQiuManYiDu";
			this.DGTSTB_XuQiuManYiDu.NullText = "";
			this.DGTSTB_XuQiuManYiDu.Width = 75;
			// 
			// MM_CaiDan
			// 
			this.MM_CaiDan.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.MMI_GongNeng,
																					  this.menuItem1,
																					  this.MMI_BangZhuBT});
			// 
			// MMI_GongNeng
			// 
			this.MMI_GongNeng.Index = 0;
			this.MMI_GongNeng.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.MMI_ShuaXin,
																						 this.MMI_XuQiuLuRu,
																						 this.menuItem8,
																						 this.MMI_TuiChu});
			this.MMI_GongNeng.Text = "文件(&F)";
			// 
			// MMI_ShuaXin
			// 
			this.MMI_ShuaXin.Index = 0;
			this.MMI_ShuaXin.Text = "刷新";
			this.MMI_ShuaXin.Click += new System.EventHandler(this.MMI_ShuaXin_Click);
			// 
			// MMI_XuQiuLuRu
			// 
			this.MMI_XuQiuLuRu.Index = 1;
			this.MMI_XuQiuLuRu.Text = "需求录入";
			this.MMI_XuQiuLuRu.Click += new System.EventHandler(this.MMI_XuQiuLuRu_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 2;
			this.menuItem8.Text = "-";
			// 
			// MMI_TuiChu
			// 
			this.MMI_TuiChu.Index = 3;
			this.MMI_TuiChu.Text = "退出";
			this.MMI_TuiChu.Click += new System.EventHandler(this.MMI_TuiChu_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 1;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.MMI_ShangXian,
																					  this.MMI_LiXian});
			this.menuItem1.Text = "操作(&O)";
			// 
			// MMI_ShangXian
			// 
			this.MMI_ShangXian.Index = 0;
			this.MMI_ShangXian.Text = "上线";
			this.MMI_ShangXian.Click += new System.EventHandler(this.MMI_ShangXian_Click);
			// 
			// MMI_LiXian
			// 
			this.MMI_LiXian.Index = 1;
			this.MMI_LiXian.Text = "离线";
			this.MMI_LiXian.Click += new System.EventHandler(this.MMI_LiXian_Click);
			// 
			// MMI_BangZhuBT
			// 
			this.MMI_BangZhuBT.Index = 2;
			this.MMI_BangZhuBT.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						  this.MMI_BangZhu,
																						  this.menuItem9,
																						  this.MMI_GuanYu});
			this.MMI_BangZhuBT.Text = "帮助(&H)";
			// 
			// MMI_BangZhu
			// 
			this.MMI_BangZhu.Index = 0;
			this.MMI_BangZhu.Text = "帮助";
			this.MMI_BangZhu.Click += new System.EventHandler(this.MMI_BangZhu_Click);
			// 
			// menuItem9
			// 
			this.menuItem9.Index = 1;
			this.menuItem9.Text = "-";
			// 
			// MMI_GuanYu
			// 
			this.MMI_GuanYu.Index = 2;
			this.MMI_GuanYu.Text = "关于";
			this.MMI_GuanYu.Click += new System.EventHandler(this.MMI_GuanYu_Click);
			// 
			// SB_ZhuangTai
			// 
			this.SB_ZhuangTai.Location = new System.Drawing.Point(0, 361);
			this.SB_ZhuangTai.Name = "SB_ZhuangTai";
			this.SB_ZhuangTai.Size = new System.Drawing.Size(608, 16);
			this.SB_ZhuangTai.TabIndex = 15;
			this.SB_ZhuangTai.Text = "应用程序启动";
			// 
			// BT_ShuanXin
			// 
			this.BT_ShuanXin.Location = new System.Drawing.Point(8, 16);
			this.BT_ShuanXin.Name = "BT_ShuanXin";
			this.BT_ShuanXin.TabIndex = 16;
			this.BT_ShuanXin.Text = "刷新";
			this.BT_ShuanXin.Click += new System.EventHandler(this.BT_ShuanXin_Click);
			// 
			// BT_DiaoKan
			// 
			this.BT_DiaoKan.Location = new System.Drawing.Point(168, 16);
			this.BT_DiaoKan.Name = "BT_DiaoKan";
			this.BT_DiaoKan.TabIndex = 17;
			this.BT_DiaoKan.Text = "调看";
			this.BT_DiaoKan.Click += new System.EventHandler(this.BT_DiaoKan_Click);
			// 
			// TM_ShuJuGengXin
			// 
			this.TM_ShuJuGengXin.Enabled = true;
			this.TM_ShuJuGengXin.Interval = 15000;
			this.TM_ShuJuGengXin.Tick += new System.EventHandler(this.TM_ShuJuGengXin_Tick);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(352, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(248, 48);
			this.pictureBox1.TabIndex = 18;
			this.pictureBox1.TabStop = false;
			// 
			// XuQiuChaXunForm
			// 
			this.AutoScale = false;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.ClientSize = new System.Drawing.Size(608, 377);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.BT_DiaoKan);
			this.Controls.Add(this.BT_ShuanXin);
			this.Controls.Add(this.SB_ZhuangTai);
			this.Controls.Add(this.GB_JieGuo);
			this.Controls.Add(this.BT_XuQiuLuRu);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(616, 424);
			this.Menu = this.MM_CaiDan;
			this.MinimumSize = new System.Drawing.Size(616, 424);
			this.Name = "XuQiuChaXunForm";
			this.Text = "人口和计划生育管理信息系统 (FPMS) ：乡级系统";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.XuQiuChaXunForm_Closing);
			this.Closed += new System.EventHandler(this.XuQiuChaXunForm_Closed);
			this.GB_JieGuo.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.DG_XuQiu)).EndInit();
			this.ResumeLayout(false);

		}

		/// <summary>
		/// 销毁控制器
		/// </summary>
		private void XiaoHui() 
		{
			//销毁控制器
			if(	jiemianKongZhi != null) 
			{
				try 
				{
					jiemianKongZhi.XiaoHui(); 
					
				}
				catch(Exception e) 
				{
					clsRiZhiChuLi.JiLuRiZhi(e.Message);  
				}
				finally
				{
					this.jiemianKongZhi = null;
				}
			}
		}

		
		#region 事件响应区域
		/// <summary>
		/// 上线菜单条单击事件响应
		/// </summary>
		private void MMI_ShangXian_Click(object sender, System.EventArgs e)
		{
			this.jiemianKongZhi.QiangZhiShangXian(); 
		}
		/// <summary>
		/// 离线菜单条单击事件响应
		/// </summary>
		private void MMI_LiXian_Click(object sender, System.EventArgs e)
		{
			this.jiemianKongZhi.QiangZhiLiXian();
		}

		/// <summary>
		/// 窗体关闭
		/// </summary>		
		private void XuQiuChaXunForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			if(DialogResult.Yes != MessageBox.Show(this,
				"您确认退出系统?","提示信息",MessageBoxButtons.YesNo))
				e.Cancel=true;				
		}

		/// <summary>
		/// 刷新按钮单击响应事件
		/// </summary>
		private void BT_ShuanXin_Click(object sender, System.EventArgs e)
		{
			this.jiemianKongZhi.ShuJuChaXun(); 
		}		
		/// <summary>
		/// 刷新菜单项目单击响应事件
		/// </summary>
		private void MMI_ShuaXin_Click(object sender, System.EventArgs e)
		{
			this.jiemianKongZhi.ShuJuChaXun(); 
		}
		/// <summary>
		/// 需求录入按钮单击响应事件
		/// </summary>
		private void BT_XuQiuLuRu_Click(object sender, System.EventArgs e)
		{
			if(!this.jiemianKongZhi.ShiFouXuYaoXiaZai()) 
			{ 
				(new XuQiuLuRuForm (jiemianKongZhi,0,null)).ShowDialog() ;
			}
			else 
			{
				MessageBox.Show(this,"请单击刷新按钮下载基本数据！","提示信息");
			}
		}
		/// <summary>
		/// 需求录入菜单项目单击响应事件
		/// </summary>
		private void MMI_XuQiuLuRu_Click(object sender, System.EventArgs e)
		{
			BT_XuQiuLuRu_Click(sender,e);		
		}

		/// <summary>
		/// 退出按钮单击响应事件
		/// </summary>
		private void MMI_TuiChu_Click(object sender, System.EventArgs e)
		{			
				this.Close();			
		}
		/// <summary>
		/// 调看按钮单击响应事件
		/// </summary>
		private void BT_DiaoKan_Click(object sender, System.EventArgs e)
		{
			//服务器端传回的查询结果
			int hang = this.DG_XuQiu.CurrentRowIndex;
			XuQiuLuRuForm xinChuanTi = null;
			if(hang >= 0 ) 
			{
				DataSet ds = jiemianKongZhi.HuoDeShuJu(clsChangLiang.SHUJU_XUQIU,hang);
				xinChuanTi = new XuQiuLuRuForm(this.jiemianKongZhi,2,ds);
				xinChuanTi.Show() ;
			}
		}
		/// <summary>
		/// 双击事件
		/// </summary>		
		private void DG_XuQiu_DoubleClick(object sender, System.EventArgs e)
		{
			//服务器端传回的查询结果
			int hang = this.DG_XuQiu.CurrentRowIndex;
			XuQiuLuRuForm xinChuanTi = null;
			if(hang >= 0 ) 
			{
				DataSet ds = jiemianKongZhi.HuoDeShuJu(clsChangLiang.SHUJU_XUQIU,hang);
				xinChuanTi = new XuQiuLuRuForm(this.jiemianKongZhi,2,ds);
				xinChuanTi.Show() ;
			}
		}
		/// <summary>
		/// 打开帮助窗体
		/// </summary>
		private void MMI_BangZhu_Click(object sender, System.EventArgs e)
		{
			BangZhuForm xinChuangTi = new BangZhuForm();
			xinChuangTi.ShowDialog();
		}
		/// <summary>
		/// 打开关于窗体
		/// </summary>
		private void MMI_GuanYu_Click(object sender, System.EventArgs e)
		{
			GuanYuForm xinChuangTi = new GuanYuForm();
			xinChuangTi.ShowDialog();
		}		

		/// <summary>
		/// 时钟时间处理，根据时钟的Interval定时执行
		/// </summary>
		private void TM_ShuJuGengXin_Tick(object sender, System.EventArgs e)
		{
			//clsRiZhiChuLi.JiLuRiZhi(DateTime.Now.ToString());
			this.jiemianKongZhi.DingShiShuJuChaXun();
		}
		/// <summary>
		/// 主视图关闭
		/// </summary>
		private void XuQiuChaXunForm_Closed(object sender, System.EventArgs e)
		{
			this.XiaoHui(); 
		}

		/// <summary>
		/// 当前应用程序退出
		/// </summary>
		private void CurrentDomain_ProcessExit(object sender, EventArgs e)
		{
			
			this.XiaoHui(); 
		}


		#endregion

		#endregion

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

		#region 公共方法区域
		public XuQiuChaXunForm()
		{			
			//初始化界面元素
			InitializeComponent();
			//注册AppDomain退出事件响应
			AppDomain.CurrentDomain.ProcessExit +=new EventHandler(CurrentDomain_ProcessExit);
			//初始化控制器			
			try 
			{
				jiemianKongZhi =  new clsXuQiuChaXunKongZhi(this);
				jiemianKongZhi.YunXin(); 
			}
			catch(Exception e) 
			{
				clsRiZhiChuLi.JiLuRiZhi(e.Message) ;
				jiemianKongZhi = null;
			}
			
		}
		/// <summary>
		/// 是否构造成功
		/// </summary>
		/// <returns>true构造成功，false构造失败</returns>

		public bool GouZaoChengGong() 
		{
			return jiemianKongZhi == null? false:true;
		}
		
		// <summary>
		/// 连接状态变化
		/// </summary>
		/// <param name="shifouLianJie">是否连接</param>
		public void LianJieZhuangTai(bool shifouLianJie) 
		{			
			//设置界面显示
			if(shifouLianJie) 
			{
				ShiZhiZhuangTai("网络已经接通！"); 
				this.MMI_LiXian.Enabled=true;
				this.MMI_ShangXian.Enabled=false;
			}
			else 
			{
				ShiZhiZhuangTai("网络已经断开！"); 
				this.MMI_LiXian.Enabled=false;
				this.MMI_ShangXian.Enabled=true;
			}
			
		}

		/// <summary>
		/// 设置状态条显示
		/// </summary>
		/// <param name="Zhi">显示值</param>
		public void ShiZhiZhuangTai(String Zhi) 
		{
			SB_ZhuangTai.Text = Zhi; 
		}

		/// <summary>
		/// 更新需求查询网格
		/// </summary>
		/// <param name="ShuJu"></param>
		public void GengXinXuQiu(DataSet ShuJu) 
		{
			xuqiuChaXun = ShuJu;
			MethodInvoker	fangfa  = new MethodInvoker(this.ShuaXinWangGe);
			this.BeginInvoke(fangfa);
		}
		
		/// <summary>
		/// 刷新网格
		/// </summary>
		public void ShuaXinWangGe() 
		{
			DataSet xinShuJu = null;
			System.Data.DataView xinShuJuShiTu= null;
			
			if(xuqiuChaXun.Tables.Count > 0) 
			{  
				xinShuJu = xuqiuChaXun;
				xinShuJuShiTu = xuqiuChaXun.Tables[0].DefaultView; 
			}
			this.DG_XuQiu.DataSource = xinShuJuShiTu;
			//this.DG_XuQiu.Refresh(); 
		}

		/// <summary>
		/// 设置数据源
		/// </summary>
		/// <param name="ShuJu"></param>
		public void  SheZhiShuJuYuan(DataSet ShuJu) 
		{			
			if(ShuJu !=null && ShuJu.Tables.Count != 0 ) 
			{
				this.DG_XuQiu.DataSource = ShuJu;			
				this.DG_XuQiu.DataMember =ShuJu.Tables[0].TableName;
			}
		}

		/// <summary>
		/// 开始下载
		/// </summary>
		public void XiaZaiKaiShi(object sender, UpdaterActionEventArgs e) 
		{		
			this.SB_ZhuangTai.Text = "应用程序开始下载......";  
		}

		/// <summary>
		/// 下载结束
		/// </summary>
		public void XiaZaiJieShu(object sender, UpdaterActionEventArgs e) 
		{		
			this.SB_ZhuangTai.Text = "应用程序下载结束......";
		}

		/// <summary>
		/// 是否开始运行新的版本程序
		/// </summary>
		/// <param name="e"></param>
		/// <returns></returns>
		public bool YunXinChengXu(UpdaterActionEventArgs e) 
		{
			DialogResult dialog = 
				MessageBox.Show(this,"你是否现在就要运行最新的程序?", "程序提示", MessageBoxButtons.YesNo );
			if( DialogResult.Yes == dialog )
			{
				return true;
			}
			else 
			{
				return false;
			}

		}
		
		/// <summary>
		/// 设置时钟的运行状态
		/// </summary>
		/// <param name="ShiFouYunXing"></param>
		public void SheZhiTimer(bool ShiFouYunXing) 
		{
			this.TM_ShuJuGengXin.Enabled=ShiFouYunXing;
		}
		#endregion

		#region Main方法区域
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{	
			try 
			{
				XuQiuChaXunForm jieMian = 	new XuQiuChaXunForm();
				if(jieMian.GouZaoChengGong())
				{
					Application.Run(jieMian);
				}
				else 
				{
					jieMian.Close(); 
					jieMian = null;
					MessageBox.Show("系统初始化错误，请查看应用程序输出日志获得更多信息");
				}
			}
			catch(Exception genException ) 
			{
				Console.WriteLine(genException.Message);
			}
		}

		
		#endregion
	
	}
}
