Exemplo n.º 1
0
        private void edtCarton_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (this.edtMoCode.Value.Trim() == string.Empty)
                {
                    ApplicationRun.GetInfoForm().AddEx("$CS_CMPleaseInputMO");
                    this.edtMoCode.TextFocus(true, true);
                    return;
                }

                if (this.edtCarton.Value.Trim() == string.Empty)
                {
                    this.edtCarton.TextFocus(true, true);
                    return;
                }

                Package.PackageFacade packageFacade = new BenQGuru.eMES.Package.PackageFacade(this.DataProvider);

                SKDCartonDetail skdCartonDetail = (SKDCartonDetail)packageFacade.QuerySKDCartobDetailWithCarton(FormatHelper.CleanString(this.edtCarton.Value.Trim().ToUpper()));

                if (skdCartonDetail != null && skdCartonDetail.moCode.Trim().ToUpper() != FormatHelper.CleanString(this.edtMoCode.Value.Trim().ToUpper()))
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_CartonNO_Have_Used $CS_Param_MOCode:" + skdCartonDetail.moCode.Trim().ToUpper()));
                    this.edtCarton.TextFocus(true, true);
                    return;
                }

                this.LoadData();
                this.edtItemCode.TextFocus(true, true);
            }
        }
Exemplo n.º 2
0
        //Process for Carton No
        private void ProcessCarton(string cartonno)
        {
            //Laws Lu,2006/05/27	包装到Carton
            Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);

            object objCarton = pf.GetCARTONINFO(cartonno);


            Domain.Package.CARTONINFO carton = null;
            if (objCarton != null)
            {
                carton = objCarton as  Domain.Package.CARTONINFO;
                if (carton.CAPACITY <= carton.COLLECTED)
                {
                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT"), false);
                }
                else
                {
                    ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(">>$CS_Please_Input_RunningCard"), false);
                }
                txtMemo.Value = carton.EATTRIBUTE1;
                //pf.UpdateCARTONINFO(carton);
                this.UpdateGrid(cartonno);
            }
            else if (cartonno != String.Empty)
            {
                //carton = objCarton as  Domain.Package.CARTONINFO;

                carton            = new BenQGuru.eMES.Domain.Package.CARTONINFO();
                carton.PKCARTONID = System.Guid.NewGuid().ToString();
                carton.CAPACITY   = 0;              //((new ItemFacade(DataProvider)).GetItem(oqcLotAddIDEventArgs.CurrentItemRoute2OP.ItemCode) as Item).ItemCartonQty;
                carton.COLLECTED  = 0;
                carton.PKCARTONID = System.Guid.NewGuid().ToString().ToUpper();
                carton.CARTONNO   = cartonno;
                carton.MUSER      = ApplicationService.Current().UserCode;

                //Laws Lu,2006/11/13 uniform system collect date
                DBDateTime dbDateTime;

                dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                carton.MDATE       = dbDateTime.DBDate;
                carton.MTIME       = dbDateTime.DBTime;
                carton.EATTRIBUTE1 = FormatHelper.CleanString(this.txtMemo.Value, 40);

                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(">>$CS_Please_Input_RunningCard"), false);
                //carton.

                //pf.AddCARTONINFO(carton);
            }

            _carton = carton;

            UpdateCartonQty();


            //End
        }
Exemplo n.º 3
0
        // Added by Icyer 2006/12/05
        private void TakeDownCarton(ActionEventArgs actionEventArgs)
        {
            bool        bDo     = false;
            ProductInfo product = actionEventArgs.ProductInfo;

            if (System.Configuration.ConfigurationSettings.AppSettings["TakeDownCartonReMORework"] == "1" &&
                product != null &&
                product.NowSimulation != null &&
                product.LastSimulation != null &&
                product.NowSimulation.MOCode != product.LastSimulation.MOCode &&
                product.LastSimulation.CartonCode != string.Empty)
            {
                MOFacade moFacade = new MOFacade(this.DataProvider);
                MO       mo       = (MO)moFacade.GetMO(product.NowSimulation.MOCode);
                if (mo == null)
                {
                    return;
                }
                BenQGuru.eMES.BaseSetting.SystemSettingFacade sysFacade = new SystemSettingFacade(this.DataProvider);
                Parameter param = (Parameter)sysFacade.GetParameter(mo.MOType, BenQGuru.eMES.Web.Helper.MOType.GroupType);
                if (param != null &&
                    param.ParameterValue == BenQGuru.eMES.Web.Helper.MOType.MOTYPE_REWORKMOTYPE)
                {
                    bDo = true;
                }
            }
            if (bDo == false)
            {
                return;
            }

            BenQGuru.eMES.Package.PackageFacade packageFacade = new BenQGuru.eMES.Package.PackageFacade(this.DataProvider);

            string strSql = "UPDATE tblSimulation SET CartonCode='' WHERE RCard='" + product.LastSimulation.LotCode + "' AND MOCode='" + product.LastSimulation.MOCode + "' ";

            this.DataProvider.CustomExecute(new SQLCondition(strSql));

            strSql = "UPDATE tblSimulationReport SET CartonCode='' WHERE RCard='" + product.LastSimulation.LotCode + "' AND MOCode='" + product.LastSimulation.MOCode + "' ";
            this.DataProvider.CustomExecute(new SQLCondition(strSql));

            packageFacade.SaveRemoveCarton2RCARDLog(product.LastSimulation.CartonCode, product.LastSimulation.LotCode, actionEventArgs.UserCode);

            packageFacade.SubtractCollected(product.LastSimulation.CartonCode);
            product.LastSimulation.CartonCode = string.Empty;
        }
