Esempio n. 1
0
        public void startPackno(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            //通过工单的数量和包规来生成箱号

            OleExec   Sfcdb     = this.DBPools["SFCDB"].Borrow();
            string    packType  = Data["packType"].ToString();
            string    wo        = Data["wo"].ToString();
            WorkOrder workorder = new WorkOrder();

            workorder.Init(wo, Sfcdb);

            T_C_PACKING t_C_PACKING = new T_C_PACKING(Sfcdb, DBTYPE);
            C_PACKING   c_PACKING   = t_C_PACKING.GetPackingBySkuAndType(workorder.SkuNO, packType, Sfcdb);
            double?     qty         = c_PACKING.MAX_QTY;

            int         packs       = (int)(workorder.WORKORDER_QTY / qty);
            string      ruleName    = c_PACKING.SN_RULE;
            T_R_PACKING t_r_packing = new T_R_PACKING(Sfcdb, DBTYPE);

            int remainQty = 0;

            if (packs * qty < workorder.WORKORDER_QTY)
            {
                remainQty = (int)(workorder.WORKORDER_QTY - packs * qty);
                packs     = packs + 1;
            }
            for (int i = 0; i < packs; i++)
            {
                string nextpackno = SNmaker.GetNextSN(ruleName, Sfcdb);
                System.Console.WriteLine(nextpackno);
                Row_R_PACKING row_r_packing = (Row_R_PACKING)t_r_packing.NewRow();

                row_r_packing.IP          = this.IP;
                row_r_packing.STATION     = "STARTPARTNO";
                row_r_packing.LINE        = "LINE0";
                row_r_packing.EDIT_EMP    = this.LoginUser.EMP_NO;
                row_r_packing.EDIT_TIME   = DateTime.Now;
                row_r_packing.CREATE_TIME = DateTime.Now;
                row_r_packing.CLOSED_FLAG = "0";
                row_r_packing.QTY         = 0;
                if (packs == i && remainQty > 0)
                {
                    row_r_packing.MAX_QTY = remainQty;
                }
                else
                {
                    row_r_packing.MAX_QTY = qty;
                }
                row_r_packing.SKUNO          = workorder.SkuNO;
                row_r_packing.PARENT_PACK_ID = "";
                row_r_packing.PACK_TYPE      = packType;
                row_r_packing.PACK_NO        = nextpackno;
                row_r_packing.ID             = t_r_packing.GetNewID(this.BU, Sfcdb);

                Sfcdb.ExecSQL(row_r_packing.GetInsertString(DBTYPE));
            }


            StationReturn.Status = StationReturnStatusValue.Pass;
        }
Esempio n. 2
0
        public void DataLoad(string packNo, string bu, OleExec sfcdb, DB_TYPE_ENUM DBType)
        {
            List <string>  itemList       = new List <string>();
            T_C_SKU        t_c_sku        = new T_C_SKU(sfcdb, DBType);
            T_R_PACKING    t_r_packing    = new T_R_PACKING(sfcdb, DBType);
            T_R_SN_PACKING t_r_sn_packing = new T_R_SN_PACKING(sfcdb, DBType);
            T_R_SN         t_r_sn         = new T_R_SN(sfcdb, DBType);
            T_C_PACKING    t_c_packing    = new T_C_PACKING(sfcdb, DBType);
            R_PACKING      packing        = new R_PACKING();
            C_SKU          sku            = new C_SKU();
            Packing        packObject     = new Packing();
            C_PACKING      c_packing      = new C_PACKING();

            packing = t_r_packing.GetRPackingByPackNo(sfcdb, packNo).GetDataObject();
            sku     = t_c_sku.GetSku(packing.SKUNO, sfcdb, DBType).GetDataObject();
            if (packing.PACK_TYPE == LogicObject.PackType.PALLET.ToString().ToUpper())
            {
                c_packing = t_c_packing.GetPackingBySkuAndType(sku.SKUNO, LogicObject.PackType.CARTON.ToString().ToUpper(), sfcdb);
                if (c_packing.MAX_QTY == 1 && bu.ToUpper().Equals("VERTIV"))
                {
                    //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN
                    itemList = t_r_packing.GetPakcingSNList(packing.ID, sfcdb);
                }
                else
                {
                    List <R_PACKING> packingList = t_r_packing.GetListPackByParentPackId(packing.ID, sfcdb);
                    foreach (R_PACKING pack in packingList)
                    {
                        itemList.Add(pack.PACK_NO);
                    }
                }
            }
            else if (packing.PACK_TYPE == LogicObject.PackType.CARTON.ToString().ToUpper())
            {
                List <Row_R_SN_PACKING> snPackingList = t_r_sn_packing.GetPackItem(packing.ID, sfcdb);
                foreach (Row_R_SN_PACKING sn in snPackingList)
                {
                    itemList.Add(t_r_sn.GetById(sn.SN_ID, sfcdb).SN);
                }
            }
            this.PackID       = packing.ID;
            this.PackNo       = packing.PACK_NO;
            this.PackType     = packing.PACK_TYPE;
            this.ParentPackID = packing.PARENT_PACK_ID;
            this.Skuno        = packing.SKUNO;
            this.SkunoVer     = sku.VERSION;
            this.MaxQty       = packing.MAX_QTY;
            this.Qty          = packing.QTY;
            this.ClosedFlag   = packing.CLOSED_FLAG;
            this.CreatTime    = packing.CREATE_TIME;
            this.EditTime     = packing.EDIT_TIME;
            this.EditEmp      = packing.EDIT_EMP;
            this.Line         = packing.LINE;
            this.Station      = packing.STATION;
            this.IP           = packing.IP;
            this.PackList     = itemList;
        }
