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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 巧得利签约查询
    /// 通过账号查询签约信息
    /// </summary>
    public class QuerySignContractQDL : 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 KHJG { get; set; }

            /// <summary>
            /// 客户账号
            /// </summary>
            public string KHZH { get; set; }

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

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

            /// <summary>
            /// 开通日期
            /// </summary>
            public string KTRQ { get; set; }

            /// <summary>
            /// 开通机构
            /// </summary>
            public string KTJG { get; set; }

            /// <summary>
            /// 开通柜员
            /// </summary>
            public string KTGY { get; set; }

            /// <summary>
            /// 解约日期
            /// </summary>
            public string JYRQ { get; set; }

            /// <summary>
            /// 解约机构
            /// </summary>
            public string JYJG { get; set; }

            /// <summary>
            /// 解约柜员
            /// </summary>
            public string JYGY { 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 QuerySignContractQDL();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd37 = ZH;
                MessageData.Fd128 = "0056";
                MessageData.Fd67 = ZT;

                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
                                                {
                                                    KHJG = x["开户机构"],
                                                    KHZH = x["客户账号"],
                                                    ZHXH = x["账户序号"],
                                                    ZT = x["状态"],
                                                    KTRQ = x["开通日期"],
                                                    KTJG = x["开通机构"],
                                                    KTGY = x["开通柜员"],
                                                    JYRQ = x["解约日期"],
                                                    JYJG = x["解约机构"],
                                                    JYGY = x["解约柜员"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
