Changeset 9 for trunk/Forms/UItemEdit.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/UItemEdit.pas
r7 r9 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 StdCtrls, Spin, EditBtn, USqlDatabase, MaskEdit ;9 StdCtrls, Spin, EditBtn, USqlDatabase, MaskEdit, 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 24 26 { private declarations } 25 27 public 28 Report: TReport; 26 29 procedure BuildControls; 27 30 end; … … 57 60 end; 58 61 62 procedure TItemEditForm.FormCreate(Sender: TObject); 63 begin 64 Report := TReport.Create; 65 Report.Base := MainForm.System; 66 end; 67 68 procedure TItemEditForm.FormDestroy(Sender: TObject); 69 begin 70 Report.Free; 71 end; 72 59 73 procedure TItemEditForm.FormShow(Sender: TObject); 60 74 begin … … 65 79 procedure TItemEditForm.BuildControls; 66 80 var 67 Properties: TDbRows;68 81 Values: TDbRows; 69 82 NewControl: TControl; … … 71 84 I: Integer; 72 85 Column: Integer; 73 ObjectInfo: TDbRows;74 86 ValueType: Integer; 75 87 const … … 78 90 LastTop := 8; 79 91 Column := 0; 80 try 81 ObjectInfo := TDbRows.Create; 82 MainForm.Database.Query(ObjectInfo, 'SELECT * FROM `Object` WHERE `Id`=' + IntToStr(MainForm.SelectedObject)); 83 if ObjectInfo.Count = 1 then begin 92 Report.Load(MainForm.SelectedObject, MainForm.SelectedObject.PrimaryKey + ' = ' + 93 IntToStr(MainForm.SelectedItem)); 84 94 85 86 95 for I := Panel1.ControlCount - 1 downto 0 do 96 Panel1.Controls[I].Free; 87 97 88 // Load column names 89 try 90 Properties := TDbRows.Create; 91 MainForm.Database.Query(Properties, 'SELECT * FROM `Property` WHERE `Object`=' + 92 IntToStr(MainForm.SelectedObject)); 93 Values := TDbRows.Create; 94 MainForm.Database.Query(Values, 'SELECT * FROM `' + ObjectInfo[0].Values['Schema'] + '`.`' + 95 ObjectInfo[0].Values['Table'] + '` WHERE ' + ObjectInfo[0].Values['PrimaryKey'] + ' = ' + 96 IntToStr(MainForm.SelectedItem)); 97 if Values.Count = 1 then 98 for I := 0 to Properties.Count - 1 do begin 98 if Report.Count = 1 then 99 for I := 0 to Report.Columns.Count - 1 do 100 if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin 101 99 102 NewControl := TLabel.Create(Panel1); 100 103 NewControl.Parent := Panel1; 101 104 NewControl.Top := LastTop; 102 105 NewControl.Left := Column * Width div ColumnCount + 10; 103 TLabel(NewControl).Caption := Properties[I].Values['Name']+ ':';106 TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 104 107 105 ValueType := StrToInt(Properties[I].Values['Type']);108 ValueType := TReportColumn(Report.Columns[I]).TypeId; 106 109 if ValueType = Integer(vtInteger) then begin 107 110 NewControl := TSpinEdit.Create(Panel1); … … 109 112 NewControl.Top := LastTop; 110 113 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 111 TSpinEdit(NewControl).Value := StrToInt( Values[0].Values[Properties[I].Values['ColumnName']]);114 TSpinEdit(NewControl).Value := StrToInt(TReportLine(Report[0]).Items[I]); 112 115 TSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 113 116 end else … … 117 120 NewControl.Top := LastTop; 118 121 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 119 TDateEdit(NewControl).Date := StrToDate( Values[0].Values[Properties[I].Values['ColumnName']]);122 TDateEdit(NewControl).Date := StrToDate(TReportLine(Report[0]).Items[I]); 120 123 TDateEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 121 124 end else … … 125 128 NewControl.Top := LastTop; 126 129 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 127 TFloatSpinEdit(NewControl).Value := StrToFloat( Values[0].Values[Properties[I].Values['ColumnName']]);130 TFloatSpinEdit(NewControl).Value := StrToFloat(TReportLine(Report[0]).Items[I]); 128 131 TFloatSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 129 132 end else … … 133 136 NewControl.Top := LastTop; 134 137 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 135 TEdit(NewControl).Text := Values[0].Values[Properties[I].Values['ColumnName']];138 TEdit(NewControl).Text := TReportLine(Report[0]).Items[I]; 136 139 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 137 140 end else … … 148 151 NewControl.Top := LastTop; 149 152 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 150 TCheckBox(NewControl).Checked := Boolean(StrToInt( Values[0].Values[Properties[I].Values['ColumnName']]));153 TCheckBox(NewControl).Checked := Boolean(StrToInt(TReportLine(Report[0]).Items[I])); 151 154 end else begin 152 155 NewControl := TEdit.Create(Panel1); … … 155 158 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 156 159 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 157 TEdit(NewControl).Text := Values[0].Values[Properties[I].Values['ColumnName']];160 TEdit(NewControl).Text := TReportLine(Report[0]).Items[I]; 158 161 end; 159 162 160 163 Column := (Column + 1) mod 2; 161 164 if Column = 0 then LastTop := LastTop + NewControl.Height + 4; 162 end else ShowMessage(SItemNotFound); 163 finally 164 Values.Free; 165 Properties.Free; 166 end; 167 end else ShowMessage(SObjectNotFound); 168 finally 169 ObjectInfo.Free; 170 end; 165 end; 171 166 end; 172 167
Note:
See TracChangeset
for help on using the changeset viewer.