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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 利率变更查询(文件)
    /// 通过输入账号等查询利率变更相关信息
    /// </summary>
    public class QueryRateChangeRecord : TFOutput
    {
        #region Output
        /// <summary>
        /// 利率变更记录
        /// 账号|户名|利率类型|原利率|新利率|调整日期|调整柜员|
        /// </summary>
        public string LLBGJL { get; internal set; }

        /// <summary>
        /// 利率变更记录
        /// 账号|户名|利率类型|原利率|新利率|调整日期|调整柜员|
        /// </summary>
        public List<E_LLBGJL> LLBGJLData { get; internal set; }

        /// <summary>
        /// 利率变更记录
        /// 账号|户名|利率类型|原利率|新利率|调整日期|调整柜员|
        /// </summary>
        public class E_LLBGJL
        {
            /// <summary>
            /// 账号
            /// </summary>
            public string ZH { get; set; }

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

            /// <summary>
            /// 利率类型
            /// </summary>
            public string LLLX { get; set; }

            /// <summary>
            /// 原利率
            /// </summary>
            public string YLL { get; set; }

            /// <summary>
            /// 新利率
            /// </summary>
            public string XLL { get; set; }

            /// <summary>
            /// 调整日期
            /// </summary>
            public string DZRQ { get; set; }

            /// <summary>
            /// 调整柜员
            /// </summary>
            public string DZGY { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 起始日期 0440
            ///  
            /// </summary>
            public string QSRQ { get; set; }

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

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

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


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryRateChangeRecord();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd44 = QSRQ;
                MessageData.Fd45 = JZRQ;
                MessageData.Fd102_1 = ZH;
                MessageData.Fd102_H = HM;
                MessageData.Fd128 = "0045";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.LLBGJLData = AnilyzeFileData<E_LLBGJL>(MessageData.FileData,
                                            "账号|户名|利率类型|原利率|新利率|调整日期|调整柜员|",
                                            x =>
                                            {
                                                return new E_LLBGJL
                                                {
                                                    ZH = x["账号"],
                                                    HM = x["户名"],
                                                    LLLX = x["利率类型"],
                                                    YLL = x["原利率"],
                                                    XLL = x["新利率"],
                                                    DZRQ = x["调整日期"],
                                                    DZGY = x["调整柜员"]
                                                };
                                            });
                output.LLBGJL = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
