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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询电话银行
    /// 通过卡号或存折号查询详细信息
    /// </summary>
    public class QueryDHYH : 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 ZH { get; set; }

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

            /// <summary>
            /// 签约日期
            /// </summary>
            public string QYRQ { get; set; }

            /// <summary>
            /// 账户类型
            /// </summary>
            public string ZHLX { get; set; }

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

        }

        #endregion

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

            /// <summary>
            /// 签约日期起 0440
            ///  
            /// </summary>
            public string RQQ { get; set; }

            /// <summary>
            /// 签约日期止 0450
            ///  
            /// </summary>
            public string RQZ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryDHYH();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = ZH;
                MessageData.Fd44 = RQQ;
                MessageData.Fd45 = RQZ;
                MessageData.Fd128 = "0090";

                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
                                                {
                                                    ZH = x["账户"],
                                                    HM = x["户名"],
                                                    QYRQ = x["签约日期"],
                                                    ZHLX = x["账户类型"],
                                                    ZT = x["状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
