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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// LIST下拉菜单列表下载
    /// 下载LIST菜单
    /// </summary>
    public class QueryComboBoxData : TFOutput
    {
        #region Output
        /// <summary>
        /// 菜单信息
        /// 类型值|描述|
        /// </summary>
        public string CDXX { get; internal set; }

        /// <summary>
        /// 菜单信息
        /// 类型值|描述|
        /// </summary>
        public List<E_CDXX> CDXXData { get; internal set; }

        /// <summary>
        /// 菜单信息
        /// 类型值|描述|
        /// </summary>
        public class E_CDXX
        {
            /// <summary>
            /// 类型值
            /// </summary>
            public string LXZ { get; set; }

            /// <summary>
            /// 描述
            /// </summary>
            public string MS { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 列表编码 0640
            ///  
            /// </summary>
            public string LBBM { get; set; }

            /// <summary>
            /// 附属信息 1230
            /// 1230域传值必须将tx_down_list的val字段置为1230域同时按一定格式替换掉tx_down_list表中的sql字段中指定的字符串 
            /// </summary>
            public string FJTJ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryComboBoxData();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "K042";
                MessageData.Fd64 = LBBM;
                MessageData.Fd123 = FJTJ;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.CDXXData = AnilyzeFileData<E_CDXX>(MessageData.FileData,
                                            "类型值|描述|",
                                            x =>
                                            {
                                                return new E_CDXX
                                                {
                                                    LXZ = x["类型值"],
                                                    MS = x["描述"]
                                                };
                                            });
                output.CDXX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
