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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        44heaptrclog.trc
        55chronis.exe
         6DebugLog.txt
  • 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
Note: See TracChangeset for help on using the changeset viewer.