Changeset 24 for trunk/UDatabase.pas
- Timestamp:
- Mar 26, 2018, 11:37:46 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDatabase.pas
r23 r24 85 85 Parent: TTable; 86 86 Values: TValues; 87 function Match(AValues: TStrings): Boolean; 87 88 procedure InitValues; 88 89 procedure Assign(Source: TRecord); … … 97 98 procedure Assign(Source: TRecords); 98 99 function SearchByValue(Name, Value: string): TRecord; 100 function SearchByValues(Values: TStrings): TRecord; 99 101 function AddNew: TRecord; 100 102 end; … … 257 259 STypeDateTime = 'Date and time'; 258 260 STypeReference = 'Reference'; 261 SFieldNotFound = 'Field %s not found'; 259 262 260 263 … … 607 610 end; 608 611 612 function TRecords.SearchByValues(Values: TStrings): TRecord; 613 var 614 I: Integer; 615 begin 616 Result := nil; 617 I := 0; 618 while (I < Count) and (TRecord(Items[I]).Match(Values)) do Inc(I); 619 if I < Count then Result := TRecord(Items[I]) 620 else Result := nil; 621 end; 622 609 623 function TRecords.AddNew: TRecord; 610 624 begin … … 651 665 652 666 { TRecord } 667 668 function TRecord.Match(AValues: TStrings): Boolean; 669 var 670 I: Integer; 671 Field: TField; 672 FieldIndex: Integer; 673 begin 674 Result := True; 675 for I := 0 to aValues.Count - 1 do begin 676 Field := Parent.Fields.SearchByName(AValues.Names[I]); 677 FieldIndex := Parent.Fields.IndexOf(Field); 678 if Assigned(Field) then begin 679 if TValue(Values[FieldIndex]).GetString <> AValues.ValueFromIndex[I] then begin 680 Result := False; 681 Break; 682 end; 683 end else raise Exception.Create(Format(SFieldNotFound, [AValues.Names[I]])); 684 end; 685 end; 653 686 654 687 procedure TRecord.InitValues;
Note:
See TracChangeset
for help on using the changeset viewer.