Esempio n. 1
0
        //Process LotCode
        private void ProcessLotCode(string lotCode)
        {
            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            OQCFacade         _OQCFacade        = new OQCFacade(this.DataProvider);

            object objSimulationReport = dataCollectFacade.GetLastLotSimulationReport(lotCode);

            if (objSimulationReport != null)
            {
                // Added By hi1/venus.Feng on 20081127 for Hisense Version : 如果没有Carton信息,则不能进行移转
                object[] objCarton2Lot = pf.GetCarton2LotByLotCode(lotCode);
                if (objCarton2Lot == null || objCarton2Lot.Length == 0)
                {
                    ClearLotCodeInfo();
                    ucMessage.Add(new UserControl.Message(MessageType.Error
                                                          , "$Error_LotNoCartonInfo $CS_Param_LotNO =" + lotCode));
                    ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                    txtLotCode.TextFocus(true, true);
                }
                else
                {
                    //add by andy xin 判断包装转移判断Lot是否在TBLLOT2CARD中有
                    //object lot2Card = _OQCFacade.GetOQCLot2Card((objSimulationReport as Domain.LotDataCollect.LotSimulationReport).LotCode, (objSimulationReport as Domain.LotDataCollect.LotSimulationReport).MOCode, "", "");
                    //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))
                    //    {

                    //        ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_RCARD_Can_not_Trans"));
                    //        this.txtLotCode.TextFocus(true, true);
                    //        return;
                    //    }
                    //}

                    DisplayLotCodeInfo(objCarton2Lot, objSimulationReport as Domain.LotDataCollect.LotSimulationReport);
                    ucMessage.Add(new UserControl.Message(">>$CS_PleaseInputCartonNo"));
                    txtCartonNO.TextFocus(true, true);
                }
                // End Added
            }
            else
            {
                ClearLotCodeInfo();
                ucMessage.Add(new UserControl.Message(MessageType.Error
                                                      , "$NoSimulation $CS_Param_LotNO =" + lotCode));
                ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                txtLotCode.TextFocus(true, true);
            }
        }
