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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 对公通存通兑签约查询
    /// 对公通存通兑签约查询
    /// </summary>
    public class QueryDGTCTDQY : TFOutput
    {
        #region Output
        /// <summary>
        /// 签约明细
        /// TITLE=~开户机构|账号|账户序号|通兑范围|类型|金额|状态|签约日期|签约柜员|解约日期|解约柜员
        /// </summary>
        public string QYMX { get; internal set; }

        /// <summary>
        /// 签约明细
        /// TITLE=~开户机构|账号|账户序号|通兑范围|类型|金额|状态|签约日期|签约柜员|解约日期|解约柜员
        /// </summary>
        public List<E_QYMX> QYMXData { get; internal set; }

        /// <summary>
        /// 签约明细
        /// TITLE=~开户机构|账号|账户序号|通兑范围|类型|金额|状态|签约日期|签约柜员|解约日期|解约柜员
        /// </summary>
        public class E_QYMX
        {
            /// <summary>
            /// 开户机构
            /// </summary>
            public string KHJG { get; set; }

            /// <summary>
            /// 账号
            /// </summary>
            public string ZH { get; set; }

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

            /// <summary>
            /// 通兑范围
            /// </summary>
            public string TDFW { get; set; }

            /// <summary>
            /// 类型
            /// </summary>
            public string LX { get; set; }

            /// <summary>
            /// 金额
            /// </summary>
            public string JE { get; set; }

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

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

            /// <summary>
            /// 签约柜员
            /// </summary>
            public string QYGY { get; set; }

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

            /// <summary>
            /// 解约柜员
            /// </summary>
            public string JYGY { get; set; }

        }

        #endregion

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

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

            /// <summary>
            /// 状态 0670
            /// 1：签约，*:解约 
            /// </summary>
            public string ZT { get; set; }

            /// <summary>
            /// 交易机构 0910
            ///  
            /// </summary>
            public string JYJG { get; set; }


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

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.QYMXData = AnilyzeFileData<E_QYMX>(MessageData.FileData,
                                            "开户机构|账号|账户序号|通兑范围|类型|金额|状态|签约日期|签约柜员|解约日期|解约柜员",
                                            x =>
                                            {
                                                return new E_QYMX
                                                {
                                                    KHJG = x["开户机构"],
                                                    ZH = x["账号"],
                                                    ZHXH = x["账户序号"],
                                                    TDFW = x["通兑范围"],
                                                    LX = x["类型"],
                                                    JE = x["金额"],
                                                    ZT = x["状态"],
                                                    QYRQ = x["签约日期"],
                                                    QYGY = x["签约柜员"],
                                                    JYRQ = x["解约日期"],
                                                    JYGY = x["解约柜员"]
                                                };
                                            });
                output.QYMX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
