Exemple #1
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);
        }
Exemple #2
0
        private Messages DropLoadedParts(string rcard)
        {
            Messages msg = new Messages();

            ActionOnLineHelper onLine            = new ActionOnLineHelper(DataProvider);
            MaterialFacade     materialFacade    = new MaterialFacade(this.DataProvider);
            ItemFacade         itemFacade        = new ItemFacade(this.DataProvider);
            DataCollectFacade  dataCollectFacade = new DataCollectFacade(this.DataProvider);
            TSFacade           tsFacade          = new TSFacade(this.DataProvider);

            string sourceRCard = dataCollectFacade.GetSourceCard(rcard.Trim().ToUpper(), string.Empty);

            ProductInfo product = GetProduct(sourceRCard);

            if (product == null || product.LastSimulation == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                return(msg);
            }

            // Marked By HI1/Venus.Feng on 20081013 for Hisense Version : GOOD can do drop

            /*
             * if (product.LastSimulation.ProductStatus != ProductStatus.NG)
             * {
             *  msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG"));
             *  return msg;
             * }
             */
            // End Marked

            msg.Add(new UserControl.Message(rcard));

            //获取所有需要拆解或者替换的Parts
            ArrayList partsToUnload = new ArrayList();

            for (int i = 0; i < this.ultraGridLoadedPart.Rows.Count; i++)
            {
                if (ultraGridLoadedPart.Rows[i].Cells[0].Text.ToLower() == "true")
                {
                    InnoObject innoObject = new InnoObject();

                    innoObject.LineIndex  = i;
                    innoObject.MCard      = ultraGridLoadedPart.Rows[i].Cells["PackedNo"].Text;
                    innoObject.MCardType  = ultraGridLoadedPart.Rows[i].Cells["MCardType"].Text;
                    innoObject.ItemIndex  = partsToUnload.Count + 1;
                    innoObject.MItemCode  = ultraGridLoadedPart.Rows[i].Cells["ItemCode"].Text;
                    innoObject.MOCode     = ultraGridLoadedPart.Rows[i].Cells["MOCode"].Text;
                    innoObject.Qty        = 1;
                    innoObject.NewBarcode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ultraGridLoadedPart.Rows[i].Cells["NewBarcode"].Text.Trim()));

                    partsToUnload.Add(innoObject);
                }
            }

            //对于需要替换的Parts,需要做类似上料中的解析和检查
            for (int i = 0; i < partsToUnload.Count; i++)
            {
                InnoObject innoObject = (InnoObject)partsToUnload[i];

                if (innoObject.NewBarcode.Trim().Length > 0)
                {
                    //抓取物料的设定
                    Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(innoObject.MItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    if (material == null)
                    {
                        msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound"));
                        return(msg);
                    }

                    string barcode = innoObject.NewBarcode.Trim();

                    //模拟一个OPBOMDetail
                    OPBOMDetail detailTemp = new 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  = innoObject.MItemCode;
                    detailTemp.OPBOMItemCode        = innoObject.MItemCode;
                    detailTemp.OPBOMItemQty         = 1;


                    MINNO newMINNO = new MINNO();
                    newMINNO.MOCode    = innoObject.MOCode.Trim();
                    newMINNO.MItemCode = material.MaterialCode.Trim();

                    Messages collectMessage = dataCollectFacade.GetMINNOByBarcode(detailTemp, barcode, newMINNO.MOCode, null, false, false, out newMINNO);

                    if (collectMessage.IsSuccess())
                    {
                        innoObject.NewLotNo          = newMINNO.LotNO;
                        innoObject.NewPCBA           = newMINNO.PCBA;
                        innoObject.NewBIOS           = newMINNO.BIOS;
                        innoObject.NewVersion        = newMINNO.Version;
                        innoObject.NewVendorItemCode = newMINNO.VendorItemCode;
                        innoObject.NewVendorCode     = newMINNO.VendorCode;
                        innoObject.NewDateCode       = newMINNO.DateCode;
                    }
                    else
                    {
                        msg.AddMessages(collectMessage);
                        return(msg);
                    }
                }
            }

            try
            {
                this.DataProvider.BeginTransaction();

                //更新试流单
                //下料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    TryEventArgs tryEventArgs = new TryEventArgs(
                        ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                        product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.MCard, string.Empty, false, false);

                    msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                    if (!msg.IsSuccess())
                    {
                        DataProvider.RollbackTransaction();
                        return(msg);
                    }
                }

                //更新试流单
                //上料中处理tbltry,tbltry2rcard
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        TryEventArgs tryEventArgs = new TryEventArgs(
                            ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode,
                            product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.NewBarcode, string.Empty, true, true);

                        msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs));
                        if (!msg.IsSuccess())
                        {
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //检查新上料是否在TS中而不可用
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];
                    if (innoObject.NewBarcode.Trim().Length > 0)
                    {
                        if (!tsFacade.RunningCardCanBeClollected(innoObject.NewBarcode.Trim(), CardType.CardType_Part))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + innoObject.NewBarcode.Trim()));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }
                    }
                }

                //拆解或者替换处理tblonwipitem,tblsimulationreport
                DropMaterialEventArgs dropMaterialEventArgs = new DropMaterialEventArgs(ActionType.DataCollectAction_DropMaterial, product.LastSimulation.RunningCard,
                                                                                        ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode,
                                                                                        product);
                dropMaterialEventArgs.OnwipItems = partsToUnload.ToArray();

                msg.AddMessages(onLine.ActionWithTransaction(dropMaterialEventArgs));
                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                //针对拆解下的物料,做TS相关的动作
                for (int i = 0; i < partsToUnload.Count; i++)
                {
                    InnoObject innoObject = (InnoObject)partsToUnload[i];

                    if (_TSList[innoObject.LineIndex] != null)
                    {
                        if (_TSErrorCodeList[innoObject.LineIndex] == null)
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Select_ErrorCode"));
                            DataProvider.RollbackTransaction();
                            return(msg);
                        }

                        Domain.TS.TS oldTS = (Domain.TS.TS)tsFacade.QueryLastTSByRunningCard(innoObject.MCard);
                        if (oldTS != null)
                        {
                            if (oldTS.TSStatus == TSStatus.TSStatus_New ||
                                oldTS.TSStatus == TSStatus.TSStatus_Confirm ||
                                oldTS.TSStatus == TSStatus.TSStatus_TS)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTS"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                            else if (oldTS.TSStatus != TSStatus.TSStatus_Reflow &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Split &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Complete &&
                                     oldTS.TSStatus != TSStatus.TSStatus_Scrap)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_WrongTSStatus"));
                                DataProvider.RollbackTransaction();
                                return(msg);
                            }
                        }

                        Domain.TS.TS newTS = (Domain.TS.TS)_TSList[innoObject.LineIndex];
                        tsFacade.AddTS(newTS);
                        foreach (TSErrorCode tsErrorCode in (TSErrorCode[])_TSErrorCodeList[innoObject.LineIndex])
                        {
                            tsErrorCode.RunningCard         = newTS.RunningCard;
                            tsErrorCode.RunningCardSequence = newTS.RunningCardSequence;
                            tsErrorCode.ItemCode            = newTS.ItemCode;
                            tsErrorCode.ModelCode           = newTS.ModelCode;
                            tsErrorCode.MOCode       = newTS.MOCode;
                            tsErrorCode.MOSeq        = newTS.MOSeq;
                            tsErrorCode.MaintainUser = newTS.MaintainUser;
                            tsErrorCode.MaintainDate = newTS.MaintainDate;
                            tsErrorCode.MaintainTime = newTS.MaintainTime;

                            tsFacade.AddTSErrorCode(tsErrorCode);
                        }
                    }
                }

                if (!msg.IsSuccess())
                {
                    DataProvider.RollbackTransaction();
                    return(msg);
                }

                if (msg.IsSuccess())
                {
                    DataProvider.CommitTransaction();
                }
                else
                {
                    DataProvider.RollbackTransaction();
                }
            }
            catch (Exception e)
            {
                this.DataProvider.RollbackTransaction();
                msg.Add(new UserControl.Message(e));
            }

            return(msg);
        }
Exemple #3
0
        // Added end

        public override Messages Action(object act)
        {
            Messages           msg     = new Messages();
            ActionOnLineHelper _helper = null;

            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;

            if (act == null)
            {
                return(msg);
            }

            DataCollect.Action.ActionEventArgs args;
            if (ObjectState == null)
            {
                args             = new BenQGuru.eMES.DataCollect.Action.ActionEventArgs();
                args.RunningCard = act.ToString().ToUpper().Trim();
            }
            else
            {
                args = ObjectState as DataCollect.Action.ActionEventArgs;
            }

            string data = act.ToString().ToUpper().Trim();

            //Laws Lu,2006/06/03	添加	获取已有连接
            if ((act as IDCTClient).DBConnection != null)
            {
                domainProvider = (act as IDCTClient).DBConnection as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
            }
            else
            {
                domainProvider = Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider()
                                 as BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider;
                (act as IDCTClient).DBConnection = domainProvider;
            }

            DataCollectFacade dataCollect = new DataCollect.DataCollectFacade(domainProvider);
            TSFacade          tsFacade    = new TSFacade(domainProvider);

            if (msg.IsSuccess())
            {
                MO          moWillGo = (MO)keypartsHT["MOWillGo"];
                ProductInfo product  = (ProductInfo)keypartsHT["ProdcutInfo"];

                if (opBomDetailCount > opBomDetailCollectNum)
                {
                    try
                    {
                        object[] opBomDetailCompare = new object[opBomDetailList.Count];
                        opBomDetailList.CopyTo(opBomDetailCompare);
                        string ItemCode = string.Empty;

                        string parseTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMParseType + ",";
                        string checkTypeSetting = "," + ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMCheckType + ",";
                        bool   checkStatus      = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).CheckStatus == BenQGuru.eMES.Web.Helper.FormatHelper.TRUE_STRING;

                        string CheckNeedVendor = string.Empty;
                        if (!string.IsNullOrEmpty(((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor))
                        {
                            CheckNeedVendor = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).NeedVendor;
                        }

                        string MItemCode   = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemCode;
                        string OBSItemCode = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMSourceItemCode;
                        int    inputLength = ((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).SerialNoLength;

                        MaterialFacade facade   = new MaterialFacade(domainProvider);
                        MINNO          newMINNO = facade.CreateNewMINNO();
                        newMINNO.MItemCode = MItemCode;

                        Messages parseSuccess    = new Messages();
                        Messages oldParseSuccess = new Messages();

                        parseSuccess.Add(new UserControl.Message(MessageType.Error, "$CS_Error_ParseFailed:"));
                        int num = 0;


                        //勾选了料号比对,必须选择解析方式
                        if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                        {
                            if (parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") < 0 &&
                                parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") < 0 &&
                                parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") < 0)
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, " $CS_Error_ParseFailed:$CheckCompareItem_Must_CheckOneParse"));
                                goto Label2;
                            }
                        }

                        //Parse from barcode
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_BARCODE.ToLower() + ",") >= 0)
                        {
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromBarcode(ref newMINNO, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }
                        //Parse from prepare
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PREPARE.ToLower() + ",") >= 0)
                        {
                            Simulation sim = (Simulation)dataCollect.GetSimulation(ID);
                            newMINNO.MOCode = sim.MOCode;
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromPrepare(ref newMINNO, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }
                        //Parse from product
                        if (!parseSuccess.IsSuccess() && parseTypeSetting.IndexOf("," + OPBOMDetailParseType.PARSE_PRODUCT.ToLower() + ",") >= 0)
                        {
                            OPBOMDetail opBOMDetailForItemCode = null;
                            if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_COMPAREITEM.ToLower() + ",") >= 0)
                            {
                                opBOMDetailForItemCode = (OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum];
                            }
                            oldParseSuccess.AddMessages(parseSuccess);
                            parseSuccess = dataCollect.ParseFromProduct(ref newMINNO, checkStatus, data, opBOMDetailForItemCode, inputLength);

                            num += 1;
                        }

                        if (!parseSuccess.IsSuccess())
                        {
                            if (num > 0)
                            {
                                oldParseSuccess.AddMessages(parseSuccess);
                                msg.AddMessages(oldParseSuccess);
                                goto Label2;
                            }

                            if (num == 0)
                            {
                                if (inputLength > 0 && data.Trim().Length != inputLength)
                                {
                                    msg.Add(new UserControl.Message(MessageType.Error, "$Error_SNLength_Wrong"));
                                    goto Label2;
                                }
                            }
                        }

                        //检查新上料是否在TS中而不可用
                        if (!tsFacade.RunningCardCanBeClollected(data, CardType.CardType_Part))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + data));
                            goto Label2;
                        }

                        #region Check if key part was used

                        if (((OPBOMDetail)opBomDetailCompare[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS &&
                            KeyPartUsed(domainProvider, data, newMINNO.MItemCode, true))
                        {
                            msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed"));
                            goto Label2;
                        }

                        #endregion

                        #region check NeedVendor


                        //如果VendorCode为空,到tblmaterial中获取
                        if (newMINNO.VendorCode == null || newMINNO.VendorCode.Trim().Length <= 0)
                        {
                            ItemFacade itemfacade  = new ItemFacade(domainProvider);
                            object     objMaterial = itemfacade.GetMaterial(newMINNO.MItemCode.Trim(), GlobalVariables.CurrentOrganizations.First().OrganizationID);
                            if (objMaterial != null)
                            {
                                newMINNO.VendorCode = ((BenQGuru.eMES.Domain.MOModel.Material)objMaterial).VendorCode;
                            }
                        }

                        if (CheckNeedVendor == NeedVendor.NeedVendor_Y)
                        {
                            Messages checkNeedVendor = new Messages();
                            checkNeedVendor = dataCollect.CheckNeedVebdor(newMINNO);

                            if (!checkNeedVendor.IsSuccess())
                            {
                                msg.AddMessages(checkNeedVendor);
                                goto Label2;
                            }
                        }

                        #endregion

                        if (checkTypeSetting.IndexOf("," + OPBOMDetailCheckType.CHECK_LINKBARCODE.ToLower() + ",") >= 0)
                        {
                            //Link barcode
                            if (string.IsNullOrEmpty(newMINNO.MItemCode))
                            {
                                newMINNO.MItemCode = MItemCode;
                            }

                            newMINNO.MItemPackedNo = data;
                            if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_KEYPARTS)
                            {
                                newMINNO.EAttribute1 = MCardType.MCardType_Keyparts;
                            }
                            else if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                            {
                                newMINNO.EAttribute1 = MCardType.MCardType_INNO;
                                newMINNO.Qty         = ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemQty;
                            }

                            opBomdetailRealCollectList.Add((object)newMINNO);
                        }

                        ++opBomDetailCollectNum;
Label2:

                        if (opBomDetailCount > opBomDetailCollectNum)
                        {
                            if (((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType != null &&
                                ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                            {
                                msg.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode));

                                ProcessBeforeReturn(this.Status, msg);
                                return(msg);
                            }
                            else
                            {
                                msg.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputKeypart:" + ((OPBOMDetail)opBomDetailList[opBomDetailCollectNum]).OPBOMSourceItemCode));

                                ProcessBeforeReturn(this.Status, msg);
                                return(msg);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    }
                }


                domainProvider.BeginTransaction();
                try
                {
                    BenQGuru.eMES.BaseSetting.BaseModelFacade dataModel = new BenQGuru.eMES.BaseSetting.BaseModelFacade(domainProvider);
                    Resource resource = (Resource)dataModel.GetResource(args.ResourceCode);

                    _helper = new ActionOnLineHelper(domainProvider);
                    ActionCheckStatus actionCheckStatus = new ActionCheckStatus();
                    actionCheckStatus.ProductInfo          = product;
                    actionCheckStatus.ProductInfo.Resource = resource;
                    ExtendSimulation lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;

                    BenQGuru.eMES.Material.WarehouseFacade wfacade = null;
                    if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                    {
                        wfacade = new WarehouseFacade(domainProvider);
                    }

                    IDCTClient client = act as IDCTClient;

                    //检查新上料是否在TS中而不可用
                    if (opBomdetailRealCollectList != null)
                    {
                        foreach (MINNO minno in opBomdetailRealCollectList)
                        {
                            if (!tsFacade.RunningCardCanBeClollected(minno.MItemPackedNo, CardType.CardType_Part))
                            {
                                msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + minno.MItemPackedNo));
                                break;
                            }
                        }
                    }

                    #region Check if key part was used

                    if (opBomdetailRealCollectList != null)
                    {
                        foreach (MINNO minno in opBomdetailRealCollectList)
                        {
                            if (minno.EAttribute1 == MCardType.MCardType_Keyparts)
                            {
                                if (KeyPartUsed(domainProvider, minno.MItemPackedNo, minno.MItemCode, false))
                                {
                                    msg.Add(new UserControl.Message(MessageType.Error, "$CS_Error_KeyPartUsed"));
                                    break;
                                }
                            }
                        }
                    }

                    #endregion

                    if (msg.IsSuccess())
                    {
                        object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count];
                        opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect);

                        string strRCard = product.NowSimulation.RunningCard;



                        msg.AddMessages(_helper.ActionWithTransaction(
                                            new CINNOActionEventArgs(
                                                ActionType.DataCollectAction_CollectINNO, strRCard,
                                                client.LoginedUser,
                                                client.ResourceCode,
                                                product,
                                                string.Empty,
                                                wfacade), actionCheckStatus, objOpBomdetailRealCollect));
                    }


                    #region 物料过账

                    if (msg.IsSuccess())
                    {
                        BaseModelFacade bMfacade = new BaseModelFacade(domainProvider);
                        object          objOP    = bMfacade.GetOperationByResource(client.ResourceCode);
                        string          strRCard = product.NowSimulation.RunningCard;

                        object[] objOpBomdetailRealCollect = new object[opBomdetailRealCollectList.Count];
                        opBomdetailRealCollectList.CopyTo(objOpBomdetailRealCollect);

                        if (opBomdetailRealCollectList != null && opBomdetailRealCollectList.Count > 0)
                        {
                            Messages messagesNew = new Messages();
                            string   ItemCode    = string.Empty;

                            DataCollectFacade dataCollectFacade = new DataCollectFacade(domainProvider);
                            object            objectSimulation  = dataCollectFacade.GetSimulation(strRCard);
                            if (objectSimulation != null)
                            {
                                ItemCode = ((Simulation)objectSimulation).ItemCode;
                            }

                            foreach (MINNO minno in opBomdetailRealCollectList)
                            {
                                messagesNew.AddMessages(_helper.ActionWithTransaction(new TryEventArgs(
                                                                                          ActionType.DataCollectAction_TryNew, client.LoginedUser, ((Operation2Resource)objOP).OPCode, client.ResourceCode,
                                                                                          ItemCode, strRCard, minno.MItemCode, minno.MItemPackedNo, string.Empty, true, true)));
                            }
                            msg.AddMessages(messagesNew);
                        }
                    }

                    #endregion

                    if (msg.IsSuccess())
                    {
                        if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                        {
                            if (wfacade != null)
                            {
                                wfacade.ExecCacheSQL();
                            }
                        }

                        #region 增加良品采集
                        {
                            Resource Resource = (Resource)dataModel.GetResource(client.ResourceCode);

                            Messages messages1 = new Messages();
                            if (actionCheckStatus.ProductInfo == null)
                            {
                                messages1 = _helper.GetIDInfo(ID);
                                actionCheckStatus.ProductInfo          = (ProductInfo)messages1.GetData().Values[0];
                                actionCheckStatus.ProductInfo.Resource = Resource;
                                lastSimulation = actionCheckStatus.ProductInfo.LastSimulation;
                                msg.AddMessages(messages1);
                            }
                            else        //将上一个Action的NowSimulation设置为本Action的LastSimulation
                            {
                                if (actionCheckStatus.ActionList.Count > 0)
                                {
                                    actionCheckStatus.ProductInfo = new ProductInfo();
                                    actionCheckStatus.ProductInfo.NowSimulation = new Simulation();
                                    actionCheckStatus.ProductInfo.Resource      = Resource;
                                    //actionCheckStatus.ProductInfo.LastSimulation =
                                    //    new ExtendSimulation(((ActionEventArgs)actionCheckStatus.ActionList[actionCheckStatus.ActionList.Count - 1]).ProductInfo.NowSimulation);
                                    actionCheckStatus.ProductInfo.LastSimulation =
                                        new ExtendSimulation((Simulation)(new DataCollectFacade(domainProvider)).GetLastSimulationOrderByDateAndTime(ID));
                                }
                            }

                            product = actionCheckStatus.ProductInfo;

                            // Changed end
                            if (msg.IsSuccess())
                            {
                                messages1.AddMessages(_helper.ActionWithTransaction(new ActionEventArgs(ActionType.DataCollectAction_GOOD, ID,
                                                                                                        client.LoginedUser, client.ResourceCode,
                                                                                                        product), actionCheckStatus));
                            }
                        }
                        #endregion
                    }

                    if (msg.IsSuccess())
                    {
                        domainProvider.CommitTransaction();
                        msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_CollectSuccess")));
                    }
                    else
                    {
                        domainProvider.RollbackTransaction();
                    }
                }
                catch (Exception ex)
                {
                    domainProvider.RollbackTransaction();

                    msg.Add(new UserControl.Message(ex));
                }
                finally
                {
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                }
            }

            if (msg.IsSuccess())
            {
                base.Action(act);

                this.ObjectState = null;
                this.keypartsHT  = null;
                this.opBomDetailList.Clear();
                this.opBomDetailCount      = 0;
                this.opBomDetailCollectNum = 0;
                this.opBomdetailRealCollectList.Clear();
                ID = string.Empty;
            }

            ProcessBeforeReturn(this.Status, msg);
            return(msg);
        }
Exemple #4
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);
                }
            }
        }