Esempio n. 2
0
        public Messages InsertLotOnWipItem(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade, object[] OPBOMDetail)
        {
            Messages returnValue = new Messages();

            string              iNNO             = ((CINNOActionEventArgs)actionEventArgs).INNO;
            LotSimulation       simulation       = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
            LotSimulationReport simulationReport = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
            MaterialFacade      material         = new MaterialFacade(_domainDataProvider);

            //object[] mINNOs = material.GetLastMINNOs(iNNO);
            object[] mINNOs = OPBOMDetail;
            int      i      = 0;

            if (mINNOs == null)
            {
                throw new Exception("$CS_INNO_NOT_EXIST");
            }

            //确定是否需要扣料
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            Parameter           objParameter        = (Parameter)systemSettingFacade.GetParameter("DEDUCTQTY", "DEDUCTMATERIAL");
            bool isDeductQty = true;

            if (objParameter == null || objParameter.ParameterAlias != "Y")
            {
                isDeductQty = false;
            }

            foreach (MINNO mINNO in mINNOs)
            {
                if (mINNO == null)
                {
                    throw new Exception("$CS_INNOnotExist");
                }
                if (!isDeductQty)//如果不扣料只记录同一首选料的一笔过账
                {
                    //原有过账记录,挪到此处
                    LotOnWipItem wipItem = new LotOnWipItem();

                    wipItem.DateCode       = mINNO.DateCode;
                    wipItem.LOTNO          = mINNO.LotNO;
                    wipItem.MItemCode      = mINNO.MItemCode;
                    wipItem.VendorCode     = mINNO.VendorCode;
                    wipItem.VendorItemCode = mINNO.VendorItemCode;
                    wipItem.Version        = mINNO.Version;
                    wipItem.MSeq           = i;
                    wipItem.MCardType      = mINNO.EAttribute1;

                    wipItem.Eattribute1         = simulation.EAttribute1;
                    wipItem.ItemCode            = simulation.ItemCode;
                    wipItem.ResCode             = simulation.ResCode;
                    wipItem.RouteCode           = simulation.RouteCode;
                    wipItem.LotCode             = simulation.LotCode;
                    wipItem.LotSeq              = simulation.LotSeq;
                    wipItem.SegmentCode         = simulationReport.SegmentCode;
                    wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                    wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                    wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                    wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                    wipItem.MOCode              = simulation.MOCode;
                    wipItem.ModelCode           = simulation.ModelCode;
                    wipItem.OPCode              = simulation.OPCode;
                    wipItem.CollectStatus       = simulation.CollectStatus;
                    wipItem.BeginDate           = simulation.BeginDate;
                    wipItem.BeginTime           = simulation.BeginTime;
                    wipItem.MaintainUser        = simulation.MaintainUser;
                    wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;

                    if (mINNO.Qty.ToString() != string.Empty && Convert.ToInt32(mINNO.Qty) != 0)
                    {
                        wipItem.Qty = mINNO.Qty * simulation.LotQty;
                    }
                    else
                    {
                        wipItem.Qty = simulation.LotQty;
                    }

                    //Laws Lu,2005/12/20,新增	采集类型
                    wipItem.ActionType = (int)MaterialType.CollectMaterial;
                    wipItem.MOSeq      = simulation.MOSeq; // Added by Icyer 2007/07/02

                    dataCollectFacade.AddLotOnWIPItem(wipItem);

                    LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                    if (simulationRpt != null)
                    {
                        dataCollectFacade.UpdateLotSimulationReport(simulationRpt);

                        // End Added
                    }
                    i++;
                }
                else
                {
                    //add by Jarvis 20120316 For 扣料
                    DeductQty(actionEventArgs, dataCollectFacade, mINNO);
                }
            }
            seqForDeductQty = 0;
            return(returnValue);
        }
