Changeset 20 for trunk/Forms
- Timestamp:
- Jun 15, 2011, 11:11:59 AM (13 years ago)
- Location:
- trunk/Forms
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UImportStructureForm.lfm
r19 r20 1 1 object ImportStructureForm: TImportStructureForm 2 Left = 32 03 Height = 2334 Top = 14 45 Width = 5 282 Left = 321 3 Height = 465 4 Top = 145 5 Width = 553 6 6 Caption = 'Import structure' 7 ClientHeight = 233 8 ClientWidth = 528 7 ClientHeight = 465 8 ClientWidth = 553 9 OnCreate = FormCreate 10 OnDestroy = FormDestroy 9 11 OnShow = FormShow 10 12 LCLVersion = '0.9.31' … … 70 72 end 71 73 object Button1: TButton 72 Left = 4 4874 Left = 473 73 75 Height = 25 74 Top = 20176 Top = 433 75 77 Width = 75 76 78 Anchors = [akRight, akBottom] … … 81 83 object Memo1: TMemo 82 84 Left = 184 83 Height = 18085 Height = 412 84 86 Top = 8 85 Width = 3 3587 Width = 360 86 88 Anchors = [akTop, akLeft, akRight, akBottom] 87 89 ScrollBars = ssAutoBoth -
trunk/Forms/UImportStructureForm.pas
r19 r20 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 USystem;9 EditBtn, USystem, SpecializedList, USqlDatabase, SpecializedDictionary; 10 10 11 11 type 12 13 { TSQLTable } 14 15 TSQLTable = class 16 Table: TDictionaryStringString; 17 Columns: TDbRows; 18 function ColumnByName(Name: string): Integer; 19 constructor Create; 20 destructor Destroy; override; 21 end; 12 22 13 23 { TImportStructureForm } … … 25 35 Memo1: TMemo; 26 36 procedure Button1Click(Sender: TObject); 37 procedure FormCreate(Sender: TObject); 38 procedure FormDestroy(Sender: TObject); 27 39 procedure FormShow(Sender: TObject); 28 40 private 41 function ObjectIdByName(Name: string): Integer; 29 42 { private declarations } 30 43 public 31 { public declarations }44 SQLTables: TListObject; // TListObject<TSQLTable> 32 45 end; 33 46 … … 38 51 39 52 uses 40 UCore, USqlDatabase, UMainForm; 53 UCore, UMainForm; 54 55 { TSQLTable } 56 57 function TSQLTable.ColumnByName(Name: string): Integer; 58 var 59 I: Integer; 60 begin 61 I := 0; 62 while (I < Columns.Count) and (Columns[I].Values['COLUMN_NAME'] <> Name) do Inc(I); 63 if I < Columns.Count then Result := I 64 else Result := -1; 65 end; 66 67 constructor TSQLTable.Create; 68 begin 69 Columns := TDbRows.Create; 70 Table := TDictionaryStringString.Create; 71 end; 72 73 destructor TSQLTable.Destroy; 74 begin 75 Columns.Free; 76 Table.Free; 77 inherited Destroy; 78 end; 41 79 42 80 {$R *.lfm} 43 81 44 82 { TImportStructureForm } 83 84 function TImportStructureForm.ObjectIdByName(Name: string): Integer; 85 var 86 I: Integer; 87 begin 88 I := 0; 89 while (I < SQLTables.Count) and (TSQLTable(SQLTables[I]).Table.Items[0].Value <> Name) do Inc(I); 90 if I < SQLTables.Count then Result := I 91 else Result := -1; 92 end; 45 93 46 94 procedure TImportStructureForm.FormShow(Sender: TObject); … … 63 111 ObjectId: Integer; 64 112 PropertyId: Integer; 113 NewTable: TSQLTable; 114 RefObjectIndex: Integer; 115 RefPropertyId: Integer; 65 116 begin 66 117 try … … 73 124 Database.Password := EditPassword.Text; 74 125 Database.Connect; 126 127 SQLTables.Clear; 75 128 GroupId := Core.System.AddGroup(Database.Database, 0); 76 129 Database.Query(DbRows, 'SHOW TABLES'); 77 130 for T := 0 to DbRows.Count - 1 do begin 131 NewTable := TSQLTable(SQLTables.AddNew(TSQLTable.Create)); 132 NewTable.Table.Assign(DbRows[T]); 78 133 TableName := DbRows[T].Items[0].Value; 79 134 Memo1.Lines.Add('Create object "' + TableName + '"'); 80 ObjectId := Core.System.AddObject(TableName, TableName, Database.Database, GroupId); 81 Database.Query(DbRows2, 'SHOW COLUMNS FROM `' + TableName + '`'); 82 for C := 0 to DbRows2.Count - 1 do begin 83 PropertyName := DbRows2[C].Values['Field']; 84 PropType := DbRows2[C].Values['Type']; 85 PropType := Copy(PropType, 1, Pos('(', PropType) - 1); 135 NewTable.Table.Add('ObjId', IntToStr(Core.System.AddObject(TableName, TableName, Database.Database, GroupId))); 136 end; 137 138 for T := 0 to SQLTables.Count - 1 do 139 with TSQLTable(SQLTables[T]) do begin 140 TableName := Table.Items[0].Value; 141 Database.Query(Columns, 'SELECT `TCOL`.`DATA_TYPE`, `TCOL`.`COLUMN_NAME`, ' + 142 ' `KCU`.`REFERENCED_TABLE_SCHEMA`, `KCU`.`REFERENCED_TABLE_NAME`, `KCU`.`REFERENCED_COLUMN_NAME`, ' + 143 ' `TC`.`CONSTRAINT_TYPE` ' + 144 ' FROM `information_schema`.`COLUMNS` AS `TCOL`' + 145 ' LEFT JOIN `information_schema`.`KEY_COLUMN_USAGE` AS `KCU` ON ' + 146 ' (`KCU`.`TABLE_SCHEMA` = `TCOL`.`TABLE_SCHEMA`) AND ' + 147 ' (`KCU`.`TABLE_NAME` = `TCOL`.`TABLE_NAME`) AND ' + 148 ' (`KCU`.`COLUMN_NAME` = `TCOL`.`COLUMN_NAME`) ' + 149 ' LEFT JOIN `information_schema`.`TABLE_CONSTRAINTS` AS `TC` ON' + 150 ' (`KCU`.`CONSTRAINT_NAME` = `TC`.`CONSTRAINT_NAME`) AND ' + 151 ' (`KCU`.`TABLE_NAME` = `TC`.`TABLE_NAME`) AND ' + 152 ' (`KCU`.`CONSTRAINT_SCHEMA` = `TC`.`CONSTRAINT_SCHEMA`)' + 153 ' WHERE ' + 154 '(`TCOL`.`TABLE_SCHEMA` = "' + Database.Database + '") AND ' + 155 '(`TCOL`.`TABLE_NAME` = "' + TableName + '")'); 156 Memo1.Lines.Add('Add properies for object "' + TableName + '"'); 157 ObjectId := StrToInt(Table.Values['ObjId']); 158 for C := 0 to Columns.Count - 1 do begin 159 PropertyName := Columns[C].Values['COLUMN_NAME']; 160 PropType := Columns[C].Values['DATA_TYPE']; 161 if Columns[C].Values['CONSTRAINT_TYPE'] = 'FOREIGN KEY' then begin 162 PropertyId := Core.System.AddPropertyRelationOne(ObjectId, PropertyName, PropertyName, 163 ObjectIdByName(Columns[C].Values['REFERENCED_TABLE_NAME'])); 164 end else 86 165 if PropType = 'int' then 87 166 PropertyId := Core.System.AddPropertyNumber(ObjectId, PropertyName, PropertyName); … … 90 169 if PropType = 'float' then 91 170 PropertyId := Core.System.AddPropertyFloat(ObjectId, PropertyName, PropertyName); 171 if PropType = 'datetime' then 172 PropertyId := Core.System.AddPropertyDateTime(ObjectId, PropertyName, PropertyName); 173 Columns[C].Add('Id', IntToStr(PropertyId)); 92 174 Memo1.Lines.Add('Create property "' + PropertyName + '" of type ' + PropType + '"'); 175 //Memo1.Lines.Add(Columns[C].Values['CONSTRAINT_TYPE']); 176 //TSQLTable(SQLTables[T]).Columns.Add(); 177 end; 178 end; 179 180 for T := 0 to SQLTables.Count - 1 do 181 with TSQLTable(SQLTables[T]) do begin 182 TableName := Table.Items[0].Value; 183 ObjectId := StrToInt(Table.Values['ObjId']); 184 for C := 0 to Columns.Count - 1 do begin 185 PropertyName := Columns[C].Values['COLUMN_NAME']; 186 PropType := Columns[C].Values['DATA_TYPE']; 187 if Columns[C].Values['CONSTRAINT_TYPE'] = 'FOREIGN KEY' then begin 188 Memo1.Lines.Add('Add relation 1:n for "' + TableName + '.' + PropertyName + '"'); 189 RefObjectIndex := ObjectIdByName(Columns[C].Values['REFERENCED_TABLE_NAME']); 190 191 RefPropertyId := TSQLTable(SQLTables[T]).ColumnByName(Columns[C].Values['COLUMN_NAME']); 192 RefPropertyId := StrToInt(TSQLTable(SQLTables[T]).Columns[RefPropertyId].Values['Id']); 193 PropertyId := Core.System.AddPropertyRelationMany(StrToInt(TSQLTable(SQLTables[RefObjectIndex]).Table.Values['ObjId']), TableName, TableName, 194 RefPropertyId); 195 end; 93 196 end; 94 197 end; … … 101 204 end; 102 205 206 procedure TImportStructureForm.FormCreate(Sender: TObject); 207 begin 208 SQLTables := TListObject.Create; 209 end; 210 211 procedure TImportStructureForm.FormDestroy(Sender: TObject); 212 begin 213 SQLTables.Free; 214 end; 215 103 216 end. 104 217 -
trunk/Forms/UItemAdd.lfm
r12 r20 1 1 object ItemAddForm: TItemAddForm 2 Left = 40 03 Height = 4 214 Top = 13 05 Width = 56 72 Left = 401 3 Height = 419 4 Top = 131 5 Width = 565 6 6 ActiveControl = Panel1 7 7 Caption = 'Add item' 8 ClientHeight = 4 219 ClientWidth = 56 78 ClientHeight = 419 9 ClientWidth = 565 10 10 OnClose = FormClose 11 11 OnCreate = FormCreate … … 15 15 object Panel1: TPanel 16 16 Left = 0 17 Height = 38 417 Height = 382 18 18 Top = 0 19 Width = 56 719 Width = 565 20 20 Align = alTop 21 21 Anchors = [akLeft, akRight, akBottom] … … 24 24 end 25 25 object ButtonCancel: TButton 26 Left = 38 426 Left = 382 27 27 Height = 25 28 Top = 39 228 Top = 390 29 29 Width = 75 30 30 Anchors = [akRight, akBottom] … … 34 34 end 35 35 object ButtonSave: TButton 36 Left = 47 236 Left = 470 37 37 Height = 25 38 Top = 39 238 Top = 390 39 39 Width = 75 40 40 Anchors = [akRight, akBottom] -
trunk/Forms/UItemEdit.lfm
r12 r20 1 1 object ItemEditForm: TItemEditForm 2 Left = 29 53 Height = 42 94 Top = 12 25 Width = 55 82 Left = 296 3 Height = 427 4 Top = 123 5 Width = 556 6 6 ActiveControl = Panel1 7 7 Caption = 'Edit item' 8 ClientHeight = 42 99 ClientWidth = 55 88 ClientHeight = 427 9 ClientWidth = 556 10 10 OnClose = FormClose 11 11 OnCreate = FormCreate … … 15 15 object Panel1: TPanel 16 16 Left = 0 17 Height = 38 617 Height = 384 18 18 Top = 0 19 Width = 55 819 Width = 556 20 20 Align = alTop 21 21 Anchors = [akLeft, akRight, akBottom] … … 24 24 end 25 25 object ButtonCancel: TButton 26 Left = 38 426 Left = 382 27 27 Height = 25 28 Top = 40028 Top = 398 29 29 Width = 75 30 30 Anchors = [akRight, akBottom] … … 34 34 end 35 35 object ButtonSave: TButton 36 Left = 47 236 Left = 470 37 37 Height = 25 38 Top = 40038 Top = 398 39 39 Width = 75 40 40 Anchors = [akRight, akBottom] -
trunk/Forms/UItemView.lfm
r17 r20 1 1 object ItemViewForm: TItemViewForm 2 Left = 31 13 Height = 46 94 Top = 11 05 Width = 62 62 Left = 312 3 Height = 467 4 Top = 111 5 Width = 624 6 6 Caption = 'View item' 7 ClientHeight = 46 98 ClientWidth = 62 67 ClientHeight = 467 8 ClientWidth = 624 9 9 OnClose = FormClose 10 10 OnCreate = FormCreate … … 14 14 LCLVersion = '0.9.31' 15 15 object ButtonClose: TButton 16 Left = 54 616 Left = 544 17 17 Height = 25 18 Top = 43 918 Top = 437 19 19 Width = 75 20 20 Anchors = [akRight, akBottom] … … 24 24 end 25 25 object ButtonEdit: TButton 26 Left = 45 826 Left = 456 27 27 Height = 25 28 Top = 43 928 Top = 437 29 29 Width = 75 30 30 Anchors = [akRight, akBottom] … … 35 35 object Panel1: TPanel 36 36 Left = 0 37 Height = 43 337 Height = 431 38 38 Top = 0 39 Width = 62 639 Width = 624 40 40 Align = alTop 41 41 Anchors = [akTop, akLeft, akRight, akBottom] 42 42 BevelOuter = bvNone 43 ClientHeight = 43 344 ClientWidth = 62 643 ClientHeight = 431 44 ClientWidth = 624 45 45 TabOrder = 2 46 46 object Panel2: TPanel 47 47 Left = 0 48 48 Height = 200 49 Top = 23 350 Width = 62 649 Top = 231 50 Width = 624 51 51 Align = alBottom 52 52 BevelOuter = bvNone 53 53 ClientHeight = 200 54 ClientWidth = 62 654 ClientWidth = 624 55 55 TabOrder = 0 56 56 object TabControl1: TTabControl … … 58 58 Height = 24 59 59 Top = 0 60 Width = 62 660 Width = 624 61 61 Align = alTop 62 62 OnChange = TabControl1Change … … 74 74 Height = 176 75 75 Top = 24 76 Width = 62 676 Width = 624 77 77 Align = alClient 78 78 Columns = <> … … 89 89 Left = 0 90 90 Height = 3 91 Top = 2 3092 Width = 62 691 Top = 228 92 Width = 624 93 93 Align = alBottom 94 94 ResizeAnchor = akBottom … … 96 96 object PanelControls: TPanel 97 97 Left = 0 98 Height = 2 3098 Height = 228 99 99 Top = 0 100 Width = 62 6100 Width = 624 101 101 Align = alClient 102 102 Anchors = [akLeft, akRight, akBottom] -
trunk/Forms/ULoginForm.lfm
r10 r20 1 1 object LoginForm: TLoginForm 2 Left = 4 793 Height = 17 74 Top = 25 55 Width = 40 52 Left = 480 3 Height = 175 4 Top = 256 5 Width = 403 6 6 BorderIcons = [biSystemMenu] 7 7 BorderStyle = bsDialog 8 8 Caption = 'Login' 9 ClientHeight = 17 710 ClientWidth = 40 59 ClientHeight = 175 10 ClientWidth = 403 11 11 LCLVersion = '0.9.31' 12 12 object Label1: TLabel -
trunk/Forms/UMainForm.lfm
r19 r20 1 1 object MainForm: TMainForm 2 Left = 26 83 Height = 45 14 Top = 15 65 Width = 64 62 Left = 269 3 Height = 450 4 Top = 157 5 Width = 644 6 6 ActiveControl = Panel1 7 7 Caption = 'ChronIS' 8 ClientHeight = 43 29 ClientWidth = 64 68 ClientHeight = 430 9 ClientWidth = 644 10 10 Menu = MainMenu1 11 11 OnClose = FormClose … … 16 16 object Panel1: TPanel 17 17 Left = 0 18 Height = 43 218 Height = 430 19 19 Top = 0 20 20 Width = 184 21 21 Align = alLeft 22 22 BevelOuter = bvNone 23 ClientHeight = 43 223 ClientHeight = 430 24 24 ClientWidth = 184 25 25 TabOrder = 0 … … 34 34 object TreeView1: TTreeView 35 35 Left = 4 36 Height = 40 836 Height = 406 37 37 Top = 19 38 38 Width = 180 … … 48 48 object Panel2: TPanel 49 49 Left = 189 50 Height = 43 250 Height = 430 51 51 Top = 0 52 Width = 45 752 Width = 455 53 53 Align = alClient 54 54 BevelOuter = bvNone 55 ClientHeight = 43 256 ClientWidth = 45 755 ClientHeight = 430 56 ClientWidth = 455 57 57 TabOrder = 1 58 58 object Label2: TLabel … … 66 66 object ListView1: TListView 67 67 Left = 2 68 Height = 37 668 Height = 374 69 69 Top = 19 70 Width = 45 370 Width = 451 71 71 Anchors = [akTop, akLeft, akRight, akBottom] 72 72 Columns = <> … … 86 86 Left = 3 87 87 Height = 25 88 Top = 40 388 Top = 401 89 89 Width = 75 90 90 Action = AItemAdd … … 95 95 Left = 83 96 96 Height = 25 97 Top = 40 397 Top = 401 98 98 Width = 75 99 99 Action = AItemDelete … … 104 104 object Splitter1: TSplitter 105 105 Left = 184 106 Height = 43 2106 Height = 430 107 107 Top = 0 108 108 Width = 5 -
trunk/Forms/UMainForm.pas
r19 r20 361 361 end; 362 362 363 if Tables.IndexOf(TypeDateTime) = -1 then begin 364 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeDateTime + '` ( ' + 365 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 366 '`CustomType` int NOT NULL,' + 367 '`Default` datetime NOT NULL,' + 368 '`Min` datetime NOT NULL,' + 369 '`Max` datetime NOT NULL,' + 370 'KEY `CustomType` (`CustomType`),' + 371 'PRIMARY KEY (`Id`)' + 372 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 373 end; 374 363 375 if Tables.IndexOf(TypeString) = -1 then begin 364 376 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeString + '` ( ' + -
trunk/Forms/USettingForm.lfm
r19 r20 1 1 object SettingForm: TSettingForm 2 Left = 37 13 Height = 32 84 Top = 13 85 Width = 44 62 Left = 372 3 Height = 326 4 Top = 139 5 Width = 444 6 6 Caption = 'Settings' 7 ClientHeight = 32 88 ClientWidth = 44 67 ClientHeight = 326 8 ClientWidth = 444 9 9 OnClose = FormClose 10 10 OnShow = FormShow … … 26 26 end 27 27 object ButtonSave: TButton 28 Left = 36 828 Left = 366 29 29 Height = 25 30 Top = 29 630 Top = 294 31 31 Width = 75 32 32 Anchors = [akRight, akBottom] … … 36 36 end 37 37 object ButtonCancel: TButton 38 Left = 2 8038 Left = 278 39 39 Height = 25 40 Top = 29 640 Top = 294 41 41 Width = 75 42 42 Anchors = [akRight, akBottom]
Note:
See TracChangeset
for help on using the changeset viewer.