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);
        }
예제 #2
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);
            }
        }
        //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);
        }