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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 模糊查询dic_data表
    /// 通过项目编号模糊查询dic_data表
    /// </summary>
    public class QueryDicDataVague : TFOutput
    {
        #region Output
        /// <summary>
        /// 内容列表
        /// 项目编号|项目顺序号|内容
        /// </summary>
        public string NRLB { get; internal set; }

        /// <summary>
        /// 内容列表
        /// 项目编号|项目顺序号|内容
        /// </summary>
        public List<E_NRLB> NRLBData { get; internal set; }

        /// <summary>
        /// 内容列表
        /// 项目编号|项目顺序号|内容
        /// </summary>
        public class E_NRLB
        {
            /// <summary>
            /// 项目编号
            /// </summary>
            public string XMBH { get; set; }

            /// <summary>
            /// 项目顺序号
            /// </summary>
            public string XMSXH { get; set; }

            /// <summary>
            /// 内容
            /// </summary>
            public string NR { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 项目顺序号 0640
            /// 1:收入  2:支出 
            /// </summary>
            public string XMSXH { get; set; }

            /// <summary>
            /// 项目编号 0820
            /// cash_ind: 现金收支码 
            /// </summary>
            public string XMBH { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryDicDataVague();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd64 = XMSXH;
                MessageData.Fd82 = XMBH;
                MessageData.Fd128 = "0029";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.NRLBData = AnilyzeFileData<E_NRLB>(MessageData.FileData,
                                            "项目编号|项目顺序号|内容",
                                            x =>
                                            {
                                                return new E_NRLB
                                                {
                                                    XMBH = x["项目编号"],
                                                    XMSXH = x["项目顺序号"],
                                                    NR = x["内容"]
                                                };
                                            });
                output.NRLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
