Esempio n. 1
0
        protected void cmdDelete_ServerClick(object sender, System.EventArgs e)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            ArrayList array = this.gridHelper.GetCheckedRows();

            if (array.Count > 0)
            {
                ArrayList oPBOMs = new ArrayList(array.Count);

                foreach (UltraGridRow row in array)
                {
                    object obj = this.GetEditObject(row);
                    if (obj != null)
                    {
                        oPBOMs.Add((OPBOM)obj);
                    }
                }

                this._opBOMFacade.DeleteOPBOM((OPBOM[])oPBOMs.ToArray(typeof(OPBOM)));

                this.RequestData();
                this.buttonHelper.PageActionStatusHandle(PageActionType.Delete);
            }
        }
Esempio n. 2
0
 public void SetUp()
 {
     persistBroker = new OLEDBPersistBroker("Provider=OraOLEDB.Oracle.1;Password=emes;Persist Security Info=True;User ID=emes;Data Source=sqcdemo");
     opBOMFacade   = new OPBOMFacade();
     modelFacade   = new ModelFacade();
     sbomFacade    = new SBOMFacade();
 }
Esempio n. 3
0
        /// <summary>
        /// ** nunit
        /// </summary>
        /// <param name="opItemControl"></param>
        public void UpdateItemControl(OPItemControl opItemControl)
        {
            //add by crystal chu 2005/04/20 OPBOM是否在使用中
            OPBOMFacade _opBOMFacade = new OPBOMFacade(this.DataProvider);

            _opBOMFacade.OPBOMChangedCheck(opItemControl.ItemCode, opItemControl.OPBOMCode, opItemControl.OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);
            this._helper.UpdateDomainObject(opItemControl);
        }
 private int GetRowCount()
 {
     if (_opBOMFacade == null)
     {
         _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
     }
     return(this._opBOMFacade.QueryOPBOMDetailCounts(FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ItemCode)), OPID, OPBOMCode, OPBOMVersion, RouteCode, string.Empty, this.Actiontype, OrgID));
 }
 private object[] LoadDataSource(int inclusive, int exclusive)
 {
     if (_opBOMFacade == null)
     {
         _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
     }
     return(this._opBOMFacade.QueryOPBOMDetail(FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ItemCode)), OPID, OPBOMCode, OPBOMVersion, RouteCode, string.Empty, this.Actiontype, inclusive, exclusive, OrgID));
 }
 private void BuildOPBOM()
 {
     if (_opBOMFacade == null)
     {
         _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
     }
     this._opBOMFacade.BuildOPBOM(ItemCode);
 }
Esempio n. 7
0
 private int GetRowCount()
 {
     if (_opBOMFacade == null)
     {
         _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
     }
     return(this._opBOMFacade.QueryOPBOMCount(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeQuery.Text)),
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtBOMCodeQuery.Text)), string.Empty, GlobalVariables.CurrentOrganizations.First().OrganizationID));
 }
Esempio n. 8
0
 private object[] LoadDataSource(int inclusive, int exclusive)
 {
     if (_opBOMFacade == null)
     {
         _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
     }
     return(this._opBOMFacade.QueryOPBOM(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeQuery.Text)),
                FormatHelper.CleanString(this.txtBOMCodeQuery.Text),
                string.Empty,
                inclusive, exclusive, GlobalVariables.CurrentOrganizations.First().OrganizationID));
 }
Esempio n. 9
0
        private object GetEditObject(Infragistics.WebUI.UltraWebGrid.UltraGridRow row)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            object obj = _opBOMFacade.GetOPBOM(row.Cells[1].Text, row.Cells[2].Text, row.Cells[7].Text, GlobalVariables.CurrentOrganizations.First().OrganizationID);

            if (obj != null)
            {
                return((OPBOM)obj);
            }

            return(null);
        }
        private object GetEditObject(GridRecord row)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            object obj = _opBOMFacade.GetOPBOMDetail(ItemCode, OPID, OPBOMCode, OPBOMVersion, row.Items.FindItemByKey("OPBOMItemCode").Value.ToString(), this.Actiontype.ToString(), GlobalVariables.CurrentOrganizations.First().OrganizationID);

            if (obj != null)
            {
                return((OPBOMDetail)obj);
            }

            return(null);
        }
Esempio n. 11
0
        /// <summary>
        /// 添加opitemcontrol,必须先判断相同的控制信息是否已经被添加,如果没有添加,则
        /// 其中的sequence取一组控制信息当中最大sequence加1
        /// ** nunit
        /// </summary>
        /// <param name="opItemControl"></param>
        public void AddOPItemControl(OPItemControl opItemControl)
        {
            if (opItemControl == null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Null_Paramter");
                //				throw new RemotingException(ErrorCenter.GetErrorServerDescription(typeof(OPBOMFacade),String.Format(ErrorCenter.ERROR_ARGUMENT_NULL,"opItemControl")));
            }

            //add by crystal chu 2005/04/20 OPBOM是否在使用中
            OPBOMFacade _opBOMFacade = new OPBOMFacade(this.DataProvider);

            _opBOMFacade.OPBOMChangedCheck(opItemControl.ItemCode, opItemControl.OPBOMCode, opItemControl.OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);

            object[] objs = QueryOPBOMItemControl(opItemControl.ItemCode, opItemControl.OPBOMItemCode, opItemControl.OPBOMCode, opItemControl.OPBOMVersion, opItemControl.OPID,
                                                  opItemControl.DateCodeStart, opItemControl.DateCodeEnd, opItemControl.VendorCode, opItemControl.VendorItemCode, opItemControl.ItemVersion,
                                                  opItemControl.BIOSVersion, opItemControl.PCBAVersion, opItemControl.CardStart, opItemControl.CardEnd);
            if (objs != null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_OPItemControl_Exist");
                //				throw new RemotingException(ErrorCenter.GetErrorServerDescription(typeof(OPItemControlFacade),String.Format(ErrorCenter.ERROR_ADDOPITEMCONTROL, opItemControl.OPBOMItemCode)));
            }
            objs = QueryOPBOMItemControl(opItemControl.ItemCode, opItemControl.OPBOMItemCode, opItemControl.OPBOMCode, opItemControl.OPBOMVersion, opItemControl.OPID, string.Empty,
                                         string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
            int sequence = 0;

            if (objs != null)
            {
                sequence = System.Int32.Parse(((OPItemControl)objs[objs.Length - 1]).Sequence.ToString()) + 1;
            }
            try
            {
                //Laws Lu,2006/11/13 uniform system collect date
                DBDateTime dbDateTime;

                dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider);

                opItemControl.MaintainDate = dbDateTime.DBDate;
                opItemControl.MaintainTime = dbDateTime.DBTime;

                opItemControl.Sequence = sequence;
                this.DataProvider.Insert(opItemControl);
            }
            catch (Exception ex)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_AddOPItemControl", String.Format("$OPBOMItemcode='{0}'", opItemControl.OPBOMItemCode), ex);
                //				throw new RemotingException(ErrorCenter.GetErrorServerDescription(typeof(OPItemControl), String.Format(ErrorCenter.ERROR_ADDOPITEMCONTROL, opItemControl.OPBOMItemCode)), ex);
            }
        }
