//===========================================================================
// 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.Collections;
using System.Data; 
using JSW.Tool;
using JSW.FPMS.Tool;
using JSW.FPMS.YiDong.ShiTu;
using JSW.FPMS.YiDong.Web;

namespace JSW.FPMS.YiDong.KongZhi
{
	/// <summary>
	/// 需求查询控制(Controler)
	/// </summary>
	public class clsXuQiuChaXunKongZhi
	{
		#region 成员变量区域
		//界面
		private XuQiuChaXunForm jieMian = null;
		//网络服务代理
		private clsXianFuWu     xianFuWu =  null;
		//需求数据
		private DataSet			xuqiuShuJu = null;
		#endregion
		 
		#region 公有方法区域
		/// <summary>
		/// 构造器
		/// </summary>
		/// <param name="JieMian">界面</param>
		public clsXuQiuChaXunKongZhi(XuQiuChaXunForm JieMian)
		{
			jieMian = JieMian;
			xianFuWu = new clsXianFuWu();
		}
		
		/// <summary>
		/// 查询最新的需求
		/// </summary>
		public void XuQiuChaXun() 
		{
			try
			{
				xuqiuShuJu = xianFuWu.XuQiuChaXun();				
				this.jieMian.ShuaXinWangGe(xuqiuShuJu);
			}
			catch(Exception e) 
			{
				clsRiZhiChuLi.JiLuRiZhi(e.Message);
			}
		}

		/// <summary>
		/// 获得选定行的需求数据
		/// </summary>		
		/// <param name="Hang">行号</param> 
		/// <returns></returns>
		public System.Data.DataSet HuoDeShuJu(int Hang)
		{
			if(xuqiuShuJu.Tables.Count<1) 
			{
				return null;
			}
			if(Hang <1) 
			{

			}
			System.Data.DataSet fanHui = null;
			System.Collections.Hashtable table = new System.Collections.Hashtable() ;				
			DataTable shujuBiao = xuqiuShuJu.Tables[0];
			DataRow   shujuHang = shujuBiao.Rows[Hang];
			DataTable xinShuJuBiao = shujuBiao.Clone(); 
			DataRow   xinShuJuHang =  xinShuJuBiao.NewRow();
			//复制数据
			for (int i=0;i<xinShuJuBiao.Columns.Count;i++)
				table.Add(xinShuJuBiao.Columns[i].ColumnName,"") ;

			for(int Loop=0;Loop<shujuBiao.Columns.Count;Loop++) 
			{
				if (table.ContainsKey(shujuBiao.Columns[Loop].ColumnName))
				{
					if (!shujuHang.IsNull(shujuBiao.Columns[Loop].ColumnName))
						xinShuJuHang[shujuBiao.Columns[Loop].ColumnName]  = shujuHang[shujuBiao.Columns[Loop].ColumnName].ToString();
				}
			}
			//生成新的DataSet
			xinShuJuBiao.Rows.Clear();
			xinShuJuBiao.Rows.Add(xinShuJuHang);
			fanHui = new DataSet() ;
			fanHui.Tables.Add(xinShuJuBiao);
			return fanHui ;
		}
		/// <summary>
		/// 需求反馈
		/// </summary>
		/// <param name="XuQiu"></param>
		public void XuQiuFanKui(Object[] XuQiu) 
		{
			this.xianFuWu.XuQiuFanKui(XuQiu);

		}
		
		#endregion
	}
}
