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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 机构现金库存查询
    /// 根据机构号查询现金库存
    /// </summary>
    public class QueryDQJGXX : 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 JGH { get; set; }

            /// <summary>
            /// 机构名称
            /// </summary>
            public string JGMC { get; set; }

            /// <summary>
            /// 机构类型
            /// </summary>
            public string JGLX { get; set; }

            /// <summary>
            /// 网点状态
            /// </summary>
            public string WDZT { get; set; }

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

            /// <summary>
            /// 机构现金库存
            /// </summary>
            public string JGXJKC { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 机构号 0910
            ///  
            /// </summary>
            public string JGH { get; set; }


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

                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
                                                {
                                                    JGH = x["机构号"],
                                                    JGMC = x["机构名称"],
                                                    JGLX = x["机构类型"],
                                                    WDZT = x["网点状态"],
                                                    LXDH = x["联系电话"],
                                                    JGXJKC = x["机构现金库存"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
