using System;
using System.Data;
using System.Collections;
using Core.Mes.ServerFrameWork;
using Core.Mes.IBaseInterface;

namespace Core.XgMes.Server.JGKC.RollManager
{
	/// <summary>
	/// StuffMove 的摘要说明。
	/// </summary>
	public class StuffMove : Core.Mes.ServerFrameWork.IComponent
	{
		public StuffMove()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
		}

		
		public ReturnObject StuffQuer(string _Where)
		{
			try
			{
                string strOut="";
				string Sql="SELECT 'FALSE'  FLAG, A.OLD_SAMPL_NO,A.SLAB_NO,A.ORD_NO,A.BUTTRESS,"+
                    "A.ORD_SEQ,A.STL_GRD,A.COIL_INDIA,A.COIL_OUTDIA,B.AREA, (SELECT CUST_NM  FROM TBZ00_CUSTOMER  WHERE  REC_TP='01' AND REC_STS='1' AND CUST_CD=C.CUST_CD )HTDW," +
					"A.COIL_THK,COIL_WTH,A.STOVENO,(A.BAHCT_NUMBER||A.SERIAL_NUMBER)BAHCT_NUMBER,"+
                    "ROUND(CAL_WGT,3)CAL_WGT,ROUND(A.ACT_WGT,3)ACT_WGT,A.TOT_DEC_GRD,B.REMARK FROM KCJ3_STUFFLIST_ZW A ,KCJ3_STUFFBUTTRESSLIST_ZW B,TBA01_ORD_COMM C " +
                    "WHERE A.OLD_SAMPL_NO=B.OLD_SAMPL_NO AND A.STORAGESTATUS='501002' AND A.ISVALID='1' AND A.ORD_NO=C.ORD_NO(+) " + _Where;
				DataSet ds=this.DBManager.ExecuteQuery(Sql,out strOut);
				if(ds!=null&&ds.Tables.Count==1)
				{
					ds.Tables[0].TableName="KCJ3_STUFFLIST";
					return new ReturnObject(ds,strOut);
				}
				return new ReturnObject(null);
			}
			catch(Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
				return new ReturnObject(null,10004,ex.ToString());
			}
           
		}
//		public ReturnObject StuffQuer_XG(string _Where)
//		{
//			try
//			{
//				string strOut="";
//				string Sql="SELECT A.OLD_SAMPL_NO,A.SLAB_NO,A.ORD_NO,A.BUTTRESS,"+
//					"A.ORD_SEQ,A.STL_GRD,A.COIL_INDIA,A.COIL_OUTDIA,"+
//					"A.COIL_THK,COIL_WTH,A.STOVENO,(A.BAHCT_NUMBER||A.SERIAL_NUMBER)BAHCT_NUMBER,"+
//					"CAL_WGT,A.ACT_WGT,A.TOT_DEC_GRD FROM KCJ3_STUFFLIST A  "+
//					"WHERE  A.STORAGESTATUS='501002' AND A.ISVALID='1'AND A.BUTTRESS='"+_Where+"'";
//				DataSet ds=this.DBManager.ExecuteQuery(Sql,out strOut);
//				if(ds!=null&&ds.Tables.Count==1)
//				{
//					ds.Tables[0].TableName="KCJ3_STUFFLIST";
//					return new ReturnObject(ds,strOut);
//				}
//				return new ReturnObject(null);
//			}
//			catch(Exception ex)
//			{
//				System.Diagnostics.Debug.WriteLine(ex.ToString());
//				return new ReturnObject(null,10004,ex.ToString());
//			}
//		}
		public ReturnObject StuffBuress_Move(ArrayList _Ship_Invno,ArrayList _OtherInfo)
		{
			try
			{
				string err = "";
				Oracle.DataAccess.Client.OracleParameter pShi_Invno = new Oracle.DataAccess.Client.OracleParameter("vSHIP_INVNO", Oracle.DataAccess.Client.OracleDbType.Varchar2);
				Oracle.DataAccess.Client.OracleParameter pOtherInfo = new Oracle.DataAccess.Client.OracleParameter("vOtherInfo", Oracle.DataAccess.Client.OracleDbType.Varchar2);
				Oracle.DataAccess.Client.OracleParameter pSuccessFlag = new Oracle.DataAccess.Client.OracleParameter("vSuccessFlag", Oracle.DataAccess.Client.OracleDbType.Varchar2);
				
				pShi_Invno.Direction = ParameterDirection.Input;
				pOtherInfo.Direction = ParameterDirection.Input;
				pSuccessFlag.Direction = ParameterDirection.Output;

				pShi_Invno.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
				pOtherInfo.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;

				pShi_Invno.Value = _Ship_Invno.ToArray(typeof(string));
				pOtherInfo.Value = _OtherInfo.ToArray(typeof(string));

				int []OSizeInf = new int[_Ship_Invno.Count];
				for(int i =0;i< _Ship_Invno.Count;i++)
				{
					OSizeInf[i ] = 200;
				}
				pShi_Invno.Size = _Ship_Invno.Count;
				pShi_Invno.ArrayBindSize = OSizeInf;

				int []NOSizeInf = new int[_OtherInfo.Count];
				for(int i =0;i< _OtherInfo.Count;i++)
				{
					NOSizeInf[i ] = 200;
				}
				pOtherInfo.Size = _OtherInfo.Count;
				pOtherInfo.ArrayBindSize = NOSizeInf;
				pSuccessFlag.Size = 400;

                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJ_STORAGEMANAGER_WX.STUFFBURESS_UPDATE", CommandType.StoredProcedure,
					new Oracle.DataAccess.Client.OracleParameter[]
					{pShi_Invno,pOtherInfo,pSuccessFlag}, out err);
				if(Common.CheckNullStr(pSuccessFlag.Value).Length>0 | Common.CheckNullStr(err).Length>0)
				{
					return new ReturnObject(null,1,pSuccessFlag.Value.ToString()+err);
				}
				else
				{
					return new ReturnObject('1');
				}
			}
			catch(System.Exception ex)
			{
				System.Diagnostics.Debug.WriteLine(ex.ToString());
				return new ReturnObject(null,ex.ToString());
			}
		}
	}
}
