//===========================================================================
// 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.Data; 
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using JSW.FPMS.YiDong.KongZhi;

namespace JSW.FPMS.YiDong.ShiTu
{
	/// <summary>
	/// XuQiuFanKui 的摘要说明。
	/// </summary>
	public class XuQiuFanKuiForm : System.Windows.Forms.Form
	{
		#region 成员变量区域
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox TB_CaiJiShiJian;

		private String[] xiTongShuJu = {"CaiJiShiJian","TiChuRen","YuFuBianMa",
										   "XuQiuLeiBie","XinXiDianBianHao","XuQiuManYiDu",
											"DaFuRen","DaFuShiJian","DaFuQingKuang"};
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox TB_TiChuRen;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox TB_YuFuBianMa;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox TB_XuQiuManYiDu;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label label7;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Button BT_TiJiao;
		private System.Windows.Forms.Button BT_QuXiao;
		private System.Windows.Forms.Label label8;
		private System.Windows.Forms.Label label9;
		private System.Windows.Forms.TextBox TB_XuQiuLeiBie;
		private System.Windows.Forms.TextBox TB_XinXiDianBianHao;
		private System.Windows.Forms.TextBox TB_DaFuRen;
		private System.Windows.Forms.TextBox TB_DaFuQingKuang;
		private System.Windows.Forms.TextBox TB_DaFuShiJian;
		//需求数据
		DataSet  xuQiu = null;
		clsXuQiuChaXunKongZhi kongZhi = null;
		bool     shifouZhiDu		= false;
		#endregion
		
