Ignore:
Timestamp:
Jun 16, 2011, 10:32:01 AM (13 years ago)
Author:
george
Message:
  • Added: Item selection form for TypeRelationOne.
  • Modified: Primary keys have to have their property record for each object.
  • Added: Object propery havet to be initialized with Editable flag.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UDataTypes.pas

    r20 r21  
    1818    function GetControlValue(Control: TWinControl): string; virtual;
    1919    procedure Load(CellValue: string); virtual;
    20     procedure LoadDef(CustomType: Integer); virtual;
     20    procedure LoadDef(ACustomType: Integer); virtual;
    2121    procedure SetDefault; virtual;
    2222    function GetStringValue: string; virtual;
     
    7474
    7575  TDataTypeRelationOne = class(TDataType)
     76  private
     77    procedure ButtonClickExecute(Sender: TObject);
     78  public
    7679    ObjectId: Integer;
    7780    SelectedItemName: string;
     
    7982    procedure SetupControl(Control: TWinControl); override;
    8083    procedure Load(CellValue: string); override;
     84    procedure LoadDef(ACustomType: Integer); override;
    8185  end;
    8286
     
    137141
    138142uses
    139   USqlDatabase, USystem, UCore;
     143  USqlDatabase, USystem, UCore, UItemSelect;
    140144
    141145function GetDataType(ACustomType: Integer): TDataType;
     
    247251{ TDataTypeRelationOne }
    248252
     253procedure TDataTypeRelationOne.ButtonClickExecute(Sender: TObject);
     254begin
     255  ItemSelectForm.ObjectId := ObjectId;
     256  ItemSelectForm.ShowModal;
     257end;
     258
    249259function TDataTypeRelationOne.CreateControl(Owner: TComponent): TWinControl;
    250260begin
    251   Result := TEdit.Create(Owner);
    252   TEdit(Result).Enabled := False;
     261  Result := TEditButton.Create(Owner);
     262  TEditButton(Result).Enabled := False;
     263  TEditButton(Result).Button.Enabled := True;
     264  TEditButton(Result).Button.OnClick := ButtonClickExecute;
    253265end;
    254266
    255267procedure TDataTypeRelationOne.SetupControl(Control: TWinControl);
    256268begin
    257   TEdit(Control).Text := SelectedItemName;
     269  TEditButton(Control).Text := SelectedItemName;
    258270end;
    259271
     
    261273begin
    262274  SelectedItemName := CellValue;
     275end;
     276
     277procedure TDataTypeRelationOne.LoadDef(ACustomType: Integer);
     278var
     279  DbRows: TDbRows;
     280begin
     281  try
     282    DbRows := TDbRows.Create;
     283    Core.System.Database.Select(DbRows, TypeRelationOne, '*', 'CustomType=' + IntToStr(ACustomType));
     284    ObjectId := StrToInt(DbRows[0].Values['Object']);
     285  finally
     286    DbRows.Free;
     287  end;
    263288end;
    264289
     
    420445end;
    421446
    422 procedure TDataType.LoadDef(CustomType: Integer);
     447procedure TDataType.LoadDef(ACustomType: Integer);
    423448begin
    424449
Note: See TracChangeset for help on using the changeset viewer.