using System;
using System.Data;
using Core.Mes.ServerFrameWork;
using Core.Mes.IBaseInterface;
using System.Collections;
using Core.XgMes.Server.StorageCommon;

namespace Core.XgMes.Server.JGKC.SteelPlateManager
{
	/// <summary>
	/// 关于库存报表的查询语句服务端的集合
	/// </summary>
	public class TurnoffReportList:Core.Mes.ServerFrameWork.IComponent
	{
		public TurnoffReportList()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

        #region "成品发运综合查询"
        public ReturnObject GetOutStorageData(string where, System.Collections.ArrayList ps, System.Collections.ArrayList pg)
        {
            try
            {
                System.Data.DataSet rtndst = new DataSet();
                if (ps.Count > 0)
                {
                    for (int i = 0; i < ps.Count; i++)
                    {
                        string err = "";
                        string sql = "";
                        sql = ps[i].ToString() + where + pg[i].ToString(); 
                        System.Data.DataSet tmpdst = this.DBManager.ExecuteQuery(sql, out err);

                        if (tmpdst != null && tmpdst.Tables.Count == 1 && tmpdst.Tables[0].Rows.Count > 0)
                        {
                            tmpdst.Tables[0].TableName = "KCJ_TURNOFFOUTSTORAGE";
                            rtndst.Merge(tmpdst.Copy());
                        }
                        if (err.Length > 0)
                        {
                            System.Diagnostics.Debug.WriteLine(err);
                            err = "";
                        }
                    }
                    if (rtndst.Tables.Count == 1)
                    {
                        return new ReturnObject(rtndst);
                    }
                }
                return new ReturnObject(null);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        #endregion
        #region "成品库存综合查询"
        public ReturnObject GetStorageData(System.Collections.ArrayList Select,System.Collections.ArrayList where,System.Collections.ArrayList Group)
		{
			try
			{
				string sql = "";
				string err = "";
				System.Data.DataSet tmpdst = null;
				System.Data.DataSet rtndst = new DataSet();
				for(int i=0;i<Select.Count;i++)
				{
					sql = Select[i].ToString()+where[i].ToString()+Group[i].ToString();
					tmpdst = this.DBManager.ExecuteQuery(sql,out err);
					if(tmpdst!=null && tmpdst.Tables.Count==1)
					{
						tmpdst.Tables[0].TableName = "KCH_TURNOFFLIST_VIEW";
						rtndst.Merge(tmpdst.Copy());
						tmpdst = null;
					}
				}
				if(rtndst.Tables.Count>0)
				{
					return new ReturnObject(rtndst);
				}
				else
				{
					return new ReturnObject(null);
				}
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
				return new ReturnObject(null);
			}
		}
		#endregion

		
		public override int minValue
		{
			get
			{
				return 30;
			}
		}
		public override int maxValue
		{
			get
			{
				return 120;
			}
		}
	}
}