		#region 私有方法区域

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(XuQiuFanKuiForm));
			this.label1 = new System.Windows.Forms.Label();
			this.TB_CaiJiShiJian = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.TB_TiChuRen = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.TB_YuFuBianMa = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.TB_XuQiuManYiDu = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.TB_DaFuRen = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.TB_DaFuShiJian = new System.Windows.Forms.TextBox();
			this.label7 = new System.Windows.Forms.Label();
			this.TB_DaFuQingKuang = new System.Windows.Forms.TextBox();
			this.panel1 = new System.Windows.Forms.Panel();
			this.TB_XinXiDianBianHao = new System.Windows.Forms.TextBox();
			this.TB_XuQiuLeiBie = new System.Windows.Forms.TextBox();
			this.label9 = new System.Windows.Forms.Label();
			this.label8 = new System.Windows.Forms.Label();
			this.panel2 = new System.Windows.Forms.Panel();
			this.BT_TiJiao = new System.Windows.Forms.Button();
			this.BT_QuXiao = new System.Windows.Forms.Button();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 8);
			this.label1.Size = new System.Drawing.Size(72, 21);
			this.label1.Text = "采集时间：";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_CaiJiShiJian
			// 
			this.TB_CaiJiShiJian.Location = new System.Drawing.Point(96, 8);
			this.TB_CaiJiShiJian.MaxLength = 10;
			this.TB_CaiJiShiJian.Size = new System.Drawing.Size(120, 21);
			this.TB_CaiJiShiJian.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(32, 32);
			this.label2.Size = new System.Drawing.Size(56, 21);
			this.label2.Text = "提出人：";
			this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_TiChuRen
			// 
			this.TB_TiChuRen.Location = new System.Drawing.Point(96, 32);
			this.TB_TiChuRen.MaxLength = 10;
			this.TB_TiChuRen.Size = new System.Drawing.Size(120, 21);
			this.TB_TiChuRen.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(16, 56);
			this.label3.Size = new System.Drawing.Size(72, 21);
			this.label3.Text = "育妇编码：";
			this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_YuFuBianMa
			// 
			this.TB_YuFuBianMa.Location = new System.Drawing.Point(96, 56);
			this.TB_YuFuBianMa.MaxLength = 10;
			this.TB_YuFuBianMa.Size = new System.Drawing.Size(120, 21);
			this.TB_YuFuBianMa.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 80);
			this.label4.Size = new System.Drawing.Size(80, 21);
			this.label4.Text = "需求满意度：";
			this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_XuQiuManYiDu
			// 
			this.TB_XuQiuManYiDu.Location = new System.Drawing.Point(96, 80);
			this.TB_XuQiuManYiDu.MaxLength = 10;
			this.TB_XuQiuManYiDu.Size = new System.Drawing.Size(120, 21);
			this.TB_XuQiuManYiDu.Text = "";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(8, 8);
			this.label5.Size = new System.Drawing.Size(80, 21);
			this.label5.Text = "答复人：";
			this.label5.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_DaFuRen
			// 
			this.TB_DaFuRen.Location = new System.Drawing.Point(96, 8);
			this.TB_DaFuRen.MaxLength = 10;
			this.TB_DaFuRen.Size = new System.Drawing.Size(120, 21);
			this.TB_DaFuRen.Text = "";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 32);
			this.label6.Size = new System.Drawing.Size(80, 21);
			this.label6.Text = "答复时间：";
			this.label6.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_DaFuShiJian
			// 
			this.TB_DaFuShiJian.Location = new System.Drawing.Point(96, 32);
			this.TB_DaFuShiJian.MaxLength = 10;
			this.TB_DaFuShiJian.Size = new System.Drawing.Size(120, 21);
			this.TB_DaFuShiJian.Text = "";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(8, 56);
			this.label7.Size = new System.Drawing.Size(80, 21);
			this.label7.Text = "答复情况：";
			this.label7.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// TB_DaFuQingKuang
			// 
			this.TB_DaFuQingKuang.Location = new System.Drawing.Point(96, 56);
			this.TB_DaFuQingKuang.MaxLength = 10;
			this.TB_DaFuQingKuang.Size = new System.Drawing.Size(120, 21);
			this.TB_DaFuQingKuang.Text = "";
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.Color.Lavender;
			this.panel1.Controls.Add(this.TB_XinXiDianBianHao);
			this.panel1.Controls.Add(this.TB_XuQiuLeiBie);
			this.panel1.Controls.Add(this.label9);
			this.panel1.Controls.Add(this.label8);
			this.panel1.Controls.Add(this.label1);
			this.panel1.Controls.Add(this.TB_CaiJiShiJian);
			this.panel1.Controls.Add(this.label2);
			this.panel1.Controls.Add(this.label3);
			this.panel1.Controls.Add(this.TB_TiChuRen);
			this.panel1.Controls.Add(this.TB_YuFuBianMa);
			this.panel1.Controls.Add(this.label4);
			this.panel1.Controls.Add(this.TB_XuQiuManYiDu);
			this.panel1.Size = new System.Drawing.Size(240, 152);
			// 
			// TB_XinXiDianBianHao
			// 
			this.TB_XinXiDianBianHao.Location = new System.Drawing.Point(96, 128);
			this.TB_XinXiDianBianHao.MaxLength = 10;
			this.TB_XinXiDianBianHao.Size = new System.Drawing.Size(120, 21);
			this.TB_XinXiDianBianHao.Text = "";
			// 
			// TB_XuQiuLeiBie
			// 
			this.TB_XuQiuLeiBie.Location = new System.Drawing.Point(96, 104);
			this.TB_XuQiuLeiBie.MaxLength = 10;
			this.TB_XuQiuLeiBie.Size = new System.Drawing.Size(120, 21);
			this.TB_XuQiuLeiBie.Text = "";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(8, 128);
			this.label9.Size = new System.Drawing.Size(80, 21);
			this.label9.Text = "信息点编号：";
			this.label9.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(0, 104);
			this.label8.Size = new System.Drawing.Size(88, 21);
			this.label8.Text = "需求代码：";
			this.label8.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// panel2
			// 
			this.panel2.BackColor = System.Drawing.Color.Lavender;
			this.panel2.Controls.Add(this.TB_DaFuRen);
			this.panel2.Controls.Add(this.label5);
			this.panel2.Controls.Add(this.TB_DaFuShiJian);
			this.panel2.Controls.Add(this.TB_DaFuQingKuang);
			this.panel2.Controls.Add(this.label6);
			this.panel2.Controls.Add(this.label7);
			this.panel2.Location = new System.Drawing.Point(0, 152);
			this.panel2.Size = new System.Drawing.Size(240, 88);
			// 
			// BT_TiJiao
			// 
			this.BT_TiJiao.Location = new System.Drawing.Point(48, 256);
			this.BT_TiJiao.Size = new System.Drawing.Size(104, 24);
			this.BT_TiJiao.Text = "反馈";
			this.BT_TiJiao.Click += new System.EventHandler(this.BT_TiJiao_Click);
			// 
			// BT_QuXiao
			// 
			this.BT_QuXiao.Location = new System.Drawing.Point(144, 256);
			this.BT_QuXiao.Size = new System.Drawing.Size(96, 24);
			this.BT_QuXiao.Text = "取消";
			this.BT_QuXiao.Click += new System.EventHandler(this.BT_QuXiao_Click);
			// 
			// XuQiuFanKuiForm
			// 
			this.BackColor = System.Drawing.Color.LavenderBlush;
			this.ClientSize = new System.Drawing.Size(242, 287);
			this.Controls.Add(this.BT_QuXiao);
			this.Controls.Add(this.BT_TiJiao);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Text = "FPMS.移动-需求反馈";

		}

		#region 事件响应区域
		/// <summary>
		/// 关闭窗口
		/// </summary>
		private void BT_QuXiao_Click(object sender, System.EventArgs e)
		{
			if(!shifouZhiDu) 
			{
				if(this.TB_DaFuRen.Text.Trim().Length<1 
					&& this.TB_DaFuQingKuang.Text.Length<1) 
				{ 
					this.Close();
				}
				else 
				{
					if(DialogResult.Yes == MessageBox.Show("已经录入反馈信息，确认退出?","提示信息",MessageBoxButtons.YesNo,
						MessageBoxIcon.Question,MessageBoxDefaultButton.Button1))
						this.Close();
						
				}
			} 
			else 
			{
				this.Close();
			}
		}
		/// <summary>
		/// 提交反馈信息
		/// </summary>
		private void BT_TiJiao_Click(object sender, System.EventArgs e)
		{
			try 
			{			
				kongZhi.XuQiuFanKui(ShuJuJianYan());
				this.Close();
				kongZhi.XuQiuChaXun();
			}
			catch(Exception genException) 
			{
				String jibenyiChang = "数据反馈出现未知的错误！";
				//获得基本异常的原始信息
				if(genException.GetType() == typeof(System.Web.Services.Protocols.SoapException)) 
				{
					System.Web.Services.Protocols.SoapException
						se = genException as System.Web.Services.Protocols.SoapException;
					 jibenyiChang = se.GetBaseException().Message;
				}
				MessageBox.Show(jibenyiChang,"提示信息",
					MessageBoxButtons.OK,MessageBoxIcon.Exclamation,MessageBoxDefaultButton.Button1);
			}
		}
		/// <summary>
		/// 数据检验，生成数据组
		/// </summary>
		private Object[] ShuJuJianYan() 
		{
			string bianhao = this.xuQiu.Tables[0].Rows[0]["BianHao"].ToString().Trim();
			string dafuren = this.TB_DaFuRen.Text.Trim();
			string dafuqingkuang = this.TB_DaFuQingKuang.Text.Trim();
			if(dafuren.Length<1) 
			{
				throw new Exception("答复人不能为空");
			}
			if(dafuqingkuang.Length<1) 
			{
				throw new Exception("答复情况不能为空");
			}	
			Object[] shuju = new Object[4];
			shuju[0] = bianhao;
			shuju[1] = dafuren;
			shuju[2] = DateTime.Now.ToString();
			shuju[3] = dafuqingkuang;
			return shuju;
		}
		#endregion 

		#endregion

		#endregion 

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

		#region 公有方法区域
		/// <summary>
		/// 构造器
		/// </summary>
		/// <param name="XuQiu">需求数据</param>
		public XuQiuFanKuiForm(DataSet XuQiu,clsXuQiuChaXunKongZhi KongZhi)
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
			xuQiu = XuQiu;
			//采集时间
			this.TB_CaiJiShiJian.Text = xuQiu.Tables[0].Rows[0][xiTongShuJu[0]].ToString().Substring(0,10);
			this.TB_CaiJiShiJian.Enabled=false;
			//提出人
			this.TB_TiChuRen.Text = xuQiu.Tables[0].Rows[0][xiTongShuJu[1]].ToString().Trim();
			this.TB_TiChuRen.Enabled=false;
			//育妇编码
			this.TB_YuFuBianMa.Text=xuQiu.Tables[0].Rows[0][xiTongShuJu[2]].ToString().Trim();
			this.TB_YuFuBianMa.Enabled=false;
			//需求类别
			this.TB_XuQiuLeiBie.Text = xuQiu.Tables[0].Rows[0][xiTongShuJu[3]].ToString().Trim();
			this.TB_XuQiuLeiBie.Enabled=false;
			//信息代码编号
			this.TB_XinXiDianBianHao.Text=xuQiu.Tables[0].Rows[0][xiTongShuJu[4]].ToString().Trim();
			this.TB_XinXiDianBianHao.Enabled=false;
			//需求满意度
			this.TB_XuQiuManYiDu.Text=xuQiu.Tables[0].Rows[0][xiTongShuJu[5]].ToString().Trim();
			this.TB_XuQiuManYiDu.Enabled=false;

			//判断是否已经答复的数据
			string dafuren = xuQiu.Tables[0].Rows[0][xiTongShuJu[6]].ToString().Trim();
			this.TB_DaFuRen.MaxLength=5;
			this.TB_DaFuShiJian.MaxLength=10;
			this.TB_DaFuQingKuang.MaxLength=20;
			if(dafuren.Length>0 ) //已经被答复过了
			{
				this.TB_DaFuRen.Text=dafuren;				
				this.TB_DaFuRen.Enabled=false;
				this.TB_DaFuShiJian.Text= xuQiu.Tables[0].Rows[0][xiTongShuJu[7]].ToString().Substring(0,10);				
				this.TB_DaFuShiJian.Enabled=false;
				this.TB_DaFuQingKuang.Text= xuQiu.Tables[0].Rows[0][xiTongShuJu[8]].ToString();				
				this.TB_DaFuQingKuang.Enabled=false;
				this.BT_TiJiao.Visible=false;
				shifouZhiDu = true;
			}
			else 
			{
				this.TB_DaFuShiJian.Text= DateTime.Now.ToShortDateString();
				this.TB_DaFuShiJian.Enabled=false;
				//得到控制器
				kongZhi = KongZhi;
			}
		}
		#endregion 
		
		
	}
}