Esempio n. 3
0
 /// <summary>
 /// 加載對應的包裝規格
 /// </summary>
 /// <param name="PackType"></param>
 /// <param name="DB"></param>
 public SKU LoadPacking(string PackType, OleExec DB)
 {
     if (!this.SkuBase.ID.Equals(""))
     {
         T_C_PACKING table = new T_C_PACKING(DB, this._DBType);
         this.Packing = table.GetPackingBySkuAndType(this.SkuBase.SKUNO, PackType, DB);
         return(this);
     }
     else
     {
         throw new MESReturnMessage("Please ensure the C_SKU property is not null before using other methods.");
     }
 }
Esempio n. 4
0
        public static Row_R_PACKING GetNewPacking(C_PACKING config, string line, string Station, string IP, string BU, string User, OleExec DB)
        {
            T_R_PACKING   TRP = new T_R_PACKING(DB, DB_TYPE_ENUM.Oracle);
            Row_R_PACKING RRP = (Row_R_PACKING)TRP.NewRow();

            RRP.PACK_NO        = SNMaker.SNmaker.GetNextSN(config.SN_RULE, DB);
            RRP.PACK_TYPE      = config.PACK_TYPE;
            RRP.PARENT_PACK_ID = "";
            RRP.SKUNO          = config.SKUNO;
            RRP.MAX_QTY        = config.MAX_QTY;
            RRP.QTY            = 0;
            RRP.CLOSED_FLAG    = "0";
            RRP.LINE           = line;
            RRP.STATION        = Station;
            RRP.ID             = TRP.GetNewID(BU, DB);
            RRP.IP             = IP;
            DB.ExecSQL(RRP.GetInsertString(DB_TYPE_ENUM.Oracle));
            RRP.AcceptChange();
            return(RRP);
        }
