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/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
Note: See TracChangeset for help on using the changeset viewer.