Esempio n. 12
0
        protected void cmdSave_ServerClick(object sender, System.EventArgs e)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            object opbom = this.GetEditObject();

            if (opbom != null)
            {
                this._opBOMFacade.UpdateOPBOM((OPBOM)opbom);

                this.RequestData();
                this.buttonHelper.PageActionStatusHandle(PageActionType.Save);
            }
        }
Esempio n. 13
0
 //Add By Bernard @ 2010-10-28
 protected void ddlControlTypeEdit_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (_opBOMFacade == null)
         {
             _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
         }
         this.ddlControlTypeEdit.Items.Clear();
         string[] controls = this._opBOMFacade.GetItemControlTypes();
         ddlControlTypeEdit.Items.Add(new ListItem("", ""));
         for (int i = 0; i < controls.Length; i++)
         {
             this.ddlControlTypeEdit.Items.Add(new ListItem(this.languageComponent1.GetString(controls[i]), controls[i]));
         }
     }
 }
Esempio n. 14
0
        /// <summary>
        /// 判断该bom是否已经被工单使用,如果使用则对应opbom上料料品的控制设置则不可以被删除
        /// ** nunit
        /// </summary>
        /// <param name="opItemControl"></param>
        public void DeleteItemControl(OPItemControl opItemControl)
        {
            if (opItemControl == null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Null_Paramter");
                //				throw new RemotingException(ErrorCenter.GetErrorServerDescription(typeof(OPBOMFacade),String.Format(ErrorCenter.ERROR_ARGUMENT_NULL,"opItemControl")));
            }

            //add by crystal chu 2005/04/20 OPBOM是否在使用中
            OPBOMFacade _opBOMFacade = new OPBOMFacade(this.DataProvider);

            _opBOMFacade.OPBOMChangedCheck(opItemControl.ItemCode, opItemControl.OPBOMCode, opItemControl.OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);

            try
            {
                this.DataProvider.Delete(opItemControl);
            }
            catch (Exception ex)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_DeleteItemControl", String.Format("[$OPBOMItemcode='{0}']", opItemControl.OPBOMItemCode), ex);
                //				throw new RemotingException(ErrorCenter.GetErrorServerDescription(typeof(OPItemControl), string.Format(ErrorCenter.ERROR_DELETEITEMCONTROL,opItemControl.OPBOMItemCode)), ex);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 根据OnWIPItem的上料记录,反推上料的BOM,然后建立对应的下料BOM
        /// </summary>
        private Messages BuildOPBomKeyPartsByOnWIPItem(string rcard, ProductInfo product, OnWIPItem[] wipItems)
        {
            Messages msg = new Messages();

            MO       mo;
            MOFacade moFacade = new MOFacade(DataProvider);

            if (product != null && product.CurrentMO != null)
            {
                mo = product.CurrentMO;
            }
            else
            {
                mo = (MO)moFacade.GetMO(product.LastSimulation.MOCode);
            }

            OPBOMFacade opBOMFacade = new OPBOMFacade(DataProvider);

            object[] objOpBoms = opBOMFacade.GetOPBOMDetails(
                product.LastSimulation.MOCode
                , wipItems[0].RouteCode
                , wipItems[0].OPCode);
            for (int i = 0; objOpBoms != null && i < objOpBoms.Length; i++)
            {
                ((OPBOMDetail)objOpBoms[i]).ActionType = (int)MaterialType.DropMaterial;
            }
            opBomKeyparts = new OPBomKeyparts(objOpBoms, Convert.ToInt32(mo.IDMergeRule), this.DataProvider);

            if (opBomKeyparts.Count == 0)
            {
                msg.Add(new UserControl.Message("$CS_NOOPBomInfo $CS_Param_MOCode =" + product.LastSimulation.MOCode
                                                + " $CS_Param_RouteCode =" + wipItems[0].RouteCode
                                                + " $CS_Param_OPCode =" + wipItems[0].OPCode));
            }

            return(msg);
        }
Esempio n. 16
0
        private object GetEditObject()
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            if (this.ValidateInput())
            {
                OPBOM oPBOM = this._opBOMFacade.CreateNewOPBOM();

                oPBOM.ItemCode         = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.drpItemCodeEdit.SelectedValue, 40));
                oPBOM.OPBOMCode        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtOPBOMCodeEdit.Text, 40));
                oPBOM.OPBOMDescription = FormatHelper.CleanString(this.txtDescriptionEdit.Text, 100);
                oPBOM.OPBOMRoute       = FormatHelper.CleanString(this.drpRouteCodeEdit.SelectedValue, 40);
                //oPBOM.OPBOMVersion = FormatHelper.PKCapitalFormat(Const.BOM_VERSION);
                oPBOM.MaintainUser   = this.GetUserCode();
                oPBOM.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;
                return(oPBOM);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 17
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. 18
0
        public Messages CKeyPartsCollect(XmlNode node)
        {
            string action = node.Attributes["action"].Value;
            string card   = node["code"].InnerText;
            string res    = node["resource"].InnerText;
            string usr    = node["user"].InnerText;
            string data   = node["data"].InnerText;

            string[] ss          = data.Split(';');
            string   MOSplitRule = node["MOSplitRule"].InnerText;

            Messages productmessages = new Messages();

            try
            {
                //数据准备
                productmessages.AddMessages(dataCollect.GetIDInfo(card));
                ProductInfo product;
                if (productmessages.IsSuccess())
                {
                    product = (ProductInfo)productmessages.GetData().Values[0];
                }
                else
                {
                    return(productmessages);
                }

                #region 先推途程,然后找OPBOM


                productmessages.AddMessages(dataCollect.CheckID(new CKeypartsActionEventArgs(
                                                                    ActionType.DataCollectAction_CollectKeyParts, card, usr,
                                                                    res, product, null)));

                if (productmessages.IsSuccess())
                {
                }
                else
                {
                    return(productmessages);
                }
                OPBomKeyparts opBomKeyparts;
                try
                {
                    BenQGuru.eMES.Common.Domain.IDomainDataProvider _provider = _provider = BenQGuru.eMES.Common.DomainDataProvider.DomainDataProviderManager.DomainDataProvider();
                    OPBOMFacade opBOMFacade = new OPBOMFacade(_provider);
                    opBomKeyparts = new OPBomKeyparts(opBOMFacade.GetOPBOMDetails(product.NowSimulation.MOCode,
                                                                                  product.NowSimulation.RouteCode, product.NowSimulation.OPCode), Convert.ToInt32(MOSplitRule), this.DataProvider);
                    if (opBomKeyparts.Count == 0)
                    {
                        productmessages.Add(new Message("$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode
                                                        + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode
                                                        + " $CS_Param_OPCode=" + product.NowSimulation.OPCode));

                        return(productmessages);
                    }
                    #endregion

                    for (int i = 0; i < ss.Length; i++)
                    {
                        opBomKeyparts.AddKeyparts(ss[i].ToUpper());
                    }
                }
                catch (Exception e)
                {
                    productmessages.Add(new Message(e));
                    return(productmessages);
                }
                productmessages.AddMessages(dataCollect.Action(new CKeypartsActionEventArgs(action, card,
                                                                                            usr, res, product, opBomKeyparts)));
                //检查数据
                if (productmessages.IsSuccess())
                {
                    DataCollectFacade df = new DataCollectFacade();
                    Simulation        s2 = (Simulation)df.GetSimulation(card);
                    if (s2 == null)
                    {
                        productmessages.Add(new Message(MessageType.Error,
                                                        "天拉"));
                        return(productmessages);
                    }
                }
                else
                {
                    return(productmessages);
                }
                return(productmessages);
            }
            catch (Exception e)
            {
                productmessages.Add(new Message(e));
                return(productmessages);
            }
        }
        protected void cmdSave_ServerClick(object sender, System.EventArgs e)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            object opBOMDetail = this.GetEditObject();

            if (opBOMDetail != null)
            {
                DataProvider.BeginTransaction();
                try
                {
                    OPBOMDetail opBOPDTL = opBOMDetail as OPBOMDetail;

                    //this._opBOMFacade.UpdateOPBOMItem( opBOPDTL );
                    this._opBOMFacade.DeleteOPBOMItem(opBOPDTL);
                    this._opBOMFacade.AddOPBOMItem(opBOPDTL);

                    //Laws Lu,2006/09/01

                    /*1,目前工序BOM建立逻辑不变,增加生效检查功能和失效功能,
                     * 初始建立的工序BOM资料处于失效状态,通过生效检查后处于生效状态,
                     * 此时不允许修改,只有失效状态的工序BOM才可以修改。
                     * 生效检查逻辑包括:完整的工序BOM包含的子阶物料(替代料)必须包含某工单所有的已发料物料代码,
                     * 比如,工单发料资料中包含5种物料,则工序BOM中的子阶物料必须也有这五种物料,
                     * 且首选料不能有这五种物料之外的其他物料。具体的工单由用户在界面指定。
                     * 举例如下:工单发料资料中有A,B,C,D四种物料*/
                    //Laws Lu,2006/12/15 取消默认为失效的设置
                    MOFacade moFac = (new FacadeFactory(DataProvider)).CreateMOFacade();

                    object objOPBOM = moFac.GetOPBOM(opBOPDTL.ItemCode, opBOPDTL.OPBOMCode, opBOPDTL.OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    //
                    if (objOPBOM != null)
                    {
                        OPBOM opBOM = objOPBOM as OPBOM;

                        opBOM.Avialable = 1;

                        moFac.UpdateOPBOM(opBOM);
                    }

                    DataProvider.CommitTransaction();
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);

                    DataProvider.RollbackTransaction();
                    throw ex;
                }
                finally
                {
                    ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                }

                this.RequestData();
                this.buttonHelper.PageActionStatusHandle(PageActionType.Save);
            }
            SetcbSourceSBOMEdit(true);
        }
