public string AddBOMNodeRelation(BOMNodeRelation r) { try { IModelBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IModelBOMRepository>(); return itemRepository.AddBOMNodeRelation(r); } catch (Exception) { throw; } }
public void UpdateBOMNodeRelation(BOMNodeRelation r, int ID) { try { IModelBOMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IModelBOMRepository>(); itemRepository.UpdateBOMNodeRelation(r, ID); } catch (Exception) { throw; } }
protected void btnSave_ServerClick(Object sender, EventArgs e) { BOMNodeRelation r = null; string ID = ""; try { // 檢查上階是否包含新的ChildBOMNodeType if (!CheckChildWithinParents()) return; bool NodeChanged = false; if (hidOldBOMNodeType.Value.Equals(GetDDL_BOMNodeType()) && !hidOldChildBOMNodeType.Value.Equals(GetDDL_ChildBOMNodeType())) { // 檢查配對是否已經存在 if (!CheckExistPair()) return; // 檢查Types是否包含新的BOMNodeType if (!CheckExistBOMNodeType()) return; iModelBOM.DeleteBOMNodeRelation(GetDDL_BOMNodeType(), hidOldChildBOMNodeType.Value); r = new BOMNodeRelation(); r.BOMNodeType = GetDDL_BOMNodeType(); r.ChildBOMNodeType = GetDDL_ChildBOMNodeType(); r.Descr = BOMNodeDescr.Text; r.Editor = userName; ID = iModelBOM.AddBOMNodeRelation(r); NodeChanged = true; } else { r = new BOMNodeRelation(); r.BOMNodeType = GetDDL_BOMNodeType(); r.ChildBOMNodeType = GetDDL_ChildBOMNodeType(); r.Descr = BOMNodeDescr.Text; r.Editor = userName; iModelBOM.UpdateBOMNodeRelation(r); } if ((dTree.Nodes.Count > 0) && NodeChanged) { NodeExistInTreeNow = true; TreeNode n = dTree.Nodes[0]; TreeScanParent_ChangeChild(ref n, GetDDL_BOMNodeType(), hidOldChildBOMNodeType.Value, NodeActionMode.MODIFY, GetDDL_ChildBOMNodeType(), ref n); if (!NodeExistInTreeNow) { DataTable result = iModelBOM.FindBOMNodeRelationByRoot(GetDDL_ChildBOMNodeType()); IList<TreeNode> lstTheSameParentNodes = TreeScanParent_FindNodes(dTree.Nodes[0], GetDDL_ChildBOMNodeType()); for (int j = 0; j < lstTheSameParentNodes.Count; j++) { n = lstTheSameParentNodes[j]; GetSubTree(ref n, GetDDL_ChildBOMNodeType(), ref result); } } if (null != dTree.SelectedNode) { dTree.SelectedNode.Selected = false; } btnSave.Disabled = true; } } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } }