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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询客户允许的介质列表
    /// 根据客户级别和客户种类返回活期和定期的介质列表
    /// </summary>
    public class QueryCustomerDielectric : TFOutput
    {
        #region Output
        /// <summary>
        /// 介质列表
        /// 介质代码|介质名称|
        /// </summary>
        public string JZLB { get; internal set; }

        /// <summary>
        /// 介质列表
        /// 介质代码|介质名称|
        /// </summary>
        public List<E_JZLB> JZLBData { get; internal set; }

        /// <summary>
        /// 介质列表
        /// 介质代码|介质名称|
        /// </summary>
        public class E_JZLB
        {
            /// <summary>
            /// 介质代码
            /// </summary>
            public string JZDM { get; set; }

            /// <summary>
            /// 介质名称
            /// </summary>
            public string JZMC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 客户类型 0670
            /// 1：个人； 2：公司 ；3：机构（指政府机关等组织）； 4：金融同业； 5：内部员工 
            /// </summary>
            public string KHLX { get; set; }

            /// <summary>
            /// 活期或定期 0680
            /// 1活期； 2定期； 
            /// </summary>
            public string HQHDQ { get; set; }

            /// <summary>
            /// 客户级别 0690
            ///  
            /// </summary>
            public string KHJB { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCustomerDielectric();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd67 = KHLX;
                MessageData.Fd68 = HQHDQ;
                MessageData.Fd69 = KHJB;
                MessageData.Fd128 = "0018";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.JZLBData = AnilyzeFileData<E_JZLB>(MessageData.FileData,
                                            "介质代码|介质名称|",
                                            x =>
                                            {
                                                return new E_JZLB
                                                {
                                                    JZDM = x["介质代码"],
                                                    JZMC = x["介质名称"]
                                                };
                                            });
                output.JZLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
