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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 现金付出/接收调剂记录查询根据新旧卡号和换证日期查询换证登记簿
    /// 根据新旧卡号和换证日期查询换证登记簿
    /// </summary>
    public class QueryHZDJB : 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 GHQZH { get; set; }

            /// <summary>
            /// 凭证号码
            /// </summary>
            public string PZHM { get; set; }

            /// <summary>
            /// 更换后账号
            /// </summary>
            public string GHHZH { get; set; }

            /// <summary>
            /// 新凭证号码
            /// </summary>
            public string XPZHM { get; set; }

            /// <summary>
            /// 介质代码
            /// </summary>
            public string JZDM { get; set; }

            /// <summary>
            /// 换证日期
            /// </summary>
            public string HZRQ { get; set; }

            /// <summary>
            /// 操作员
            /// </summary>
            public string CZY { get; set; }

            /// <summary>
            /// 换证原因
            /// </summary>
            public string HZYY { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 更换后账号 0310
            ///  
            /// </summary>
            public string GHHZH { get; set; }

            /// <summary>
            /// 更换日期起 0440
            ///  
            /// </summary>
            public string GHRQQ { get; set; }

            /// <summary>
            /// 更换日期止 0450
            ///  
            /// </summary>
            public string GHRQZ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryHZDJB();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = GHQZH;
                MessageData.Fd31 = GHHZH;
                MessageData.Fd44 = GHRQQ;
                MessageData.Fd45 = GHRQZ;
                MessageData.Fd128 = "0086";

                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
                                                {
                                                    GHQZH = x["更换前账号"],
                                                    PZHM = x["凭证号码"],
                                                    GHHZH = x["更换后账号"],
                                                    XPZHM = x["新凭证号码"],
                                                    JZDM = x["介质代码"],
                                                    HZRQ = x["换证日期"],
                                                    CZY = x["操作员"],
                                                    HZYY = x["换证原因"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
