예제 #1
0
        private bool CartonPack()
        {
            if (this.ucLabelRCardForCarton.Value.Trim() == "")
            {
                this.SetInputMessageByFlowControl();
                return(false);
            }
            string rcard = FormatHelper.CleanString(this.ucLabelRCardForCarton.Value.Trim().ToUpper());

            //转换成起始序列号
            if (_face == null)
            {
                _face = new DataCollectFacade(this.DataProvider);
            }
            string sourceCard = _face.GetSourceCard(rcard, string.Empty);

            //end

            if (this.ucLabelCartonNo.Value.Trim() == "")
            {
                m_FlowControl = 1;
                this.SetInputMessageByFlowControl();
                return(false);
            }

            #region RCard Length Check
            if (chkCardLen.Checked && chkCardLen.Value.Trim().Length > 0)
            {
                if (rcard.Length != Convert.ToInt32(chkCardLen.Value.Replace("-", "")))
                {
                    ucMessage.AddEx(this._FunctionName, "$CS_RCARD: " + this.ucLabelRCardForCarton.Value, new UserControl.Message(MessageType.Error, "$CS_CARD_NO_LEN_CHECK_FAIL"), false);
                    this.m_FlowControl = 3;
                    this.SetInputMessageByFlowControl();
                    return(false);
                }
            }
            #endregion
            #region RCard First Char Check
            if (chkCardFChar.Checked && chkCardFChar.Value.Trim().Length > 0)
            {
                if (rcard.IndexOf(chkCardFChar.Value.Trim()) != 0)
                {
                    ucMessage.AddEx(this._FunctionName, "$CS_RCARD: " + this.ucLabelRCardForCarton.Value, new UserControl.Message(MessageType.Error, "$CS_CARD_NO_FCHAR_CHECK_FAIL"), false);
                    this.m_FlowControl = 3;
                    this.SetInputMessageByFlowControl();
                    return(false);
                }
            }
            #endregion

            ucMessage.AddWithoutEnter("<<");
            ucMessage.AddBoldText(ucLabelRCardForCarton.Value.Trim());

            if (!checkRcard(rcard, sourceCard))
            {
                this.m_FlowControl = 3;
                this.SetInputMessageByFlowControl();
                return(false);
            }

            Simulation objSimulation = _face.GetSimulation(sourceCard.Trim().ToUpper()) as Simulation;
            string     lastAction    = objSimulation.LastAction.Trim();

            ItemFacade itemFacade = new ItemFacade(DataProvider);
            Item       item       = itemFacade.GetItem((objSimulation as Simulation).ItemCode.ToUpper().Trim(), GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item;
            string     newMOCode  = objSimulation.MOCode.Trim().ToUpper();

            PackageFacade pf = new PackageFacade(DataProvider);
            //check产品序列号是否重复包装
            //object rcardobj = pf.GetCarton2RCARD("", sourceCard.Trim().ToUpper());
            object rcardobj = pf.GetCarton2RcardByRcard(sourceCard.Trim().ToUpper());
            if (rcardobj != null)
            {
                ucMessage.AddEx(this._FunctionName, "$CS_CARTON_NO: " + ((Carton2RCARD)rcardobj).CartonCode, new UserControl.Message(MessageType.Error, "$CS_CARD_HAS_PACKED"), false);
                this.m_FlowControl = 3;
                this.SetInputMessageByFlowControl();
                return(false);
            }

            string cartonNo = FormatHelper.CleanString(ucLabelCartonNo.Value.Trim().ToUpper());

            #region OQC检查
            //modified by lisa@2012-8-29
            //1,序列号是维修回流过来的,即属于未判定的LOT并且不属于任何小箱,应该装在之前的箱中。
            OQCFacade _OQCFacade     = new OQCFacade(this.DataProvider);
            object    lot2Card       = _OQCFacade.GetOQCLot2Card(sourceCard.Trim().ToUpper(), newMOCode, "", "");
            Boolean   blnCheckCarton = true;
            if (lot2Card != null)
            {
                OQCLot oqcLot = _OQCFacade.GetOQCLot((lot2Card as OQCLot2Card).LOTNO, OQCFacade.Lot_Sequence_Default) as OQCLot;
                if (!(oqcLot.LOTStatus == OQCLotStatus.OQCLotStatus_Reject || oqcLot.LOTStatus == OQCLotStatus.OQCLotStatus_Rejecting ||
                      oqcLot.LOTStatus == OQCLotStatus.OQCLotStatus_Pass || oqcLot.LOTStatus == OQCLotStatus.OQCLotStatus_Passing))
                {
                    if ((!String.IsNullOrEmpty(((OQCLot2Card)lot2Card).EAttribute1)) && cartonNo != ((OQCLot2Card)lot2Card).EAttribute1.ToString())
                    {
                        ucMessage.AddEx(this._FunctionName, " ", new UserControl.Message(MessageType.Error, "$RCard:" + sourceCard + "$ShouedPackInCarton:" + ((OQCLot2Card)lot2Card).EAttribute1.ToString()), false);
                        this.m_FlowControl = 3;
                        this.SetInputMessageByFlowControl();
                        return(false);
                    }

                    if ((!String.IsNullOrEmpty(((OQCLot2Card)lot2Card).EAttribute1)) && cartonNo == ((OQCLot2Card)lot2Card).EAttribute1.ToString())
                    {
                        blnCheckCarton = false;
                    }
                }
            }

            //2,产品序列号是新的,或者是返工回来的,则不能放入已归属了Lot的小箱
            if (blnCheckCarton)
            {
                object objLot2Carton = _OQCFacade.GetLot2CartonByCartonNo(cartonNo);
                if (objLot2Carton != null)
                {
                    ucMessage.AddEx(this._FunctionName, "$CS_CARTON_NO: " + this.ucLabelCartonNo.Value, new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_OQC"), false);
                    this.m_FlowControl = 1;
                    this.SetInputMessageByFlowControl();
                    return(false);
                }
            }
            #endregion


            #region check箱
            if (!checkCarton(cartonNo))
            {
                return(false);
            }


            //check一个箱子只能放一个类型的产品,并且只能放一个工单的产品
            object[] objects = pf.GetCarton2RCARDByCartonNO(cartonNo);
            if (objects != null)
            {
                string oldMOCode = ((Carton2RCARD)objects[0]).MOCode.Trim().ToUpper();
                if (newMOCode != oldMOCode)
                {
                    ucMessage.AddEx(this._FunctionName, "", new UserControl.Message(MessageType.Error, "$OneCarton_OneMoCode"), true);
                    this.m_FlowControl = 3;
                    this.SetInputMessageByFlowControl();
                    return(false);
                }
                object obj = pf.GetItemCodeByMOCode(oldMOCode);
                if (obj != null)
                {
                    if (item.ItemCode != ((CartonCollection)obj).ItemCode)
                    {
                        ucMessage.AddEx(this._FunctionName, "", new UserControl.Message(MessageType.Error, "$OneCarton_OneProduct"), true);
                        this.m_FlowControl = 3;
                        this.SetInputMessageByFlowControl();
                        return(false);
                    }
                }
            }
            #endregion
            // 包装动作
            this.AfterToSave();
            return(true);
        }