Exemplo n.º 4
0
        private void LoadData()
        {
            Package.PackageFacade packageFacade = new BenQGuru.eMES.Package.PackageFacade(this.DataProvider);

            object[] skdCartonDetailList = packageFacade.QuerySKDCartobDetailWithCapity(this.edtCarton.Value.Trim().ToUpper(),
                                                                                        this.edtMoCode.Value.Trim().ToUpper());
            _DataTableLoadedPart.Clear();
            if (skdCartonDetailList != null)
            {
                foreach (SKDCartonDetailWithCapity skdCartonDetailWithCapity in skdCartonDetailList)
                {
                    _DataTableLoadedPart.Rows.Add(new object[] {
                        false,
                        skdCartonDetailWithCapity.SBItemCode,
                        skdCartonDetailWithCapity.MaterialName,
                        skdCartonDetailWithCapity.planQty,
                        skdCartonDetailWithCapity.cartonQty,
                        skdCartonDetailWithCapity.moQty
                    });
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 插入数据库
        /// </summary>
        private void InsertData(object objIns, ConfigObject cfgObj, string[] rowHeader, string[] rowData)
        {
            // 插入主记录
            if (this.RowDataExist == true)                                 // 数据已存在
            {
                if (this.UpdateRepeatData == DataRepeatDeal.Update)        // 更新
                {
                    if (objIns is BenQGuru.eMES.Domain.Package.PKRuleStep) //包装规则做特殊检查 joe song 20080220
                    {
                        BenQGuru.eMES.Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(this.dataProvider);
                        pf.UpdatePKRuleStep(objIns as BenQGuru.eMES.Domain.Package.PKRuleStep);
                    }
                    else
                    {
                        this.dataProvider.Update(objIns);
                    }
                }

                else if (this.UpdateRepeatData == DataRepeatDeal.Ignore)    // 忽略
                {
                    throw new Exception("$Import_Unique_Data_Exist");
                }
                else if (this.UpdateRepeatData == DataRepeatDeal.Cancel)    // 终止
                {
                    throw new Exception("$DATA_REPEAT_CANCEL");
                }
            }
            else                                                   // 数据不存在,则Insert
            if (objIns is BenQGuru.eMES.Domain.Package.PKRuleStep) //包装规则做特殊检查 joe song 20080220
            {
                BenQGuru.eMES.Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(this.dataProvider);
                pf.AddPKRuleStep(objIns as BenQGuru.eMES.Domain.Package.PKRuleStep);
            }
            else
            {
                this.dataProvider.Insert(objIns);
            }

            // 插入外部记录
            for (int i = 0; i < cfgObj.FieldList.Count; i++)
            {
                if (cfgObj.FieldList[i].ForeignItem == true)
                {
                    if (cfgObj.FieldList[i].IgnoreForeignWhenNull == true)      // 数据为空则忽略子项
                    {
                        int dataIndex = -1;
                        if (ImportDataMapping == DataMappingType.ByIndex)
                        {
                            if (i < rowHeader.Length)
                            {
                                dataIndex = i;
                            }
                        }
                        else
                        {
                            for (int n = 0; n < rowHeader.Length; n++)
                            {
                                if (rowHeader[n] == cfgObj.FieldList[i].Text ||
                                    UserControl.MutiLanguages.ParserMessage(cfgObj.FieldList[i].Name) == rowHeader[n])
                                {
                                    dataIndex = n;
                                    break;
                                }
                            }
                        }
                        if (dataIndex == -1)
                        {
                            return;
                        }
                        string strValue = rowData[dataIndex].Trim().ToUpper();
                        if (strValue == "")
                        {
                            break;
                        }
                    }

                    ConfigObject foreignCfgObj = cfgObj.FieldList[i].ForeignObject;
                    object       objForeignIns = CreateObjectInstance(foreignCfgObj);
                    AssignDataSubItem(objForeignIns, foreignCfgObj, rowHeader, rowData, objIns, cfgObj);
                    CheckEntityTotal(ref objForeignIns, foreignCfgObj);

                    if (this.RowDataExist == true)                          // 数据已存在
                    {
                        if (this.UpdateRepeatData == DataRepeatDeal.Update) // 更新
                        {
                            //针对用户默认组织
                            if (foreignCfgObj.Type == typeof(BenQGuru.eMES.Domain.BaseSetting.User2Org).ToString())
                            {
                                UpdateUser2Org(objForeignIns);
                            }
                            else
                            {
                                this.dataProvider.Update(objForeignIns);
                            }
                        }
                        else if (this.UpdateRepeatData == DataRepeatDeal.Ignore)    // 忽略
                        {
                            return;
                        }
                        else if (this.UpdateRepeatData == DataRepeatDeal.Cancel)    // 终止
                        {
                            throw new Exception("DATA_REPEAT");
                        }
                    }
                    else    // 数据不存在,则Insert
                    {
                        this.dataProvider.Insert(objForeignIns);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public Messages Execute(ActionEventArgs oqcLotRemoveIDEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);

            try
            {
                ActionOnLineHelper dataCollect     = new ActionOnLineHelper(this.DataProvider);
                ActionOQCHelper    actionOQCHelper = new ActionOQCHelper(this.DataProvider);
                OQCFacade          oqcFacade       = new OQCFacade(this.DataProvider);

                //检查批的状态
                if (!actionOQCHelper.IsOQCLotInitial(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO))
                {
                    throw new Exception("$Error_OQCLotNOIsNotInitial");
                }
                //填写SIMULATION 检查工单、ID、途程、操作
                messages.AddMessages(dataCollect.CheckID(oqcLotRemoveIDEventArgs));
                if (messages.IsSuccess())
                {
                    #region update FQCLotSize,Laws Lu,2005/10/24,修改
                    object obj = oqcFacade.GetOQCLot(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                    if (obj == null)
                    {
                        throw new Exception("$Error_OQCLotNotExisted");
                    }
                    OQCLot oqcLot = obj as OQCLot;
                    oqcLot.LotSize = -1;                    //oqcFacade.GetOQCLotSizeFromOQCLot2Card( ((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO);
                    oqcFacade.UpdateOQCLotSize(oqcLot);
                    #endregion

                    #region OQCADDID 自身的检查

                    //检查批的状态
                    if (actionOQCHelper.IsOQCLotComplete(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO))
                    {
                        throw new Exception("$Error_OQCLotNOHasComplete");
                    }
                    #endregion

                    //把nowsimulation 的actionlist的OqcAdd,oQCDelete,replace为空
                    oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.ActionList = oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.ActionList.Replace(ActionType.DataCollectAction_OQCLotAddID, "");
                    oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.ActionList = oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.ActionList.Replace(ActionType.DataCollectAction_OQCLotRemoveID, "");


                    oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.LOTNO = String.Empty;

                    /* added by jessie lee, 2006/6/20
                     * Power0063:包装时,如果从抽检批中删除一个产品,应该从包装箱中删除此产品。 */
                    string cartoncode = string.Empty;
                    if (oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.CartonCode != null &&
                        oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.CartonCode.Length > 0)
                    {
                        cartoncode = oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.CartonCode;
                        oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.CartonCode = string.Empty;
                    }

                    messages.AddMessages(dataCollect.Execute(oqcLotRemoveIDEventArgs));

                    if (messages.IsSuccess())
                    {
                        //删除对应OQCLot2Card,如果是最后一个则删除对应OQCLot
                        #region OQC
                        object objLot2Card = oqcFacade.GetOQCLot2Card(oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.RunningCard, oqcLotRemoveIDEventArgs.ProductInfo.NowSimulation.MOCode, ((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                        if (objLot2Card == null)
                        {
                            throw new Exception("$Error_OQClot2CardNotExisted");
                        }
                        oqcFacade.DeleteOQCLot2Card((OQCLot2Card)objLot2Card);
                        object[] objs = oqcFacade.ExactQueryOQCLot2Card(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                        if (objs == null)
                        {
                            //删除OQCLot2ErrorCode
                            oqcFacade.DeleteOQCLot2ErrorCode(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default.ToString());
                            //删除OQCLOTCheckList
                            obj = oqcFacade.GetOQCLOTCheckList(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                            if (obj != null)
                            {
                                oqcFacade.DeleteOQCLOTCheckList((OQCLOTCheckList)obj);
                            }

                            //删除OQCLot
                            obj = oqcFacade.GetOQCLot(((OQCLotRemoveIDEventArgs)oqcLotRemoveIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                            if (obj == null)
                            {
                                throw new Exception("$Error_OQClotNotExisted");
                            }
                            oqcFacade.DeleteOQCLot((OQCLot)obj);
                        }

                        #endregion

                        /* added by jessie lee, 2006/6/20
                         * Power0063:包装时,如果从抽检批中删除一个产品,应该从包装箱中删除此产品。 */
                        #region Carton
                        if (cartoncode.Length > 0)
                        {
                            Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);
                            object objCarton         = pf.GetCARTONINFO(cartoncode);

                            if (objCarton != null)
                            {
                                BenQGuru.eMES.Domain.Package.CARTONINFO carton = objCarton as BenQGuru.eMES.Domain.Package.CARTONINFO;
                                pf.SubtractCollected((carton as BenQGuru.eMES.Domain.Package.CARTONINFO).CARTONNO);
                            }
                        }
                        #endregion
                        //AMOI  MARK  START  20050806 增加按资源统计产量
                        #region 填写统计报表 按资源统计
                        //ReportHelper reportCollect= new ReportHelper(this.DataProvider);
                        //messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
                        //    ,oqcLotRemoveIDEventArgs.ActionType,oqcLotRemoveIDEventArgs.ProductInfo));
                        #endregion
                        //AMOI  MARK  END
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Exemplo n.º 7
0
        public Messages Execute(ActionEventArgs oqcLotAddIDEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);

            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);
                ActionOQCHelper    oqcHelper   = new ActionOQCHelper(this.DataProvider);
                OQCFacade          oqcFacade   = new OQCFacade(this.DataProvider);
                //填写SIMULATION 检查工单、ID、途程、操作
                messages.AddMessages(dataCollect.CheckID(oqcLotAddIDEventArgs));

                if (messages.IsSuccess())
                {
                    if (((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation == null)
                    {
                        throw new Exception("$System_Error");
                    }

                    #region update FQCLotSize
                    object obj = oqcFacade.GetOQCLot(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                    if (obj == null)
                    {
                        throw new Exception("$Error_OQCLotNotExisted");
                    }
                    OQCLot oqcLot = obj as OQCLot;
                    oqcLot.LotSize = 1;                    //oqcFacade.GetOQCLotSizeFromOQCLot2Card( ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO);
                    //TODO:Laws Lu,2005/10/17,需要修改	更新数量

                    oqcFacade.UpdateOQCLotSize(oqcLot);
                    #endregion

                    #region OQCADDID 自身的检查
                    #region 只是forcase工具使用,真实的情况是从前台已经产生
                    object objOQCLot = oqcFacade.GetOQCLot(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO, OQCFacade.Lot_Sequence_Default);
                    if (objOQCLot == null)
                    {
                        OQCLot newOQCLot = oqcFacade.CreateNewOQCLot();
                        newOQCLot.LOTNO        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO));
                        newOQCLot.AcceptSize   = 0;
                        newOQCLot.AcceptSize1  = 0;
                        newOQCLot.AcceptSize2  = 0;
                        newOQCLot.AQL          = 0;
                        newOQCLot.AQL1         = 0;
                        newOQCLot.AQL2         = 0;
                        newOQCLot.LotSequence  = OQCFacade.Lot_Sequence_Default;
                        newOQCLot.OQCLotType   = "oqclottype_normal";
                        newOQCLot.LotSize      = 0;
                        newOQCLot.LOTStatus    = OQCLotStatus.OQCLotStatus_Initial;
                        newOQCLot.LOTTimes     = 0;
                        newOQCLot.MaintainUser = oqcLotAddIDEventArgs.UserCode;
                        newOQCLot.RejectSize   = 0;
                        newOQCLot.RejectSize1  = 0;
                        newOQCLot.RejectSize2  = 0;
                        newOQCLot.SampleSize   = 0;
                        oqcFacade.AddOQCLot(newOQCLot);
                    }
                    #endregion


                    //检查批的状态
                    if (!oqcHelper.IsOQCLotComplete(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO))
                    {
                        //Write off by Laws Lu/2006/05/25
//						//是否同一ItemCode
//						if( oqcHelper.IsRemixItemCode( ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.ItemCode,((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO))
//						{
//							throw new Exception("$Error_RemixItemCode");
//						}
                        //End Write off

                        //是否混单
                        if (!((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).IsRemixMO)
                        {
                            //如除了正准备的工单号外,还有其他的工单存在则报错
                            if (oqcHelper.IsRemixMOCode(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO, ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.MOCode))
                            {
                                throw new Exception("$Error_RemixMO");
                            }
                        }
                        //一个ID只能属于一个批(reject,pass状态除外)
                        if (!(oqcHelper.IsIDHasOnlyOQCLotNo(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).RunningCard, ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.MOCode, ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO)))
                        {
                            throw new Exception("$Error_IDHasExistedInOtherOQCLotNO");
                        }
                        //检查完工数量
                        if (((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).IsCheckOQCLotMaxSize)
                        {
                            if (oqcHelper.GetIDCountInOQCLotNo(((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO) >= ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotMaxSize)
                            {
                                throw new Exception("$Error_OQClotQtyExceedMaxQty");
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("$Error_OQCLotNOHasComplete");
                    }
                    #endregion
                    string cartonno = (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).CartonNo;

                    oqcLotAddIDEventArgs.ProductInfo.NowSimulation.LOTNO = (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).OQCLotNO;

                    //oqcLotAddIDEventArgs.ProductInfo.NowSimulation.CartonCode = (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).CartonNo;
                    // Added by Icyer 2006/06/07
                    string oldCartonNo = oqcLotAddIDEventArgs.ProductInfo.NowSimulation.CartonCode;
                    if (cartonno != string.Empty)
                    {
                        oqcLotAddIDEventArgs.ProductInfo.NowSimulation.CartonCode = (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).CartonNo;
                    }
                    // Added end
                    //是否该产品是否属于wip的其他站
                    messages.AddMessages(dataCollect.Execute(oqcLotAddIDEventArgs));

                    DBDateTime dbDateTime;
                    //Laws Lu,2006/11/13 uniform system collect date
                    if (oqcLotAddIDEventArgs.ProductInfo.WorkDateTime != null)
                    {
                        dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                        oqcLotAddIDEventArgs.ProductInfo.WorkDateTime = dbDateTime;
                    }
                    else
                    {
                        dbDateTime = oqcLotAddIDEventArgs.ProductInfo.WorkDateTime;
                    }

                    if (messages.IsSuccess())
                    {
                        if (cartonno != string.Empty && cartonno != oldCartonNo)
                        {
                            //Laws Lu,2006/05/27	包装到Carton
                            Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);

                            object objCarton = pf.GetCARTONINFO(cartonno);

                            if (objCarton != null)
                            {
                                BenQGuru.eMES.Domain.Package.CARTONINFO carton = objCarton as BenQGuru.eMES.Domain.Package.CARTONINFO;

                                /* added by jessie lee, 20006/6/20
                                 * Power0086:达到最大包装数量时及时提示 */
                                if (carton.CAPACITY == carton.COLLECTED + 1)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Normal, "$CARTON_ALREADY_FULL_PlEASE_CHANGE"));
                                }
                                //Laws Lu,2006/06/22 modify cancle exception and use message
                                if (carton.CAPACITY <= carton.COLLECTED)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT"));
                                }
                                else
                                {
                                    pf.UpdateCollected((carton as BenQGuru.eMES.Domain.Package.CARTONINFO).CARTONNO);
                                }
                            }
                            else if (cartonno != String.Empty)
                            {
                                //Laws Lu,2006/06/22	modify check if carton exist
                                object objExistCTN = pf.GetExistCARTONINFO(cartonno);

                                if (objExistCTN != null)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FULL_PlEASE_CHANGE"));
                                }
                                else
                                {
                                    BenQGuru.eMES.Domain.Package.CARTONINFO carton = new BenQGuru.eMES.Domain.Package.CARTONINFO();

                                    carton.CAPACITY   = ((new ItemFacade(DataProvider)).GetItem(oqcLotAddIDEventArgs.ProductInfo.NowSimulation.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty;
                                    carton.COLLECTED  = 1 /** oqcLotAddIDEventArgs.ProductInfo.NowSimulation.IDMergeRule*/;
                                    carton.PKCARTONID = System.Guid.NewGuid().ToString().ToUpper();
                                    carton.CARTONNO   = cartonno;
                                    carton.MUSER      = oqcLotAddIDEventArgs.UserCode;



                                    carton.MDATE = dbDateTime.DBDate;
                                    carton.MTIME = dbDateTime.DBTime;
                                    //carton.

                                    //joe song 20060630 Carton Memo
                                    carton.EATTRIBUTE1 = (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).CartonMemo;

                                    if (carton.CAPACITY == 0)                                   //Get carton capacity by item
                                    {
                                        messages.Add(new UserControl.Message(MessageType.Error
                                                                             , "$CS_PLEASE_MAINTEIN_ITEMCARTON $CS_Param_ID =" + oqcLotAddIDEventArgs.RunningCard));
                                    }
                                    else
                                    {
                                        pf.AddCARTONINFO(carton);
                                    }
                                }
                            }
                            //End
                        }
                    }

                    if (messages.IsSuccess())
                    {
                        //填写对应的runningcard 到OQCLotNO
                        #region add OQCLot2Card
                        OQCLot2Card oqcLot2Card = oqcFacade.CreateNewOQCLot2Card();
                        oqcLot2Card.ItemCode            = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.ItemCode;
                        oqcLot2Card.CollectType         = oqcLotAddIDEventArgs.CollectType;
                        oqcLot2Card.LOTNO               = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).OQCLotNO;
                        oqcLot2Card.LotSequence         = OQCFacade.Lot_Sequence_Default;
                        oqcLot2Card.MaintainUser        = oqcLotAddIDEventArgs.UserCode;
                        oqcLot2Card.MaintainDate        = dbDateTime.DBDate;
                        oqcLot2Card.MaintainTime        = dbDateTime.DBTime;
                        oqcLot2Card.MOCode              = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.MOCode;
                        oqcLot2Card.ModelCode           = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.ModelCode;
                        oqcLot2Card.OPCode              = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.OPCode;
                        oqcLot2Card.ResourceCode        = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.ResourceCode;
                        oqcLot2Card.RouteCode           = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.RouteCode;
                        oqcLot2Card.RunningCard         = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.RunningCard;
                        oqcLot2Card.RunningCardSequence = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.RunningCardSequence;
                        oqcLot2Card.SegmnetCode         = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.SegmentCode;
                        oqcLot2Card.ShiftCode           = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.ShiftCode;
                        oqcLot2Card.ShiftTypeCode       = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.ShiftTypeCode;
                        oqcLot2Card.Status              = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.Status;
                        oqcLot2Card.StepSequenceCode    = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.StepSequenceCode;
                        oqcLot2Card.TimePeriodCode      = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulationReport.TimePeriodCode;
                        //oqcLot2Card.EAttribute1 =  (oqcLotAddIDEventArgs as OQCLotAddIDEventArgs).CartonNo;
                        oqcLot2Card.EAttribute1 = oqcLotAddIDEventArgs.ProductInfo.NowSimulation.CartonCode;                    // Added by Icyer 2006/06/08
                        oqcLot2Card.MOSeq       = ((OQCLotAddIDEventArgs)oqcLotAddIDEventArgs).ProductInfo.NowSimulation.MOSeq; // Added by Icyer 2007/07/02    增加 MOSeq 栏位

                        oqcFacade.AddOQCLot2Card(oqcLot2Card);
                        #endregion
                        //AMOI  MARK  START  20050806 增加按资源统计产量
                        #region 填写统计报表 按资源统计
                        //ReportHelper reportCollect= new ReportHelper(this.DataProvider);
                        //messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
                        //    ,oqcLotAddIDEventArgs.ActionType,oqcLotAddIDEventArgs.ProductInfo));
                        #endregion
                        //AMOI  MARK  END
                    }
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Exemplo n.º 8
0
        //Process for Running Card
        private void ProcessRcard(string rcard)
        {
            //1.Get simulation and check it
            DataCollectFacade dcf = new DataCollectFacade(DataProvider);

            //Laws Lu,2007/01/05,新增	缓解性能问题
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            //ActionOnLineHelper onlineHelper = new ActionOnLineHelper(DataProvider);
            Domain.DataCollect.Simulation sim = (new DataCollectFacade(DataProvider)).GetSimulation(rcard)
                                                as Domain.DataCollect.Simulation;

            if (sim == null)           //rcard must exist
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                //txtRCard.TextFocus(true, true);
                return;
            }

            if (sim != null && sim.CartonCode != String.Empty)           //rcard must not link with any carton
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(MessageType.Error
                                                                                                                               , "$CS_RCARD_ALREADY_BELONGTO_CARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                //txtRCard.TextFocus(true, true);
                return;
            }

            sim.CartonCode = txtCartonNO.Value.Trim().ToUpper();

            //2.Get cartion
            int flag = 0;            //Not Need Add

            Domain.MOModel.Item item = ((new ItemFacade(DataProvider)).GetItem(sim.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Domain.MOModel.Item);
            if (_carton.CAPACITY == 0)           //Get carton capacity by item
            {
                flag = 1;

                if (item.ItemCartonQty == 0)
                {
                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                         , "$CS_PLEASE_MAINTEIN_ITEMCARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);
                    //txtRCard.TextFocus(true, true);
                    return;
                }
                _carton.CAPACITY = item.ItemCartonQty;
            }

            //3.set simulation cartoncode by current carton
            DataProvider.BeginTransaction();
            try
            {
                bool isSuccessful = true;

                Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);
                if (flag == 1)               //need add new carton and update simulation
                {
                    _carton.COLLECTED = 1;

                    if (isSuccessful)
                    {
                        //Laws Lu,2006/06/30 support memo
                        _carton.EATTRIBUTE1 = txtMemo.Value.ToUpper().Trim();

                        //更新Carton号
                        dcf.UpdateSimulation(sim);

                        //ProductInfo product = onlineHelper.GetIDInfoBySimulation(sim);
//						Domain.DataCollect.SimulationReport simReport = onlineHelper.FillSimulationReport(product);
//						dcf.UpdateSimulationReport(simReport);
                        dcf.UpdateSimulationReportCartonNo(sim.RunningCard, sim.MOCode, _carton.CARTONNO);

                        //建立新Carton
                        pf.AddCARTONINFO(_carton);
                    }
                }
                else if (_carton.CAPACITY > _carton.COLLECTED)               //just need update carton and simulation
                {
                    if (Convert.ToInt32(_carton.CAPACITY) != item.ItemCartonQty)
                    {
                        isSuccessful = false;
                        ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                             , "$CS_ITEMCARTON_NOT_MATCH_CARTON $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()
                                                                                                                                             + " $CS_CARTON_NO =" + _carton.CARTONNO), false);
                    }

                    if (isSuccessful)
                    {
                        //Laws Lu,2006/06/30 support memo
                        _carton.EATTRIBUTE1 = txtMemo.Value.ToUpper().Trim();
                        //更新Carton号
                        dcf.UpdateSimulation(sim);
                        //ProductInfo product = onlineHelper.GetIDInfoBySimulation(sim);
//						Domain.DataCollect.SimulationReport simReport = onlineHelper.FillSimulationReport(product);
//						dcf.UpdateSimulationReport(simReport);
                        dcf.UpdateSimulationReportCartonNo(sim.RunningCard, sim.MOCode, _carton.CARTONNO);
                        //更新Carton中数量
                        //Laws Lu,2006/06/23	modify support update memo
                        pf.UpdateCollected(_carton.CARTONNO, _carton.EATTRIBUTE1);

                        /* added by jessie lee, 2006/6/16
                         * 更新备注 */
                        //pf.UpdateCARTONINFO(_carton);
                    }
                }
                else
                {
                    isSuccessful = false;
                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Error
                                                                                                                                         , "$CARTON_ALREADY_FILL_OUT"), false);
                }

                if (isSuccessful)
                {
                    DataProvider.CommitTransaction();

                    ucMessage.AddEx(this._FunctionName, this.txtCartonNO.Caption + " " + this.txtCartonNO.Value, new UserControl.Message(MessageType.Success
                                                                                                                                         , "$CS_RCARD_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper()), false);

                    ProcessCarton(txtCartonNO.Value.Trim().ToUpper());
//					if(_carton.COLLECTED != 1)
//					{
//						_carton.COLLECTED = _carton.COLLECTED + 1;
//					}
                    //UpdateCartonQty();
                }
                else
                {
                    DataProvider.RollbackTransaction();
                }
            }
            catch (Exception ex)
            {
                ucMessage.AddEx(this._FunctionName, this.txtRCard.Caption + " " + this.txtRCard.Value, new UserControl.Message(ex), false);
                DataProvider.RollbackTransaction();
            }
            finally
            {
                //Laws Lu,2007/01/05,新增	缓解性能问题
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
//				(DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();

                txtRCard.TextFocus(true, true);
            }
        }
Exemplo n.º 9
0
        public UserControl.Messages Execute(ActionEventArgs cartonPackEventArgs)
        {
            Messages         messages         = new Messages();
            DataCollectDebug dataCollectDebug = new DataCollectDebug(this.GetType().ToString() + "Collect");

            dataCollectDebug.WhenFunctionIn(messages);

            try
            {
                ActionOnLineHelper dataCollect = new ActionOnLineHelper(this.DataProvider);

                messages.AddMessages(dataCollect.CheckID(cartonPackEventArgs));

                if (messages.IsSuccess())
                {
                    if (((CartonPackEventArgs)cartonPackEventArgs).ProductInfo.NowSimulation == null)
                    {
                        throw new Exception("$System_Error");
                    }

                    string cartonno    = (cartonPackEventArgs as CartonPackEventArgs).CartonNo;
                    string oldCartonNo = cartonPackEventArgs.ProductInfo.NowSimulation.CartonCode;
                    if (cartonno != string.Empty)
                    {
                        cartonPackEventArgs.ProductInfo.NowSimulation.CartonCode = (cartonPackEventArgs as CartonPackEventArgs).CartonNo;
                    }

                    //Laws Lu,2005/08/15,新增	完工逻辑,在其他Check都通过的情况下,所有的RunningCard应该是GOOD状态
                    //暂时不考虑线外工序
                    DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                    if (cartonPackEventArgs.ProductInfo.NowSimulation.RouteCode != "" && dataCollectFacade.OPIsMORouteLastOP(
                            cartonPackEventArgs.ProductInfo.NowSimulation.MOCode
                            , cartonPackEventArgs.ProductInfo.NowSimulation.RouteCode
                            , cartonPackEventArgs.ProductInfo.NowSimulation.OPCode))
                    {
                        cartonPackEventArgs.ProductInfo.NowSimulation.IsComplete  = "1";
                        cartonPackEventArgs.ProductInfo.NowSimulation.EAttribute1 = "GOOD";
                        //完工自动入库
                        dataCollectFacade.AutoInventory(cartonPackEventArgs.ProductInfo.NowSimulation, cartonPackEventArgs.UserCode);
                    }
                    //End Laws Lu

                    messages.AddMessages(dataCollect.Execute(cartonPackEventArgs));
                    DBDateTime dbDateTime;
                    if (cartonPackEventArgs.ProductInfo.WorkDateTime != null)
                    {
                        dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                        cartonPackEventArgs.ProductInfo.WorkDateTime = dbDateTime;
                    }
                    else
                    {
                        dbDateTime = cartonPackEventArgs.ProductInfo.WorkDateTime;
                    }
                    if (messages.IsSuccess())
                    {
                        if (cartonno != string.Empty && cartonno != oldCartonNo)
                        {
                            Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider);

                            object objCarton = pf.GetCARTONINFO(cartonno);

                            if (objCarton != null)
                            {
                                BenQGuru.eMES.Domain.Package.CARTONINFO carton = objCarton as BenQGuru.eMES.Domain.Package.CARTONINFO;
                                if (carton.CAPACITY == carton.COLLECTED + 1)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Normal, "$CARTON_ALREADY_FULL_PlEASE_CHANGE"));
                                }

                                if (carton.CAPACITY <= carton.COLLECTED)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FILL_OUT"));
                                }
                                else
                                {
                                    pf.UpdateCollected((carton as BenQGuru.eMES.Domain.Package.CARTONINFO).CARTONNO);
                                }
                            }
                            else if (cartonno != String.Empty)
                            {
                                object objExistCTN = pf.GetExistCARTONINFO(cartonno);

                                if (objExistCTN != null)
                                {
                                    messages.Add(new UserControl.Message(MessageType.Error, "$CARTON_ALREADY_FULL_PlEASE_CHANGE"));
                                }
                                else
                                {
                                    BenQGuru.eMES.Domain.Package.CARTONINFO carton = new BenQGuru.eMES.Domain.Package.CARTONINFO();

                                    carton.CAPACITY   = ((new ItemFacade(DataProvider)).GetItem(cartonPackEventArgs.ProductInfo.NowSimulation.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty;
                                    carton.COLLECTED  = 1 /** oqcLotAddIDEventArgs.ProductInfo.NowSimulation.IDMergeRule*/;
                                    carton.PKCARTONID = System.Guid.NewGuid().ToString().ToUpper();
                                    carton.CARTONNO   = cartonno;
                                    carton.MUSER      = cartonPackEventArgs.UserCode;
                                    carton.MDATE      = dbDateTime.DBDate;
                                    carton.MTIME      = dbDateTime.DBTime;
                                    //carton.

                                    //joe song 20060630 Carton Memo
                                    carton.EATTRIBUTE1 = (cartonPackEventArgs as CartonPackEventArgs).CartonMemo;

                                    if (carton.CAPACITY == 0)//Get carton capacity by item
                                    {
                                        messages.Add(new UserControl.Message(MessageType.Error
                                                                             , "$CS_PLEASE_MAINTEIN_ITEMCARTON $CS_Param_ID =" + cartonPackEventArgs.RunningCard));
                                    }
                                    else
                                    {
                                        if (carton.CAPACITY == carton.COLLECTED)
                                        {
                                            messages.Add(new UserControl.Message(MessageType.Normal, "$CARTON_ALREADY_FULL_PlEASE_CHANGE"));
                                        }

                                        pf.AddCARTONINFO(carton);
                                    }
                                }
                            }

                            // Update lot2card.eattribute1=cartonno
                            OQCFacade oqcFacade = new OQCFacade(this.DataProvider);
                            oqcFacade.UpdateLot2CardCartonCode(cartonPackEventArgs.ProductInfo.NowSimulation.RunningCard,
                                                               cartonPackEventArgs.ProductInfo.NowSimulation.MOCode,
                                                               cartonPackEventArgs.ProductInfo.NowSimulation.ItemCode,
                                                               cartonno);
                        }
                    }

                    // 产生汇总报表
                    //if (messages.IsSuccess())
                    //{
                    //    ReportHelper reportCollect = new ReportHelper(this.DataProvider);
                    //    messages.AddMessages(reportCollect.ReportLineQuanMaster(this.DataProvider, cartonPackEventArgs.ActionType, cartonPackEventArgs.ProductInfo));
                    //    messages.AddMessages(reportCollect.ReportResQuanMaster(this.DataProvider
                    //        , cartonPackEventArgs.ActionType, cartonPackEventArgs.ProductInfo));
                    //}
                }
            }
            catch (Exception e)
            {
                messages.Add(new Message(e));
            }
            dataCollectDebug.WhenFunctionOut(messages);
            return(messages);
        }
Exemplo n.º 10
0
        private void edtItemCode_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (this.edtMoCode.Value.Trim() == string.Empty)
                {
                    ApplicationRun.GetInfoForm().AddEx("$CS_CMPleaseInputMO");
                    this.edtMoCode.TextFocus(true, true);
                    return;
                }

                if (this.edtCarton.Value.Trim() == string.Empty)
                {
                    ApplicationRun.GetInfoForm().AddEx("$CS_PLEASE_INPUT_CARTONNO");
                    this.edtCarton.TextFocus(true, true);
                    return;
                }

                if (ultraGridDetail.Rows.Count <= 0)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_GRID_NO_RECORD"));
                    this.edtItemCode.TextFocus(true, true);
                    return;
                }

                if (!this.CheckGrid())
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_GRID_SELECT_ONE_RECORD"));
                    this.edtItemCode.TextFocus(false, true);
                    return;
                }

                Package.PackageFacade         packageFacade     = new BenQGuru.eMES.Package.PackageFacade(this.DataProvider);
                DataCollect.DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
                ItemFacade itemFacade = new ItemFacade(this.DataProvider);

                SKDCartonDetail skdCartonDetail = (SKDCartonDetail)packageFacade.GetSKDCartonDetail(this.edtMoCode.Value.Trim().ToUpper(),
                                                                                                    this.edtItemCode.Value.Trim().ToUpper());
                if (skdCartonDetail != null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Carton_Have_In_This_moCode"));
                    this.edtItemCode.TextFocus(true, true);
                    return;
                }

                //下面做物料的检查
                Messages msg          = new Messages();
                string   materialCode = string.Empty;

                for (int i = 0; i < ultraGridDetail.Rows.Count; i++)
                {
                    if (ultraGridDetail.Rows[i].Cells[0].Value.ToString().ToLower() == "true")
                    {
                        materialCode = ultraGridDetail.Rows[i].Cells[1].Value.ToString();
                        _itemCode    = materialCode;
                        break;
                    }
                }

                Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(materialCode, GlobalVariables.CurrentOrganizations.First().OrganizationID);

                if (material == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound"));
                    this.edtItemCode.TextFocus(true, true);
                    return;
                }

                OPBOMDetail detailTemp = new OPBOMDetail();

                //模拟一个OPBOMDetail
                detailTemp.OPBOMItemControlType = material.MaterialControlType;
                detailTemp.OPBOMParseType       = material.MaterialParseType;
                detailTemp.OPBOMCheckType       = material.MaterialCheckType;
                detailTemp.CheckStatus          = material.CheckStatus;
                detailTemp.SerialNoLength       = material.SerialNoLength;
                detailTemp.NeedVendor           = material.NeedVendor;
                detailTemp.OPBOMSourceItemCode  = materialCode;
                detailTemp.OPBOMItemCode        = materialCode;
                detailTemp.OPBOMItemQty         = 1;

                MINNO newMinno = new MINNO();

                newMinno.MOCode    = this.edtMoCode.Value.Trim().ToUpper();
                newMinno.MItemCode = material.MaterialCode.Trim();

                msg = dataCollectFacade.GetMINNOByBarcode(detailTemp, this.edtItemCode.Value.Trim().ToUpper(), this.edtMoCode.Value.Trim().ToUpper(), null, false, true, out newMinno);

                if (!msg.IsSuccess())
                {
                    ApplicationRun.GetInfoForm().Add(msg);
                    this.edtItemCode.TextFocus(true, true);
                    return;
                }

                //检查上料资料
                if (this.checkCINNO.Checked)
                {
                    object[] onWipItemObjects = dataCollectFacade.QueryOnWIPItemWithmoCode(this.edtItemCode.Value.Trim().ToUpper(), materialCode, this.edtMoCode.Value.Trim().ToUpper());
                    if (onWipItemObjects == null)
                    {
                        ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Have_CollectMertial"));
                        this.edtItemCode.TextFocus(true, true);
                        return;
                    }
                }

                this.DataProvider.BeginTransaction();
                try
                {
                    MOFacade          moFacade   = new MOFacade(this.DataProvider);
                    DBDateTime        dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    Domain.MOModel.MO mo         = (Domain.MOModel.MO)moFacade.GetMO(this.edtMoCode.Value.Trim().ToUpper());

                    SKDCartonDetail newSKDCartonDetail = new SKDCartonDetail();

                    newSKDCartonDetail.moCode   = this.edtMoCode.Value.Trim().ToUpper();
                    newSKDCartonDetail.CartonNO = this.edtCarton.Value.Trim().ToUpper();
                    if (mo != null)
                    {
                        newSKDCartonDetail.ItemCode = mo.ItemCode;
                    }

                    newSKDCartonDetail.SBItemCode   = materialCode;
                    newSKDCartonDetail.MCard        = this.edtItemCode.Value.Trim().ToUpper();
                    newSKDCartonDetail.MaintainUser = ApplicationService.Current().UserCode;
                    newSKDCartonDetail.MaintainDate = dBDateTime.DBDate;
                    newSKDCartonDetail.MaintainTime = dBDateTime.DBTime;

                    packageFacade.AddSKDCartonDetail(newSKDCartonDetail);

                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SKDCarton_Succes"));
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();
                    msg.Add(new UserControl.Message(ex));
                    ApplicationRun.GetInfoForm().Add(msg);
                }
                finally
                {
                    this.DataProvider.CommitTransaction();
                    this.LoadData();
                    this.MakeGridChecked();
                    this.edtItemCode.TextFocus(true, true);
                }
            }
        }