Changeset 21 for trunk/USystem.pas


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/USystem.pas

    r20 r21  
    77uses
    88  Classes, SysUtils, SpecializedList, SpecializedDictionary, USqlDatabase,
    9   Strings, UDataTypes, Dialogs;
     9  Strings, UDataTypes, Dialogs, ComCtrls, StdCtrls;
    1010
    1111const
     
    5353  end;
    5454
     55  { TReport }
     56
    5557  TReport = class(TListObject)
    5658    Base: TChronisBase;
     
    5860    constructor Create;
    5961    destructor Destroy; override;
     62    procedure FillListColumns(AColumns: TListColumns);
    6063    procedure Load(Obj: TChronisObject; Filter: string = '');
    6164  end;
     
    102105    function AddGroup(Name: string; ParentGroupId: Integer = 0): Integer;
    103106    function AddObject(Name, TableName, Schema: string; GroupId: Integer): Integer;
    104     function AddProperty(ObjectId: Integer; Name, ColumnName: string; CustomType: Integer): Integer;
     107    function AddProperty(ObjectId: Integer; Name, ColumnName: string;
     108      CustomType: Integer; Editable: Boolean): Integer;
    105109    function AddPropertyNumber(ObjectId: Integer; Name,
    106       ColumnName: string; Default: Integer = 0; Min: Integer = Low(Integer);
     110      ColumnName: string; Editable: Boolean; Default: Integer = 0; Min: Integer = Low(Integer);
    107111      Max: Integer = High(Integer)): Integer;
    108112    function AddPropertyFloat(ObjectId: Integer; Name,
    109       ColumnName: string; Default: Double = 0; Min: Double = 0;
     113      ColumnName: string; Editable: Boolean; Default: Double = 0; Min: Double = 0;
    110114      Max: Double = 0): Integer;
    111115    function AddPropertyDateTime(ObjectId: Integer; Name,
    112       ColumnName: string; Default: TDateTime = 0; Min: TDateTime = 0;
     116      ColumnName: string; Editable: Boolean; Default: TDateTime = 0; Min: TDateTime = 0;
    113117      Max: TDateTime = 0): Integer;
    114118    function AddPropertyString(ObjectId: Integer; Name, ColumnName: string;
    115       Default: string = ''; MaxLength: Integer = 255): Integer;
     119      Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer;
    116120    function AddPropertyRelationOne(ObjectId: Integer; Name, ColumnName: string;
    117       ReferedObject: Integer): Integer;
     121      Editable: Boolean; ReferedObject: Integer): Integer;
    118122    function AddPropertyRelationMany(ObjectId: Integer; Name, ColumnName: string;
    119       ReferedObjectProperty: Integer): Integer;
     123      Editable: Boolean; ReferedObjectProperty: Integer): Integer;
    120124    function AddObjectGroup(Name: string): Integer;
    121125    function AddEnumeration(Name: string): Integer;
     
    188192        '` WHERE `Object`=' + IntToStr(Obj.Id));
    189193      Columns.Clear;
    190       NewColumn := TReportColumn.Create;
    191       Columns.Add(NewColumn);
    192       NewColumn.Caption := 'Id';
    193       NewColumn.ColumnName := 'Id';
    194       NewColumn.CustomType := TDataTypeNumber.Create;
    195194
    196195      for I := 0 to Properties.Count - 1 do begin
     
    212211      System.Delete(ColumnsQuery, 1, 2);
    213212      if Filter <> '' then Filter := ' WHERE ' + Filter;
    214       Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ' FROM `' + Obj.Schema + '`.`' +
     213      Base.Database.Query(Values, 'SELECT ' + ColumnsQuery + ', `' + Obj.PrimaryKey + '` AS `SYS_PRIMARY_KEY` FROM `' + Obj.Schema + '`.`' +
    215214        Obj.Table + '`' + Filter);
    216215      for I := 0 to Values.Count - 1 do begin
    217216        NewItem := TReportLine.Create;
    218217        //NewItem.Items.Add(Values[I].Values[Obj.PrimaryKey]);
    219         NewItem.Id := StrToInt(Values[I].Values[Obj.PrimaryKey]);
     218        NewItem.Id := StrToInt(Values[I].Values['SYS_PRIMARY_KEY']);
    220219        for C := 0 to Columns.Count - 1 do
    221220        if not TReportColumn(Columns[C]).VirtualItem then begin
     
    289288
    290289function TChronisBase.AddProperty(ObjectId: Integer; Name, ColumnName: string;
    291   CustomType: Integer): Integer;
     290  CustomType: Integer; Editable: Boolean): Integer;
    292291var
    293292  DbRows: TDbRows;
     
    301300    Data.Add('ColumnName', ColumnName);
    302301    Data.Add('CustomType', IntToStr(CustomType));
    303     Data.Add('Editable', '1');
     302    Data.Add('Editable', IntToStr(Integer(Editable)));
    304303    Database.Insert(PropertyTable, Data);
    305304    Result := Database.LastInsertId;
     
    311310
    312311function TChronisBase.AddPropertyNumber(ObjectId: Integer; Name,
    313   ColumnName: string; Default: Integer = 0; Min: Integer = Low(Integer);
     312  ColumnName: string; Editable: Boolean; Default: Integer = 0; Min: Integer = Low(Integer);
    314313  Max: Integer = High(Integer)): Integer;
    315314var
     
    335334    //CustomTypeId := Database.LastInsertId;
    336335
    337     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     336    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    338337  finally
    339338    Data.Free;
     
    343342
    344343function TChronisBase.AddPropertyFloat(ObjectId: Integer; Name,
    345   ColumnName: string; Default: Double; Min: Double; Max: Double): Integer;
     344  ColumnName: string; Editable: Boolean; Default: Double; Min: Double; Max: Double): Integer;
    346345var
    347346  DbRows: TDbRows;
     
    366365    //CustomTypeId := Database.LastInsertId;
    367366
    368     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     367    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    369368  finally
    370369    Data.Free;
     
    374373
    375374function TChronisBase.AddPropertyDateTime(ObjectId: Integer; Name,
    376   ColumnName: string; Default: TDateTime; Min: TDateTime; Max: TDateTime
     375  ColumnName: string; Editable: Boolean; Default: TDateTime; Min: TDateTime; Max: TDateTime
    377376  ): Integer;
    378377var
     
    398397    //CustomTypeId := Database.LastInsertId;
    399398
    400     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     399    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    401400  finally
    402401    Data.Free;
     
    406405
    407406function TChronisBase.AddPropertyString(ObjectId: Integer; Name,
    408   ColumnName: string; Default: string = ''; MaxLength: Integer = 255): Integer;
     407  ColumnName: string; Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer;
    409408var
    410409  DbRows: TDbRows;
     
    428427    //CustomTypeId := Database.LastInsertId;
    429428
    430     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     429    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    431430  finally
    432431    Data.Free;
     
    436435
    437436function TChronisBase.AddPropertyRelationOne(ObjectId: Integer; Name,
    438   ColumnName: string; ReferedObject: Integer): Integer;
     437  ColumnName: string; Editable: Boolean; ReferedObject: Integer): Integer;
    439438var
    440439  DbRows: TDbRows;
     
    457456    //CustomTypeId := Database.LastInsertId;
    458457
    459     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     458    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    460459  finally
    461460    Data.Free;
     
    465464
    466465function TChronisBase.AddPropertyRelationMany(ObjectId: Integer; Name,
    467   ColumnName: string; ReferedObjectProperty: Integer): Integer;
     466  ColumnName: string; Editable: Boolean; ReferedObjectProperty: Integer): Integer;
    468467var
    469468  DbRows: TDbRows;
     
    486485    //CustomTypeId := Database.LastInsertId;
    487486
    488     Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId);
     487    Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId, Editable);
    489488  finally
    490489    Data.Free;
     
    591590  Columns.Free;
    592591  inherited Destroy;
     592end;
     593
     594procedure TReport.FillListColumns(AColumns: TListColumns);
     595var
     596  I: Integer;
     597  NewColumn: TListColumn;
     598begin
     599  AColumns.Clear;
     600  for I := 0 to Columns.Count - 1 do
     601  if not TReportColumn(Columns[I]).VirtualItem then begin
     602    NewColumn := AColumns.Add;
     603    NewColumn.Caption := TReportColumn(Columns[I]).Caption;
     604  end;
    593605end;
    594606
Note: See TracChangeset for help on using the changeset viewer.