Esempio n. 20
0
        protected void cmdAdd_ServerClick(object sender, System.EventArgs e)
        {
            if (_opBOMFacade == null)
            {
                _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
            }
            if (_itemFacade == null)
            {
                _itemFacade = new FacadeFactory(base.DataProvider).CreateItemFacade();
            }

            ArrayList array = this.GetNoRepeatSelectObjs(this.gridHelper.GetCheckedRows());

            if (array.Count > 0)
            {
                ArrayList sboms        = new ArrayList();
                Hashtable notInOPBOMHT = this.GetNotInOPBOMHashtalbe();
                string    returnMsg    = string.Empty;

                foreach (GridRecord row in array)
                {
                    object obj = this.GetEditObject(row);
                    if (obj != null)
                    {
                        if (notInOPBOMHT.Contains(((SBOM)obj).SBOMItemCode))//只有不在opbom中的子阶料才可以添加到列表中
                        {
                            sboms.Add((SBOM)obj);
                        }
                    }
                }
                if (sboms.Count > 0)
                {
                    ItemRoute2OP itemRoute2Operation = (ItemRoute2OP)_itemFacade.GetItemRoute2Op(OPID, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                    _opBOMFacade.AssignBOMItemToOperation(OPBOMCode, OPBOMVersion, itemRoute2Operation, (SBOM[])sboms.ToArray(typeof(SBOM)), this.Actiontype);

                    //Laws Lu,2006/09/01

                    /*1,目前工序BOM建立逻辑不变,增加生效检查功能和失效功能,
                     * 初始建立的工序BOM资料处于失效状态,通过生效检查后处于生效状态,
                     * 此时不允许修改,只有失效状态的工序BOM才可以修改。
                     * 生效检查逻辑包括:完整的工序BOM包含的子阶物料(替代料)必须包含某工单所有的已发料物料代码,
                     * 比如,工单发料资料中包含5种物料,则工序BOM中的子阶物料必须也有这五种物料,
                     * 且首选料不能有这五种物料之外的其他物料。具体的工单由用户在界面指定。
                     * 举例如下:工单发料资料中有A,B,C,D四种物料*/
                    DataProvider.BeginTransaction();
                    try
                    {
                        MOFacade moFac = (new FacadeFactory(DataProvider)).CreateMOFacade();

                        object objOPBOM = moFac.GetOPBOM(itemRoute2Operation.ItemCode, OPBOMCode, OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);

                        if (objOPBOM != null)
                        {
                            OPBOM opBOM = objOPBOM as OPBOM;

                            opBOM.Avialable = 0;

                            moFac.UpdateOPBOM(opBOM);
                        }
                        // Added by Icyer 2005/08/16
                        // 同时将物料加入到物料主档中
                        BenQGuru.eMES.Material.WarehouseFacade wf = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
                        wf.AddWarehouseItem((SBOM[])sboms.ToArray(typeof(SBOM)));

                        DataProvider.CommitTransaction();
                        //this.cmdReturn_ServerClick(sender,e);
                        // Added end
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message);

                        DataProvider.RollbackTransaction();
                        throw ex;
                    }
                    finally
                    {
                        ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                    }

                    foreach (SBOM somobject in (SBOM[])sboms.ToArray(typeof(SBOM)))
                    {
                        ItemFacade itemFacade = new ItemFacade(this.DataProvider);
                        Domain.MOModel.Material MaterialObject = (Domain.MOModel.Material)itemFacade.GetMaterial(somobject.SBOMItemCode.Trim().ToUpper(), GlobalVariables.CurrentOrganizations.First().OrganizationID);
                        if (MaterialObject != null)
                        {
                            if (MaterialObject.MaterialCheckType.IndexOf(OPBOMDetailCheckType.CHECK_LINKBARCODE) < 0)
                            {
                                returnMsg += "$ITEM_NOT_LINKBARCODE:" + somobject.SBOMItemCode.Trim().ToUpper() + "\n ";
                            }
                        }
                    }
                }

                //if (addItemMessage.Trim()!=string.Empty && addItemMessage.Trim().Length>0)
                //{
                //    WebInfoPublish.Publish(this, addItemMessage, this.languageComponent1);
                //}

                this.RequestData();
                this.Return(sender, e, returnMsg);
            }
        }
Esempio n. 21
0
        // Added by Icyer 2006/12/15
        // 检查产品
        private Messages CheckProduct(object act, string runningCard)
        {
            // 查询产品信息
            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            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;
            }

            ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

            UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard);
            ProductInfo          product    = (ProductInfo)msgProduct.GetData().Values[0];

            if (product == null || product.LastSimulation == null)
            {
                msgProduct.ClearMessages();
                msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                return(msgProduct);
            }
            mergeList = new Hashtable();
            mergeList.Add("ProdcutInfo", msgProduct);

            // 转换比例
            //this.IDMergeRule = Convert.ToInt32(product.LastSimulation.IDMergeRule);	// 转换比例从工序中读

            IDCTClient  client      = act as IDCTClient;
            OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider);
            // 检查途程
            Messages messages1 = _helper.CheckID(
                new CKeypartsActionEventArgs(
                    ActionType.DataCollectAction_Split,
                    product.LastSimulation.RunningCard,
                    client.LoginedUser,
                    client.ResourceCode,
                    product,
                    null,
                    null));

            if (messages1.IsSuccess() == true)
            {
                object op = new ItemFacade(domainProvider).GetItemRoute2Operation(
                    product.NowSimulation.ItemCode,
                    product.NowSimulation.RouteCode,
                    product.NowSimulation.OPCode);
                if (op == null)
                {
                    messages1.Add(new UserControl.Message(MessageType.Error, "$Error_CS_Current_OP_Not_Exist"));
                    return(messages1);
                }
                if (((ItemRoute2OP)op).OPControl[(int)BenQGuru.eMES.BaseSetting.OperationList.IDTranslation] != '1')
                {
                    messages1.Add(new UserControl.Message(MessageType.Error, "$CS_OP_Not_SplitOP"));                            //当前工序不是序号转换工序
                    return(messages1);
                }
                // 转换比例
                this.IDMergeRule = 1;
                if (((ItemRoute2OP)op).IDMergeType == IDMergeType.IDMERGETYPE_ROUTER)
                {
                    this.IDMergeRule = (int)((ItemRoute2OP)op).IDMergeRule;
                }
                // 序号转换类型
                mergeIdType = ((ItemRoute2OP)op).IDMergeType;
                ArrayList listId = new ArrayList();
                mergeList.Add("MergeIdList", listId);
            }
            else
            {
                return(messages1);
            }

            return(msgProduct);
        }
        private object GetEditObject()
        {
            if (this.ValidateInput())
            {
                if (_itemFacade == null)
                {
                    _itemFacade = new FacadeFactory(base.DataProvider).CreateItemFacade();
                }
                if (_opBOMFacade == null)
                {
                    _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
                }

                OPBOMDetail opBOMDetail = this._opBOMFacade.CreateNewOPBOMDetail();

                opBOMDetail.OPBOMItemSeq         = int.Parse(this.TextboxOPBOMItemSeqEdit.Text);
                opBOMDetail.IsItemCheck          = OPBOMFacade.OPBOMISItemCheckValue_DEFAULT;
                opBOMDetail.ItemCheckValue       = OPBOMFacade.OPBOMItemCheckValue_DEFAULT;
                opBOMDetail.ItemCode             = ItemCode;
                opBOMDetail.MaintainUser         = this.GetUserCode();
                opBOMDetail.OPBOMCode            = OPBOMCode;
                opBOMDetail.OPBOMItemCode        = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeEdit.Text));
                opBOMDetail.OPBOMItemControlType = FormatHelper.CleanString(this.drpItemControlTypeEdit.SelectedValue);
                opBOMDetail.OPBOMItemName        = FormatHelper.CleanString(this.txtBOMItemNameEdit.Text);
                opBOMDetail.OPBOMItemQty         = System.Decimal.Parse(this.txtItemQtyEdit.Text);
                opBOMDetail.OPBOMItemType        = OPBOMFacade.OPBOMITEMTYPE_DEFAULT;
                opBOMDetail.OPBOMItemUOM         = FormatHelper.CleanString(this.txtBOMItemUOMEdit.Text);
                opBOMDetail.OPBOMSourceItemCode  = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtSourceItemCodeEdit.Text));

                ItemRoute2OP itemRoute2OP = (ItemRoute2OP)_itemFacade.GetItemRoute2Op(OPID, GlobalVariables.CurrentOrganizations.First().OrganizationID);

                opBOMDetail.OPID                   = OPID;
                opBOMDetail.OPBOMVersion           = this.DropdownlistSBOMVersionQuery.SelectedValue;
                opBOMDetail.OPCode                 = itemRoute2OP.OPCode;
                opBOMDetail.OPBOMItemEffectiveDate = 20051231;
                opBOMDetail.OPBOMItemEffectiveTime = 0;
                opBOMDetail.OPBOMItemInvalidDate   = 21001231;
                opBOMDetail.OPBOMItemInvalidTime   = 0;
                opBOMDetail.OPBOMItemVersion       = this.DropdownlistSBOMVersionQuery.SelectedValue;
                opBOMDetail.ActionType             = this.Actiontype;
                opBOMDetail.OrganizationID         = GlobalVariables.CurrentOrganizations.First().OrganizationID;

                if (chkValid.Checked)
                {
                    opBOMDetail.OPBOMValid = int.Parse(BenQGuru.eMES.Web.Helper.FormatHelper.TRUE_STRING);
                }
                else
                {
                    opBOMDetail.OPBOMValid = int.Parse(BenQGuru.eMES.Web.Helper.FormatHelper.FALSE_STRING);
                }

                //Parse Type
                opBOMDetail.OPBOMParseType = string.Empty;
                if (chkParseBarcode.Checked)
                {
                    opBOMDetail.OPBOMParseType += "," + OPBOMDetailParseType.PARSE_BARCODE;
                }
                if (chkParsePrepare.Checked)
                {
                    opBOMDetail.OPBOMParseType += "," + OPBOMDetailParseType.PARSE_PREPARE;
                }
                if (chkParseProduct.Checked)
                {
                    opBOMDetail.OPBOMParseType += "," + OPBOMDetailParseType.PARSE_PRODUCT;
                }
                if (opBOMDetail.OPBOMParseType.Length > 0)
                {
                    opBOMDetail.OPBOMParseType = opBOMDetail.OPBOMParseType.Substring(1);
                }
                else
                {
                    opBOMDetail.OPBOMParseType = " ";
                }
                if (chkParseProduct.Checked && this.chkCheckStatus.Checked)
                {
                    opBOMDetail.CheckStatus = BenQGuru.eMES.Web.Helper.FormatHelper.TRUE_STRING;
                }
                else
                {
                    opBOMDetail.CheckStatus = BenQGuru.eMES.Web.Helper.FormatHelper.FALSE_STRING;
                }

                //Check Type
                opBOMDetail.OPBOMCheckType = string.Empty;
                if (chkLinkBarcode.Checked)
                {
                    opBOMDetail.OPBOMCheckType += "," + OPBOMDetailCheckType.CHECK_LINKBARCODE;
                }
                if (chkCompareItem.Checked)
                {
                    opBOMDetail.OPBOMCheckType += "," + OPBOMDetailCheckType.CHECK_COMPAREITEM;
                }
                if (opBOMDetail.OPBOMCheckType.Length > 0)
                {
                    opBOMDetail.OPBOMCheckType = opBOMDetail.OPBOMCheckType.Substring(1);
                }
                else
                {
                    opBOMDetail.OPBOMCheckType = " ";
                }

                if (chkSNLength.Checked)
                {
                    int snLength = int.Parse(this.txtSNLength.Text);
                    opBOMDetail.SerialNoLength = snLength;
                }
                else
                {
                    opBOMDetail.SerialNoLength = 0;
                }

                if (this.chkNeedVendor.Checked)
                {
                    opBOMDetail.NeedVendor = NeedVendor.NeedVendor_Y;
                }
                else
                {
                    opBOMDetail.NeedVendor = NeedVendor.NeedVendor_N;
                }

                return(opBOMDetail);
            }
            else
            {
                return(null);
            }
        }
        //private void gridWebGrid_DblClick(object sender, Infragistics.WebUI.UltraWebGrid.ClickEventArgs e)
        //{
        //    object obj = this.GetEditObject(e.Row);

        //    if (obj != null)
        //    {
        //        this.SetEditObject(obj);

        //        this.buttonHelper.PageActionStatusHandle(PageActionType.Update);
        //    }

        //}

        protected void cmdAdd_ServerClick(object sender, System.EventArgs e)
        {
            if (chbSourceSBOMEdit.Checked)
            {
                Response.Redirect(this.MakeRedirectUrl("FOPBOMOperationItemSP.aspx",
                                                       new string[] { "itemcode", "opbomcode", "opbomversion", "routecode", "opid", "actiontype", "OrgID" },
                                                       new string[] { ItemCode, OPBOMCode, OPBOMVersion, RouteCode, OPID, this.Actiontype.ToString(), OrgID.ToString() }));
            }
            else
            {
                object opBOMDetail = this.GetEditObject();

                if (opBOMDetail != null)
                {
                    if (_itemFacade == null)
                    {
                        _itemFacade = new FacadeFactory(base.DataProvider).CreateItemFacade();
                    }
                    if (_itemFacade.GetMaterial(((OPBOMDetail)opBOMDetail).OPBOMItemCode, ((OPBOMDetail)opBOMDetail).OrganizationID) == null)
                    {
                        ExceptionManager.Raise(this.GetType().BaseType, "$Error_Material_NotFound", lblBOMItemCodeEdit.Text + ": " + ((OPBOMDetail)opBOMDetail).OPBOMItemCode);
                    }

                    if (_itemFacade.GetMaterial(((OPBOMDetail)opBOMDetail).OPBOMSourceItemCode, ((OPBOMDetail)opBOMDetail).OrganizationID) == null)
                    {
                        ExceptionManager.Raise(this.GetType().BaseType, "$Error_Material_NotFound", lblSourceItemCode.Text + ": " + ((OPBOMDetail)opBOMDetail).OPBOMSourceItemCode);
                    }

                    if (_opBOMFacade == null)
                    {
                        _opBOMFacade = new FacadeFactory(base.DataProvider).CreateOPBOMFacade();
                    }
                    DataProvider.BeginTransaction();
                    try
                    {
                        OPBOMDetail opBOPDTL = opBOMDetail as OPBOMDetail;
                        this._opBOMFacade.AddOPBOMItem(opBOPDTL);
                        //Laws Lu,2006/09/01

                        /*1,目前工序BOM建立逻辑不变,增加生效检查功能和失效功能,
                         * 初始建立的工序BOM资料处于失效状态,通过生效检查后处于生效状态,
                         * 此时不允许修改,只有失效状态的工序BOM才可以修改。
                         * 生效检查逻辑包括:完整的工序BOM包含的子阶物料(替代料)必须包含某工单所有的已发料物料代码,
                         * 比如,工单发料资料中包含5种物料,则工序BOM中的子阶物料必须也有这五种物料,
                         * 且首选料不能有这五种物料之外的其他物料。具体的工单由用户在界面指定。
                         * 举例如下:工单发料资料中有A,B,C,D四种物料*/
                        //Laws Lu,2006/12/15 取消默认为失效状态

                        MOFacade moFac = (new FacadeFactory(DataProvider)).CreateMOFacade();

                        object objOPBOM = moFac.GetOPBOM(opBOPDTL.ItemCode, opBOPDTL.OPBOMCode, opBOPDTL.OPBOMVersion, GlobalVariables.CurrentOrganizations.First().OrganizationID);
                        //
                        if (objOPBOM != null)
                        {
                            OPBOM opBOM = objOPBOM as OPBOM;

                            opBOM.Avialable = 1;

                            moFac.UpdateOPBOM(opBOM);
                        }
                        // Added by Icyer 2005/08/16
                        // 同时将物料加入到物料主档中
                        BenQGuru.eMES.Material.WarehouseFacade wf = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
                        wf.AddWarehouseItem((OPBOMDetail)opBOMDetail);

                        DataProvider.CommitTransaction();
                        // Added end
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message);

                        DataProvider.RollbackTransaction();
                        throw ex;
                    }
                    finally
                    {
                        ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                    }

                    this.gridHelper.GridBind(this.pagerToolBar.PageIndex, this.pagerToolBar.PageSize);
                    this.pagerToolBar.RowCount = GetRowCount();
                    this.buttonHelper.PageActionStatusHandle(PageActionType.Add);
                }
            }
            SetcbSourceSBOMEdit(true);
        }
