Changeset 15 for trunk/Forms


Ignore:
Timestamp:
Jun 13, 2011, 8:25:31 AM (13 years ago)
Author:
george
Message:
  • Modified: USqlDatabase used from CoolWeb package.
  • Added: Store item data to database for Add and Edit dialog.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        44heaptrclog.trc
        55chronis.exe
         6DebugLog.txt
  • trunk/Forms/UItemAdd.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9    StdCtrls, Spin, EditBtn, MaskEdit, USqlDatabase, USystem;
     9  StdCtrls, Spin, EditBtn, MaskEdit, USqlDatabase, USystem,
     10  SpecializedDictionary, SpecializedList;
    1011
    1112type
     
    2829  public
    2930    Report: TReport;
     31    ControlList: TListObject;
    3032  end;
    3133
     
    4850
    4951procedure TItemAddForm.ButtonSaveClick(Sender: TObject);
     52var
     53  Data: TDictionaryStringString;
     54  I: Integer;
     55  DataType: TDataType;
    5056begin
     57  with Core.System do
     58  try
     59    Data := TDictionaryStringString.Create;
     60    for I := 0 to Report.Columns.Count - 1 do
     61    if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
     62      DataType := TReportColumn(Report.Columns[I]).CustomType;
     63      Data.Add(TReportColumn(Report.Columns[I]).ColumnName, DataType.GetControlValue(TWinControl(ControlList[I])));
     64    end;
     65    Database.Insert(MainForm.SelectedObject.Table, Data, MainForm.SelectedObject.Schema);
     66  finally
     67    Data.Free;
     68  end;
     69  MainForm.LoadItemList;
    5170  Close;
    5271end;
     
    6281  Report := TReport.Create;
    6382  Report.Base := Core.System;
     83  ControlList := TListObject.Create;
     84  ControlList.OwnsObjects := False;
    6485end;
    6586
     
    6788begin
    6889  Report.Free;
     90  ControlList.Free;
    6991end;
    7092
     
    97119
    98120  // Load column names
     121  ControlList.Clear;
    99122    for I := 0 to Report.Columns.Count - 1 do
    100123    if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
     
    113136      NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    114137      NewControl.Width := (Width div ColumnCount) div 2 - 20;
     138      ControlList.Add(NewControl);
    115139
    116140      Column := (Column + 1) mod 2;
    117141      if Column = 0 then LastTop := LastTop + NewControl.Height + 4;
    118     end;
     142    end else ControlList.Add(nil);
    119143end;
    120144
  • trunk/Forms/UItemEdit.pas

    r14 r15  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   StdCtrls, Spin, EditBtn, USqlDatabase, MaskEdit, USystem;
     9  StdCtrls, Spin, EditBtn, USqlDatabase, MaskEdit, USystem,
     10  SpecializedList, SpecializedDictionary;
    1011
    1112type
     
    2728  public
    2829    Report: TReport;
     30    ControlList: TListObject;
    2931    procedure BuildControls;
    3032  end;
     
    4850
    4951procedure TItemEditForm.ButtonSaveClick(Sender: TObject);
     52var
     53  Data: TDictionaryStringString;
     54  I: Integer;
     55  DataType: TDataType;
    5056begin
    51 
     57  with Core.System do
     58  try
     59    Data := TDictionaryStringString.Create;
     60    for I := 0 to Report.Columns.Count - 1 do
     61    if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin
     62      DataType := TReportColumn(Report.Columns[I]).CustomType;
     63      Data.Add(TReportColumn(Report.Columns[I]).ColumnName, DataType.GetControlValue(TWinControl(ControlList[I])));
     64    end;
     65    Database.Update(MainForm.SelectedObject.Table, Data,
     66      '`Id` = ' + IntToStr(MainForm.SelectedItem), MainForm.SelectedObject.Schema);
     67  finally
     68    Data.Free;
     69  end;
     70  if (MainForm.SelectedObject.Table = ObjectGroupTable) or
     71  (MainForm.SelectedObject.Table = ObjectTable) then
     72    MainForm.LoadTree;
    5273  MainForm.LoadItemList;
    5374  Close;
     
    6485  Report := TReport.Create;
    6586  Report.Base := Core.System;
     87  ControlList := TListObject.Create;
     88  ControlList.OwnsObjects := False;
    6689end;
    6790
    6891procedure TItemEditForm.FormDestroy(Sender: TObject);
    6992begin
     93  ControlList.Free;
    7094  Report.Free;
    7195end;
     
    115139      NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    116140      NewControl.Width := (Width div ColumnCount) div 2 - 20;
     141      ControlList.Add(NewControl);
    117142
    118143      Column := (Column + 1) mod 2;
    119144      if Column = 0 then LastTop := LastTop + NewControl.Height + 4;
    120    end;
     145   end else ControlList.Add(nil);
    121146end;
    122147
  • trunk/Forms/UMainForm.pas

    r14 r15  
    407407  ObjectId := AddObject('Object groups', 'ObjectGroup', Core.System.Database.Database, GroupId);
    408408    AddPropertyString(ObjectId, 'Name', 'Name');
     409    AddPropertyNumber(ObjectId, 'Parent', 'Parent');
    409410  ObjectId := AddObject('Objects', 'Object', Core.System.Database.Database, GroupId);
    410411    AddPropertyString(ObjectId, 'Name', 'Name');
     
    417418    AddPropertyString(ObjectId, 'Name', 'Name');
    418419    AddPropertyString(ObjectId, 'Type', 'DbType');
    419     AddPropertyNumber(ObjectId, 'Parent', 'Parent');
     420    //AddPropertyNumber(ObjectId, 'Parent', 'Parent');
    420421  ObjectId := AddObject('Property groups', 'PropertyGroup', Core.System.Database.Database, GroupId);
    421422  ObjectId := AddObject('Properties', 'Property', Core.System.Database.Database, GroupId);
Note: See TracChangeset for help on using the changeset viewer.