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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询抵质押明细信息(文件)
    /// 通过抵质押查询抵质押明细信息
    /// </summary>
    public class QueryCollateralDetail : TFOutput
    {
        #region Output
        /// <summary>
        /// 抵质押详细列表
        /// 抵质押品编号|序号|抵质押品名称|入库状态|户名|
        /// </summary>
        public string DZYLB { get; internal set; }

        /// <summary>
        /// 抵质押详细列表
        /// 抵质押品编号|序号|抵质押品名称|入库状态|户名|
        /// </summary>
        public List<E_DZYLB> DZYLBData { get; internal set; }

        /// <summary>
        /// 抵质押详细列表
        /// 抵质押品编号|序号|抵质押品名称|入库状态|户名|
        /// </summary>
        public class E_DZYLB
        {
            /// <summary>
            /// 抵质押品编号
            /// </summary>
            public string DZYPBH { get; set; }

            /// <summary>
            /// 序号
            /// </summary>
            public string XH { get; set; }

            /// <summary>
            /// 抵质押品名称
            /// </summary>
            public string DZYPMC { get; set; }

            /// <summary>
            /// 入库状态
            /// </summary>
            public string RKZT { get; set; }

            /// <summary>
            /// 户名
            /// </summary>
            public string HM { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 抵质押编号 0370
            /// 抵质押编号 
            /// </summary>
            public string DZYBH { get; set; }

            /// <summary>
            /// 操作类型 0670
            /// 1是入库 2是出库 3是修改 
            /// </summary>
            public string CZLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCollateralDetail();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd37 = DZYBH;
                MessageData.Fd128 = "0062";
                MessageData.Fd67 = CZLX;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.DZYLBData = AnilyzeFileData<E_DZYLB>(MessageData.FileData,
                                            "抵质押品编号|序号|抵质押品名称|入库状态|户名|",
                                            x =>
                                            {
                                                return new E_DZYLB
                                                {
                                                    DZYPBH = x["抵质押品编号"],
                                                    XH = x["序号"],
                                                    DZYPMC = x["抵质押品名称"],
                                                    RKZT = x["入库状态"],
                                                    HM = x["户名"]
                                                };
                                            });
                output.DZYLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
