Changeset 9 for trunk/Forms/UItemAdd.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/UItemAdd.pas
r7 r9 1 1 unit UItemAdd; 2 2 3 {$mode objfpc}{$H+}3 {$mode Delphi}{$H+} 4 4 5 5 interface … … 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 StdCtrls, Spin, EditBtn, MaskEdit, USqlDatabase ;9 StdCtrls, Spin, EditBtn, MaskEdit, USqlDatabase, USystem; 10 10 11 11 type … … 20 20 procedure ButtonSaveClick(Sender: TObject); 21 21 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 22 procedure FormCreate(Sender: TObject); 23 procedure FormDestroy(Sender: TObject); 22 24 procedure FormShow(Sender: TObject); 23 25 private … … 25 27 { private declarations } 26 28 public 27 { public declarations }29 Report: TReport; 28 30 end; 29 31 … … 56 58 end; 57 59 60 procedure TItemAddForm.FormCreate(Sender: TObject); 61 begin 62 Report := TReport.Create; 63 Report.Base := MainForm.System; 64 end; 65 66 procedure TItemAddForm.FormDestroy(Sender: TObject); 67 begin 68 Report.Free; 69 end; 70 58 71 procedure TItemAddForm.FormShow(Sender: TObject); 59 72 begin … … 64 77 procedure TItemAddForm.BuildControls; 65 78 var 66 Properties: TDbRows;67 Values: TDbRows;68 79 NewControl: TControl; 69 80 LastTop: Integer; 70 81 I: Integer; 71 82 Column: Integer; 72 ObjectInfo: TDbRows;73 83 ValueType: Integer; 74 84 const … … 77 87 LastTop := 8; 78 88 Column := 0; 79 try80 ObjectInfo := TDbRows.Create;81 MainForm.Database.Query(ObjectInfo, 'SELECT * FROM `Object` WHERE `Id`=' + IntToStr(MainForm.SelectedObject));82 if ObjectInfo.Count = 1 then begin83 89 84 85 90 for I := Panel1.ControlCount - 1 downto 0 do 91 Panel1.Controls[I].Free; 86 92 87 // Load column names88 try89 Properties := TDbRows.Create; 90 MainForm.Database.Query(Properties, 'SELECT * FROM `Property` WHERE `Object`=' +91 IntToStr(MainForm.SelectedObject));92 for I := 0 to Properties.Count - 1 dobegin93 Report.Load(MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' + 94 IntToStr(MainForm.SelectedItem)); 95 96 // Load column names 97 for I := 0 to Report.Columns.Count - 1 do 98 if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin 93 99 NewControl := TLabel.Create(Panel1); 94 100 NewControl.Parent := Panel1; 95 101 NewControl.Top := LastTop; 96 102 NewControl.Left := Column * Width div ColumnCount + 10; 97 TLabel(NewControl).Caption := Properties[I].Values['Name']+ ':';103 TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 98 104 99 ValueType := StrToInt(Properties[I].Values['Type']);105 ValueType := TReportColumn(Report.Columns[I]).TypeId; 100 106 if ValueType = Integer(vtInteger) then begin 101 107 NewControl := TSpinEdit.Create(Panel1); … … 149 155 if Column = 0 then LastTop := LastTop + NewControl.Height + 4; 150 156 end; 151 152 finally153 Properties.Free;154 end;155 end else ShowMessage(SObjectNotFound);156 finally157 ObjectInfo.Free;158 end;159 157 end; 160 158
Note:
See TracChangeset
for help on using the changeset viewer.