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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询揽存登记簿
    /// 查询揽存登记簿
    /// </summary>
    public class QueryLCDJB : 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 JE { get; set; }

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

            /// <summary>
            /// 截止日期
            /// </summary>
            public string JZRQ { get; set; }

            /// <summary>
            /// 交易柜员
            /// </summary>
            public string JYGY { get; set; }

            /// <summary>
            /// 明细数
            /// </summary>
            public string MXS { get; set; }

            /// <summary>
            /// 备注
            /// </summary>
            public string BZ { 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>
            /// 交易机构 0910
            ///  
            /// </summary>
            public string JYJG { get; set; }


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

                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["账户序号"],
                                                    JE = x["金额"],
                                                    QYRQ = x["签约日期"],
                                                    JZRQ = x["截止日期"],
                                                    JYGY = x["交易柜员"],
                                                    MXS = x["明细数"],
                                                    BZ = x["备注"]
                                                };
                                            });
                output.QYMX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
