public void Duplicate() { if (!isProcessingMultipleDuplicates) { MainViewModel.EntitiesUndoRedoManager.PauseActionId(); } foreach (BASELINE_ITEMProjection selectedEntity in MainViewModel.SelectedEntities) { BASELINE_ITEMProjection newProjection = new BASELINE_ITEMProjection(); DataUtils.ShallowCopy(newProjection.BASELINE_ITEM, selectedEntity.BASELINE_ITEM); newProjection.BASELINE_ITEM.GUID = Guid.Empty; AREA selectedAREA = AREACollection.FirstOrDefault(x => x.GUID == newProjection.BASELINE_ITEM.GUID_AREA); DISCIPLINE selectedDISCIPLINE = DISCIPLINECollection.FirstOrDefault(x => x.GUID == newProjection.BASELINE_ITEM.GUID_DISCIPLINE); DOCTYPE selectedDOCTYPE = DOCTYPECollection.FirstOrDefault(x => x.GUID == newProjection.BASELINE_ITEM.GUID_DOCTYPE); newProjection.BASELINE_ITEM.INTERNAL_NUM = BluePrintDataUtils.BASELINEITEM_Generate_InternalNumber(loadPROJECT, MainViewModel.Entities, selectedAREA, selectedDISCIPLINE, selectedDOCTYPE, newProjection.GUID); MainViewModel.EntitiesUndoRedoManager.AddUndo(newProjection, null, null, null, EntityMessageType.Added); MainViewModel.Save(newProjection); } if (!isProcessingMultipleDuplicates) { MainViewModel.EntitiesUndoRedoManager.UnpauseActionId(); } }
void PopulateNavigationalProperties() { foreach (BASELINE_ITEMProjection projection in MainViewModel.Entities) { if (projection.BASELINE_ITEM.GUID_DISCIPLINE != null && projection.BASELINE_ITEM.DISCIPLINE == null) { projection.BASELINE_ITEM.DISCIPLINE = DISCIPLINECollection.FirstOrDefault(x => x.GUID == projection.BASELINE_ITEM.GUID_DISCIPLINE); } if (projection.BASELINE_ITEM.GUID_AREA != null && projection.BASELINE_ITEM.AREA == null) { projection.BASELINE_ITEM.AREA = AREACollection.FirstOrDefault(x => x.GUID == projection.BASELINE_ITEM.GUID_AREA); } } }
/// <summary> /// Influence column(s) when changes happens in other column /// </summary> public void CellValueChanging(CellValueChangedEventArgs e) { if (e.RowHandle != GridControl.NewItemRowHandle) { return; } BASELINE_ITEMProjection activeBASELINE_ITEM = (BASELINE_ITEMProjection)e.Row; if (e.Column.FieldName == BindableBase.GetPropertyName(() => new BASELINE_ITEMProjection().BASELINE_ITEM) + "." + BindableBase.GetPropertyName(() => new BASELINE_ITEM().GUID_WORKPACK)) { WORKPACK chosenWORKPACK = WORKPACKCollection.FirstOrDefault(entity => entity.GUID == (Guid)e.Value); if (chosenWORKPACK != null) { activeBASELINE_ITEM.BASELINE_ITEM.GUID_AREA = chosenWORKPACK.GUID_DAREA; activeBASELINE_ITEM.BASELINE_ITEM.GUID_DOCTYPE = chosenWORKPACK.GUID_DDOCTYPE; activeBASELINE_ITEM.BASELINE_ITEM.GUID_DEPARTMENT = chosenWORKPACK.GUID_DDEPARTMENT; activeBASELINE_ITEM.BASELINE_ITEM.GUID_DISCIPLINE = chosenWORKPACK.GUID_DDISCIPLINE; activeBASELINE_ITEM.BASELINE_ITEM.GUID_PHASE = chosenWORKPACK.PHASE != null ? chosenWORKPACK.GUID_DPHASE : null; var SelectedAREA = AREACollection.FirstOrDefault(x => x.GUID == chosenWORKPACK.GUID_DAREA); var SelectedDOCTYPE = DOCTYPECollection.FirstOrDefault(x => x.GUID == chosenWORKPACK.GUID_DDOCTYPE); var SelectedDISCIPLINE = DISCIPLINECollection.FirstOrDefault(x => x.GUID == chosenWORKPACK.GUID_DDISCIPLINE); activeBASELINE_ITEM.BASELINE_ITEM.INTERNAL_NUM = BluePrintDataUtils.BASELINEITEM_Generate_InternalNumber(loadPROJECT, MainViewModel.Entities, SelectedAREA, SelectedDISCIPLINE, SelectedDOCTYPE); MainViewModel.UpdateSelectedEntity(); } } else if (e.Column.FieldName == BindableBase.GetPropertyName(() => new BASELINE_ITEMProjection().BASELINE_ITEM) + "." + BindableBase.GetPropertyName(() => new BASELINE_ITEM().GUID_DOCTYPE)) { DOCTYPE chosenDOCTYPE = DOCTYPECollection.FirstOrDefault(entity => entity.GUID == (Guid)e.Value); if (chosenDOCTYPE != null && chosenDOCTYPE.GUID_DDEPARTMENT != null) { activeBASELINE_ITEM.BASELINE_ITEM.GUID_DEPARTMENT = chosenDOCTYPE.DEPARTMENT.GUID; MainViewModel.UpdateSelectedEntity(); } } }