Esempio n. 24
0
        // Added by Icyer 2006/12/15
        // 检查产品
        private Messages CheckProduct(object act, string runningCard)
        {
            // 查询产品信息
            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            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;
            }

            try
            {
                //为改善性能
                ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = false;
                ((SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();

                ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

                // Added by Icyer 2007/03/16	如果归属工单,则做归属工单检查,否则做序列号途程检查
                UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard);
                ProductInfo          product    = (ProductInfo)msgProduct.GetData().Values[0];
                MO           moWillGo           = null;
                ActionGoToMO actionGoMO         = new ActionGoToMO(domainProvider);
                Messages     msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard);
                if (msgMo.IsSuccess() == false)         // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误
                {
                    return(msgMo);
                }
                if (msgMo.GetData() != null)    // 需要归属工单,做归属工单检查
                {
                    product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation();
                    UserControl.Message msgMoData = msgMo.GetData();
                    moWillGo = (MO)msgMoData.Values[0];
                    moCode   = moWillGo.MOCode;
                    ActionGoToMO          goToMO            = new ActionGoToMO(domainProvider);
                    GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs(
                        ActionType.DataCollectAction_GoMO,
                        runningCard,
                        ((IDCTClient)act).LoginedUser,
                        ((IDCTClient)act).ResourceCode,
                        product,
                        moWillGo.MOCode);
                    msgMo = goToMO.CheckIn(MOActionEventArgs);
                    if (!MOActionEventArgs.PassCheck)
                    {
                        msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                    ActionType.DataCollectAction_CollectINNO,
                                                    runningCard,
                                                    ((IDCTClient)act).LoginedUser,
                                                    ((IDCTClient)act).ResourceCode,
                                                    product, null, null));
                    }
                }
                else    // 不需要归属工单,检查序列号途程
                {
                    if (product == null || product.LastSimulation == null)
                    {
                        msgProduct.ClearMessages();
                        msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                        return(msgProduct);
                    }
                    msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                ActionType.DataCollectAction_CollectINNO,
                                                runningCard,
                                                ((IDCTClient)act).LoginedUser,
                                                ((IDCTClient)act).ResourceCode,
                                                product, null, null));
                }
                if (msgMo.IsSuccess() == false)
                {
                    return(msgMo);
                }
                // Added end

                keypartsHT = new Hashtable();
                keypartsHT.Add("ProdcutInfo", product);
                keypartsHT.Add("MOWillGo", moWillGo);

                IDCTClient  client       = act as IDCTClient;
                OPBOMFacade opBOMFacade  = new OPBOMFacade(domainProvider);
                MOFacade    moFacade     = new MOFacade(domainProvider);
                object[]    objBomDetail = null;
                Messages    messages1    = new Messages();
                if (moWillGo == null)
                {
                    // 检查途程
                    messages1 = _helper.CheckID(
                        new CKeypartsActionEventArgs(
                            ActionType.DataCollectAction_CollectINNO,
                            product.LastSimulation.RunningCard,
                            client.LoginedUser,
                            client.ResourceCode,
                            product,
                            null,
                            null));
                }
                if (messages1.IsSuccess() == true)
                {
                    //objBomDetail = opBOMFacade.GetOPBOMDetails(
                    //    product.NowSimulation.MOCode,
                    //    product.NowSimulation.RouteCode,
                    //    product.NowSimulation.OPCode);

                    //Miodified by Scott
                    MO moNew = (MO)moFacade.GetMO(product.NowSimulation.MOCode);

                    objBomDetail = opBOMFacade.QueryOPBOMDetail(product.NowSimulation.ItemCode, string.Empty, string.Empty, moNew.BOMVersion,
                                                                product.NowSimulation.RouteCode, product.NowSimulation.OPCode, (int)MaterialType.CollectMaterial,
                                                                int.MinValue, int.MaxValue, moNew.OrganizationID, true);

                    if (objBomDetail == null)
                    {
                        messages1.Add(new UserControl.Message(MessageType.Error, "$CS_OPBOM_NotFound"));
                    }
                }
                else
                {
                    return(messages1);
                }

                //object mo = moFacade.GetMO( product.LastSimulation.MOCode );
                object mo = moWillGo;
                if (moWillGo == null)
                {
                    mo = moFacade.GetMO(product.LastSimulation.MOCode);
                }

                //OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider);
                // 查询OPBOM
                if (objBomDetail == null)
                {
                    msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode
                                               + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode
                                               + " $CS_Param_OPCode =" + product.NowSimulation.OPCode));
                    return(msgProduct);
                }
                else
                {
                    this.filterOpBomDetail(ref objBomDetail);

                    if (objBomDetail == null || objBomDetail.Length <= 0)
                    {
                        msgProduct.Add(new Message(MessageType.Error, "$CS_OPBOM_NotFound"));
                        return(msgProduct);
                    }

                    for (int i = 0; i < objBomDetail.Length; i++)
                    {
                        if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot")
                        {
                            opBomDetailCount += 1;
                        }
                        else
                        {
                            opBomDetailCount += Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty);
                        }
                    }
                    for (int i = 0; i < objBomDetail.Length; i++)
                    {
                        if (((OPBOMDetail)objBomDetail[i]).OPBOMItemControlType == "item_control_lot")
                        {
                            opBomDetailList.Add(objBomDetail[i]);
                        }
                        else
                        {
                            int number = Convert.ToInt32(((OPBOMDetail)objBomDetail[i]).OPBOMItemQty);
                            for (int j = 0; j < number; j++)
                            {
                                opBomDetailList.Add(objBomDetail[i]);
                            }
                        }
                    }

                    if (((OPBOMDetail)objBomDetail[0]).OPBOMItemControlType == BOMItemControlType.ITEM_CONTROL_LOT)
                    {
                        msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Lot " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode));
                    }
                    else
                    {
                        msgProduct.Add(new UserControl.Message(MessageType.Normal, ">>$DCT_PLEASE_INPUT_Keyparts " + ((OPBOMDetail)objBomDetail[0]).OPBOMSourceItemCode));
                    }
                    // keypartsHT.Add("KeypartsInfo", opBomKeyparts);
                    keypartsHT.Add("Opbomdetail", objBomDetail);
                }
                return(msgProduct);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)domainProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