Esempio n. 5
0
        public static void CartionAndPalletAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec SFCDB = Station.SFCDB;
            string  Run   = "";

            try
            {
                Run = (Station.StationSession.Find(T => T.MESDataType == Paras[0].SESSION_TYPE && T.SessionKey == Paras[0].SESSION_KEY).Value).ToString();
                if (Run.ToUpper() == "FALSE")
                {
                    return;
                }
            }
            catch
            {
            }
            MESStationSession sessionSN = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionSN == null)
            {
                throw new System.Exception("sessionSN miss ");
            }

            MESStationSession sessionCartion = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionCartion == null)
            {
                throw new System.Exception("sessionCartion miss ");
            }

            MESStationSession sessionPallet = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (sessionPallet == null)
            {
                throw new System.Exception("sessionPallet miss ");
            }

            MESStationSession sessionPrintPL = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_PL" && t.SessionKey == "1");

            if (sessionPrintPL == null)
            {
                sessionPrintPL = new MESStationSession()
                {
                    MESDataType = "ISPRINT_PL", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintPL);
            }
            sessionPrintPL.Value = "FALSE";
            MESStationSession sessionPrintCTN = Station.StationSession.Find(t => t.MESDataType == "ISPRINT_CTN" && t.SessionKey == "1");

            if (sessionPrintCTN == null)
            {
                sessionPrintCTN = new MESStationSession()
                {
                    MESDataType = "ISPRINT_CTN", SessionKey = "1", Value = "FALSE"
                };
                Station.StationSession.Add(sessionPrintCTN);
            }
            sessionPrintCTN.Value = "FALSE";

            SN SN = (SN)sessionSN.Value;

            if (SN.isPacked(Station.SFCDB))
            {
                throw new System.Exception($@"{SN.SerialNo} is packed!");
            }

            CartionBase cartion = (CartionBase)sessionCartion.Value;
            PalletBase  Pallet  = (PalletBase)sessionPallet.Value;



            cartion.Add(SN, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

            if (cartion.DATA.MAX_QTY <= cartion.GetCount(Station.SFCDB))
            {
                sessionPrintCTN.Value = "TRUE";
                //設置打印變量
                MESStationSession CTNPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_CTN" && T.SessionKey == "1");
                if (CTNPrintSession == null)
                {
                    CTNPrintSession = new MESStationSession()
                    {
                        MESDataType = "PRINT_CTN", SessionKey = "1"
                    };
                    Station.StationSession.Add(CTNPrintSession);
                }
                CTNPrintSession.Value = cartion.DATA.PACK_NO;
                T_C_PACKING      TCP           = new T_C_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                List <C_PACKING> PackConfigs   = TCP.GetPackingBySku(SN.SkuNo, Station.SFCDB);
                C_PACKING        CartionConfig = PackConfigs.Find(T => T.PACK_TYPE == "CARTION");
                C_PACKING        PalletConfig  = PackConfigs.Find(T => T.PACK_TYPE == "PALLET");
                if (CartionConfig == null)
                {
                    throw new Exception("Can't find CartionConfig");
                }
                if (PalletConfig == null)
                {
                    throw new Exception("Can't find PalletConfig");
                }
                if (Pallet.DATA.MAX_QTY <= Pallet.GetCount(Station.SFCDB))
                {
                    sessionPrintPL.Value = "TRUE";
                    //設置打印變量
                    MESStationSession PlPrintSession = Station.StationSession.Find(T => T.MESDataType == "PRINT_PL" && T.SessionKey == "1");
                    if (PlPrintSession == null)
                    {
                        PlPrintSession = new MESStationSession()
                        {
                            MESDataType = "PRINT_PL", SessionKey = "1"
                        };
                        Station.StationSession.Add(PlPrintSession);
                    }
                    PlPrintSession.Value = Pallet.DATA.PACK_NO;

                    Pallet.DATA.CLOSED_FLAG = "1";
                    Pallet.DATA.EDIT_TIME   = DateTime.Now;
                    Pallet.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                    Station.SFCDB.ExecSQL(Pallet.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));

                    Pallet.DATA = PackingBase.GetNewPacking(PalletConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
                }
                cartion.DATA.CLOSED_FLAG = "1";
                cartion.DATA.EDIT_TIME   = DateTime.Now;
                cartion.DATA.EDIT_EMP    = Station.LoginUser.EMP_NO;
                Station.SFCDB.ExecSQL(cartion.DATA.GetUpdateString(DB_TYPE_ENUM.Oracle));
                cartion.DATA = PackingBase.GetNewPacking(CartionConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);

                Pallet.Add(cartion, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            sessionCartion.Value = cartion;
            sessionPallet.Value  = Pallet;

            cartion.DATA.AcceptChange();
            Pallet.DATA.AcceptChange();
        }
Esempio n. 6
0
        public static void LoadPackingBySkuStation(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            MESStationSession sessionSKU = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionSKU == null)
            {
                throw new Exception("Can't load session SKU");
            }
            LogicObject.SKU   SKU           = (LogicObject.SKU)sessionSKU.Value;
            MESStationSession sessionCarton = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionCarton == null)
            {
                sessionCarton = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, SessionKey = Paras[1].SESSION_KEY
                };
                Station.StationSession.Add(sessionCarton);
            }

            MESStationSession sessionPallet = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionPallet == null)
            {
                sessionPallet = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, SessionKey = Paras[2].SESSION_KEY
                };
                Station.StationSession.Add(sessionPallet);
            }

            T_C_PACKING      TCP           = new T_C_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            List <C_PACKING> PackConfigs   = TCP.GetPackingBySku(SKU.SkuNo, Station.SFCDB);
            C_PACKING        CartionConfig = PackConfigs.Find(T => T.PACK_TYPE == "CARTON");
            C_PACKING        PalletConfig  = PackConfigs.Find(T => T.PACK_TYPE == "PALLET");

            if (CartionConfig == null)
            {
                throw new Exception("Can't find CartionConfig");
            }
            if (PalletConfig == null)
            {
                throw new Exception("Can't find PalletConfig");
            }

            T_R_PACKING   TRP        = new T_R_PACKING(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            Row_R_PACKING RowCartion = null;

            try
            {
                RowCartion = (Row_R_PACKING)TRP.GetObjBySelect($@"select * from R_PACKING where SKUNO='{SKU.SkuNo}' 
and PACK_TYPE='{CartionConfig.PACK_TYPE}' 
and LINE='{Station.Line}' 
and STATION='{Station.StationName}' 
and IP='{Station.IP}' and CLOSED_FLAG='0'", Station.SFCDB, DB_TYPE_ENUM.Oracle);
            }
            catch
            {
                RowCartion = Packing.PackingBase.GetNewPacking(CartionConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }

            Row_R_PACKING RowPallet = null;

            try
            {
                RowPallet = (Row_R_PACKING)TRP.GetObjBySelect($@"select * from R_PACKING where SKUNO='{SKU.SkuNo}' 
and PACK_TYPE='{PalletConfig.PACK_TYPE}' 
and LINE='{Station.Line}' 
and STATION='{Station.StationName}' 
and IP='{Station.IP}' and CLOSED_FLAG='0'", Station.SFCDB, DB_TYPE_ENUM.Oracle);
            }
            catch
            {
                RowPallet = Packing.PackingBase.GetNewPacking(PalletConfig, Station.Line, Station.StationName, Station.IP, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }
            Packing.CartionBase Cartion = new Packing.CartionBase(RowCartion);
            Packing.PalletBase  Pallet  = new Packing.PalletBase(RowPallet);
            if (Cartion.DATA.PARENT_PACK_ID == null || Cartion.DATA.PARENT_PACK_ID == "")
            {
                Pallet.Add(Cartion, Station.BU, Station.LoginUser.EMP_NO, Station.SFCDB);
            }

            sessionCarton.Value = Cartion;
            sessionPallet.Value = Pallet;
        }
Esempio n. 7
0
        /// <summary>
        /// 移棧板或卡通內的數據
        /// add by fgg 2018.06.08
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void MovePackingSessionValue(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 8)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057", new string[] { }));
            }

            MESStationSession sessionOne = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            if (sessionOne.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }

            MESStationSession sessionTwo = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }
            if (sessionTwo.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }

            MESStationSession sessionValue = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (sessionValue == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }
            if (sessionValue.Value.ToString() == "")
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY }));
            }

            MESStationSession sessionItemListOne = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (sessionItemListOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY }));
            }

            MESStationSession sessionItemListTwo = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY);

            if (sessionItemListTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[4].SESSION_TYPE + Paras[4].SESSION_KEY }));
            }

            MESStationSession sessionCountOne = Station.StationSession.Find(t => t.MESDataType == Paras[5].SESSION_TYPE && t.SessionKey == Paras[5].SESSION_KEY);

            if (sessionCountOne == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[5].SESSION_TYPE + Paras[5].SESSION_KEY }));
            }

            MESStationSession sessionCountTwo = Station.StationSession.Find(t => t.MESDataType == Paras[6].SESSION_TYPE && t.SessionKey == Paras[6].SESSION_KEY);

            if (sessionCountTwo == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[6].SESSION_TYPE + Paras[6].SESSION_KEY }));
            }

            R_Station_Action_Para moveFlag = Paras[7];

            bool moveToRight;

            if (moveFlag.VALUE.ToString().Equals("0"))
            {
                moveToRight = true;
            }
            else if (moveFlag.VALUE.ToString().Equals("1"))
            {
                moveToRight = false;
            }
            else
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[7].SESSION_TYPE + Paras[7].SESSION_KEY }));
            }

            try
            {
                LogicObject.Packing packOne        = (LogicObject.Packing)sessionOne.Value;;
                LogicObject.Packing packTwo        = (LogicObject.Packing)sessionTwo.Value;;
                string              result         = "";
                T_R_PACKING         t_r_packing    = new T_R_PACKING(Station.SFCDB, Station.DBType);
                T_R_SN_PACKING      t_r_sn_packing = new T_R_SN_PACKING(Station.SFCDB, Station.DBType);
                T_R_SN              t_r_sn         = new T_R_SN(Station.SFCDB, Station.DBType);
                T_R_MOVE_LIST       t_r_move_list  = new T_R_MOVE_LIST(Station.SFCDB, Station.DBType);
                T_C_PACKING         t_c_packing    = new T_C_PACKING(Station.SFCDB, Station.DBType);
                LogicObject.Packing packOneObject  = new LogicObject.Packing();
                LogicObject.Packing packTwoObject  = new LogicObject.Packing();
                R_SN            r_sn;
                Row_R_MOVE_LIST rowMoveList;
                Row_R_PACKING   rowPacking;
                C_PACKING       c_packing = new C_PACKING();
                if (packOne.ClosedFlag == "0")
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packOne.PackNo }));
                }
                if (packTwo.ClosedFlag == "0")
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180613090152", new string[] { packTwo.PackNo }));
                }
                if (!packOne.PackType.Equals(packTwo.PackType))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612114250", new string[] { packOne.PackNo, packTwo.PackNo }));
                }
                if (!packOne.Skuno.Equals(packTwo.Skuno))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141141", new string[] { packOne.PackNo, packTwo.PackNo }));
                }
                if (!packOne.SkunoVer.Equals(packTwo.SkunoVer))
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141356", new string[] { packOne.PackNo, packTwo.PackNo }));
                }

                Newtonsoft.Json.Linq.JArray moveValueArray = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(sessionValue.Value.ToString());

                if (packOne.PackType == LogicObject.PackType.PALLET.ToString().ToUpper())
                {
                    for (int i = 0; i < moveValueArray.Count; i++)
                    {
                        c_packing = t_c_packing.GetPackingBySkuAndType(packTwo.Skuno, LogicObject.PackType.CARTON.ToString().ToUpper(), Station.SFCDB);
                        if (c_packing.MAX_QTY == 1 && Station.BU.ToUpper().Equals("VERTIV"))
                        {
                            //更新棧板號
                            //VERTIV 當卡通包規為1時,調棧板顯示卡通內的SN,故更新信息另外處理
                            R_PACKING packingObjectTemp = t_r_packing.GetPackingObjectBySN(moveValueArray[i].ToString(), Station.SFCDB);
                            if (packingObjectTemp == null)
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180620114012", new string[] { moveValueArray[i].ToString() }));
                            }
                            if (!t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packOne.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                            }
                            if (t_r_packing.CheckPackNoExistByParentPackID(packingObjectTemp.PACK_NO, packTwo.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                            }
                            result     = t_r_packing.UpdateParentPackIDByPackNo(packingObjectTemp.PACK_NO, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                            rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, packingObjectTemp.PACK_NO);
                        }
                        else
                        {
                            if (!t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packOne.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                            }
                            if (t_r_packing.CheckPackNoExistByParentPackID(moveValueArray[i].ToString(), packTwo.PackID, Station.SFCDB))
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                            }
                            //更新棧板號
                            result     = t_r_packing.UpdateParentPackIDByPackNo(moveValueArray[i].ToString(), packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                            rowPacking = t_r_packing.GetRPackingByPackNo(Station.SFCDB, moveValueArray[i].ToString());
                        }
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        //寫入記錄

                        rowMoveList               = (Row_R_MOVE_LIST)t_r_move_list.NewRow();
                        rowMoveList.ID            = t_r_move_list.GetNewID(Station.BU, Station.SFCDB);
                        rowMoveList.MOVE_ID       = rowPacking.ID;
                        rowMoveList.FROM_LOCATION = packOne.PackID;
                        rowMoveList.TO_LOCATION   = packTwo.PackID;
                        rowMoveList.PACK_TYPE     = packOne.PackType;
                        rowMoveList.MOVE_EMP      = Station.LoginUser.EMP_NO;
                        rowMoveList.MOVE_DATE     = Station.GetDBDateTime();
                        result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType));
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" }));
                        }
                    }
                }
                else if (packOne.PackType == LogicObject.PackType.CARTON.ToString().ToUpper())
                {
                    for (int i = 0; i < moveValueArray.Count; i++)
                    {
                        r_sn = new R_SN();
                        r_sn = t_r_sn.GetDetailBySN(moveValueArray[i].ToString(), Station.SFCDB);
                        if (!t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packOne.PackID, Station.SFCDB))
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141600", new string[] { moveValueArray[i].ToString(), packOne.PackNo }));
                        }
                        if (t_r_sn_packing.CheckSNExistByPackID(r_sn.ID, packTwo.PackID, Station.SFCDB))
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612141824", new string[] { moveValueArray[i].ToString(), packTwo.PackNo }));
                        }
                        //更新卡通號
                        result = t_r_sn_packing.UpdatePackIDBySnID(r_sn.ID, packTwo.PackID, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_SN_PACKING" }));
                        }

                        result = t_r_packing.UpdateQtyByID(packTwo.PackID, true, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }
                        result = t_r_packing.UpdateQtyByID(packOne.PackID, false, 1, Station.LoginUser.EMP_NO, Station.SFCDB);
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000025", new string[] { "R_PACKING" }));
                        }

                        //寫入記錄
                        rowMoveList               = (Row_R_MOVE_LIST)t_r_move_list.NewRow();
                        rowMoveList.ID            = t_r_move_list.GetNewID(Station.BU, Station.SFCDB);
                        rowMoveList.MOVE_ID       = r_sn.ID;
                        rowMoveList.FROM_LOCATION = packOne.PackID;
                        rowMoveList.TO_LOCATION   = packTwo.PackID;
                        rowMoveList.PACK_TYPE     = packOne.PackType;
                        rowMoveList.MOVE_EMP      = Station.LoginUser.EMP_NO;
                        rowMoveList.MOVE_DATE     = Station.GetDBDateTime();
                        result = Station.SFCDB.ExecSQL(rowMoveList.GetInsertString(Station.DBType));
                        if (Convert.ToInt32(result) == 0)
                        {
                            throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { "R_MOVE_LIST" }));
                        }
                    }
                }
                else
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180607163531", new string[] { "Pack:" + packOne.PackType }));
                }
                //關閉卡通或棧板
                result = t_r_packing.UpdateCloseFlagByPackID(packOne.PackID, "1", Station.SFCDB);
                if (Convert.ToInt32(result) == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packOne.PackNo }));
                }
                //關閉卡通或棧板
                result = t_r_packing.UpdateCloseFlagByPackID(packTwo.PackID, "1", Station.SFCDB);
                if (Convert.ToInt32(result) == 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180612154506", new string[] { packTwo.PackNo }));
                }

                packOneObject.DataLoad(packOne.PackNo, Station.BU, Station.SFCDB, Station.DBType);
                packTwoObject.DataLoad(packTwo.PackNo, Station.BU, Station.SFCDB, Station.DBType);
                sessionOne.Value = packOneObject;
                sessionTwo.Value = packTwoObject;
                if (moveToRight)
                {
                    sessionItemListOne.Value = packOneObject.PackList;
                    sessionItemListTwo.Value = packTwoObject.PackList;
                    sessionCountOne.Value    = packOneObject.PackList.Count;
                    sessionCountTwo.Value    = packTwoObject.PackList.Count;
                }
                else
                {
                    sessionItemListOne.Value = packTwoObject.PackList;
                    sessionItemListTwo.Value = packOneObject.PackList;
                    sessionCountOne.Value    = packTwoObject.PackList.Count;
                    sessionCountTwo.Value    = packOneObject.PackList.Count;
                }
                Station.StationMessages.Add(new StationMessage()
                {
                    Message = MESReturnMessage.GetMESReturnMessage("MSGCODE20180612142034", new string[] { packOne.PackNo.ToString(), moveValueArray.Count.ToString(), packTwo.PackNo.ToString() }),
                    State   = StationMessageState.Pass
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }