Changeset 22 for trunk/UDatabase.pas
- Timestamp:
- Mar 24, 2018, 12:33:48 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDatabase.pas
r21 r22 75 75 TFields = class(TObjectList) 76 76 Table: TTable; 77 function FindByName(Name: string): TField;77 function SearchByName(Name: string): TField; 78 78 procedure Assign(Source: TFields); 79 79 end; … … 84 84 Parent: TTable; 85 85 Values: TValues; 86 procedure InitValues; 86 87 procedure Assign(Source: TRecord); 87 88 constructor Create; … … 94 95 Parent: TTable; 95 96 procedure Assign(Source: TRecords); 97 function SearchByValue(Name, Value: string): TRecord; 96 98 end; 97 99 … … 175 177 function SearchByName(Name: string): TDataType; 176 178 end; 179 180 TDbRows = USqlDatabase.TDbRows; 177 181 178 182 { TDbClient } … … 577 581 end; 578 582 583 function TRecords.SearchByValue(Name, Value: string): TRecord; 584 var 585 I: Integer; 586 FieldIndex: Integer; 587 Field: TField; 588 begin 589 Result := nil; 590 Field := Parent.Fields.SearchByName(Name); 591 if Assigned(Field) then begin 592 FieldIndex := Parent.Fields.IndexOf(Field); 593 I := 0; 594 while (I < Count) and (TValue(TRecord(Items[I]).Values[FieldIndex]).GetString <> Value) do Inc(I); 595 if I < Count then Result := TRecord(Items[I]) 596 else Result := nil; 597 end; 598 end; 599 579 600 { TFields } 580 601 581 function TFields. FindByName(Name: string): TField;602 function TFields.SearchByName(Name: string): TField; 582 603 var 583 604 I: Integer; … … 604 625 605 626 { TRecord } 627 628 procedure TRecord.InitValues; 629 var 630 I: Integer; 631 begin 632 Values.Clear; 633 for I := 0 to Parent.Fields.Count - 1 do 634 Values.Add(TField(Parent.Fields[I]).GetValueClass.Create); 635 end; 606 636 607 637 procedure TRecord.Assign(Source: TRecord);
Note:
See TracChangeset
for help on using the changeset viewer.