Esempio n. 25
0
        // Added by Icyer 2006/12/15
        // 检查产品
        private Messages CheckProduct(object act, string runningCard)
        {
            // 查询产品信息
            BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider domainProvider = null;
            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;
            }

            ActionOnLineHelper _helper = new ActionOnLineHelper(domainProvider);

            /*	Removed by Icyer 2007/03/16
             * UserControl.Messages msgProduct =  _helper.GetIDInfo( runningCard ) ;
             * ProductInfo product= (ProductInfo)msgProduct.GetData().Values[0];
             * if (product == null || product.LastSimulation == null)
             * {
             *      msgProduct.ClearMessages();
             *      msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
             *      return msgProduct;
             * }
             */

            // Added by Icyer 2007/03/16	如果归属工单,则做归属工单检查,否则做序列号途程检查
            UserControl.Messages msgProduct = _helper.GetIDInfo(runningCard);
            ProductInfo          product    = (ProductInfo)msgProduct.GetData().Values[0];
            MO           moWillGo           = null;
            ActionGoToMO actionGoMO         = new ActionGoToMO(domainProvider);
            Messages     msgMo = actionGoMO.GetItemCodeFromGoMoRCard(((IDCTClient)act).ResourceCode, runningCard);

            if (msgMo.IsSuccess() == false)                     // 如果有错误,表示需要归属工单,但是解析工单或查询工单发生错误
            {
                return(msgMo);
            }
            if (msgMo.GetData() != null)                // 需要归属工单,做归属工单检查
            {
                product.NowSimulation = new BenQGuru.eMES.Domain.DataCollect.Simulation();
                UserControl.Message msgMoData = msgMo.GetData();
                moWillGo = (MO)msgMoData.Values[0];
                ActionGoToMO          goToMO            = new ActionGoToMO(domainProvider);
                GoToMOActionEventArgs MOActionEventArgs = new GoToMOActionEventArgs(
                    ActionType.DataCollectAction_GoMO,
                    runningCard,
                    ((IDCTClient)act).LoginedUser,
                    ((IDCTClient)act).ResourceCode,
                    product,
                    moWillGo.MOCode);
                msgMo = goToMO.CheckIn(MOActionEventArgs);
                if (!MOActionEventArgs.PassCheck)
                {
                    msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                                ActionType.DataCollectAction_CollectKeyParts,
                                                runningCard,
                                                ((IDCTClient)act).LoginedUser,
                                                ((IDCTClient)act).ResourceCode,
                                                product, null, null));
                }
            }
            else                // 不需要归属工单,检查序列号途程
            {
                if (product == null || product.LastSimulation == null)
                {
                    msgProduct.ClearMessages();
                    msgProduct.Add(new UserControl.Message(MessageType.Error, "$NoSimulation"));
                    return(msgProduct);
                }
                msgMo = _helper.CheckID(new CKeypartsActionEventArgs(
                                            ActionType.DataCollectAction_CollectKeyParts,
                                            runningCard,
                                            ((IDCTClient)act).LoginedUser,
                                            ((IDCTClient)act).ResourceCode,
                                            product, null, null));
            }
            if (msgMo.IsSuccess() == false)
            {
                return(msgMo);
            }
            // Added end

            keypartsHT = new Hashtable();
            keypartsHT.Add("ProdcutInfo", msgProduct);
            keypartsHT.Add("MOWillGo", moWillGo);

            IDCTClient  client      = act as IDCTClient;
            OPBOMFacade opBOMFacade = new OPBOMFacade(domainProvider);

            object[] objBomDetail = null;
            Messages messages1    = new Messages();

            if (moWillGo == null)
            {
                // 检查途程
                messages1 = _helper.CheckID(
                    new CKeypartsActionEventArgs(
                        ActionType.DataCollectAction_CollectKeyParts,
                        product.LastSimulation.RunningCard,
                        client.LoginedUser,
                        client.ResourceCode,
                        product,
                        null,
                        null));
            }
            if (messages1.IsSuccess() == true)
            {
                objBomDetail = opBOMFacade.GetOPBOMDetails(
                    product.NowSimulation.MOCode,
                    product.NowSimulation.RouteCode,
                    product.NowSimulation.OPCode);
            }
            else
            {
                return(messages1);
            }

            MOFacade moFacade = new MOFacade(domainProvider);
            //object mo = moFacade.GetMO( product.LastSimulation.MOCode );
            object mo = moWillGo;

            if (moWillGo == null)
            {
                mo = moFacade.GetMO(product.LastSimulation.MOCode);
            }

            // 查询OPBOM
            OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider);

            if (opBomKeyparts.Count == 0)
            {
                msgProduct.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode=" + product.NowSimulation.MOCode
                                           + " $CS_Param_RouteCode=" + product.NowSimulation.RouteCode
                                           + " $CS_Param_OPCode =" + product.NowSimulation.OPCode));
                return(msgProduct);
            }
            else
            {
                this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString());
                keypartsHT.Add("KeypartsInfo", opBomKeyparts);
            }
            return(msgProduct);
        }
