Changeset 9 for trunk/Forms
- Timestamp:
- Dec 26, 2010, 8:12:59 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 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.lfm
r7 r9 4 4 Top = 130 5 5 Width = 567 6 ActiveControl = Panel1 6 7 Caption = 'Add item' 7 8 ClientHeight = 421 8 9 ClientWidth = 567 9 10 OnClose = FormClose 11 OnCreate = FormCreate 12 OnDestroy = FormDestroy 10 13 OnShow = FormShow 11 14 LCLVersion = '0.9.29' -
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 -
trunk/Forms/UItemEdit.lfm
r7 r9 9 9 ClientWidth = 558 10 10 OnClose = FormClose 11 OnCreate = FormCreate 12 OnDestroy = FormDestroy 11 13 OnShow = FormShow 12 14 LCLVersion = '0.9.29' -
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 -
trunk/Forms/UItemView.lfm
r7 r9 1 1 object ItemViewForm: TItemViewForm 2 Left = 3 373 Height = 4 164 Top = 1 355 Width = 5522 Left = 311 3 Height = 469 4 Top = 110 5 Width = 626 6 6 Caption = 'View item' 7 ClientHeight = 4 168 ClientWidth = 5527 ClientHeight = 469 8 ClientWidth = 626 9 9 OnClose = FormClose 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 10 12 OnShow = FormShow 11 13 LCLVersion = '0.9.29' 12 14 object ButtonClose: TButton 13 Left = 47215 Left = 546 14 16 Height = 25 15 Top = 38617 Top = 439 16 18 Width = 75 17 19 Anchors = [akRight, akBottom] … … 20 22 TabOrder = 0 21 23 end 22 object Panel1: TPanel23 Left = 024 Height = 37825 Top = 026 Width = 55227 Align = alTop28 Anchors = [akLeft, akRight, akBottom]29 BevelOuter = bvNone30 TabOrder = 131 end32 24 object ButtonEdit: TButton 33 Left = 38425 Left = 458 34 26 Height = 25 35 Top = 38627 Top = 439 36 28 Width = 75 37 29 Anchors = [akRight, akBottom] 38 30 Caption = 'Edit' 39 31 OnClick = ButtonEditClick 32 TabOrder = 1 33 end 34 object Panel1: TPanel 35 Left = 0 36 Height = 433 37 Top = 0 38 Width = 626 39 Align = alTop 40 Anchors = [akTop, akLeft, akRight, akBottom] 41 BevelOuter = bvNone 42 ClientHeight = 433 43 ClientWidth = 626 40 44 TabOrder = 2 45 object Panel2: TPanel 46 Left = 0 47 Height = 200 48 Top = 233 49 Width = 626 50 Align = alBottom 51 BevelOuter = bvNone 52 ClientHeight = 200 53 ClientWidth = 626 54 TabOrder = 0 55 object TabControl1: TTabControl 56 Left = 0 57 Height = 32 58 Top = 0 59 Width = 626 60 Align = alTop 61 TabIndex = 0 62 TabOrder = 0 63 Tabs.Strings = ( 64 'Tab1' 65 'Tab2' 66 'Tab3' 67 ) 68 TabStop = False 69 end 70 object ListView1: TListView 71 Left = 0 72 Height = 168 73 Top = 32 74 Width = 626 75 Align = alClient 76 Columns = <> 77 TabOrder = 1 78 end 79 end 80 object Splitter1: TSplitter 81 Cursor = crVSplit 82 Left = 0 83 Height = 3 84 Top = 230 85 Width = 626 86 Align = alBottom 87 ResizeAnchor = akBottom 88 end 89 object PanelControls: TPanel 90 Left = 0 91 Height = 230 92 Top = 0 93 Width = 626 94 Align = alClient 95 Anchors = [akLeft, akRight, akBottom] 96 BevelOuter = bvNone 97 TabOrder = 2 98 end 41 99 end 42 100 end -
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 -
trunk/Forms/UMainForm.lfm
r8 r9 6 6 ActiveControl = Panel1 7 7 Caption = 'ChronIS' 8 ClientHeight = 4 228 ClientHeight = 418 9 9 ClientWidth = 649 10 10 Menu = MainMenu1 … … 16 16 object Panel1: TPanel 17 17 Left = 0 18 Height = 4 2218 Height = 418 19 19 Top = 0 20 20 Width = 184 21 21 Align = alLeft 22 22 BevelOuter = bvNone 23 ClientHeight = 4 2223 ClientHeight = 418 24 24 ClientWidth = 184 25 25 TabOrder = 0 26 26 object Label1: TLabel 27 27 Left = 7 28 Height = 1 428 Height = 18 29 29 Top = 4 30 Width = 4430 Width = 51 31 31 Caption = 'Groups:' 32 32 ParentColor = False 33 33 end 34 34 object TreeView1: TTreeView 35 Left = 836 Height = 39 835 Left = 4 36 Height = 394 37 37 Top = 19 38 Width = 1 7638 Width = 180 39 39 Anchors = [akTop, akLeft, akRight, akBottom] 40 DefaultItemHeight = 1 640 DefaultItemHeight = 19 41 41 Images = ImageListActions 42 42 ReadOnly = True … … 48 48 object Panel2: TPanel 49 49 Left = 189 50 Height = 4 2250 Height = 418 51 51 Top = 0 52 52 Width = 460 53 53 Align = alClient 54 54 BevelOuter = bvNone 55 ClientHeight = 4 2255 ClientHeight = 418 56 56 ClientWidth = 460 57 57 TabOrder = 1 58 58 object Label2: TLabel 59 Left = 1160 Height = 1 459 Left = 2 60 Height = 18 61 61 Top = 4 62 Width = 4662 Width = 54 63 63 Caption = 'Reports:' 64 64 ParentColor = False 65 65 end 66 66 object ListView1: TListView 67 Left = 368 Height = 36 667 Left = 2 68 Height = 362 69 69 Top = 19 70 Width = 45 070 Width = 456 71 71 Anchors = [akTop, akLeft, akRight, akBottom] 72 72 Columns = <> … … 86 86 Left = 3 87 87 Height = 25 88 Top = 3 9388 Top = 389 89 89 Width = 75 90 90 Action = AItemAdd … … 95 95 Left = 83 96 96 Height = 25 97 Top = 3 9397 Top = 389 98 98 Width = 75 99 99 Action = AItemDelete … … 104 104 object Splitter1: TSplitter 105 105 Left = 184 106 Height = 4 22106 Height = 418 107 107 Top = 0 108 108 Width = 5 -
trunk/Forms/UMainForm.pas
r8 r9 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,8 Registry, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 9 StdCtrls, ActnList, Menus, ExtCtrls, USqlDatabase, DOM, XMLRead, XMLWrite, 10 UPersistentForm, UTreeState, SpecializedList ;10 UPersistentForm, UTreeState, SpecializedList, URegistry, USystem; 11 11 12 12 const … … 14 14 15 15 type 16 TDbValueType = (vtNone, vtInteger, vtString, vtText, vtDateTime, vtFloat, vtImage, vtBoolean,17 vtIPv4, vtMAC, vtIPv6, vtFile, vtGPS, vtEnumeration, vtHyperlink, vtPassword,18 vtReference, vtDate, vtTime, vtColor);19 20 { TReportLine }21 22 TReportLine = class23 Id: Integer;24 Items: TListString;25 constructor Create;26 destructor Destroy; override;27 end;28 29 16 { TMainForm } 30 17 … … 96 83 OriginalWindowState: TWindowState; 97 84 ScreenBounds: TRect; 85 RegistryKey: string; 86 RegistryRootKey: HKEY; 98 87 procedure LoadConfiguration; 88 procedure LoadFromRegistry; 89 procedure SaveToRegistry; 99 90 public 100 SelectedObject: Integer; 91 SelectedObjectId: Integer; 92 SelectedObject: TChronisObject; 101 93 SelectedItem: Integer; 102 94 PersistentForm: TPersistentForm; 103 Database: TSQLDatabase;104 95 TreeState: TTreeState; 105 Report: TListObject; 96 System: TChronisBase; 97 Report: TReport; 106 98 procedure LoadTree; 107 99 procedure LoadItemList; … … 121 113 uses 122 114 UItemView, UItemEdit, UItemAdd; 123 124 { TReportLine }125 126 constructor TReportLine.Create;127 begin128 Items := TListString.Create;129 end;130 131 destructor TReportLine.Destroy;132 begin133 Items.Free;134 inherited Destroy;135 end;136 115 137 116 {$R *.lfm} … … 157 136 with ChildNodes[I3] do begin 158 137 if NodeName = 'hostname' then 159 Database.HostName := TextContent;138 System.Database.HostName := TextContent; 160 139 if NodeName = 'schema' then 161 Database.Database := TextContent;140 System.Database.Database := TextContent; 162 141 if NodeName = 'username' then 163 Database.UserName := TextContent;142 System.Database.UserName := TextContent; 164 143 if NodeName = 'password' then 165 Database.Password := TextContent;144 System.Database.Password := TextContent; 166 145 end; 167 146 end; … … 172 151 end; 173 152 153 procedure TMainForm.LoadFromRegistry; 154 begin 155 with TRegistryEx.Create do 156 try 157 RootKey := RegistryRootKey; 158 OpenKey(RegistryKey, True); 159 Panel1.Width := ReadIntegerWithDefault('GroupTreeWidth', 200); 160 finally 161 Free; 162 end; 163 end; 164 165 procedure TMainForm.SaveToRegistry; 166 begin 167 with TRegistryEx.Create do 168 try 169 RootKey := RegistryRootKey; 170 OpenKey(RegistryKey, True); 171 WriteInteger('GroupTreeWidth', Panel1.Width); 172 finally 173 Free; 174 end; 175 end; 176 174 177 procedure TMainForm.FormCreate(Sender: TObject); 175 178 begin 176 Database := TSqlDatabase.Create; 179 System := TChronisBase.Create; 180 System.Database := TSqlDatabase.Create; 177 181 LoadConfiguration; 178 Database.Connect;182 System.Database.Connect; 179 183 TreeState := TTreeState.Create; 184 Report := TReport.Create; 185 Report.Base := System; 186 SelectedObject := TChronisObject.Create; 187 SelectedObject.Base := System; 188 RegistryRootKey := HKEY_CURRENT_USER; 189 RegistryKey := '\Software\Chronosoft\Chronis'; 180 190 PersistentForm := TPersistentForm.Create; 181 Report := TListObject.Create;191 PersistentForm.RegistryKey := RegistryKey; 182 192 end; 183 193 … … 186 196 Report.Free; 187 197 TreeState.Free; 188 Database.Free;189 198 PersistentForm.Free; 199 System.Free; 190 200 end; 191 201 … … 193 203 begin 194 204 PersistentForm.Save(Self); 205 SaveToRegistry; 195 206 end; 196 207 … … 208 219 begin 209 220 if Assigned(TreeView1.Selected) then begin 210 SelectedObject := 9;221 SelectedObjectId := 9; 211 222 SelectedItem := Integer(TreeView1.Selected.Data); 212 223 ItemEditForm.Show; … … 222 233 begin 223 234 if Assigned(TreeView1.Selected) then begin 224 SelectedObject := 8;235 SelectedObjectId := 8; 225 236 SelectedItem := Integer(TreeView1.Selected.Data); 226 237 ItemEditForm.Show; … … 274 285 PersistentForm.Load(Self); 275 286 LoadTree; 287 LoadFromRegistry; 276 288 end; 277 289 … … 351 363 try 352 364 DbRows := TDbRows.Create; 353 Database.Query(DbRows, 'SELECT * FROM `ObjectGroup`');365 System.Database.Query(DbRows, 'SELECT * FROM `ObjectGroup`'); 354 366 for I := 0 to DbRows.Count - 1 do begin 355 367 NewNode := AddChild(TopItem, DbRows[I].Values['Name']); … … 359 371 try 360 372 ObjectDbRows := TDbRows.Create; 361 Database.Query(ObjectDbRows, 'SELECT * FROM `Object` WHERE `Group`=' + DbRows[I].Values['Id']);373 System.Database.Query(ObjectDbRows, 'SELECT * FROM `Object` WHERE `Group`=' + DbRows[I].Values['Id']); 362 374 for O := 0 to ObjectDbRows.Count - 1 do begin 363 375 NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']); … … 380 392 procedure TMainForm.LoadItemList; 381 393 var 382 DbRows: TDbRows; 383 Properties: TDbRows; 384 Values: TDbRows; 394 NewColumn: TListColumn; 385 395 I: Integer; 386 C: Integer; 387 NewItem: TReportLine; 388 NewColumn: TListColumn; 389 begin 390 SelectedObject := 0; 396 begin 397 SelectedObjectId := 0; 391 398 if Assigned(TreeView1.Selected) then 392 399 with ListView1 do begin 393 400 Visible := True; 394 Report.Clear; 395 try 396 DbRows := TDbRows.Create; 397 Database.Query(DbRows, 'SELECT * FROM `Object` WHERE `Id`=' + IntToStr(Integer(TreeView1.Selected.Data))); 398 if DbRows.Count = 1 then begin 399 SelectedObject := StrToInt(DbRows[0].Values['Id']); 400 401 // Load column names 402 try 403 Properties := TDbRows.Create; 404 Database.Query(Properties, 'SELECT * FROM `Property` WHERE `Object`=' + 405 DbRows[0].Values['Id']); 406 Columns.Clear; 407 NewColumn := Columns.Add; 408 NewColumn.Caption := 'Id'; 409 for I := 0 to Properties.Count - 1 do begin 410 NewColumn := Columns.Add; 411 NewColumn.Caption := Properties[I].Values['Name']; 412 end; 413 414 ListView1Resize(Self); 415 416 // Load items 417 Values := TDbRows.Create; 418 Database.Query(Values, 'SELECT * FROM `' + DbRows[0].Values['Schema'] + '`.`' + 419 DbRows[0].Values['Table'] + '`'); 420 for I := 0 to Values.Count - 1 do begin 421 NewItem := TReportLine.Create; 422 NewItem.Items.Add(Values[I].Values[DbRows[0].Values['PrimaryKey']]); 423 NewItem.Id := StrToInt(Values[I].Values[DbRows[0].Values['PrimaryKey']]); 424 for C := 0 to Properties.Count - 1 do begin 425 NewItem.Items.Add(Values[I].Values[Properties[C].Values['ColumnName']]); 426 end; 427 Report.Add(NewItem); 428 end; 429 Items.Count := Values.Count; 430 Refresh; 431 finally 432 Properties.Free; 433 Values.Free; 434 end; 401 SelectedObject.Load(Integer(TreeView1.Selected.Data)); 402 Report.Load(SelectedObject); 403 404 Columns.Clear; 405 for I := 0 to Report.Columns.Count - 1 do begin 406 NewColumn := Columns.Add; 407 NewColumn.Caption := TReportColumn(Report.Columns[I]).Caption; 435 408 end; 436 finally437 DbRows.Free;438 439 end;409 Items.Count := Report.Count; 410 Refresh; 411 end; 412 ListView1Resize(Self); 440 413 end; 441 414
Note:
See TracChangeset
for help on using the changeset viewer.