Changeset 14 for trunk/Forms
- Timestamp:
- Jun 10, 2011, 2:16:52 PM (13 years ago)
- Location:
- trunk/Forms
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UItemAdd.pas
r12 r14 36 36 37 37 uses 38 UMainForm ;38 UMainForm, UDataTypes, UCore; 39 39 40 40 {$R *.lfm} … … 61 61 begin 62 62 Report := TReport.Create; 63 Report.Base := MainForm.System;63 Report.Base := Core.System; 64 64 end; 65 65 … … 77 77 procedure TItemAddForm.BuildControls; 78 78 var 79 NewControl: T Control;79 NewControl: TWinControl; 80 80 LastTop: Integer; 81 81 I: Integer; 82 82 Column: Integer; 83 83 ValueType: Integer; 84 NewLabel: TLabel; 85 DataType: TDataType; 84 86 const 85 87 ColumnCount = 2; … … 97 99 for I := 0 to Report.Columns.Count - 1 do 98 100 if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin 99 NewControl := TLabel.Create(Panel1); 101 NewLabel := TLabel.Create(Panel1); 102 NewLabel.Parent := Panel1; 103 NewLabel.Top := LastTop; 104 NewLabel.Left := Column * Width div ColumnCount + 10; 105 NewLabel.Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 106 107 DataType := TReportColumn(Report.Columns[I]).CustomType; 108 NewControl := DataType.CreateControl(Panel1); 109 DataType.SetDefault; 110 DataType.SetupControl(NewControl); 100 111 NewControl.Parent := Panel1; 101 112 NewControl.Top := LastTop; 102 NewControl.Left := Column * Width div ColumnCount + 10; 103 TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 104 105 ValueType := TReportColumn(Report.Columns[I]).TypeDef.TypeIndex; 106 if ValueType = Integer(vtInteger) then begin 107 NewControl := TSpinEdit.Create(Panel1); 108 NewControl.Parent := Panel1; 109 NewControl.Top := LastTop; 110 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 111 TSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 112 end else 113 if ValueType = Integer(vtDate) then begin 114 NewControl := TDateEdit.Create(Panel1); 115 NewControl.Parent := Panel1; 116 NewControl.Top := LastTop; 117 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 118 TDateEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 119 end else 120 if ValueType = Integer(vtFloat) then begin 121 NewControl := TFloatSpinEdit.Create(Panel1); 122 NewControl.Parent := Panel1; 123 NewControl.Top := LastTop; 124 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 125 TFloatSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 126 end else 127 if ValueType = Integer(vtString) then begin 128 NewControl := TEdit.Create(Panel1); 129 NewControl.Parent := Panel1; 130 NewControl.Top := LastTop; 131 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 132 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 133 end else 134 if ValueType = Integer(vtPassword) then begin 135 NewControl := TMaskEdit.Create(Panel1); 136 NewControl.Parent := Panel1; 137 NewControl.Top := LastTop; 138 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 139 TMaskEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 140 end else 141 if ValueType = Integer(vtBoolean) then begin 142 NewControl := TCheckBox.Create(Panel1); 143 NewControl.Parent := Panel1; 144 NewControl.Top := LastTop; 145 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 146 end else begin 147 NewControl := TEdit.Create(Panel1); 148 NewControl.Parent := Panel1; 149 NewControl.Top := LastTop; 150 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 151 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 152 end; 113 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 114 NewControl.Width := (Width div ColumnCount) div 2 - 20; 153 115 154 116 Column := (Column + 1) mod 2; -
trunk/Forms/UItemEdit.pas
r12 r14 36 36 37 37 uses 38 UMainForm ;38 UMainForm, UDataTypes, UCore; 39 39 40 40 {$R *.lfm} … … 63 63 begin 64 64 Report := TReport.Create; 65 Report.Base := MainForm.System;65 Report.Base := Core.System; 66 66 end; 67 67 … … 80 80 var 81 81 Values: TDbRows; 82 NewControl: TControl;83 82 LastTop: Integer; 84 83 I: Integer; 85 84 Column: Integer; 86 ValueType: Integer; 85 DataType: TDataType; 86 NewControl: TWinControl; 87 NewLabel: TLabel; 87 88 const 88 89 ColumnCount = 2; … … 100 101 if TReportColumn(Report.Columns[I]).ColumnName <> 'Id' then begin 101 102 102 NewControl := TLabel.Create(Panel1); 103 NewLabel := TLabel.Create(Panel1); 104 NewLabel.Parent := Panel1; 105 NewLabel.Top := LastTop; 106 NewLabel.Left := Column * Width div ColumnCount + 10; 107 NewLabel.Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 108 109 DataType := TReportColumn(Report.Columns[I]).CustomType; 110 NewControl := DataType.CreateControl(Panel1); 111 DataType.Load(TReportLine(Report[0]).Items[I]); 112 DataType.SetupControl(NewControl); 103 113 NewControl.Parent := Panel1; 104 114 NewControl.Top := LastTop; 105 NewControl.Left := Column * Width div ColumnCount + 10; 106 TLabel(NewControl).Caption := TReportColumn(Report.Columns[I]).Caption + ':'; 107 108 ValueType := TReportColumn(Report.Columns[I]).TypeDef.TypeIndex; 109 if ValueType = Integer(vtInteger) then begin 110 NewControl := TSpinEdit.Create(Panel1); 111 NewControl.Parent := Panel1; 112 NewControl.Top := LastTop; 113 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 114 TSpinEdit(NewControl).Value := StrToInt(TReportLine(Report[0]).Items[I]); 115 TSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 116 end else 117 if ValueType = Integer(vtDate) then begin 118 NewControl := TDateEdit.Create(Panel1); 119 NewControl.Parent := Panel1; 120 NewControl.Top := LastTop; 121 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 122 TDateEdit(NewControl).Date := StrToDate(TReportLine(Report[0]).Items[I]); 123 TDateEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 124 end else 125 if ValueType = Integer(vtFloat) then begin 126 NewControl := TFloatSpinEdit.Create(Panel1); 127 NewControl.Parent := Panel1; 128 NewControl.Top := LastTop; 129 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 130 TFloatSpinEdit(NewControl).Value := StrToFloat(TReportLine(Report[0]).Items[I]); 131 TFloatSpinEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 132 end else 133 if ValueType = Integer(vtString) then begin 134 NewControl := TEdit.Create(Panel1); 135 NewControl.Parent := Panel1; 136 NewControl.Top := LastTop; 137 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 138 TEdit(NewControl).Text := TReportLine(Report[0]).Items[I]; 139 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 140 end else 141 if ValueType = Integer(vtPassword) then begin 142 NewControl := TMaskEdit.Create(Panel1); 143 NewControl.Parent := Panel1; 144 NewControl.Top := LastTop; 145 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 146 TMaskEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 147 end else 148 if ValueType = Integer(vtBoolean) then begin 149 NewControl := TCheckBox.Create(Panel1); 150 NewControl.Parent := Panel1; 151 NewControl.Top := LastTop; 152 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 153 TCheckBox(NewControl).Checked := Boolean(StrToInt(TReportLine(Report[0]).Items[I])); 154 end else begin 155 NewControl := TEdit.Create(Panel1); 156 NewControl.Parent := Panel1; 157 NewControl.Top := LastTop; 158 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 159 TEdit(NewControl).Width := (Width div ColumnCount) div 2 - 20; 160 TEdit(NewControl).Text := TReportLine(Report[0]).Items[I]; 161 end; 115 NewControl.Left := Column * Width div ColumnCount + (Width div ColumnCount) div 2; 116 NewControl.Width := (Width div ColumnCount) div 2 - 20; 162 117 163 118 Column := (Column + 1) mod 2; -
trunk/Forms/UItemView.pas
r12 r14 42 42 43 43 uses 44 UMainForm, UItemEdit ;44 UMainForm, UItemEdit, UDataTypes, UCore; 45 45 46 46 {$R *.lfm} … … 57 57 begin 58 58 Report := TReport.Create; 59 Report.Base := MainForm.System;59 Report.Base := Core.System; 60 60 end; 61 61 … … 93 93 I: Integer; 94 94 Column: Integer; 95 DataType: TDataType; 95 96 const 96 97 ColumnCount = 2; … … 107 108 108 109 if Report.Count = 1 then 109 for I := 0 to Report.Columns.Count - 1 do 110 if TReportColumn(Report.Columns[I]).TypeDef.TypeIndex = Integer(vtPointer) then begin 110 for I := 0 to Report.Columns.Count - 1 do begin 111 DataType := TReportColumn(Report.Columns[I]).CustomType; 112 if DataType is TDataTypeRelationOne then begin 111 113 TabControl1.Tabs.Add(TReportColumn(Report.Columns[I]).Caption); 112 114 end else begin … … 126 128 if Column = 0 then LastTop := LastTop + 24; 127 129 end; 130 end; 128 131 Panel2.Visible := TabControl1.Tabs.Count > 0; 129 132 end; -
trunk/Forms/UMainForm.pas
r13 r14 104 104 PersistentForm: TPersistentForm; 105 105 TreeState: TTreeState; 106 System: TChronisBase;107 106 Report: TReport; 108 107 procedure LoadTree; … … 138 137 OpenKey(RegistryKey, True); 139 138 Panel1.Width := ReadIntegerWithDefault('GroupTreeWidth', 200); 140 System.Database.Database := ReadStringWithDefault('DatabaseSchema', 'chronis');141 System.Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost');142 System.Database.UserName := ReadStringWithDefault('DatabaseUserName', 'chronis');143 System.Database.Password := ReadStringWithDefault('DatabasePassword', '');139 Core.System.Database.Database := ReadStringWithDefault('DatabaseSchema', 'chronis'); 140 Core.System.Database.Hostname := ReadStringWithDefault('DatabaseHostName', 'localhost'); 141 Core.System.Database.UserName := ReadStringWithDefault('DatabaseUserName', 'chronis'); 142 Core.System.Database.Password := ReadStringWithDefault('DatabasePassword', ''); 144 143 with Core.CoolTranslator1 do 145 144 Language := Languages.SearchByCode(ReadStringWithDefault('LanguageCode', '')); … … 156 155 OpenKey(RegistryKey, True); 157 156 WriteInteger('GroupTreeWidth', Panel1.Width); 158 WriteString('DatabaseSchema', System.Database.Database);159 WriteString('DatabaseHostName', System.Database.Hostname);160 WriteString('DatabaseUserName', System.Database.UserName);161 WriteString('DatabasePassword', System.Database.Password);157 WriteString('DatabaseSchema', Core.System.Database.Database); 158 WriteString('DatabaseHostName', Core.System.Database.Hostname); 159 WriteString('DatabaseUserName', Core.System.Database.UserName); 160 WriteString('DatabasePassword', Core.System.Database.Password); 162 161 with Core.CoolTranslator1 do 163 162 WriteString('LanguageCode', Language.Code); … … 177 176 I: Integer; 178 177 begin 179 with System do178 with Core.System do 180 179 try 181 180 DbRows := TDbRows.Create; … … 245 244 '`Name` varchar(255) NOT NULL,' + 246 245 '`DbType` varchar(255) NOT NULL,' + 247 '`TypeIndex` int(11) NOT NULL,' +248 246 'PRIMARY KEY (`Id`)' + 249 247 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); … … 326 324 end; 327 325 328 if Tables.IndexOf(CustomType ) = -1 then begin329 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + CustomType + '` ( ' +326 if Tables.IndexOf(CustomTypeTableName) = -1 then begin 327 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + CustomTypeTableName + '` ( ' + 330 328 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 331 329 '`Type` int NOT NULL,' + … … 373 371 EnumId: Integer; 374 372 begin 375 with System do begin373 with Core.System do begin 376 374 TypeNumber := AddType('Number', 'INT', vtInteger); 377 375 TypeString := AddType('String', 'VARCHAR(255)', vtString); … … 407 405 GroupId := AddObjectGroup('System'); 408 406 409 ObjectId := AddObject('Object groups', 'ObjectGroup', System.Database.Database, GroupId);407 ObjectId := AddObject('Object groups', 'ObjectGroup', Core.System.Database.Database, GroupId); 410 408 AddPropertyString(ObjectId, 'Name', 'Name'); 411 ObjectId := AddObject('Objects', 'Object', System.Database.Database, GroupId);409 ObjectId := AddObject('Objects', 'Object', Core.System.Database.Database, GroupId); 412 410 AddPropertyString(ObjectId, 'Name', 'Name'); 413 411 AddPropertyNumber(ObjectId, 'Group', 'Group'); … … 416 414 AddPropertyString(ObjectId, 'Primary key', 'PrimaryKey'); 417 415 AddPropertyNumber(ObjectId, 'Sequence', 'Sequence'); 418 ObjectId := AddObject('Property types', 'Type', System.Database.Database, GroupId);416 ObjectId := AddObject('Property types', 'Type', Core.System.Database.Database, GroupId); 419 417 AddPropertyString(ObjectId, 'Name', 'Name'); 420 418 AddPropertyString(ObjectId, 'Type', 'DbType'); 421 AddPropertyNumber(ObjectId, 'Type index', 'TypeIndex');422 419 AddPropertyNumber(ObjectId, 'Parent', 'Parent'); 423 ObjectId := AddObject('Property groups', 'PropertyGroup', System.Database.Database, GroupId);424 ObjectId := AddObject('Properties', 'Property', System.Database.Database, GroupId);420 ObjectId := AddObject('Property groups', 'PropertyGroup', Core.System.Database.Database, GroupId); 421 ObjectId := AddObject('Properties', 'Property', Core.System.Database.Database, GroupId); 425 422 AddPropertyString(ObjectId, 'Name', 'Name'); 426 423 AddPropertyNumber(ObjectId, 'Object', 'Object'); 427 AddPropertyNumber(ObjectId, 'Property Group', 'PropertyGroup');428 AddPropertyNumber(ObjectId, ' Type', 'Type');424 AddPropertyNumber(ObjectId, 'Property group', 'PropertyGroup'); 425 AddPropertyNumber(ObjectId, 'Custom type', 'CustomType'); 429 426 AddProperty(ObjectId, 'Editable', 'Editable', TypeBoolean); 430 AddPropertyString(ObjectId, 'Column Name', 'ColumnName');427 AddPropertyString(ObjectId, 'Column name', 'ColumnName'); 431 428 end; 432 429 end; … … 434 431 procedure TMainForm.FormCreate(Sender: TObject); 435 432 begin 436 System := TChronisBase.Create;437 System.Database := TSqlDatabase.Create;438 433 TreeState := TTreeState.Create; 439 434 Report := TReport.Create; 440 Report.Base := System;435 Report.Base := Core.System; 441 436 SelectedObject := TChronisObject.Create; 442 SelectedObject.Base := System;437 SelectedObject.Base := Core.System; 443 438 RegistryRootKey := HKEY_CURRENT_USER; 444 439 RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' + … … 453 448 TreeState.Free; 454 449 PersistentForm.Free; 455 System.Free;456 450 end; 457 451 … … 564 558 PersistentForm.Load(Self); 565 559 LoadFromRegistry; 566 System.Database.Connect;560 Core.System.Database.Connect; 567 561 InitStructure; 568 System.LoadTypes;562 Core.System.LoadTypes; 569 563 LoadTree; 570 564 end; … … 645 639 try 646 640 DbRows := TDbRows.Create; 647 System.Database.Query(DbRows, 'SELECT * FROM `' + ObjectGroupTable + '`');641 Core.System.Database.Query(DbRows, 'SELECT * FROM `' + ObjectGroupTable + '`'); 648 642 for I := 0 to DbRows.Count - 1 do begin 649 643 NewNode := AddChild(TopItem, DbRows[I].Values['Name']); … … 653 647 try 654 648 ObjectDbRows := TDbRows.Create; 655 System.Database.Query(ObjectDbRows, 'SELECT * FROM `' + ObjectTable + '` WHERE `Group`=' + DbRows[I].Values['Id']);649 Core.System.Database.Query(ObjectDbRows, 'SELECT * FROM `' + ObjectTable + '` WHERE `Group`=' + DbRows[I].Values['Id']); 656 650 for O := 0 to ObjectDbRows.Count - 1 do begin 657 651 NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']);
Note:
See TracChangeset
for help on using the changeset viewer.