Esempio n. 26
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();            //Keyparts

            //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;
            }


            msg = CheckData(data, domainProvider);

            if (keypartsHT == null)
            {
                // 按照逻辑,走到这个分支应该是错误的
                string strFile = @"C:\DCT_EmptyMessage.txt";
                string strLine = DateTime.Now.ToString("yyyy-MM-dd HH:mi:ss") + "\t" + "ActionCollectKeyParts" + "\t" + "Missing Product In Action, RunningCard:" + args.RunningCard + ",Input:" + data;
                System.IO.StreamWriter writer = new System.IO.StreamWriter(strFile, true);
                writer.WriteLine(strLine);
                writer.Close();
                //
                if (msg.IsSuccess() &&
                    (keypartsHT == null || keypartsHT.ContainsKey("ProdcutInfo") == false))
                {
                    //检查序列号
                    _helper = new ActionOnLineHelper(domainProvider);
                    msg     = _helper.GetIDInfo(args.RunningCard);
                    // Added by Icyer 2006/12/14
                    // 检查序列号
                    ProductInfo product = (ProductInfo)msg.GetData().Values[0];
                    if (product == null || product.LastSimulation == null)
                    {
                        msg.ClearMessages();
                        msg.Add(new Message(MessageType.Error, "$NoSimulation"));
                    }
//					base.Action (act);
//					ActionCollectKeyparts actionCollectKeyparts = this;
//					this.NextAction = actionCollectKeyparts;
//					this.Status = ActionStatus.PrepareData;
//					return msg;
                    // Added end
                }

                if (msg.IsSuccess() &&
                    (keypartsHT == null || keypartsHT.ContainsKey("KeypartsInfo") == false))
                {
                    try
                    {
                        keypartsHT = new Hashtable();
                        keypartsHT.Add("ProdcutInfo", msg);

                        ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                        /*	Removed by Icyer 2006/12/14
                         * 如果序列号已在本上料工序,则GetMORouteNextOperation会取下一个工序,导致找不到OPBOM
                         * 改变推导OPBOM的逻辑
                         * ItemFacade itemFacade = new ItemFacade(domainProvider);
                         * object op = itemFacade.GetMORouteNextOperation(
                         *      product.LastSimulation.MOCode,
                         *      product.LastSimulation.RouteCode,
                         *      product.LastSimulation.OPCode);
                         *
                         * OPBOMFacade opBOMFacade=new OPBOMFacade( domainProvider);
                         * object[] objBomDetail = opBOMFacade.GetOPBOMDetails(
                         *      product.LastSimulation.MOCode,
                         *      product.LastSimulation.RouteCode,
                         *      (op as ItemRoute2OP).OPCode);
                         */
                        // Added by Icyer 2006/12/14
                        IDCTClient  client       = act as IDCTClient;
                        OPBOMFacade opBOMFacade  = new OPBOMFacade(domainProvider);
                        object[]    objBomDetail = null;
                        DataCollect.ActionOnLineHelper onLine = new ActionOnLineHelper(domainProvider);
                        Messages messages1 = onLine.CheckID(
                            new CKeypartsActionEventArgs(
                                ActionType.DataCollectAction_CollectKeyParts,
                                product.LastSimulation.RunningCard,
                                client.LoginedUser,
                                client.ResourceCode,
                                product,
                                null,
                                null));
                        if (messages1.IsSuccess() == true)
                        {
                            objBomDetail = opBOMFacade.GetOPBOMDetails(
                                product.NowSimulation.MOCode,
                                product.NowSimulation.RouteCode,
                                product.NowSimulation.OPCode);
                        }
                        else
                        {
                            throw new Exception(messages1.OutPut());
                        }
                        // Added end

                        MOFacade moFacade = new MOFacade(domainProvider);
                        object   mo       = moFacade.GetMO(product.LastSimulation.MOCode);

                        OPBomKeyparts opBomKeyparts = new OPBomKeyparts(objBomDetail, Convert.ToInt32(((MO)mo).IDMergeRule), domainProvider);

                        if (opBomKeyparts.Count == 0)
                        {
                            /*	Removed by Icyer 2006/12/27 @ YHI
                             * msg.Add(new Message(MessageType.Error, "$CS_NOOPBomInfo $CS_Param_MOCode="+product.LastSimulation.MOCode
                             +" $CS_Param_RouteCode="+product.LastSimulation.RouteCode
                             +" $CS_Param_OPCode ="+product.LastSimulation.OPCode));
                             * throw new Exception(msg.OutPut());
                             */
                            throw new Exception("$CS_NOOPBomInfo");
                        }
                        else
                        {
                            //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode);	// Removed by Icyer 2006/12/14

                            keypartsHT.Add("KeypartsInfo", opBomKeyparts);
                        }
                    }
                    catch (Exception ex)
                    {
                        /*	Removed by Icyer 2006/12/27 @ YHI
                         * keypartsHT = null;
                         * this.NeedCancel = true;
                         * throw ex;
                         */
                        // Added by Icyer 2006/12/27 @ YHI
                        base.Action(act);
                        ActionCollectKeyparts actionCollectKeyparts = this;
                        this.NextAction = actionCollectKeyparts;
                        this.Status     = ActionStatus.PrepareData;
                        msg.ClearMessages();
                        msg.Add(new UserControl.Message(MessageType.Error, ex.Message));
                        msg.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts"));
                        return(msg);
                        // Added end
                    }
                }
            }

            if (msg.IsSuccess())
            {
                OPBomKeyparts opBomKeyparts = (OPBomKeyparts)keypartsHT["KeypartsInfo"];
                msg = keypartsHT["ProdcutInfo"] as Messages;
                MO moWillGo = (MO)keypartsHT["MOWillGo"];

                ProductInfo product = (ProductInfo)msg.GetData().Values[0];

                Messages msgResult = new Messages();
                if (opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount())
                {
                    try
                    {
                        //opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode);
                        if (moWillGo == null)
                        {
                            msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, product.LastSimulation.MOCode));
                        }
                        else
                        {
                            msgResult.AddMessages(opBomKeyparts.AddKeyparts(data, moWillGo.MOCode));
                        }
                    }
                    catch (Exception ex)
                    {
                        msgResult.Add(new UserControl.Message(MessageType.Error, ex.Message));
                    }

                    keypartsHT["KeypartsInfo"] = opBomKeyparts;
                }

                if (msgResult.IsSuccess() == false || opBomKeyparts.Count > opBomKeyparts.GetbomKeypartCount())
                {
                    base.Action(act);
                    ActionCollectKeyparts actionCollectKeyparts = this;
                    this.NextAction = actionCollectKeyparts;

                    this.Status = ActionStatus.PrepareData;

                    this.OutMesssage = new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts " + (opBomKeyparts.GetbomKeypartCount() + 1).ToString() + "/" + opBomKeyparts.Count.ToString());
                    if (msgResult.IsSuccess() == false)
                    {
                        //msgResult.Add(new UserControl.Message(MessageType.Normal, "$DCT_PLEASE_INPUT_Keyparts"));
                        return(msgResult);
                    }
                    else
                    {
                        return(msg);
                    }
                }

                //((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.OpenConnection();
                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);
                    DataCollectFacade dataCollect       = new DataCollect.DataCollectFacade(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;

                    msg.AddMessages(_helper.ActionWithTransaction(
                                        new CKeypartsActionEventArgs(
                                            ActionType.DataCollectAction_CollectKeyParts,
                                            product.NowSimulation.RunningCard,
                                            client.LoginedUser,
                                            client.ResourceCode,
                                            product,
                                            opBomKeyparts,
                                            wfacade), actionCheckStatus));

                    // Added by Icyer 2006/12/28 @ YHI	采集集成上料
                    bool bLoadedINNO = false;
                    if (this.NeedCollectINNO == true && msg.IsSuccess() == true)
                    {
                        string strRCard = product.NowSimulation.RunningCard;
                        UserControl.Messages msgProduct = _helper.GetIDInfo(strRCard);
                        product = (ProductInfo)msgProduct.GetData().Values[0];
                        CINNOActionEventArgs argsInno = new CINNOActionEventArgs(
                            ActionType.DataCollectAction_CollectINNO,
                            strRCard,
                            client.LoginedUser,
                            client.ResourceCode,
                            product,
                            INNOCode,
                            wfacade
                            );
                        IAction action = new BenQGuru.eMES.DataCollect.Action.ActionFactory(domainProvider).CreateAction(ActionType.DataCollectAction_CollectINNO);
                        msg.AddMessages(action.Execute(argsInno));
                        if (msg.IsSuccess() == true)
                        {
                            bLoadedINNO = true;
                            msg.Add(new UserControl.Message(MessageType.Success, string.Format("$CS_INNO_CollectSuccess[" + this.INNOCode + "] $CS_Keyparts_CollectSuccess")));
                        }
                    }
                    // Added end
                    if (msg.IsSuccess())
                    {
                        if (System.Configuration.ConfigurationSettings.AppSettings["NeedMaterialModule"].Trim() == "1")
                        {
                            if (wfacade != null)
                            {
                                wfacade.ExecCacheSQL();
                            }
                        }

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

                    msg.Add(new UserControl.Message(ex));
                }
                finally
                {
                    ((BenQGuru.eMES.Common.DomainDataProvider.SQLDomainDataProvider)domainProvider).PersistBroker.CloseConnection();
                }
                base.Action(act);
                ActionRCard actRcard1 = new ActionRCard();
                actRcard1.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard");
                this.NextAction       = actRcard1;
                this.ObjectState      = null;
                this.keypartsHT       = null;
                this.Status           = ActionStatus.PrepareData;
                return(msg);
            }

            base.Action(act);

            //Web.Helper.ActionType acttype = new Web.Helper.ActionType();
