private object GetEditObject() { if (_opItemControlFacade == null) { _opItemControlFacade = new FacadeFactory(base.DataProvider).CreateOPItemControlFacade(); } if (this.ValidateInput()) { OPItemControl opItemControl = (OPItemControl)this._opItemControlFacade.CreateNewOPItemControl(); opItemControl.ItemCode = ItemCode; opItemControl.BIOSVersion = FormatHelper.CleanString(txtBIOSVersionEdit.Text.ToString(), 100); opItemControl.CardEnd = FormatHelper.CleanString(this.txtCardEndEdit.Text, 40); opItemControl.CardStart = FormatHelper.CleanString(this.txtCardStartEdit.Text, 40); opItemControl.DateCodeEnd = FormatHelper.CleanString(this.txtDateCodeEndEdit.Text, 40); opItemControl.DateCodeStart = FormatHelper.CleanString(this.txtDataCodeStartEdit.Text, 40); opItemControl.ItemCode = ItemCode; opItemControl.ItemVersion = FormatHelper.CleanString(this.txtItemVersion.Text, 100); opItemControl.MEMO = FormatHelper.CleanString(this.txtMemoEdit.Text, 100); opItemControl.OPBOMCode = OPBOMCode; opItemControl.OPBOMVersion = OPBOMVersion; opItemControl.OPID = OPID; opItemControl.OPBOMItemCode = OPBOMItemCode; opItemControl.PCBAVersion = FormatHelper.CleanString(this.txtPCBAVersionEdit.Text, 100); opItemControl.VendorCode = FormatHelper.CleanString(this.txtSupplierCodeEdit.Text, 100); opItemControl.VendorItemCode = FormatHelper.CleanString(this.txtSupplierCodeEdit.Text, 100); opItemControl.MaintainUser = this.GetUserCode(); return(opItemControl); } else { return(null); } }
[Test] public void OPItemControlFacadeTest_DeleteOPItemControl() { OPItemControl opItemControl = (OPItemControl)this.opItemControlFacade.GetOPBOMItemControl(itemCode, opID, opBOMItemCode, opBOMCode, opBOMVersion, 0); this.opItemControlFacade.DeleteItemControl(opItemControl); Assert.AreEqual(this.opItemControlFacade.GetOPBOMItemControlCounts(itemCode, opID, opBOMItemCode, opBOMCode, opBOMVersion), 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); }
[Test] public void OPItemControlFacadeTest_UpdateOPItemControl() { OPItemControl opItemControl = (OPItemControl)this.opItemControlFacade.GetOPBOMItemControl(itemCode, opID, opBOMItemCode, opBOMCode, opBOMVersion, 0); opItemControl.MEMO = "this is for update"; this.opItemControlFacade.UpdateItemControl(opItemControl); Assert.AreEqual(((OPItemControl)this.opItemControlFacade.GetOPBOMItemControl(itemCode, opID, opBOMItemCode, opBOMCode, opBOMVersion, 0)).MEMO, "this is for update"); }
/// <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); } }
/// <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); } }
[Test] public void OPItemControlFacadeTest_AddOPItemControl() { OPItemControl opItemControl = this.opItemControlFacade.CreateNewOPItemControl(); opItemControl.ItemCode = itemCode; opItemControl.ItemVersion = "ItemVersion"; opItemControl.MaintainUser = "******"; opItemControl.MEMO = "this is for test !"; // opItemControl.OBCode = opBOMCode; opItemControl.OPBOMItemCode = opBOMItemCode; opItemControl.DateCodeStart = "4444"; opItemControl.DateCodeEnd = "5555"; opItemControl.BIOSVersion = "BIOSVersion"; opItemControl.OPBOMVersion = opBOMVersion; opItemControl.OPID = opID; opItemControl.PCBAVersion = "PCBAVersion"; opItemControl.Sequence = 0; opItemControl.VendorCode = "Vendor Code"; opItemControl.VendorItemCode = "Vender ItemCode"; opItemControl.CardStart = "1111111"; opItemControl.CardEnd = "5555555"; this.opItemControlFacade.AddOPItemControl(opItemControl); Assert.AreEqual(this.opItemControlFacade.GetOPBOMItemControlCounts(itemCode, opID, opBOMItemCode, opBOMCode, opBOMVersion), 1); }