Esempio n. 3
0
        public Messages DeductQty(ActionEventArgs actionEventArgs, DataCollectFacade dataCollectFacade, MINNO minno)
        {
            SystemSettingFacade systemSettingFacade = new SystemSettingFacade(this.DataProvider);
            MaterialFacade      materialFacade      = new MaterialFacade(this.DataProvider);
            MOFacade            moFacade            = new MOFacade(this.DataProvider);
            OPBOMFacade         opbomFacade         = new OPBOMFacade(this.DataProvider);
            ItemFacade          itemFacade          = new ItemFacade(this.DataProvider);
            InventoryFacade     inventoryFacade     = new InventoryFacade(this.DataProvider);
            LotSimulation       simulation          = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulation;
            LotSimulationReport simulationReport    = ((CINNOActionEventArgs)actionEventArgs).ProductInfo.NowSimulationReport;
            Messages            returnValue         = new Messages();
            string lotNoList = string.Empty;// add by Jarvis For onWipItem

            ProductInfo   productionInfo = actionEventArgs.ProductInfo;
            LotSimulation sim            = actionEventArgs.ProductInfo.NowSimulation;
            int           orgid          = actionEventArgs.ProductInfo.Resource.OrganizationID;
            MO            mo             = actionEventArgs.ProductInfo.CurrentMO;

            if (mo == null)
            {
                mo = moFacade.GetMO(sim.MOCode) as MO;
            }

            //获取当前工单号
            string moCode = productionInfo.NowSimulation.MOCode;
            //获取当前工序号
            string opCode = productionInfo.NowSimulation.OPCode;
            //获取当前产品号
            string itemCode = productionInfo.NowSimulation.ItemCode;
            //获取途程代码
            string routeCode = productionInfo.NowSimulation.RouteCode;
            string resCode   = productionInfo.Resource.ResourceCode;
            //获取ORGID
            int    orgID    = productionInfo.Resource.OrganizationID;
            string moBomVer = string.Empty;

            object objMo = moFacade.GetMO(moCode);

            if (objMo != null)
            {
                moBomVer = (objMo as MO).BOMVersion;
            }

            //获取物料名称
            string MItemName = string.Empty;

            Domain.MOModel.Material material = ((Domain.MOModel.Material)itemFacade.GetMaterial(minno.MItemCode, orgID));
            if (material != null)
            {
                MItemName = material.MaterialName;
            }

            //添加产品已上料扣料判断  tblonwip
            string  lotNo = productionInfo.NowSimulation.LotCode;
            decimal seq   = productionInfo.NowSimulation.LotSeq;

            //object[] objOnWip = dataCollectFacade.QueryLotOnWIP(lotNo, moCode, opCode, "CINNO");

            //if (objOnWip != null && objOnWip.Length > 0)
            //{
            //    return returnValue;
            //}

            //remove by Jarvis 不检查工单BOM 20120321
            //object[] objMoBoms = moFacade.QueryMoBom(sim.ItemCode, minno.MItemCode, sim.MOCode);//检查工单BOM是否有该首选料, Jarvis 20120319
            //if (objMoBoms == null)
            //{
            //    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$Error_NotExistInMoBOM" + String.Format("[$MOCode='{0}']", sim.MOCode));
            //}

            object[] opbomObjs = opbomFacade.QueryOPBOMDetail(sim.ItemCode, minno.MItemCode, string.Empty, string.Empty, string.Empty, sim.RouteCode, opCode, (int)MaterialType.CollectMaterial, int.MinValue, int.MaxValue, orgid, true);
            if (opbomObjs == null)
            {
                throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$Error_NotExistInOPBOM" + String.Format("[$ItemCode='{0}']", sim.ItemCode));
            }

            object[] moRouteObjs = moFacade.QueryMORoutes(sim.MOCode, sim.RouteCode);
            if (moRouteObjs == null)
            {
                throw new Exception("$Error_MORouteNOExist");
            }

            bool iflag = false;

            decimal iOPBOMItemQty = 0;

            //需要比对的子阶料料号 比对成功的 只在工单生产BOM 中
            if (opbomObjs == null)//去掉检查工单BOM是否为空
            {
                return(returnValue);
            }

            //以工单标准BOM为基准,扣减当前工单的倒冲库存地(tblmo. EATTRIBUTE2)中相对应的库存信息
            //for (int n = 0; n < objMoBoms.Length; n++)//去掉工单BOM 20120321 Jarvis
            //{
            //求得opbom中对应的料品
            string TempMOBOMItemCode = minno.MItemCode;

            iflag         = false;
            iOPBOMItemQty = 0;
            for (int j = 0; j < opbomObjs.Length; j++)
            {
                if (TempMOBOMItemCode.ToUpper() == ((OPBOMDetail)opbomObjs[j]).OPBOMItemCode.ToUpper() ||
                    TempMOBOMItemCode.ToUpper() == ((OPBOMDetail)opbomObjs[j]).OPBOMSourceItemCode.ToUpper())
                {   //子阶料存在或有替代料可用
                    iflag = true;
                    //TempMOBOMItemCode = ((OPBOMDetail)opbomObjs[j]).OPBOMItemCode;//remove by Jarvis 20120316
                    //For 替代料,记录首选料号,Jarvis 20120316
                    //TempMOBOMItemCode = ((MOBOM)objMoBoms[n]).MOBOMItemCode;

                    iOPBOMItemQty  = (decimal)((OPBOMDetail)opbomObjs[j]).OPBOMItemQty;
                    iOPBOMItemQty *= sim.LotQty;

                    break;
                }
            }

            //比对成功:子阶料料号一致
            if (iflag)//子阶料不存在, 即只在工单标准bom中
            {
                //object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(mo.EAttribute2, TempMOBOMItemCode.ToUpper());
                object[] objInfos = inventoryFacade.QueryStorageInfoByIDAndMCode(TempMOBOMItemCode.ToUpper());
                if (objInfos == null)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
                }

                //获取物料的总库存数,Jarvis 20120316
                //decimal total = inventoryFacade.GetStorageQty(mo.EAttribute2, TempMOBOMItemCode.ToUpper());
                decimal total = inventoryFacade.GetStorageQty(TempMOBOMItemCode.ToUpper());

                if (total < iOPBOMItemQty)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "]" + "$CS_StorageQty_ERROR");
                }

                #region //先判断备料批号中的数据量,不够扣减就退出
                decimal   temlotQty          = 0;
                object[]  objStorageLotInfo  = null;
                ArrayList StorageLotInfoList = new ArrayList();

                //获取子阶料的备料信息,Jarvis 20120316,按Seq排序
                object[] minnoss = materialFacade.QueryMINNO_New(moCode, routeCode, opCode, resCode, moBomVer, minno.MSourceItemCode);    //获取同一首选料的备料信息,Jarvis 20120321

                //获取备料信息中可扣减数,Jarvis 20120316
                foreach (MINNO temp in minnoss)
                {
                    //objStorageLotInfo = inventoryFacade.QueryStorageLot(temp.LotNO, mo.EAttribute2, temp.MItemCode);
                    objStorageLotInfo = inventoryFacade.QueryStorageLot(temp.LotNO, temp.MItemCode);
                    if (objStorageLotInfo != null)
                    {
                        foreach (StorageLotInfo lotInfo in objStorageLotInfo)
                        {
                            temlotQty += lotInfo.Lotqty;
                            if (lotInfo.Lotqty <= 0)    //如果批数量为0不记录该批
                            {
                                continue;
                            }
                            StorageLotInfoList.Add(lotInfo);
                        }
                    }
                }


                if (temlotQty < iOPBOMItemQty)
                {
                    throw new Exception("$CS_ItemCode[" + minno.MItemCode + "-" + MItemName + "]" + "$CS_DeductQty_ERROR");
                }
                #endregion

                #region 数量可以扣减

                foreach (StorageLotInfo lotInfo in StorageLotInfoList)
                {
                    if (iOPBOMItemQty > lotInfo.Lotqty)
                    {
                        iOPBOMItemQty = iOPBOMItemQty - lotInfo.Lotqty;
                        inventoryFacade.DeleteStorageLotInfo(lotInfo);
                        this.UpdateStorageQty(lotInfo, inventoryFacade, lotInfo.Lotqty);
                        lotNoList += ("," + lotInfo.Lotno + ",");

                        #region 记录过账信息
                        LotOnWipItem wipItem    = new LotOnWipItem();
                        MINNO        minnoTemp  = null;
                        object[]     minnoTemps = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, lotInfo.Mcode, minno.MSourceItemCode, lotInfo.Lotno);
                        if (minnoTemps != null)
                        {
                            minnoTemp = (MINNO)minnoTemps[0];
                        }
                        wipItem.DateCode       = minnoTemp.DateCode;
                        wipItem.LOTNO          = minnoTemp.LotNO;
                        wipItem.MItemCode      = minnoTemp.MItemCode;
                        wipItem.VendorCode     = minnoTemp.VendorCode;
                        wipItem.VendorItemCode = minnoTemp.VendorItemCode;
                        wipItem.Version        = minnoTemp.Version;
                        wipItem.MSeq           = seqForDeductQty;
                        wipItem.MCardType      = minno.EAttribute1;

                        wipItem.Eattribute1         = simulation.EAttribute1;
                        wipItem.ItemCode            = simulation.ItemCode;
                        wipItem.ResCode             = simulation.ResCode;
                        wipItem.RouteCode           = simulation.RouteCode;
                        wipItem.LotCode             = simulation.LotCode;
                        wipItem.LotSeq              = simulation.LotSeq;
                        wipItem.SegmentCode         = simulationReport.SegmentCode;
                        wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                        wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                        wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                        wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                        wipItem.MOCode              = simulation.MOCode;
                        wipItem.ModelCode           = simulation.ModelCode;
                        wipItem.OPCode              = simulation.OPCode;
                        wipItem.CollectStatus       = simulation.CollectStatus;
                        wipItem.BeginDate           = simulation.BeginDate;
                        wipItem.BeginTime           = simulation.BeginTime;
                        wipItem.MaintainUser        = simulation.MaintainUser;
                        wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;
                        wipItem.Qty = lotInfo.Lotqty;

                        wipItem.ActionType = (int)MaterialType.CollectMaterial;
                        wipItem.MOSeq      = simulation.MOSeq;

                        dataCollectFacade.AddLotOnWIPItem(wipItem);

                        LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                        if (simulationRpt != null)
                        {
                            dataCollectFacade.UpdateLotSimulationReport(simulationRpt);
                        }
                        seqForDeductQty++;
                        #endregion
                    }
                    else
                    {
                        lotInfo.Lotqty = lotInfo.Lotqty - iOPBOMItemQty;
                        inventoryFacade.UpdateStorageLotInfo(lotInfo);
                        this.UpdateStorageQty(lotInfo, inventoryFacade, iOPBOMItemQty);

                        #region 记录过账信息
                        LotOnWipItem wipItem    = new LotOnWipItem();
                        MINNO        minnoTemp  = null;
                        object[]     minnoTemps = materialFacade.QueryMINNO(moCode, routeCode, opCode, resCode, moBomVer, lotInfo.Mcode, minno.MSourceItemCode, lotInfo.Lotno);
                        if (minnoTemps != null)
                        {
                            minnoTemp = (MINNO)minnoTemps[0];
                        }
                        wipItem.DateCode       = minnoTemp.DateCode;
                        wipItem.LOTNO          = minnoTemp.LotNO;
                        wipItem.MItemCode      = minnoTemp.MItemCode;
                        wipItem.VendorCode     = minnoTemp.VendorCode;
                        wipItem.VendorItemCode = minnoTemp.VendorItemCode;
                        wipItem.Version        = minnoTemp.Version;
                        wipItem.MSeq           = seqForDeductQty;
                        wipItem.MCardType      = minno.EAttribute1;

                        wipItem.Eattribute1         = simulation.EAttribute1;
                        wipItem.ItemCode            = simulation.ItemCode;
                        wipItem.ResCode             = simulation.ResCode;
                        wipItem.RouteCode           = simulation.RouteCode;
                        wipItem.LotCode             = simulation.LotCode;
                        wipItem.LotSeq              = simulation.LotSeq;
                        wipItem.SegmentCode         = simulationReport.SegmentCode;
                        wipItem.BeginShiftCode      = simulationReport.BeginShiftCode;
                        wipItem.ShiftTypeCode       = simulationReport.ShiftTypeCode;
                        wipItem.StepSequenceCode    = simulationReport.StepSequenceCode;
                        wipItem.BeginTimePeriodCode = simulationReport.BeginTimePeriodCode;
                        wipItem.MOCode              = simulation.MOCode;
                        wipItem.ModelCode           = simulation.ModelCode;
                        wipItem.OPCode              = simulation.OPCode;
                        wipItem.CollectStatus       = simulation.CollectStatus;
                        wipItem.BeginDate           = simulation.BeginDate;
                        wipItem.BeginTime           = simulation.BeginTime;
                        wipItem.MaintainUser        = simulation.MaintainUser;
                        wipItem.TransStatus         = TransactionStatus.TransactionStatus_YES;
                        wipItem.Qty = iOPBOMItemQty;

                        wipItem.ActionType = (int)MaterialType.CollectMaterial;
                        wipItem.MOSeq      = simulation.MOSeq;

                        dataCollectFacade.AddLotOnWIPItem(wipItem);

                        LotSimulationReport simulationRpt = dataCollectFacade.GetLastLotSimulationReport(wipItem.LotCode);
                        if (simulationRpt != null)
                        {
                            dataCollectFacade.UpdateLotSimulationReport(simulationRpt);
                        }
                        seqForDeductQty++;
                        #endregion
                        iOPBOMItemQty = 0;
                        lotNoList    += ("," + lotInfo.Lotno + ",");
                        break;
                    }
                }

                #endregion
            }
            //}
            return(returnValue);
        }
