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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 凭证付出/收入及信息记录查询
    /// 根据对方柜员和发生日期，返回相应的该柜员付出调剂在途信息列表
    /// </summary>
    public class QueryCertificatePayIncome : TFOutput
    {
        #region Output
        /// <summary>
        /// 调出凭证信息列表
        /// 后台返回文件，内容包括：凭证类别|凭证类型|起始号码|终止号码|数量|付出柜员|对方柜员|调剂日期|
        /// </summary>
        public string DCPZXXLB { get; internal set; }

        /// <summary>
        /// 调出凭证信息列表
        /// 后台返回文件，内容包括：凭证类别|凭证类型|起始号码|终止号码|数量|付出柜员|对方柜员|调剂日期|
        /// </summary>
        public List<E_DCPZXXLB> DCPZXXLBData { get; internal set; }

        /// <summary>
        /// 调出凭证信息列表
        /// 后台返回文件，内容包括：凭证类别|凭证类型|起始号码|终止号码|数量|付出柜员|对方柜员|调剂日期|
        /// </summary>
        public class E_DCPZXXLB
        {
            /// <summary>
            /// 凭证类别
            /// </summary>
            public string PZLB { 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 FCGY { get; set; }

            /// <summary>
            /// 对方柜员
            /// </summary>
            public string DFGY { get; set; }

            /// <summary>
            /// 调剂日期
            /// </summary>
            public string DJRQ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 发生日期 0440
            /// (null) 
            /// </summary>
            public string FSRQ { get; set; }

            /// <summary>
            /// 柜员号 0910
            /// 接收柜员查询时通过该域传值 
            /// </summary>
            public string DFGY { get; set; }

            /// <summary>
            /// 凭证操作状态 0720
            /// 1-入库 2-下发 3-领入 4-付出 5-收入 6-出售 7-上缴 8-作废上缴 9-收缴 A-作废收缴 B-挂失 C-解挂 D-柜员使用 E-作废 F-出售收回 G-客户使用 H-注销 K-购买 L-重新入库 M-销毁 N-撤消 
            /// </summary>
            public string CZZT { get; set; }

            /// <summary>
            /// 柜员号 0920
            /// 付出柜员查询时通过该域传值 
            /// </summary>
            public string GYH { get; set; }

            /// <summary>
            /// 印章类 0710
            /// 传1只保留印章类，传其他只保留其他
            /// </summary>
            public string IsYZL { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryCertificatePayIncome();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd44 = FSRQ;
                MessageData.Fd91 = DFGY;
                MessageData.Fd128 = "0005";
                MessageData.Fd72 = CZZT;
                MessageData.Fd92 = GYH;
                MessageData.Fd71 = IsYZL;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.DCPZXXLBData = AnilyzeFileData<E_DCPZXXLB>(MessageData.FileData,
                                            "凭证类别|凭证类型|起始号码|终止号码|数量|付出柜员|对方柜员|调剂日期|",
                                            x =>
                                            {
                                                return new E_DCPZXXLB
                                                {
                                                    PZLB = x["凭证类别"],
                                                    PZLX = x["凭证类型"],
                                                    QSHM = x["起始号码"],
                                                    ZZHM = x["终止号码"],
                                                    SL = x["数量"],
                                                    FCGY = x["付出柜员"],
                                                    DFGY = x["对方柜员"],
                                                    DJRQ = x["调剂日期"]
                                                };
                                            });
                output.DCPZXXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
