Changeset 9 for trunk/Forms/UItemView.pas
- Timestamp:
- Dec 26, 2010, 8:12:59 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 2 2 Config.xml 3 3 chronis 4 heaptrclog.trc
-
- Property svn:ignore
-
trunk/Forms/UItemView.pas
r7 r9 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ExtCtrls, USqlDatabase;9 ExtCtrls, ComCtrls, USqlDatabase, USystem; 10 10 11 11 type … … 16 16 ButtonClose: TButton; 17 17 ButtonEdit: TButton; 18 ListView1: TListView; 18 19 Panel1: TPanel; 20 Panel2: TPanel; 21 PanelControls: TPanel; 22 Splitter1: TSplitter; 23 TabControl1: TTabControl; 19 24 procedure ButtonCancelClick(Sender: TObject); 20 25 procedure ButtonCloseClick(Sender: TObject); 21 26 procedure ButtonEditClick(Sender: TObject); 22 27 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 28 procedure FormCreate(Sender: TObject); 29 procedure FormDestroy(Sender: TObject); 23 30 procedure FormShow(Sender: TObject); 24 31 private 25 32 { private declarations } 26 33 public 34 Report: TReport; 27 35 procedure BuildControls; 28 36 end; … … 44 52 begin 45 53 MainForm.PersistentForm.Save(Self); 54 end; 55 56 procedure TItemViewForm.FormCreate(Sender: TObject); 57 begin 58 Report := TReport.Create; 59 Report.Base := MainForm.System; 60 end; 61 62 procedure TItemViewForm.FormDestroy(Sender: TObject); 63 begin 64 Report.Free; 46 65 end; 47 66 … … 70 89 procedure TItemViewForm.BuildControls; 71 90 var 72 Properties: TDbRows;73 Values: TDbRows;74 91 NewControl: TControl; 75 92 LastTop: Integer; 76 93 I: Integer; 77 94 Column: Integer; 78 ObjectInfo: TDbRows;79 95 const 80 96 ColumnCount = 2; … … 82 98 LastTop := 8; 83 99 Column := 0; 84 try85 ObjectInfo := TDbRows.Create;86 MainForm.Database.Query(ObjectInfo, 'SELECT * FROM `Object` WHERE `Id`=' + IntToStr(MainForm.SelectedObject));87 if ObjectInfo.Count = 1 then begin100 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; 88 104 89 for I := Panel1.ControlCount - 1 downto 0 do90 Panel1.Controls[I].Free;105 TabControl1.Tabs.Clear; 106 // Load column names 91 107 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 + ':'; 108 118 109 NewControl := TLabel.Create(Panel1);110 NewControl.Parent := Panel1;111 112 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]; 114 124 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; 125 127 end; 128 Panel2.Visible := TabControl1.Tabs.Count > 0; 126 129 end; 127 130
Note:
See TracChangeset
for help on using the changeset viewer.