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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 对公客户信息查询
    /// 根据对公户名查询客户信息
    /// </summary>
    public class QueryEnterpriseCustomerInfo : 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 KHH { get; set; }

            /// <summary>
            /// 客户类型
            /// </summary>
            public string KHLX { get; set; }

            /// <summary>
            /// 客户名称
            /// </summary>
            public string KHMC { get; set; }

            /// <summary>
            /// 创建日期
            /// </summary>
            public string CJRQ { get; set; }

            /// <summary>
            /// 联系电话
            /// </summary>
            public string LXDH { get; set; }

            /// <summary>
            /// 联系地址
            /// </summary>
            public string LXDZ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 户名 0250
            ///  
            /// </summary>
            public string HM { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryEnterpriseCustomerInfo();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd25 = HM;
                MessageData.Fd128 = "0060";

                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
                                                {
                                                    KHH = x["客户号"],
                                                    KHLX = x["客户类型"],
                                                    KHMC = x["客户名称"],
                                                    CJRQ = x["创建日期"],
                                                    LXDH = x["联系电话"],
                                                    LXDZ = x["联系地址"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