Esempio n. 4
0
        //Process Carton NO
        private void ProcessCarton(string cartonno)
        {
            DataCollectFacade dcf     = new DataCollectFacade(DataProvider);
            string            lotCode = txtLotCode.Value.Trim().ToUpper();

            #region lotCode 从当前Carton移转到另外一个Carton
            InventoryFacade materialDCF = new InventoryFacade(DataProvider);

            if (!CheckTargetCarton(cartonno))
            {
                if (!m_NeedAddNewCarton)
                {
                    ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                    txtCartonNO.TextFocus(true, true);
                    return;
                }
            }
            object objSimulationReport = dcf.GetLastLotSimulationReport(lotCode);

            if (objSimulationReport != null)
            {
                Domain.LotDataCollect.LotSimulationReport simulationReport = objSimulationReport as Domain.LotDataCollect.LotSimulationReport;

                //simulationReport.CartonCode = cartonno.Trim().ToUpper();


                #region 移转操作
                DataProvider.BeginTransaction();
                try
                {
                    //Add By Bernard @ 2010-11-01
                    string moCode           = txtMoCode.Value.Trim().ToUpper();
                    string oldCartonno      = ucLabelComboxCurrentCarton.SelectedItemText;
                    bool   m_HasCartonAdded = false;
                    //end
                    decimal    oldCartonQty  = 0;
                    Carton2Lot oldCarton2Lot = (Carton2Lot)pf.GetCarton2Lot(oldCartonno.Trim().ToUpper(), lotCode.Trim().ToUpper());
                    if (oldCarton2Lot != null)
                    {
                        oldCartonQty = oldCarton2Lot.CartonQty;
                    }

                    int capaCity = ((new ItemFacade(DataProvider)).GetItem(simulationReport.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty;



                    //包装箱不存在,为CartonInfo表增加一个包装箱信息
                    if (m_NeedAddNewCarton)
                    {
                        if (oldCartonQty > capaCity)
                        {
                            ucMessage.Add(new UserControl.Message(MessageType.Error
                                                                  , "$CS_CartonQty_IS_Large $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                            ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                            this.DataProvider.RollbackTransaction();
                            txtCartonNO.TextFocus(true, true);
                            return;
                        }

                        DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);
                        BenQGuru.eMES.Domain.Package.CARTONINFO newCarton = new BenQGuru.eMES.Domain.Package.CARTONINFO();

                        newCarton.CARTONNO    = cartonno.Trim().ToUpper();
                        newCarton.CAPACITY    = capaCity;
                        newCarton.COLLECTED   = 0;
                        newCarton.EATTRIBUTE1 = "";
                        newCarton.PKCARTONID  = System.Guid.NewGuid().ToString().ToUpper();
                        newCarton.MUSER       = ApplicationService.Current().UserCode;
                        newCarton.MDATE       = currentDateTime.DBDate;
                        newCarton.MTIME       = currentDateTime.DBTime;
                        pf.AddCARTONINFO(newCarton);

                        //0.向tblcarton2rcard表增加一个包装箱 Add By Bernard @ 2010-11-01
                        Carton2Lot newCarton2Lot = new Carton2Lot();
                        newCarton2Lot.CartonCode  = cartonno.Trim().ToUpper();
                        newCarton2Lot.LotCode     = lotCode;
                        newCarton2Lot.CartonQty   = oldCartonQty;
                        newCarton2Lot.MUser       = ApplicationService.Current().UserCode;
                        newCarton2Lot.MDate       = currentDateTime.DBDate;
                        newCarton2Lot.MTime       = currentDateTime.DBTime;
                        newCarton2Lot.Eattribute1 = "";
                        newCarton2Lot.MOCode      = moCode;

                        pf.AddCarton2Lot(newCarton2Lot);
                        m_HasCartonAdded = true;
                        //end
                    }


                    //判断箱中采集数量是否大与包装容量
                    object obj = pf.GetCARTONINFO(cartonno.Trim().ToUpper());
                    Domain.Package.CARTONINFO carton = obj as Domain.Package.CARTONINFO;
                    if ((carton.COLLECTED + oldCartonQty) > carton.CAPACITY)
                    {
                        this.DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_CartonQty_IS_Large $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }


                    //1.判断新箱与旧箱内产品工单代码是否一致 Add By Bernard @ 2010-11-01
                    object oldObj = pf.GetCarton2Lot(oldCartonno, lotCode);

                    string newMOCode = moCode;
                    string oldMOCode = ((Carton2Lot)oldObj).MOCode;

                    if (oldMOCode == newMOCode)        //工单代码一致
                    {
                        if (m_HasCartonAdded == false) //箱号没有新增,则向Carton2RCard新增一条记录
                        {
                            DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                            object newObj = pf.GetCarton2Lot(cartonno, lotCode);
                            if (newObj == null)
                            {
                                Carton2Lot carton2Lot = new Carton2Lot();
                                carton2Lot.LotCode     = lotCode;
                                carton2Lot.CartonQty   = oldCartonQty;
                                carton2Lot.CartonCode  = cartonno;
                                carton2Lot.MOCode      = moCode;
                                carton2Lot.MUser       = ApplicationService.Current().UserCode;
                                carton2Lot.MDate       = currentDateTime.DBDate;
                                carton2Lot.MTime       = currentDateTime.DBTime;
                                carton2Lot.Eattribute1 = "";
                                pf.AddCarton2Lot(carton2Lot);
                            }
                            else
                            {
                                Carton2Lot carton2Lot = newObj as Carton2Lot;
                                carton2Lot.CartonQty = carton2Lot.CartonQty + oldCartonQty;
                                carton2Lot.MUser     = ApplicationService.Current().UserCode;
                                carton2Lot.MDate     = currentDateTime.DBDate;
                                carton2Lot.MTime     = currentDateTime.DBTime;
                                pf.UpdateCarton2Lot(carton2Lot);
                            }
                        }
                        //end

                        dcf.RemoveFromCarton(simulationReport.LotCode, oldCartonno, ApplicationService.Current().UserCode);

                        pf.UpdateCollected(cartonno.Trim().ToUpper(), oldCartonQty);


                        //记log
                        pf.AddCarton2LotLog(cartonno, simulationReport.LotCode, oldCartonQty, ApplicationService.Current().UserCode);
                        //end
                    }
                    else
                    {
                        DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }

                    //判断相中的批次是否属于同一批次
                    int mocodeCount = pf.GetMoCountByCartonNo(cartonno);
                    if (mocodeCount > 1)
                    {
                        DataProvider.RollbackTransaction();
                        ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper()));
                        ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo"));
                        txtCartonNO.TextFocus(true, true);
                        return;
                    }
                    //end


                    DataProvider.CommitTransaction();

                    ucMessage.Add(new UserControl.Message(MessageType.Success
                                                          , "$CS_LOTCODE_TRANSFER_CARTON_SUCCESS $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                    ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                    txtLotCode.TextFocus(true, true);
                    txtCartonNO.Value = String.Empty;
                    ClearLotCodeInfo();
                }
                catch (Exception ex)
                {
                    DataProvider.RollbackTransaction();
                    ucMessage.Add(new UserControl.Message(ex));

                    txtCartonNO.TextFocus(true, true);
                }
                finally
                {
                    (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection();
                }
                #endregion
            }
            else
            {
                ucMessage.Add(new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper()));
                ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode"));
                ClearLotCodeInfo();
                txtLotCode.TextFocus(true, true);
            }

            #endregion
        }