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
{
    public class SendManager : Core.Mes.ServerFrameWork.IComponent
    {

        //获取排车信息
        public ReturnObject GetAskPlanData(string where, string strlx)
        {
            try
            {
                string PSql = "";
                if (strlx == "1")
                {
                    PSql = " SELECT T1.ASKPLAN_ID,T1.PACTNO,C.BUYERNAME BUYERCODE,T1.INCEPTCORPCODE ICODE,B.INCEPTCORPNAME INCEPTCORPCODE,TO_CHAR(T1.INCEPTDATE,'YY-MM-DD')INCEPTDATE,T1.WEIGHT,T1.TRANSNO,T1.REMARK "
                         + " FROM KCJ_PLAN T1,SEL_INCEPTCORPINFO B,SEL_BUYERBASEINFO C WHERE T1.INCEPTCORPCODE=B.INCEPTCORPCODE(+) AND T1.BUYERCODE =C.BUYERCODE(+) "
                         + " AND T1.ISVALID='1' AND T1.PL='0' " + where;
                }
                else
                {
                    PSql = " SELECT T1.ASKPLAN_ID,T1.PACTNO,C.BUYERNAME BUYERCODE,T1.INCEPTCORPCODE ICODE,B.INCEPTCORPNAME INCEPTCORPCODE,TO_CHAR(T1.INCEPTDATE,'YY-MM-DD')INCEPTDATE,T1.WEIGHT,T1.TRANSNO,T1.REMARK "
                   + " FROM KCJ_PLAN T1,SEL_INCEPTCORPINFO B,SEL_BUYERBASEINFO C WHERE T1.INCEPTCORPCODE=B.INCEPTCORPCODE(+) AND T1.BUYERCODE=C.BUYERCODE(+) "
                   + " AND T1.ISVALID='1' AND T1.PL='1' " + where;
                }

                string err = "";
                System.Data.DataSet rtndst = new DataSet();
                System.Data.DataSet tmpdst = this.DBManager.ExecuteQuery(PSql, out err);
                if (tmpdst != null && tmpdst.Tables.Count == 1 && tmpdst.Tables[0].Rows.Count > 0)
                {
                    tmpdst.Tables[0].TableName = "SEL_ASKVEHICLEPLAN_C";
                    return new ReturnObject(tmpdst);

                }
                else
                {
                    return new ReturnObject(null);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }

        //获得发运明细
        public ReturnObject GetSendListData(string where,string strlx)
        {
            try
            {
                string sql = "";
                if (strlx == "1")
                {
                    sql = "SELECT B.INCEPTCORPNAME,C.BUTTRESS,C.CONDOLENUMBER,C.SERIALNUMBER,E.NAME_ CLASSORDER,"
                                + "F.NAME_ CLASSTEAM,C.TRAINWAGON,C.PLANVEHICLEID,C.PACTNO,C.ORDERFORMNUMBER,C.ROLLNO,C.PLANNO,C.STEELTYPE,"
                                + "C.PLY,C.WIDTH,C.LENGTH,C.WEIGHT,H.NAME_ DETERMINANTRESULT,'' CUTSIDE,''STANDROLL,"
                                + "''DETECTMAR,G.NAME_ ROLE,"
                                + "C.STOVENO,"
                                + "(select round(c.pickstoragetime-intime,0) from kcj_storagelist_zw  where billetid =  c.serialnumber) age,"
                                + "C.ID,K.NAME_ USE,L.NAME_ STANDARDNO,C.PICKSTORAGEMAN,"
                                + "TO_CHAR(C.PICKSTORAGETIME,'YYYY-MM-DD HH24:MI:SS') PICKSTORAGETIME,C.LISTNUMBER,"
                                + "C.REMARK,DECODE(C.ISVALID,'1','√',NULL) ISVALID,C.ADDWEIGHT "


                                + "FROM KCJ_PLAN A,SEL_INCEPTCORPINFO B,KCJ_TURNOFFSENDLIST_ZW C,"
                                + "SCM_BASE_INFO E,SCM_BASE_INFO F,SCM_BASE_INFO G,SCM_BASE_INFO H,"
                                + "SCM_BASE_INFO K,SCM_BASE_INFO L "
                                + " "
                                + "WHERE A.INCEPTCORPCODE=B.INCEPTCORPCODE(+) "
                                + "AND A.ASKPLAN_ID(+)=C.PLANVEHICLEID AND C.ISVALID<>'0'  "
                                + "AND C.CLASSORDER=E.ID_(+) AND C.CLASSTEAM=F.ID_(+) AND C.ROLE=G.ID_(+) AND C.DETERMINANTRESULT=H.ID_(+) "
                                + "AND C.USE=K.ID_(+) AND C.STANDARDNO=L.ID_(+) "
                          
                                + "AND C.LISTNUMBER NOT LIKE 'XB%'"
                                + where;
                }
                else
                {
                    sql = "SELECT B.INCEPTCORPNAME,C.BUTTRESS,C.CONDOLENUMBER,C.SERIALNUMBER,E.NAME_ CLASSORDER,"
                              + "F.NAME_ CLASSTEAM,C.TRAINWAGON,C.PLANVEHICLEID,C.PACTNO,C.ORDERFORMNUMBER,C.ROLLNO,C.PLANNO,C.STEELTYPE,"
                              + "C.PLY,C.WIDTH,C.LENGTH,C.WEIGHT,H.NAME_ DETERMINANTRESULT,'' CUTSIDE,''STANDROLL,"
                              + "''DETECTMAR,G.NAME_ ROLE,"
                              + "C.STOVENO,"

                              + "C.ID,K.NAME_ USE,L.NAME_ STANDARDNO,C.PICKSTORAGEMAN,"
                              + "TO_CHAR(C.PICKSTORAGETIME,'YYYY-MM-DD HH24:MI:SS') PICKSTORAGETIME,C.LISTNUMBER,"
                              + "C.REMARK,DECODE(C.ISVALID,'1','√',NULL) ISVALID,C.ADDWEIGHT "


                              + "FROM KCJ_PLAN A,SEL_INCEPTCORPINFO B,KCJ_TURNOFFSENDLIST_ZW C,"
                              + "SCM_BASE_INFO E,SCM_BASE_INFO F,SCM_BASE_INFO G,SCM_BASE_INFO H,"
                              + "SCM_BASE_INFO K,SCM_BASE_INFO L "
                              + " "
                              + "WHERE A.INCEPTCORPCODE=B.INCEPTCORPCODE(+)  "
                              + "AND A.ASKPLAN_ID(+)=C.PLANVEHICLEID AND C.ISVALID<>'0'  "
                              + "AND C.CLASSORDER=E.ID_(+) AND C.CLASSTEAM=F.ID_(+) AND C.ROLE=G.ID_(+) AND C.DETERMINANTRESULT=H.ID_(+) "
                              + "AND C.USE=K.ID_(+) AND C.STANDARDNO=L.ID_(+) "
                            
                              + "AND C.LISTNUMBER NOT LIKE 'BP%'"
                              + where;
                }
                string err = "";
                System.Data.DataSet dst = this.DBManager.ExecuteQuery(sql, out err);
                if (dst != null && dst.Tables.Count == 1 && dst.Tables[0].Rows.Count > 0)
                {
                    dst.Tables[0].TableName = "KCJ_TURNOFFSENDLIST";
                    return new ReturnObject(dst);
                }
                else
                {
                    return new ReturnObject(null);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        //获得库存的可发资源
        public ReturnObject GetCanSendList(string where, string strlx,string strlxx)
        {
            try
            {
                string err = "";
                string sql = "";
                if (strlxx == "YL")
                {
                    if (strlx == "1")
                    {
                        sql = "SELECT 'FALSE' FLAG,SUBSTR(A.ORDERNO,1,LENGTH(A.ORDERNO)-3)PACTNO,C.PACTINDEX PLANNUMBER,"
                                   + "A.ROLLNUMBER,A.ORDERNO,A.STOVENO,TO_CHAR(B.BUTTRESS)BUTTRESS,B.CONDOLENUMBER,"
                                   + "A.BILLETID,A.INSTEEL,A.DETERMINANTCARDNUMBER,A.PLY,A.WIDTH,A.LENGTH,A.THEORYWEIGHT,"
                                   + "D.NAME_ RULE,E.NAME_ CUTSIDESTATE,F.NAME_ DETERMINANTRESULT,"
                                   + "I.NAME_ FACEQUALITY,''STANDROLLERROLL,"
                                   + "L.NAME_ DETECTMARBOOKIN"


                                   + ",B.REMARK,"




                                   + "A.DETECTMARBOOKIN KDETECT "


                                   + "FROM KCJ_STORAGELIST_ZW A,KCJ_STORAGEBUTTRESSLIST_ZW B,SEL_PACTDETAIL C,SCM_BASE_INFO D,SCM_BASE_INFO E,"
                                   + "SCM_BASE_INFO F,SCM_BASE_INFO I,"
                                   + "SCM_BASE_INFO L  "
                                   + "WHERE B.BILLETID=A.BILLETID AND A.ORDERNO=C.ORDERNO(+) AND A.STORAGESTATUS='501002' AND C.SENDSTATUS=E.ID_(+) "
                                   + "AND A.RULE=D.ID_(+)  AND A.DETERMINANTRESULT=F.ID_(+) "
                                   + "AND A.FACEQUALITY=I.ID_(+) "
                                   + "AND A.DETECTMARBOOKIN=L.ID_(+) "
                                   + "AND (B.BILLETID LIKE 'H%' OR B.BILLETID LIKE 'Z%') "
                                   + where
                                   + "";
                    }
                    else
                    {
                        sql = "SELECT 'FALSE' FLAG,SUBSTR(A.ORDERNO,1,LENGTH(A.ORDERNO)-3)PACTNO,C.PACTINDEX PLANNUMBER,"
                                   + "A.ROLLNUMBER,A.ORDERNO,A.STOVENO,TO_CHAR(B.BUTTRESS)BUTTRESS,B.CONDOLENUMBER,"
                                   + "A.BILLETID,A.INSTEEL,A.DETERMINANTCARDNUMBER,A.PLY,A.WIDTH,A.LENGTH,A.THEORYWEIGHT,"
                                   + "D.NAME_ RULE,E.NAME_ CUTSIDESTATE,F.NAME_ DETERMINANTRESULT,"
                                   + "I.NAME_ FACEQUALITY,''STANDROLLERROLL,"
                                   + "L.NAME_ DETECTMARBOOKIN "


                                   + ",B.REMARK,"




                                   + "A.DETECTMARBOOKIN KDETECT "


                                   + "FROM KCJ_STORAGELIST_ZW A,KCJ_STORAGEBUTTRESSLIST_ZW B,SEL_PACTDETAIL C,SCM_BASE_INFO D,SCM_BASE_INFO E, "
                                   + "SCM_BASE_INFO F,SCM_BASE_INFO I,"
                                   + "SCM_BASE_INFO L  "
                                   + "WHERE B.BILLETID=A.BILLETID AND A.ORDERNO=C.ORDERNO(+) AND A.STORAGESTATUS='501002' AND C.SENDSTATUS=E.ID_(+) "
                                   + "AND A.RULE=D.ID_(+)  AND A.DETERMINANTRESULT=F.ID_(+) "
                                   + "AND A.FACEQUALITY=I.ID_(+) "
                                   + "AND A.DETECTMARBOOKIN=L.ID_(+) "
                                   + "AND (B.BILLETID LIKE 'E%' OR B.BILLETID LIKE 'Y%' OR B.BILLETID LIKE 'B%') "
                                   + where;
                    }
                }
                else
                {
                    if (strlx == "1")
                    {
                        sql = "SELECT 'FALSE' FLAG,C.PACTNO,C.PACTINDEX PLANNUMBER,"
                                   + "A.ROLLNUMBER,A.ORDERNO,A.STOVENO,TO_CHAR(B.BUTTRESS)BUTTRESS,B.CONDOLENUMBER,"
                                   + "A.BILLETID,A.INSTEEL,A.DETERMINANTCARDNUMBER,A.PLY,A.WIDTH,A.LENGTH,A.THEORYWEIGHT,"
                                   + "D.NAME_ RULE,E.NAME_ CUTSIDESTATE,F.NAME_ DETERMINANTRESULT,"
                                   + "I.NAME_ FACEQUALITY,''STANDROLLERROLL,"
                                   + "L.NAME_ DETECTMARBOOKIN"


                                   + ",B.REMARK,"




                                   + "A.DETECTMARBOOKIN KDETECT "


                                   + "FROM KCJ_TURNOFFLIST_ZW A,KCJ_TURNOFFBUTTRESSLIST_ZW B,SEL_PACTDETAIL C,SCM_BASE_INFO D,SCM_BASE_INFO E,"
                                   + "SCM_BASE_INFO F,SCM_BASE_INFO I,"
                                   + "SCM_BASE_INFO L  "
                                   + "WHERE B.BILLETID=A.BILLETID AND A.ORDERNO=C.ORDERNO(+) AND A.STORAGESTATUS='501602' AND C.SENDSTATUS=E.ID_(+) "
                                   + "AND A.RULE=D.ID_(+)  AND A.DETERMINANTRESULT=F.ID_(+) "
                                   + "AND A.FACEQUALITY=I.ID_(+) "
                                   + "AND A.DETECTMARBOOKIN=L.ID_(+) "
                                   + "AND (B.BILLETID LIKE 'H%' OR B.BILLETID LIKE 'Z%') "
                                   + where
                                   + "";
                    }
                    else
                    {
                        sql = "SELECT 'FALSE' FLAG,C.PACTNO,C.PACTINDEX PLANNUMBER,"
                                   + "A.ROLLNUMBER,A.ORDERNO,A.STOVENO,TO_CHAR(B.BUTTRESS)BUTTRESS,B.CONDOLENUMBER,"
                                   + "A.BILLETID,A.INSTEEL,A.DETERMINANTCARDNUMBER,A.PLY,A.WIDTH,A.LENGTH,A.THEORYWEIGHT,"
                                   + "D.NAME_ RULE,E.NAME_ CUTSIDESTATE,F.NAME_ DETERMINANTRESULT,"
                                   + "I.NAME_ FACEQUALITY,''STANDROLLERROLL,"
                                   + "L.NAME_ DETECTMARBOOKIN "


                                   + ",B.REMARK,"




                                   + "A.DETECTMARBOOKIN KDETECT "


                                   + "FROM KCJ_TURNOFFLIST_ZW A,KCJ_TURNOFFBUTTRESSLIST_ZW B,SEL_PACTDETAIL C,SCM_BASE_INFO D,SCM_BASE_INFO E, "
                                   + "SCM_BASE_INFO F,SCM_BASE_INFO I,"
                                   + "SCM_BASE_INFO L  "
                                   + "WHERE B.BILLETID=A.BILLETID AND A.ORDERNO=C.ORDERNO(+) AND A.STORAGESTATUS='501602' AND C.SENDSTATUS=E.ID_(+) "
                                   + "AND A.RULE=D.ID_(+)  AND A.DETERMINANTRESULT=F.ID_(+) "
                                   + "AND A.FACEQUALITY=I.ID_(+) "
                                   + "AND A.DETECTMARBOOKIN=L.ID_(+) "
                                   + "AND (B.BILLETID LIKE 'E%' OR B.BILLETID LIKE 'Y%' OR B.BILLETID LIKE 'B%') "
                                   + where;
                    }
                }
                System.Data.DataSet rtndst = this.DBManager.ExecuteQuery(sql, out err);
                if (rtndst != null && rtndst.Tables.Count == 1 && rtndst.Tables[0].Rows.Count > 0)
                {
                    rtndst.Tables[0].TableName = "KCJ_TURNOFFBUTTRESSLIST_VIEW";
                    return new ReturnObject(rtndst);
                }
                else
                {
                    return new ReturnObject(null);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null, 10000, ex.ToString());
            }
        }
        /// <summary>
        ///根据明细号获取发运信息
        /// </summary>
        /// <param name="ListCoding"></param>
        /// <returns></returns>
        public ReturnObject GetListData(string ListCoding,string strlx)
        {
            try
            {
                string sql = "SELECT A.PLANVEHICLEID,A.TRAINWAGON,A.CERTIFICATENO,A.PACTNO,D.BUYERNAME CUSTOMER,C.INCEPTCORPNAME,"
                            + "A.PICKSTORAGETIME,A.CLASSORDER,A.CLASSTEAM,A.PICKSTORAGEMAN "
                            + "FROM KCJ_TURNOFFSENDLIST_ZW A,SEL_PACTDETAIL B,SEL_INCEPTCORPINFO C,SEL_BUYERBASEINFO D   WHERE B.BUYERCODE=D.BUYERCODE(+) AND B.INCEPTCORPCODE=C.INCEPTCORPCODE(+) AND A.ORDERFORMNUMBER=B.ORDERNO(+) AND A.LISTNUMBER='" + ListCoding + "' "
                            + "AND A.ISVALID<>'0' AND ROWNUM=1";
                string err = "";
                System.Data.DataSet rtndst = this.DBManager.ExecuteQuery(sql, out err);
                if (rtndst != null && rtndst.Tables.Count == 1 && rtndst.Tables[0].Rows.Count > 0)
                {
                    return new ReturnObject(rtndst);
                }
                return new ReturnObject(null);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }

        /// <summary>
        /// 获取明细编码
        /// </summary>
        /// <param name="type"></param>
        /// <param name="Year"></param>
        /// <returns></returns>
        public ReturnObject GetListCoding(string type, string Year)
        {
            try
            {
                string err = "";
                Oracle.DataAccess.Client.OracleParameter ptype = new Oracle.DataAccess.Client.OracleParameter("vtype", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pYear = new Oracle.DataAccess.Client.OracleParameter("vYear", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pListCoding = new Oracle.DataAccess.Client.OracleParameter("vListCoding", Oracle.DataAccess.Client.OracleDbType.Varchar2);

                ptype.Direction = ParameterDirection.Input;
                pYear.Direction = ParameterDirection.Input;
                pListCoding.Direction = ParameterDirection.Output;

                ptype.Value = type;
                pYear.Value = Year;

                pListCoding.Size = 400;
                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJZW_GetListCoding", CommandType.StoredProcedure,
                    new Oracle.DataAccess.Client.OracleParameter[] { ptype, pYear, pListCoding }, out err);
                return new ReturnObject(FixDBManager.CheckNullStr(pListCoding.Value));
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        /// <summary>
        /// 获取板块合同号
        /// </summary>
        /// <param name="BiletID"></param>
        /// <returns></returns>
        public ReturnObject GetListOrderData(string BiletID,string strlx)
        {
            try
            {
                string sql = "";
                if (strlx == "YL")
                {
                    sql = "SELECT SUBSTR(F.ORDERNO,1,LENGTH(F.ORDERNO)-3) FROM KCJ_STORAGELIST_ZW F  WHERE  BILLETID='" + BiletID + "'"

                                + " AND ROWNUM=1";
                }
                else
                {
                    sql = "SELECT SUBSTR(F.ORDERNO,1,LENGTH(F.ORDERNO)-3) FROM KCJ_TURNOFFLIST_ZW F  WHERE  BILLETID='" + BiletID + "'"

                              + " AND ROWNUM=1";
                }
                string err = "";
                System.Data.DataSet rtndst = this.DBManager.ExecuteQuery(sql, out err);
                if (rtndst != null && rtndst.Tables.Count == 1 && rtndst.Tables[0].Rows.Count > 0)
                {
                    return new ReturnObject(rtndst);
                }
                return new ReturnObject(null);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        private string[] GetPrintDataSqlYL(string ListCoding)
        {
            string Sql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.CLIPTYPEPROCESS='103001' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                        + "A.ORDERBUYER ROLLNO,TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET,"
                        + "A.ADDWEIGHT WEIGHT,A.SERIALNUMBER,"//SUBSTR(A.SERIALNUMBER,INSTR(A.SERIALNUMBER,'.',1)+1,LENGTH(A.SERIALNUMBER)-INSTR(A.SERIALNUMBER,'.',1)) 
                        + " '' PICKSTORAGETIME,(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=A.CLIPTYPEPROCESS)  CUTSIDE "
                        + "FROM KCJ_TURNOFFSENDLIST_ZW A,KCJ_STORAGELIST_ZW B WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND A.SERIALNUMBER=B.BILLETID "
                        + "AND A.LISTNUMBER='" + ListCoding + "' ORDER BY A.STEELTYPE,A.ORDERBUYER";
            //双定
            string SSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.CLIPTYPEPROCESS='103001' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND A.ROLE='102203' AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.WIDTH,A.LENGTH,A.DETERMINANTRESULT,A.CLIPTYPEPROCESS";
            //定长
            string CSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.CLIPTYPEPROCESS='103001' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.LENGTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND A.ROLE='102201' AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.LENGTH,A.DETERMINANTRESULT,A.CLIPTYPEPROCESS";
            //定宽
            string KSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.CLIPTYPEPROCESS='103001' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND (A.ROLE='102202' OR A.ROLE='102206') AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.WIDTH,A.DETERMINANTRESULT,A.CLIPTYPEPROCESS";
            //非定
            string FSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.CLIPTYPEPROCESS='103001' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'非' SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND (A.ROLE='102204' OR A.ROLE='102205') AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.DETERMINANTRESULT,A.CLIPTYPEPROCESS";
          
                Sql = string.Format(Sql, " ");
                SSql = string.Format(SSql, " ");
                KSql = string.Format(KSql, " ");
                CSql = string.Format(CSql, " ");
                FSql = string.Format(FSql, " ");
          
            //zw 2008-04-07
            string[] rtnSql = new string[] { Sql, SSql, KSql, CSql, FSql };//,FSql 
            return rtnSql;
        }
        //获取板材加工打印明细的数据
        public ReturnObject GetPrintData(string ListCoding, string strlx, string strRole, string strllx)
        {
            try
            {
                System.Data.DataSet rtndst = new DataSet();
                string tmpRollNO = "";
                int tmpCount = 0;
                System.Decimal tmpWeight = 0;
                string SendType = "";
                string JBFlag = "";
                string err = "";
                string sql = "SELECT SENDTYPE FROM KCJ_TURNOFFSENDLIST_ZW WHERE ISVALID<>'0'  AND LISTNUMBER='" + ListCoding + "'";
                System.Data.DataSet tmpdst = this.DBManager.ExecuteQuery(sql, out err);
                if (tmpdst != null && tmpdst.Tables.Count == 1 && tmpdst.Tables[0].Rows.Count > 0)
                {
                    SendType = FixDBManager.CheckNullStr(tmpdst.Tables[0].Rows[0][0]);
                    
                }
                else
                {
                    return new ReturnObject(null);
                }
                tmpdst = null;
                #region "形成打印头"
                string Top = GetPrintTopSql(SendType,  ListCoding);
                tmpdst = this.DBManager.ExecuteQuery(Top, out err);
                if (tmpdst != null && tmpdst.Tables.Count == 1 && tmpdst.Tables[0].Rows.Count > 0)
                {
                    tmpdst.Tables[0].TableName = "TOP";
                    rtndst.Merge(tmpdst.Copy());
                }
                else
                {
                    return new ReturnObject(null);
                }
                #endregion

                #region "形成打印数据源"
               
                    string[] DataSql = new string[10];
                    if (strllx=="YL")
                    {
                        DataSql = GetPrintDataSqlYL(ListCoding);
                    }
                    else
                    {

                    DataSql = GetPrintDataSql(ListCoding);
                    }
                  
                   
                 

                    for (int idx = 0; idx < DataSql.Length; idx++)
                    {
                        tmpdst = null;
                        tmpdst = this.DBManager.ExecuteQuery(DataSql[idx], out err);
                        if (tmpdst != null && tmpdst.Tables.Count == 1 && tmpdst.Tables[0].Rows.Count > 0)
                        {
                            tmpdst.Tables[0].TableName = "DATA";
                            rtndst.Merge(tmpdst.Copy());
                            if (idx == 0)
                            {
                                for (int i = 0; i < rtndst.Tables["DATA"].Rows.Count; i++)
                                {
                                    if (tmpRollNO != "" && tmpRollNO != FixDBManager.CheckNullStr(rtndst.Tables["DATA"].Rows[i]["ROLLNO"]))
                                    {
                                        System.Data.DataRow nrow = rtndst.Tables["DATA"].NewRow();
                                        nrow["SERIALNUMBER"] = "小计：";
                                        if (strlx == "3")
                                        {
                                            nrow["SPET"] = FixDBManager.CheckNullStr(tmpCount) + " 卷";
                                        }
                                        else
                                        {
                                            nrow["SPET"] = FixDBManager.CheckNullStr(tmpCount) + " 张";
                                        }
                                        nrow["WEIGHT"] = tmpWeight;
                                        rtndst.Tables["DATA"].Rows.InsertAt(nrow, i);
                                        i = i + 1;
                                        tmpRollNO = FixDBManager.CheckNullStr(rtndst.Tables["DATA"].Rows[i]["ROLLNO"]);
                                        tmpCount = 1;
                                        tmpWeight = FixDBManager.CheckNullDecimal(rtndst.Tables["DATA"].Rows[i]["WEIGHT"]);
                                    }
                                    else
                                    {
                                        tmpRollNO = FixDBManager.CheckNullStr(rtndst.Tables["DATA"].Rows[i]["ROLLNO"]);
                                        tmpCount = tmpCount + 1;
                                        tmpWeight = tmpWeight + FixDBManager.CheckNullDecimal(rtndst.Tables["DATA"].Rows[i]["WEIGHT"]);
                                    }

                                }
                                System.Data.DataRow nrow1 = rtndst.Tables["DATA"].NewRow();
                                nrow1["SERIALNUMBER"] = "小计：";
                                if (strlx == "3")
                                {
                                    nrow1["SPET"] = FixDBManager.CheckNullStr(tmpCount) + " 卷";
                                }
                                else
                                {
                                    nrow1["SPET"] = FixDBManager.CheckNullStr(tmpCount) + " 张";
                                }

                                nrow1["WEIGHT"] = tmpWeight;
                                rtndst.Tables["DATA"].Rows.InsertAt(nrow1, rtndst.Tables["DATA"].Rows.Count);
                                System.Data.DataRow nrow2 = rtndst.Tables["DATA"].NewRow();
                                nrow2["STEELTYPE"] = "按规格";
                                nrow2["SERIALNUMBER"] = "分类统计";
                                rtndst.Tables["DATA"].Rows.Add(nrow2);
                            }
                        }
                        else
                        {
                            if (idx == 0)
                                return new ReturnObject(null);
                        }
                    
                }
              

                #endregion
                if (rtndst.Tables.Count == 2)
                    return new ReturnObject(rtndst);
                return new ReturnObject(null);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        private string[] GetPrintDataSql(string ListCoding)
        {
            string Sql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.FACEQUALITY='512602' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                        + "A.ROLLNO ROLLNO,TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET,"
                        + "A.ADDWEIGHT WEIGHT,A.SERIALNUMBER,"//SUBSTR(A.SERIALNUMBER,INSTR(A.SERIALNUMBER,'.',1)+1,LENGTH(A.SERIALNUMBER)-INSTR(A.SERIALNUMBER,'.',1)) 
                        + "  TO_CHAR(A.PICKSTORAGETIME,'YY-MM-DD')PICKSTORAGETIME,(SELECT NAME_ FROM SCM_BASE_INFO WHERE ID_=C.SENDSTATUS)  CUTSIDE "
                        + "FROM KCJ_TURNOFFSENDLIST_ZW A,KCJ_TURNOFFLIST_ZW B ,SEL_PACTDETAIL C WHERE A.ISVALID<>'0' AND A.ORDERFORMNUMBER=C.ORDERNO(+) AND A.SERIALNUMBER=B.BILLETID "
                        + "AND A.LISTNUMBER='" + ListCoding + "' ORDER BY A.STEELTYPE,A.ORDERBUYER,A.CREATTIME ASC ";
            //双定
            string SSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.FACEQUALITY='512602' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH)||'×'||TO_CHAR(A.LENGTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND A.ROLE='102203' AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.WIDTH,A.LENGTH,A.DETERMINANTRESULT,A.FACEQUALITY";
            //定长
            string CSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.FACEQUALITY='512602' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.LENGTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND A.ROLE='102201' AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.LENGTH,A.DETERMINANTRESULT,A.FACEQUALITY";
            //定宽
            string KSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.FACEQUALITY='512602' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'×'||TO_CHAR(A.WIDTH) SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND (A.ROLE='102202' OR A.ROLE='102206') AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.WIDTH,A.DETERMINANTRESULT,A.FACEQUALITY";
            //非定
            string FSql = "SELECT (CASE WHEN A.DETERMINANTRESULT LIKE '401403%' AND A.FACEQUALITY='512602' THEN '次品' ELSE A.STEELTYPE END) STEELTYPE,"
                         + "TO_CHAR(COUNT(A.SERIALNUMBER))||'张' SERIALNUMBER,"
                         + "TO_CHAR(A.PLY)||'非' SPET,"
                         + "SUM(A.ADDWEIGHT) WEIGHT,NULL SERIALNUMBER,NULL PICKSTORAGETIME,NULL CUTSIDE "
                         + "FROM KCJ_TURNOFFSENDLIST_ZW A "
                         + "WHERE A.ISVALID<>'0' AND A.DUMMYSENDFLAG<>'1' AND (A.ROLE='102204' OR A.ROLE='102205') AND A.LISTNUMBER='" + ListCoding + "' "
                         + "GROUP BY A.STEELTYPE,A.PLY,A.DETERMINANTRESULT,A.FACEQUALITY";
        
                Sql = string.Format(Sql, " ");
                SSql = string.Format(SSql, " ");
                KSql = string.Format(KSql, " ");
                CSql = string.Format(CSql, " ");
                FSql = string.Format(FSql, " ");
          
            string[] rtnSql = new string[] { Sql, SSql, KSql, CSql, FSql };//,FSql 
            return rtnSql;
        }
      
        private string GetPrintTopSql(string SendType,  string ListCoding)
        {
   

            //正式
            string sql = "SELECT T1.*,T2.QUANTITY,T2.WEIGHT FROM "
                + "("
                + "SELECT (substr(a.orderformnumber,1,length(a.orderformnumber)-3))PACTNO,CASE WHEN A.ORDERFORMNUMBER LIKE '17%' THEN '新钢贸易（北京）有限公司' ELSE B.BUYERCODE END BUYERCODE,C.ASKPLAN_ID ASKPLAN_ID,D.STATIONNAME,"
                +" CASE WHEN (SELECT COUNT(1) FROM SEL_INCEPTCORPINFO WHERE INCEPTCORPCODE=A.inceptcorpcode)>0 THEN "
                +" (SELECT INCEPTCORPNAME FROM SEL_INCEPTCORPINFO WHERE INCEPTCORPCODE=A.inceptcorpcode) "
                +" WHEN (SELECT COUNT(1) FROM tbz00_customer WHERE CUST_CD=A.inceptcorpcode)>0 THEN "
                +" (SELECT CUST_NM FROM tbz00_customer WHERE CUST_CD=A.inceptcorpcode) "
                + " END INCEPTCORPNAME,"
                +"TO_CHAR(A.PICKSTORAGETIME,'YYYY-MM-DD') PICKSTORAGETIME,"
                + "A.TRAINWAGON,F.BUYERNAME,A.LISTNUMBER,A.REMARK,NULL CREATOR "
                + "FROM KCJ_TURNOFFSENDLIST_ZW A,SEL_PACTDETAIL B,KCJ_PLAN C,SEL_STATIONINFO D,SEL_INCEPTCORPINFO E,SEL_BUYERBASEINFO F "
                + "WHERE A.PLANVEHICLEID=C.ASKPLAN_ID AND A.ORDERFORMNUMBER=B.ORDERNO(+)  AND B.STATIONCODE=D.STATIONCODE(+) "
                + "AND B.BUYERCODE=F.BUYERCODE(+) AND A.ISVALID<>'0' AND A.LISTNUMBER='" + ListCoding + "' AND ROWNUM=1 "
               
                + ") T1 "
                + "LEFT JOIN "
                + "("
                + "SELECT COUNT(SERIALNUMBER) QUANTITY,SUM(ADDWEIGHT) WEIGHT,LISTNUMBER FROM KCJ_TURNOFFSENDLIST_ZW "
                + "WHERE ISVALID<>'0' AND DUMMYSENDFLAG<>'1' GROUP BY LISTNUMBER "
                + ") T2 ON T1.LISTNUMBER=T2.LISTNUMBER";

                    return sql;
        }
        //提交发运新增
        public ReturnObject CommitAddSendList(System.Collections.ArrayList Billets, System.Collections.ArrayList SendInfo, string SendType)
        {
            try
            {
                string err = "";
                Oracle.DataAccess.Client.OracleParameter pBillets = new Oracle.DataAccess.Client.OracleParameter("vBillets", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSendInfo = new Oracle.DataAccess.Client.OracleParameter("vSendInfo", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSendType = new Oracle.DataAccess.Client.OracleParameter("vSendType", Oracle.DataAccess.Client.OracleDbType.Varchar2);
  
                Oracle.DataAccess.Client.OracleParameter pFaileInfo = new Oracle.DataAccess.Client.OracleParameter("vFaileInfo", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSuccessFlag = new Oracle.DataAccess.Client.OracleParameter("vSuccessFlag", Oracle.DataAccess.Client.OracleDbType.Varchar2);

                pBillets.Direction = ParameterDirection.Input;
                pSendInfo.Direction = ParameterDirection.Input;
                pSendType.Direction = ParameterDirection.Input;
            
                pFaileInfo.Direction = ParameterDirection.Output;
                pSuccessFlag.Direction = ParameterDirection.Output;

                pBillets.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
                pSendInfo.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
                pFaileInfo.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;

                pBillets.Value = Billets.ToArray(typeof(string));
                pSendInfo.Value = SendInfo.ToArray(typeof(string));
                pSendType.Value = SendType;
                

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

                int[] NSizeInf = new int[SendInfo.Count];
                for (int i = 0; i < SendInfo.Count; i++)
                {
                    NSizeInf[i] = 200;
                }
                pSendInfo.Size = SendInfo.Count;
                pSendInfo.ArrayBindSize = NSizeInf;

                int OutSize = 200;
                int[] OutSizeInf = new int[OutSize];
                for (int i = 0; i < OutSize; i++)
                {
                    OutSizeInf[i] = 2000;
                }

                pFaileInfo.Size = OutSize;
                pFaileInfo.ArrayBindSize = OutSizeInf;
                pSuccessFlag.Size = 400;

                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJ_STORAGEMANAGER_WX.ADDSENDLIST_P", CommandType.StoredProcedure,
                        new Oracle.DataAccess.Client.OracleParameter[] { pBillets, pSendInfo, pFaileInfo, pSuccessFlag }, out err);

                    if (FixDBManager.CheckNullStr(pSuccessFlag.Value).Length > 0 | FixDBManager.CheckNullStr(err).Length > 0)
                    {
                        return new ReturnObject(null, 1, pSuccessFlag.Value.ToString() + err);
                    }
                    else
                    {
                        Oracle.DataAccess.Types.OracleString[] FaileInfo = (Oracle.DataAccess.Types.OracleString[])pFaileInfo.Value;
                        System.Collections.ArrayList rtnList = new ArrayList();
                        if (FaileInfo.Length > 0)
                        {
                            for (int i = 0; i < FaileInfo.Length; i++)
                            {
                                rtnList.Add(FaileInfo[i].Value);
                            }
                        }
                        if (rtnList.Count > 0)
                        {
                            return new ReturnObject(rtnList);
                        }
                        else
                        {
                            return new ReturnObject('1');
                        }
                    }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                return new ReturnObject(null);
            }
        }
        public ReturnObject DelSendList(System.Collections.ArrayList Billets, System.Collections.ArrayList SendInfo, string strlx)
        {
            try
            {
                string err = "";
                Oracle.DataAccess.Client.OracleParameter pBillets = new Oracle.DataAccess.Client.OracleParameter("vBillets", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSendInfo = new Oracle.DataAccess.Client.OracleParameter("vSendInfo", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSuccessFlag = new Oracle.DataAccess.Client.OracleParameter("vSuccessFlag", Oracle.DataAccess.Client.OracleDbType.Varchar2);

                pBillets.Direction = ParameterDirection.Input;
                pSendInfo.Direction = ParameterDirection.Input;
                pSuccessFlag.Direction = ParameterDirection.Output;
                pBillets.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;
                pSendInfo.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;

                pBillets.Value = Billets.ToArray(typeof(string));
                pSendInfo.Value = SendInfo.ToArray(typeof(string));

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

                int[] NSizeInf = new int[SendInfo.Count];
                for (int i = 0; i < SendInfo.Count; i++)
                {
                    NSizeInf[i] = 200;
                }
                pSendInfo.Size = SendInfo.Count;
                pSendInfo.ArrayBindSize = NSizeInf;

                pSuccessFlag.Size = 400;

                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJ_STORAGEMANAGER_WX.DELSENDLIST_P", CommandType.StoredProcedure,
                           new Oracle.DataAccess.Client.OracleParameter[] { pBillets, pSendInfo, pSuccessFlag }, out err);
              
                if (FixDBManager.CheckNullStr(pSuccessFlag.Value).Length > 0 | FixDBManager.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);
            }
        }
        public ReturnObject addDJ(ArrayList arbilletid, ArrayList ar)
        {


            try
            {
                string err = "";
                Oracle.DataAccess.Client.OracleParameter pScids = new Oracle.DataAccess.Client.OracleParameter("vScids", 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);

                pScids.Direction = ParameterDirection.Input;
                pOtherInfo.Direction = ParameterDirection.Input;
                pSuccessFlag.Direction = ParameterDirection.Output;

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

                pScids.Value = arbilletid.ToArray(typeof(string));
                pOtherInfo.Value = ar.ToArray(typeof(string));

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

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

                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJ_STORAGEMANAGER_WX.KCJ_PACTNO_ADD", CommandType.StoredProcedure,
                    new Oracle.DataAccess.Client.OracleParameter[] { pScids, 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());
            }
        }

        public ReturnObject CommitLoadVecihle(System.Collections.ArrayList LoadInfo, string type)
        {
            try
            {
                string err = "1";
                Oracle.DataAccess.Client.OracleParameter pLoadInfo = new Oracle.DataAccess.Client.OracleParameter("vLoadInfo", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pType = new Oracle.DataAccess.Client.OracleParameter("vType", Oracle.DataAccess.Client.OracleDbType.Varchar2);
                Oracle.DataAccess.Client.OracleParameter pSuccessFlag = new Oracle.DataAccess.Client.OracleParameter("vSuccessFlag", Oracle.DataAccess.Client.OracleDbType.Varchar2);

                pLoadInfo.Direction = ParameterDirection.Input;
                pType.Direction = ParameterDirection.Input;
                pSuccessFlag.Direction = ParameterDirection.Output;

                pLoadInfo.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray;

                //pLoadInfo.Value = LoadInfo.ToArray(typeof(string));
                if (LoadInfo.Count > 0)
                    pLoadInfo.Value = LoadInfo.ToArray(typeof(string));
                else
                    pLoadInfo.Value = new string[] { "Empty" };


                pType.Value = type;

                int[] OSizeInf = new int[LoadInfo.Count];
                for (int i = 0; i < LoadInfo.Count; i++)
                {
                    OSizeInf[i] = 200;
                }
                pLoadInfo.Size = LoadInfo.Count;
                pLoadInfo.ArrayBindSize = OSizeInf;
                pSuccessFlag.Size = 400;

                ((STMes.DBManager)DBManagerList["ODPDBZW"]).ExecuteNonQuery_NoDBSever("KCJ_STORAGEMANAGER_WX.LOADVECIHLE_BC", CommandType.StoredProcedure,
                new Oracle.DataAccess.Client.OracleParameter[] { pLoadInfo, pType, pSuccessFlag }, out err);
                err = pSuccessFlag.Value.ToString();
                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);
            }
        }
    }
}
