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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 对公关联证件查询
    /// 查询该客户已关联的证件信息
    /// </summary>
    public class QueryEnterpriseRelationID : TFOutput
    {
        #region Output
        /// <summary>
        /// 证件列表
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|
        /// </summary>
        public string ZJLB { get; internal set; }

        /// <summary>
        /// 证件列表
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|
        /// </summary>
        public List<E_ZJLB> ZJLBData { get; internal set; }

        /// <summary>
        /// 证件列表
        /// 客户编码|证件类型|证件号码|开始日期|结束日期|
        /// </summary>
        public class E_ZJLB
        {
            /// <summary>
            /// 客户编码
            /// </summary>
            public string KHBM { get; set; }

            /// <summary>
            /// 证件类型
            /// </summary>
            public string ZJLX { get; set; }

            /// <summary>
            /// 证件号码
            /// </summary>
            public string ZJHM { get; set; }

            /// <summary>
            /// 开始日期
            /// </summary>
            public string KSRQ { get; set; }

            /// <summary>
            /// 结束日期
            /// </summary>
            public string JSRQ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 客户号 0280
            ///  
            /// </summary>
            public string KHH { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryEnterpriseRelationID();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd28 = KHH;
                MessageData.Fd128 = "0037";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.ZJLBData = AnilyzeFileData<E_ZJLB>(MessageData.FileData,
                                            "客户编码|证件类型|证件号码|开始日期|结束日期|",
                                            x =>
                                            {
                                                return new E_ZJLB
                                                {
                                                    KHBM = x["客户编码"],
                                                    ZJLX = x["证件类型"],
                                                    ZJHM = x["证件号码"],
                                                    KSRQ = x["开始日期"],
                                                    JSRQ = x["结束日期"]
                                                };
                                            });
                output.ZJLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
