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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 柜员凭证信息查询
    /// 通过柜员号查询柜员凭证台账
    /// </summary>
    public class QueryNormalCertificate : TFOutput
    {
        #region Output
        /// <summary>
        /// 凭证列表
        /// 凭证类别|凭证代码|凭证类型|起始号码|终止号码|数量|凭证状态|
        /// </summary>
        public string PZLB { get; internal set; }

        /// <summary>
        /// 凭证列表
        /// 凭证类别|凭证代码|凭证类型|起始号码|终止号码|数量|凭证状态|
        /// </summary>
        public List<E_PZLB> PZLBData { get; internal set; }

        /// <summary>
        /// 凭证列表
        /// 凭证类别|凭证代码|凭证类型|起始号码|终止号码|数量|凭证状态|
        /// </summary>
        public class E_PZLB
        {
            /// <summary>
            /// 凭证类别
            /// </summary>
            public string PZLB { get; set; }

            /// <summary>
            /// 凭证代码
            /// </summary>
            public string PZDM { get; set; }

            /// <summary>
            /// 凭证类型
            /// </summary>
            public string PZLX { get; set; }

            /// <summary>
            /// 起始号码
            /// </summary>
            public string QSHM { get; set; }

            /// <summary>
            /// 终止号码
            /// </summary>
            public string ZZHM { get; set; }

            /// <summary>
            /// 数量
            /// </summary>
            public string SL { get; set; }

            /// <summary>
            /// 凭证状态
            /// </summary>
            public string PZZT { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 柜员号 0920
            ///  
            /// </summary>
            public string GYH { get; set; }
            /// <summary>
            /// 待销毁标志
            /// </summary>
            public string XHBZ { get; set; }
            /// <summary>
            /// 印章类 0710
            /// 传1只保留印章类，传其他只保留其他
            /// </summary>
            public string IsYZL { get; set; }

            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryNormalCertificate();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd92 = GYH;
                MessageData.Fd128 = "0039";
                MessageData.Fd70 = XHBZ;
                MessageData.Fd71 = IsYZL;
                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.PZLBData = AnilyzeFileData<E_PZLB>(MessageData.FileData,
                                            "凭证类别|凭证代码|凭证类型|起始号码|终止号码|数量|凭证状态|",
                                            x =>
                                            {
                                                return new E_PZLB
                                                {
                                                    PZLB = x["凭证类别"],
                                                    PZDM = x["凭证代码"],
                                                    PZLX = x["凭证类型"],
                                                    QSHM = x["起始号码"],
                                                    ZZHM = x["终止号码"],
                                                    SL = x["数量"],
                                                    PZZT = x["凭证状态"]
                                                };
                                            });
                output.PZLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
