Ignore:
Timestamp:
Dec 26, 2010, 8:12:59 PM (14 years ago)
Author:
george
Message:
  • Modified: Non-visual functions moved to USystem unit.
  • Modified: Loading of object, properties and values rebuilded to general structures.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22Config.xml
        33chronis
         4heaptrclog.trc
  • trunk/Forms/UItemView.pas

    r7 r9  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   ExtCtrls, USqlDatabase;
     9  ExtCtrls, ComCtrls, USqlDatabase, USystem;
    1010
    1111type
     
    1616    ButtonClose: TButton;
    1717    ButtonEdit: TButton;
     18    ListView1: TListView;
    1819    Panel1: TPanel;
     20    Panel2: TPanel;
     21    PanelControls: TPanel;
     22    Splitter1: TSplitter;
     23    TabControl1: TTabControl;
    1924    procedure ButtonCancelClick(Sender: TObject);
    2025    procedure ButtonCloseClick(Sender: TObject);
    2126    procedure ButtonEditClick(Sender: TObject);
    2227    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
     28    procedure FormCreate(Sender: TObject);
     29    procedure FormDestroy(Sender: TObject);
    2330    procedure FormShow(Sender: TObject);
    2431  private
    2532    { private declarations }
    2633  public
     34    Report: TReport;
    2735    procedure BuildControls;
    2836  end;
     
    4452begin
    4553  MainForm.PersistentForm.Save(Self);
     54end;
     55
     56procedure TItemViewForm.FormCreate(Sender: TObject);
     57begin
     58  Report := TReport.Create;
     59  Report.Base := MainForm.System;
     60end;
     61
     62procedure TItemViewForm.FormDestroy(Sender: TObject);
     63begin
     64  Report.Free;
    4665end;
    4766
     
    7089procedure TItemViewForm.BuildControls;
    7190var
    72   Properties: TDbRows;
    73   Values: TDbRows;
    7491  NewControl: TControl;
    7592  LastTop: Integer;
    7693  I: Integer;
    7794  Column: Integer;
    78   ObjectInfo: TDbRows;
    7995const
    8096  ColumnCount = 2;
     
    8298  LastTop := 8;
    8399  Column := 0;
    84   try
    85   ObjectInfo := TDbRows.Create;
    86   MainForm.Database.Query(ObjectInfo, 'SELECT * FROM `Object` WHERE `Id`=' + IntToStr(MainForm.SelectedObject));
    87   if ObjectInfo.Count = 1 then begin
     100  Report.Load(MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' +
     101    IntToStr(MainForm.SelectedItem));
     102  for I := PanelControls.ControlCount - 1 downto 0 do
     103    PanelControls.Controls[I].Free;
    88104
    89     for I := Panel1.ControlCount - 1 downto 0 do
    90       Panel1.Controls[I].Free;
     105  TabControl1.Tabs.Clear;
     106  // Load column names
    91107
    92     // Load column names
    93     try
    94     Properties := TDbRows.Create;
    95     MainForm.Database.Query(Properties, 'SELECT * FROM `Property` WHERE `Object`=' +
    96       IntToStr(MainForm.SelectedObject));
    97     Values := TDbRows.Create;
    98     MainForm.Database.Query(Values, 'SELECT * FROM `' + ObjectInfo[0].Values['Schema'] + '`.`' +
    99       ObjectInfo[0].Values['Table'] + '` WHERE ' + ObjectInfo[0].Values['PrimaryKey'] + ' = ' +
    100       IntToStr(MainForm.SelectedItem));
    101     if Values.Count = 1 then
    102     for I := 0 to Properties.Count - 1 do begin
    103       NewControl := TLabel.Create(Panel1);
    104       NewControl.Parent := Panel1;
    105       NewControl.Top := LastTop;
    106       NewControl.Left := Column * Width div ColumnCount + 10;
    107       TLabel(NewControl).Caption := Properties[I].Values['Name'] + ':';
     108  if Report.Count = 1 then
     109  for I := 0 to Report.Columns.Count - 1 do
     110  if TReportColumn(Report.Columns[I]).TypeId = 20 then begin
     111    TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption);
     112  end else begin
     113    NewControl := TLabel.Create(PanelControls);
     114    NewControl.Parent := PanelControls;
     115    NewControl.Top := LastTop;
     116    NewControl.Left := Column * Width div ColumnCount + 10;
     117    TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':';
    108118
    109       NewControl := TLabel.Create(Panel1);
    110       NewControl.Parent := Panel1;
    111       NewControl.Top := LastTop;
    112       NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
    113       TLabel(NewControl).Caption := Values[0].Values[Properties[I].Values['ColumnName']];
     119    NewControl := TLabel.Create(PanelControls);
     120    NewControl.Parent := PanelControls;
     121    NewControl.Top := LastTop;
     122    NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2;
     123    TLabel(NewControl).Caption := TReportLine(Report[0]).Items[I];
    114124
    115       Column := (Column + 1) mod 2;
    116       if Column = 0 then LastTop := LastTop + NewControl.Height + 4;
    117     end else ShowMessage(SItemNotFound);
    118     finally
    119       Values.Free;
    120       Properties.Free;
    121     end;
    122   end else ShowMessage(SObjectNotFound);
    123   finally
    124     ObjectInfo.Free;
     125    Column := (Column + 1) mod 2;
     126    if Column = 0 then LastTop := LastTop + 24;
    125127  end;
     128  Panel2.Visible := TabControl1.Tabs.Count > 0;
    126129end;
    127130
Note: See TracChangeset for help on using the changeset viewer.