/// <summary> /// Sets properties according on changed child records /// </summary> /// <param name="rootRecord">The root record</param> /// <param name="parentRecord">The parent record</param> /// <returns>The list of UPCRMRecord</returns> public List <UPCRMRecord> ChangedChildRecordsForRootRecordParentRecord( UPCRMRecord rootRecord, UPCRMRecord parentRecord) { this.count = this.SerialEntry.Columns.Count; if (!string.IsNullOrWhiteSpace(this.SerialEntryRecordId) && this.SerialEntryRecordId != IdNew) { this.destinationRootRecord = new UPCRMRecordWithParameter(this.SerialEntry.DestInfoAreaId, this.SerialEntryRecordId); this.DestinationRootRecord = this.destinationRootRecord; } else if (this.DestinationRootRecord == null) { this.ProcessDestinationRootRecordNull(rootRecord, parentRecord); } else if (this.DestinationRootRecord is UPCRMRecordWithParameter) { this.destinationRootRecord = (UPCRMRecordWithParameter)this.DestinationRootRecord; if (this.destinationRootRecord.IsNew && this.SerialEntry.DestinationTemplateFilter != null) { this.additionalDestinationTemplateFilterRecords = this.destinationRootRecord.ApplyValuesFromTemplateFilter( this.SerialEntry.DestinationTemplateFilter, false); } } if (this.SerialEntry.ChildrenCount != 0) { this.destinationChildRecords = new List <UPCRMRecordWithParameter>(this.SerialEntry.ChildrenCount); this.tentativeChildRecords = new List <UPCRMRecordWithParameter>(this.SerialEntry.ChildrenCount); for (var childIndex = 0; childIndex < this.SerialEntry.ChildrenCount; childIndex++) { this.destinationChildRecords.Add(null); this.tentativeChildRecords.Add(null); } } this.ProcessSerialEntryColumns(rootRecord); return(this.ProcessDestinations()); }
private void ProcessUpseColumnFromDestChild( UPCRMRecord rootRecord, bool changedValue, string stringValue, string origVal) { var childIndex = ((UPSEDestinationChildColumn)this.column).ChildIndex; object childRecordObject = this.tentativeChildRecords[childIndex]; UPCRMRecordWithParameter childRecord; if (childRecordObject == null) { var childRecordId = string.Empty; if (this.ChildRecordIds != null) { childRecordId = this.ChildRecordIds[childIndex]; } if (string.IsNullOrWhiteSpace(childRecordId)) { childRecord = new UPCRMRecordWithParameter(this.SerialEntry.DestChildInfoAreaId, null); if (this.SerialEntry.DestinationChildTemplateFilter != null) { childRecord.ApplyValuesFromTemplateFilter( this.SerialEntry.DestinationChildTemplateFilter); } childRecord.AddLink(new UPCRMLink(this.DestinationRootRecord, -1)); var sourceChild = this.SerialEntry.SourceChildren[childIndex]; childRecord.AddLink(new UPCRMLink(sourceChild.Record, -1)); if (rootRecord != null) { childRecord.AddLink(new UPCRMLink(rootRecord, -1)); } } else { childRecord = new UPCRMRecordWithParameter(this.SerialEntry.DestChildInfoAreaId, childRecordId); } this.tentativeChildRecords[childIndex] = childRecord; } else { childRecord = (UPCRMRecordWithParameter)childRecordObject; } if (changedValue && this.destinationChildRecords[childIndex] == null) { if (childRecord.IsNew) { ++this.newChildRecordCount; } else { ++this.modifiedChildRecordCount; } this.destinationChildRecords[childIndex] = childRecord; } if (this.destinationColumn.DontSave) { childRecord.NewValueFromValueFieldIdOnlyOffline(stringValue, origVal, this.column.FieldId, true); } else { childRecord.NewValueFromValueFieldId(stringValue, origVal, this.column.FieldId); } if (changedValue && !string.IsNullOrEmpty(stringValue)) { childRecord.HasValues = true; } }
private void ProcessDestinationRootRecordNull(UPCRMRecord rootRecord, UPCRMRecord parentRecord) { this.destinationRootRecord = new UPCRMRecordWithParameter(this.SerialEntry.DestInfoAreaId); this.DestinationRootRecord = this.destinationRootRecord; if (this.CreateUnchanged) { this.destinationRootRecord.HasValues = true; } if (this.SerialEntry.DestinationTemplateFilter != null) { this.additionalDestinationTemplateFilterRecords = this.destinationRootRecord.ApplyValuesFromTemplateFilter(this.SerialEntry.DestinationTemplateFilter, false); } if (rootRecord != null) { this.destinationRootRecord.AddLink(new UPCRMLink(rootRecord, -1)); } this.destinationRootRecord.AddLink(new UPCRMLink(this.RowRecordIdentification, -1)); if (parentRecord != null) { this.destinationRootRecord.AddLink(new UPCRMLink(parentRecord, -1)); } if (!string.IsNullOrWhiteSpace(this.ListingRecordId)) { this.destinationRootRecord.AddLink(new UPCRMLink( this.SerialEntry.ListingController.InfoAreaId, this.ListingRecordId, -1)); } var sourceColumnWithLink = true; if (this.SerialEntry.SourceColumnsForFunction != null) { foreach (var key in this.SerialEntry.SourceColumnsForFunction.Keys) { if (key.StartsWith("Copy")) { var sourceColumn = this.SerialEntry.SourceColumnsForFunction.ValueOrDefault(key); var destColumn = this.SerialEntry.DestColumnsForFunction.ValueOrDefault(key) as UPSEDestinationColumn; if (destColumn != null && string.IsNullOrEmpty(destColumn.InitialValue) && destColumn.InfoAreaId == this.destinationRootRecord.InfoAreaId) { this.destinationRootRecord.NewValueFieldId( (string)this.ValueAtIndex(sourceColumn.PositionInControl), destColumn.FieldId); if (key.Length == 4) { sourceColumnWithLink = false; } } } } } this.ProcessSerialEntryColumns(sourceColumnWithLink); }