//			if(acttype.Items.Contains(args.RunningCard))
//			{
//				(act as IDCTClient).CachedAction = null;
//			}

            ActionRCard actRcard = new ActionRCard();

            actRcard.OutMesssage = new UserControl.Message(MessageType.Normal, "$CS_Please_Input_RunningCard");
            this.NextAction      = actRcard;
            // Added by Icyer 2006/12/14
            this.ObjectState = null;
            this.keypartsHT  = null;
            this.Status      = ActionStatus.PrepareData;
            // Added end

            return(msg);
        }
Esempio n. 27
0
        private Messages LoadData(string rcard)
        {
            Messages msg = new Messages();

            _DataTableLoadedPart.Clear();

            MOFacade       moFacade       = new MOFacade(this.DataProvider);
            OPBOMFacade    opBOMFacade    = new OPBOMFacade(this.DataProvider);
            MaterialFacade materialFacade = new MaterialFacade(this.DataProvider);
            ItemFacade     itemFacade     = new ItemFacade(this.DataProvider);

            //根据当前的序列号获取产品原始的序列号
            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            string            sourceRCard       = dataCollectFacade.GetSourceCard(rcard, string.Empty);

            //Get Product Info
            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

            //Get loaded parts
            OnWIPItem[] onWIPItems = materialFacade.QueryLoadedPartByRCard(product.LastSimulation.RunningCard, string.Empty);

            if (onWIPItems == null)
            {
                msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_CINNO"));
                return(msg);
            }

            try
            {
                if (onWIPItems != null)
                {
                    for (int i = 0; i < onWIPItems.Length; i++)
                    {
                        MO  mo    = (MO)moFacade.GetMO(onWIPItems[i].MOCode);
                        int orgID = GlobalVariables.CurrentOrganizations.First().OrganizationID;
                        if (mo != null)
                        {
                            orgID = mo.OrganizationID;
                        }

                        Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(onWIPItems[i].MItemCode, orgID);
                        //changed by hiro 08/11/04
                        if (material != null)
                        {
                            _DataTableLoadedPart.Rows.Add(new object[] {
                                false,
                                false,
                                string.Empty,
                                i + 1,
                                onWIPItems[i].MItemCode,
                                onWIPItems[i].MOCode,
                                onWIPItems[i].MCARD,
                                material.MaterialDescription == null ? "" : material.MaterialDescription,
                                string.Empty,
                                onWIPItems[i].MCardType
                            });
                        }
                        //end by hiro
                    }
                }
            }
            catch (Exception E)
            {
                msg.Add(new UserControl.Message(E));
            }

            return(msg);
        }