using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 综合签约查询
    /// 通过账号查询签约信息
    /// </summary>
    public class QueryZHQY : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 客户账号|账户序号|户名|签约类型|状态|
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 客户账号|账户序号|户名|签约类型|状态|
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 客户账号|账户序号|户名|签约类型|状态|
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 客户账号
            /// </summary>
            public string KHZH { get; set; }

            /// <summary>
            /// 账户序号
            /// </summary>
            public string ZHXH { get; set; }

            /// <summary>
            /// 户名
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 签约类型
            /// </summary>
            public string QYLX { get; set; }

            /// <summary>
            /// 状态
            /// </summary>
            public string ZT { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 账号 0370
            ///  
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 状态 0670
            /// 1:正常 ; *:取消 
            /// </summary>
            public string ZT { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryZHQY();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd37 = ZH;
                MessageData.Fd67 = ZT;
                MessageData.Fd128 = "0088";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJData = AnilyzeFileData<E_WJ>(MessageData.FileData,
                                            "客户账号|账户序号|户名|签约类型|状态|",
                                            x =>
                                            {
                                                return new E_WJ
                                                {
                                                    KHZH = x["客户账号"],
                                                    ZHXH = x["账户序号"],
                                                    HM = x["户名"],
                                                    QYLX = x["签约类型"],
                                                    ZT = x["状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
