- Timestamp:
- Jun 10, 2011, 8:23:37 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UMainForm.lfm
r11 r13 115 115 Category = 'Item' 116 116 Caption = 'Delete' 117 OnExecute = AItemDeleteExecute 117 118 end 118 119 object AItemAdd: TAction -
trunk/Forms/UMainForm.pas
r12 r13 68 68 procedure AInitSystemValuesExecute(Sender: TObject); 69 69 procedure AItemAddExecute(Sender: TObject); 70 procedure AItemDeleteExecute(Sender: TObject); 70 71 procedure AItemEditExecute(Sender: TObject); 71 72 procedure AItemViewExecute(Sender: TObject); … … 116 117 SObjectNotFound = 'Object not found'; 117 118 SGroup = 'Groups'; 119 SItemDeletion = 'Delete items'; 120 SReallyWantToDelete = 'Really want to delete selected items?'; 118 121 119 122 … … 171 174 Data: TDictionaryStringString; 172 175 ObjectId: Integer; 176 Tables: TListString; 177 I: Integer; 173 178 begin 174 179 with System do 175 180 try 176 181 DbRows := TDbRows.Create; 182 Tables := TListString.Create; 177 183 Data := TDictionaryStringString.Create; 178 184 179 Database.Query(DbRows, 'SHOW TABLES LIKE "' + InformationTable + '"'); 180 if DbRows.Count = 0 then begin 185 Database.Query(DbRows, 'SHOW TABLES'); 186 Tables.Count := DbRows.Count; 187 for I := 0 to DbRows.Count - 1 do 188 Tables[I] := DbRows[I].Items[0].Value; 189 190 if Tables.IndexOf(InformationTable) = -1 then begin 181 191 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + InformationTable + '` ( ' + 182 192 '`Version` varchar(255) NOT NULL,' + … … 189 199 StructureVersion := DbRows[0].Values['Version']; 190 200 191 Database.Query(DbRows, 'SHOW TABLES LIKE "' + ObjectTable + '"'); 192 if DbRows.Count = 0 then begin 201 if Tables.IndexOf(ObjectTable) = -1 then begin 193 202 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + ObjectTable + '` ( ' + 194 203 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + … … 197 206 '`Table` varchar(255) NOT NULL,' + 198 207 '`PrimaryKey` varchar(255) NOT NULL DEFAULT "Id", ' + 199 '`Sequence` int(11) NOT NULL ,' +208 '`Sequence` int(11) NOT NULL DEFAULT 0,' + 200 209 '`Group` int(11) NOT NULL,' + 201 ' PRIMARY KEY (`Id`),' +202 ' KEY `Group` (`Group`)' +210 'KEY `Group` (`Group`),' + 211 'PRIMARY KEY (`Id`)' + 203 212 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 204 213 205 214 end; 206 215 207 Database.Query(DbRows, 'SHOW TABLES LIKE "' + ObjectGroupTable + '"'); 208 if DbRows.Count = 0 then begin 216 if Tables.IndexOf(ObjectGroupTable) = -1 then begin 209 217 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + ObjectGroupTable + '` ( ' + 210 218 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 211 219 '`Name` varchar(255) NOT NULL,' + 212 '`Parent` int(11) NOT NULL,' + 213 '`Sequence` int(11) NOT NULL,' + 220 '`Parent` int(11) NOT NULL DEFAULT 0,' + 221 '`Sequence` int(11) NOT NULL DEFAULT 0,' + 222 'KEY `Parent` (`Parent`),' + 214 223 'PRIMARY KEY (`Id`)' + 215 224 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 216 225 end; 217 226 218 Database.Query(DbRows, 'SHOW TABLES LIKE "' + PropertyTable + '"'); 219 if DbRows.Count = 0 then begin 227 if Tables.IndexOf(PropertyTable) = -1 then begin 220 228 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + PropertyTable + '` ( ' + 221 229 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 222 230 '`Name` varchar(255) NOT NULL,' + 223 231 '`Object` int(11) NOT NULL,' + 224 '`PropertyGroup` int(11) NOT NULL,' + 225 '`Type` int(11) NOT NULL,' + 232 '`PropertyGroup` int(11) NOT NULL DEFAULT 0,' + 233 '`CustomType` int(11) NOT NULL,' + 234 '`Editable` bool NOT NULL DEFAULT 1,' + 226 235 '`ColumnName` varchar(255) NOT NULL,' + 227 236 'KEY `Object` (`Object`),' + 228 237 'KEY `PropertyGroup` (`PropertyGroup`),' + 229 'KEY ` Type` (`Type`),' +238 'KEY `CustomType` (`CustomType`),' + 230 239 'PRIMARY KEY (`Id`)' + 231 240 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 232 241 end; 233 Database.Query(DbRows, 'SHOW TABLES LIKE "' + PropertyTypeTable + '"'); 234 if DbRows.Count = 0 then begin 242 if Tables.IndexOf(PropertyTypeTable) = -1 then begin 235 243 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + PropertyTypeTable + '` ( ' + 236 244 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + … … 238 246 '`DbType` varchar(255) NOT NULL,' + 239 247 '`TypeIndex` int(11) NOT NULL,' + 240 '`Parent` int(11) NOT NULL,' +241 '`ParameterTable` varchar(255) NOT NULL,' +242 248 'PRIMARY KEY (`Id`)' + 243 249 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 244 250 end; 245 Database.Query(DbRows, 'SHOW TABLES LIKE "' + PropertyGroupTable + '"'); 246 if DbRows.Count = 0then begin251 252 if Tables.IndexOf(PropertyGroupTable) = -1 then begin 247 253 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + PropertyGroupTable + '` ( ' + 248 254 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + … … 254 260 end; 255 261 262 if Tables.IndexOf(EnumerationState) = -1 then begin 263 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + EnumerationState + '` ( ' + 264 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 265 '`Enumeration` int(11) NOT NULL,' + 266 '`Name` varchar(255) NOT NULL,' + 267 '`Sequence` int(11) NOT NULL DEFAULT 0,' + 268 'KEY `Enumeration` (`Enumeration`),' + 269 'PRIMARY KEY (`Id`)' + 270 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 271 end; 272 273 if Tables.IndexOf(Enumeration) = -1 then begin 274 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + Enumeration + '` ( ' + 275 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 276 '`Name` varchar(255) NOT NULL,' + 277 'PRIMARY KEY (`Id`)' + 278 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 279 end; 280 281 if Tables.IndexOf(TypeEnumeration) = -1 then begin 282 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeEnumeration + '` ( ' + 283 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 284 '`Enumeration` int(11) NOT NULL,' + 285 'KEY `Enumeration` (`Enumeration`),' + 286 'PRIMARY KEY (`Id`)' + 287 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 288 end; 289 290 if Tables.IndexOf(TypeRelationOne) = -1 then begin 291 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeRelationOne + '` ( ' + 292 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 293 '`Type` int(11) NOT NULL,' + 294 '`Object` int(11) NOT NULL,' + 295 'KEY `Type` (`Type`),' + 296 'PRIMARY KEY (`Id`)' + 297 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 298 end; 299 300 if Tables.IndexOf(TypeRelationMany) = -1 then begin 301 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeRelationMany + '` ( ' + 302 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 303 '`Type` int(11) NOT NULL,' + 304 '`ObjectProperty` int(11) NOT NULL,' + 305 'KEY `Type` (`Type`),' + 306 'PRIMARY KEY (`Id`)' + 307 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 308 end; 309 310 if Tables.IndexOf(TypeFile) = -1 then begin 311 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeFile + '` ( ' + 312 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 313 '`Name` varchar(255) NOT NULL,' + 314 '`Size` int(11) NOT NULL,' + 315 'PRIMARY KEY (`Id`)' + 316 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 317 end; 318 319 if Tables.IndexOf(TypeGPS) = -1 then begin 320 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeGPS + '` ( ' + 321 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 322 '`Latitude` double NOT NULL,' + 323 '`Longitude` double NOT NULL,' + 324 'PRIMARY KEY (`Id`)' + 325 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 326 end; 327 328 if Tables.IndexOf(CustomType) = -1 then begin 329 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + CustomType + '` ( ' + 330 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 331 '`Type` int NOT NULL,' + 332 'KEY `Type` (`Type`),' + 333 'PRIMARY KEY (`Id`)' + 334 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 335 end; 336 337 if Tables.IndexOf(TypeNumber) = -1 then begin 338 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeNumber + '` ( ' + 339 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 340 '`CustomType` int NOT NULL,' + 341 '`Default` int NOT NULL,' + 342 '`Min` int NOT NULL,' + 343 '`Max` int NOT NULL,' + 344 'KEY `CustomType` (`CustomType`),' + 345 'PRIMARY KEY (`Id`)' + 346 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 347 end; 348 349 if Tables.IndexOf(TypeString) = -1 then begin 350 Database.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `' + TypeString + '` ( ' + 351 '`Id` int(11) NOT NULL AUTO_INCREMENT,' + 352 '`CustomType` int NOT NULL,' + 353 '`Default` VARCHAR(255) NOT NULL,' + 354 '`MaxLength` int NOT NULL,' + 355 'KEY `CustomType` (`CustomType`),' + 356 'PRIMARY KEY (`Id`)' + 357 ') ENGINE=InnoDB DEFAULT CHARSET=utf8'); 358 end; 256 359 finally 360 Tables.Free; 257 361 Data.Free; 258 362 DbRows.Free; … … 265 369 TypeNumber: Integer; 266 370 TypeString: Integer; 371 TypeBoolean: Integer; 267 372 GroupId: Integer; 373 EnumId: Integer; 268 374 begin 269 375 with System do begin 270 376 TypeNumber := AddType('Number', 'INT', vtInteger); 271 TypeString := AddType('String', 'VAR (255)', vtString);377 TypeString := AddType('String', 'VARCHAR(255)', vtString); 272 378 AddType('Text', 'TEXT', vtText); 273 379 AddType('Date and time', 'DATETIME', vtDateTime); 274 380 AddType('Floating number', 'FLOAT', vtFloat); 275 381 AddType('Image', 'BLOB', vtImage); 276 AddType('Boolean', 'BOOL', vtBoolean);382 TypeBoolean := AddType('Boolean', 'BOOL', vtBoolean); 277 383 AddType('IPv4', 'BINARY(4)', vtIPv4); 278 384 AddType('IPv6', 'BINARY(16)', vtIPv6); 279 385 AddType('MAC address', 'BINARY(6)', vtMAC); 280 AddType('File', ' ', vtFile);281 AddType('GPS', ' ', vtGPS);386 AddType('File', 'INT', vtFile); 387 AddType('GPS', 'INT', vtGPS); 282 388 AddType('Currency', 'FLOAT', vtCurrency); 283 AddType('Enumeration', ' ', vtEnumeration);389 AddType('Enumeration', 'INT', vtEnumeration); 284 390 AddType('Time', 'TIME', vtTime); 285 391 AddType('Date', 'DATE', vtDate); 286 392 AddType('Color', 'INT', vtColor); 393 AddType('Hyperlink', 'VARCHAR(255)', vtHyperlink); 394 AddType('RelationOne', 'INT', vtRelationOne); 395 AddType('RelationMany', 'INT', vtRelationMany); 396 AddType('Password', 'VARCHAR(255)', vtPassword); 397 398 EnumId := AddEnumeration('Boolean'); 399 AddEnumerationState(EnumId, 'False'); 400 AddEnumerationState(EnumId, 'True'); 401 402 EnumId := AddEnumeration('Priority'); 403 AddEnumerationState(EnumId, 'Low'); 404 AddEnumerationState(EnumId, 'Normal'); 405 AddEnumerationState(EnumId, 'High'); 287 406 288 407 GroupId := AddObjectGroup('System'); 289 408 290 409 ObjectId := AddObject('Object groups', 'ObjectGroup', System.Database.Database, GroupId); 291 AddProperty (ObjectId, 'Name', 'Name', TypeString);410 AddPropertyString(ObjectId, 'Name', 'Name'); 292 411 ObjectId := AddObject('Objects', 'Object', System.Database.Database, GroupId); 293 AddProperty (ObjectId, 'Name', 'Name', TypeString);294 AddProperty (ObjectId, 'Group', 'Group', TypeNumber);295 AddProperty (ObjectId, 'Schema', 'Schema', TypeString);296 AddProperty (ObjectId, 'Table', 'Table', TypeString);297 AddProperty (ObjectId, 'Primary key', 'PrimaryKey', TypeString);298 AddProperty (ObjectId, 'Sequence', 'Sequence', TypeNumber);412 AddPropertyString(ObjectId, 'Name', 'Name'); 413 AddPropertyNumber(ObjectId, 'Group', 'Group'); 414 AddPropertyString(ObjectId, 'Schema', 'Schema'); 415 AddPropertyString(ObjectId, 'Table', 'Table'); 416 AddPropertyString(ObjectId, 'Primary key', 'PrimaryKey'); 417 AddPropertyNumber(ObjectId, 'Sequence', 'Sequence'); 299 418 ObjectId := AddObject('Property types', 'Type', System.Database.Database, GroupId); 300 AddProperty (ObjectId, 'Name', 'Name', TypeString);301 AddProperty (ObjectId, 'Type', 'DbType', TypeString);302 AddProperty (ObjectId, 'Type index', 'TypeIndex', TypeNumber);303 AddProperty (ObjectId, 'Parent', 'Parent', TypeNumber);419 AddPropertyString(ObjectId, 'Name', 'Name'); 420 AddPropertyString(ObjectId, 'Type', 'DbType'); 421 AddPropertyNumber(ObjectId, 'Type index', 'TypeIndex'); 422 AddPropertyNumber(ObjectId, 'Parent', 'Parent'); 304 423 ObjectId := AddObject('Property groups', 'PropertyGroup', System.Database.Database, GroupId); 305 424 ObjectId := AddObject('Properties', 'Property', System.Database.Database, GroupId); 306 AddProperty(ObjectId, 'Name', 'Name', TypeString); 307 AddProperty(ObjectId, 'Object', 'Object', TypeNumber); 308 AddProperty(ObjectId, 'PropertyGroup', 'PropertyGroup', TypeNumber); 309 AddProperty(ObjectId, 'Type', 'Type', TypeNumber); 310 AddProperty(ObjectId, 'ColumnName', 'ColumnName', TypeString); 425 AddPropertyString(ObjectId, 'Name', 'Name'); 426 AddPropertyNumber(ObjectId, 'Object', 'Object'); 427 AddPropertyNumber(ObjectId, 'PropertyGroup', 'PropertyGroup'); 428 AddPropertyNumber(ObjectId, 'Type', 'Type'); 429 AddProperty(ObjectId, 'Editable', 'Editable', TypeBoolean); 430 AddPropertyString(ObjectId, 'ColumnName', 'ColumnName'); 311 431 end; 312 432 end; … … 412 532 end; 413 533 414 procedure TMainForm.AItemAddExecute(Sender: TObject);415 begin416 ItemAddForm.Show;417 end;418 419 534 procedure TMainForm.AExitExecute(Sender: TObject); 420 535 begin … … 426 541 InitSystemValues; 427 542 LoadTree; 543 end; 544 545 procedure TMainForm.AItemAddExecute(Sender: TObject); 546 begin 547 ItemAddForm.ShowModal; 548 end; 549 550 procedure TMainForm.AItemDeleteExecute(Sender: TObject); 551 begin 552 if MessageDlg(SItemDeletion, SReallyWantToDelete, mtConfirmation, [mbYes, mbNo], 0) = mrYes then begin 553 554 end; 428 555 end; 429 556 -
trunk/USystem.pas
r12 r13 16 16 PropertyTypeTable = 'Type'; 17 17 PropertyGroupTable = 'PropertyGroup'; 18 TypeEnumeration = 'TypeEnumeration'; 19 TypeFile = 'TypeFile'; 20 TypeGPS = 'TypeGPS'; 21 TypeRelationOne = 'TypeRelationOne'; 22 TypeRelationMany = 'TypeRelationMany'; 23 CustomType = 'TypeCustom'; 24 Enumeration = 'Enumeration'; 25 EnumerationState = 'EnumerationState'; 26 TypeNumber = 'TypeNumber'; 27 TypeString = 'TypeString'; 18 28 19 29 type 20 TDbValueType = (vtNone, vtInteger, vtString, vtText, vtDateTime, vtFloat, vtImage, vtBoolean,21 vt IPv4, vtMAC, vtIPv6, vtFile, vtGPS, vtEnumeration, vtHyperlink, vtPassword,22 vt Reference, vtDate, vtTime, vtColor, vtCurrency);30 TDbValueType = (vtNone, vtInteger, vtString, vtText, vtDateTime, vtFloat, vtImage, 31 vtBoolean, vtIPv4, vtIPv6, vtMAC, vtFile, vtGPS, vtCurrency, vtEnumeration, 32 vtTime, vtDate, vtColor, vtHyperlink, vtRelationOne, vtRelationMany, vtPassword); 23 33 24 34 TChronisType = class; … … 90 100 function AddObject(Name, TableName, Schema: string; GroupId: Integer): Integer; 91 101 function AddProperty(ObjectId: Integer; Name, ColumnName: string; DataType: Integer): Integer; 102 function AddPropertyNumber(ObjectId: Integer; Name, 103 ColumnName: string; Default: Integer = 0; Min: Integer = 0; 104 Max: Integer = High(Integer)): Integer; 105 function AddPropertyString(ObjectId: Integer; Name, ColumnName: string; 106 Default: string = ''; MaxLength: Integer = 255): Integer; 92 107 function AddObjectGroup(Name: string): Integer; 108 function AddEnumeration(Name: string): Integer; 109 function AddEnumerationState(Enum: Integer; Name: string): Integer; 93 110 procedure LoadTypes; 94 111 constructor Create; 95 112 destructor Destroy; override; 113 private 96 114 end; 97 115 … … 99 117 100 118 implementation 119 120 resourcestring 121 SUnsupportedType = 'Unsupported property type "%s"'; 101 122 102 123 { TChronisTypeList } … … 159 180 NewColumn.TypeDef := Base.Types.FindByTypeIndex(Integer(vtInteger)); 160 181 for I := 0 to Properties.Count - 1 do 161 if Properties[I].Values['Type'] <> IntToStr( 20) then begin182 if Properties[I].Values['Type'] <> IntToStr(Integer(vtRelationMany)) then begin 162 183 NewColumn := TReportColumn.Create; 163 184 Columns.Add(NewColumn); … … 165 186 NewColumn.ColumnName := Properties[I].Values['ColumnName'];; 166 187 NewColumn.TypeDef := Base.Types.FindById(StrToInt(Properties[I].Values['Type'])); 188 if not Assigned(NewColumn.TypeDef) then 189 raise Exception.Create(Format(SUnsupportedType, [Properties[I].Values['Type']])); 167 190 end; 168 191 … … 181 204 NewItem.Id := StrToInt(Values[I].Values[Obj.PrimaryKey]); 182 205 for C := 0 to Properties.Count - 1 do 183 if Properties[C].Values['Type'] <> IntToStr( 20) then begin206 if Properties[C].Values['Type'] <> IntToStr(Integer(vtRelationMany)) then begin 184 207 NewItem.Items.Add(Values[I].Values[Properties[C].Values['ColumnName']]); 185 208 end; … … 244 267 Data.Add('Object', IntToStr(ObjectId)); 245 268 Data.Add('ColumnName', ColumnName); 246 Data.Add('Type', IntToStr(DataType)); 269 Data.Add('CustomType', IntToStr(DataType)); 270 Data.Add('Editable', '1'); 247 271 Database.Insert(PropertyTable, Data); 248 272 Result := Database.LastInsertId; … … 253 277 end; 254 278 279 function TChronisBase.AddPropertyNumber(ObjectId: Integer; Name, 280 ColumnName: string; Default: Integer = 0; Min: Integer = 0; 281 Max: Integer = High(Integer)): Integer; 282 var 283 DbRows: TDbRows; 284 Data: TDictionaryStringString; 285 CustomTypeId: Integer; 286 begin 287 try 288 DbRows := TDbRows.Create; 289 Data := TDictionaryStringString.Create; 290 291 Data.Clear; 292 Data.Add('Type', IntToStr(Integer(vtInteger))); 293 Database.Insert(CustomType, Data); 294 CustomTypeId := Database.LastInsertId; 295 296 Data.Clear; 297 Data.Add('CustomType', IntToStr(CustomTypeId)); 298 Data.Add('Min', IntToStr(Min)); 299 Data.Add('Max', IntToStr(Max)); 300 Data.Add('Default', IntToStr(Default)); 301 Database.Insert(TypeNumber, Data); 302 CustomTypeId := Database.LastInsertId; 303 304 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId); 305 finally 306 Data.Free; 307 DbRows.Free; 308 end; 309 end; 310 311 function TChronisBase.AddPropertyString(ObjectId: Integer; Name, 312 ColumnName: string; Default: string = ''; MaxLength: Integer = 255): Integer; 313 var 314 DbRows: TDbRows; 315 Data: TDictionaryStringString; 316 CustomTypeId: Integer; 317 begin 318 try 319 DbRows := TDbRows.Create; 320 Data := TDictionaryStringString.Create; 321 322 Data.Clear; 323 Data.Add('Type', IntToStr(Integer(vtString))); 324 Database.Insert(CustomType, Data); 325 CustomTypeId := Database.LastInsertId; 326 327 Data.Clear; 328 Data.Add('CustomType', IntToStr(CustomTypeId)); 329 Data.Add('MaxLength', IntToStr(MaxLength)); 330 Data.Add('Default', Default); 331 Database.Insert(TypeString, Data); 332 CustomTypeId := Database.LastInsertId; 333 334 Result := AddProperty(ObjectId, Name, ColumnName, CustomTypeId); 335 finally 336 Data.Free; 337 DbRows.Free; 338 end; 339 end; 340 255 341 function TChronisBase.AddObjectGroup(Name: string): Integer; 256 342 var … … 263 349 Data.Add('Name', Name); 264 350 Database.Insert(ObjectGroupTable, Data); 351 Result := Database.LastInsertId; 352 finally 353 Data.Free; 354 DbRows.Free; 355 end; 356 end; 357 358 function TChronisBase.AddEnumeration(Name: string): Integer; 359 var 360 DbRows: TDbRows; 361 Data: TDictionaryStringString; 362 begin 363 try 364 DbRows := TDbRows.Create; 365 Data := TDictionaryStringString.Create; 366 Data.Add('Name', Name); 367 Database.Insert(Enumeration, Data); 368 Result := Database.LastInsertId; 369 finally 370 Data.Free; 371 DbRows.Free; 372 end; 373 end; 374 375 function TChronisBase.AddEnumerationState(Enum: Integer; Name: string 376 ): Integer; 377 var 378 DbRows: TDbRows; 379 Data: TDictionaryStringString; 380 begin 381 try 382 DbRows := TDbRows.Create; 383 Data := TDictionaryStringString.Create; 384 Data.Add('Enumeration', IntToStr(Enum)); 385 Data.Add('Name', Name); 386 Database.Insert(EnumerationState, Data); 265 387 Result := Database.LastInsertId; 266 388 finally -
trunk/chronis.lpi
r12 r13 97 97 </Item4> 98 98 </RequiredPackages> 99 <Units Count="3 3">99 <Units Count="37"> 100 100 <Unit0> 101 101 <Filename Value="chronis.lpr"/> 102 102 <IsPartOfProject Value="True"/> 103 103 <UnitName Value="chronis"/> 104 <EditorIndex Value=" 8"/>104 <EditorIndex Value="12"/> 105 105 <WindowIndex Value="0"/> 106 106 <TopLine Value="14"/> … … 117 117 <TopLine Value="330"/> 118 118 <CursorPos X="1" Y="347"/> 119 <UsageCount Value="4 9"/>119 <UsageCount Value="45"/> 120 120 <DefaultSyntaxHighlighter Value="Delphi"/> 121 121 </Unit1> … … 129 129 <TopLine Value="118"/> 130 130 <CursorPos X="25" Y="144"/> 131 <UsageCount Value=" 103"/>131 <UsageCount Value="99"/> 132 132 <DefaultSyntaxHighlighter Value="Delphi"/> 133 133 </Unit2> … … 141 141 <TopLine Value="1"/> 142 142 <CursorPos X="24" Y="14"/> 143 <UsageCount Value=" 103"/>143 <UsageCount Value="99"/> 144 144 <DefaultSyntaxHighlighter Value="Delphi"/> 145 145 </Unit3> … … 148 148 <IsPartOfProject Value="True"/> 149 149 <UnitName Value="UPersistentForm"/> 150 <EditorIndex Value="1 0"/>150 <EditorIndex Value="14"/> 151 151 <WindowIndex Value="0"/> 152 152 <TopLine Value="55"/> … … 160 160 <IsPartOfProject Value="True"/> 161 161 <UnitName Value="USqlDatabase"/> 162 <EditorIndex Value=" 7"/>162 <EditorIndex Value="11"/> 163 163 <WindowIndex Value="0"/> 164 164 <TopLine Value="209"/> 165 <CursorPos X=" 36" Y="222"/>165 <CursorPos X="1" Y="221"/> 166 166 <UsageCount Value="264"/> 167 167 <Loaded Value="True"/> … … 172 172 <IsPartOfProject Value="True"/> 173 173 <UnitName Value="URegistry"/> 174 <EditorIndex Value=" 9"/>174 <EditorIndex Value="13"/> 175 175 <WindowIndex Value="0"/> 176 176 <TopLine Value="19"/> … … 188 188 <EditorIndex Value="0"/> 189 189 <WindowIndex Value="0"/> 190 <TopLine Value=" 95"/>191 <CursorPos X="1 9" Y="113"/>190 <TopLine Value="1"/> 191 <CursorPos X="15" Y="1"/> 192 192 <UsageCount Value="327"/> 193 193 <Loaded Value="True"/> … … 203 203 <EditorIndex Value="1"/> 204 204 <WindowIndex Value="0"/> 205 <TopLine Value="1 34"/>206 <CursorPos X=" 40" Y="141"/>205 <TopLine Value="129"/> 206 <CursorPos X="34" Y="133"/> 207 207 <UsageCount Value="318"/> 208 208 <Loaded Value="True"/> … … 217 217 <ResourceBaseClass Value="Form"/> 218 218 <UnitName Value="ULoginForm"/> 219 <EditorIndex Value="1 2"/>219 <EditorIndex Value="16"/> 220 220 <WindowIndex Value="0"/> 221 221 <TopLine Value="14"/> … … 235 235 <EditorIndex Value="2"/> 236 236 <WindowIndex Value="0"/> 237 <TopLine Value=" 148"/>238 <CursorPos X=" 40" Y="160"/>237 <TopLine Value="613"/> 238 <CursorPos X="1" Y="625"/> 239 239 <UsageCount Value="317"/> 240 240 <Loaded Value="True"/> … … 255 255 <ResourceBaseClass Value="Form"/> 256 256 <UnitName Value="UItemAdd"/> 257 <EditorIndex Value="1 1"/>257 <EditorIndex Value="15"/> 258 258 <WindowIndex Value="0"/> 259 259 <TopLine Value="85"/> … … 269 269 <TopLine Value="963"/> 270 270 <CursorPos X="3" Y="974"/> 271 <UsageCount Value=" 8"/>271 <UsageCount Value="4"/> 272 272 <DefaultSyntaxHighlighter Value="Delphi"/> 273 273 </Unit13> … … 277 277 <TopLine Value="43"/> 278 278 <CursorPos X="1" Y="60"/> 279 <UsageCount Value="1 5"/>279 <UsageCount Value="11"/> 280 280 </Unit14> 281 281 <Unit15> … … 284 284 <TopLine Value="68"/> 285 285 <CursorPos X="1" Y="85"/> 286 <UsageCount Value=" 12"/>286 <UsageCount Value="8"/> 287 287 </Unit15> 288 288 <Unit16> … … 292 292 <TopLine Value="593"/> 293 293 <CursorPos X="15" Y="606"/> 294 <UsageCount Value=" 7"/>294 <UsageCount Value="3"/> 295 295 </Unit16> 296 296 <Unit17> … … 299 299 <TopLine Value="2104"/> 300 300 <CursorPos X="3" Y="2109"/> 301 <UsageCount Value=" 7"/>301 <UsageCount Value="3"/> 302 302 </Unit17> 303 303 <Unit18> … … 307 307 <TopLine Value="1"/> 308 308 <CursorPos X="6" Y="1"/> 309 <UsageCount Value="1 8"/>309 <UsageCount Value="14"/> 310 310 <DefaultSyntaxHighlighter Value="Delphi"/> 311 311 </Unit18> … … 315 315 <TopLine Value="1"/> 316 316 <CursorPos X="3" Y="21"/> 317 <UsageCount Value="1 8"/>317 <UsageCount Value="14"/> 318 318 <DefaultSyntaxHighlighter Value="Delphi"/> 319 319 </Unit19> … … 322 322 <IsPartOfProject Value="True"/> 323 323 <UnitName Value="USystem"/> 324 <EditorIndex Value="6"/> 325 <WindowIndex Value="0"/> 326 <TopLine Value="272"/> 327 <CursorPos X="27" Y="286"/> 328 <UsageCount Value="44"/> 324 <IsVisibleTab Value="True"/> 325 <EditorIndex Value="10"/> 326 <WindowIndex Value="0"/> 327 <TopLine Value="185"/> 328 <CursorPos X="33" Y="176"/> 329 <UsageCount Value="83"/> 329 330 <Loaded Value="True"/> 330 331 <DefaultSyntaxHighlighter Value="Delphi"/> … … 336 337 <TopLine Value="912"/> 337 338 <CursorPos X="14" Y="929"/> 338 <UsageCount Value="1 5"/>339 <UsageCount Value="11"/> 339 340 </Unit21> 340 341 <Unit22> … … 343 344 <TopLine Value="1"/> 344 345 <CursorPos X="15" Y="18"/> 345 <UsageCount Value=" 13"/>346 <UsageCount Value="9"/> 346 347 </Unit22> 347 348 <Unit23> … … 350 351 <TopLine Value="1"/> 351 352 <CursorPos X="11" Y="30"/> 352 <UsageCount Value=" 10"/>353 <UsageCount Value="6"/> 353 354 <DefaultSyntaxHighlighter Value="Delphi"/> 354 355 </Unit23> … … 359 360 <ResourceBaseClass Value="DataModule"/> 360 361 <UnitName Value="UCore"/> 361 <EditorIndex Value=" 5"/>362 <EditorIndex Value="9"/> 362 363 <WindowIndex Value="0"/> 363 364 <TopLine Value="3"/> 364 365 <CursorPos X="32" Y="17"/> 365 <UsageCount Value=" 28"/>366 <UsageCount Value="67"/> 366 367 <Loaded Value="True"/> 367 368 <LoadedDesigner Value="True"/> … … 374 375 <ResourceBaseClass Value="Form"/> 375 376 <UnitName Value="USettingForm"/> 376 <IsVisibleTab Value="True"/> 377 <EditorIndex Value="4"/> 378 <WindowIndex Value="0"/> 379 <TopLine Value="1"/> 380 <CursorPos X="29" Y="9"/> 381 <UsageCount Value="27"/> 377 <EditorIndex Value="8"/> 378 <WindowIndex Value="0"/> 379 <TopLine Value="40"/> 380 <CursorPos X="45" Y="15"/> 381 <UsageCount Value="66"/> 382 382 <Loaded Value="True"/> 383 383 <LoadedDesigner Value="True"/> … … 388 388 <IsPartOfProject Value="True"/> 389 389 <UnitName Value="UApplicationInfo"/> 390 <EditorIndex Value=" 3"/>390 <EditorIndex Value="7"/> 391 391 <WindowIndex Value="0"/> 392 392 <TopLine Value="37"/> 393 393 <CursorPos X="48" Y="56"/> 394 <UsageCount Value=" 27"/>394 <UsageCount Value="66"/> 395 395 <Loaded Value="True"/> 396 396 <DefaultSyntaxHighlighter Value="Delphi"/> … … 402 402 <TopLine Value="97"/> 403 403 <CursorPos X="26" Y="109"/> 404 <UsageCount Value=" 13"/>404 <UsageCount Value="9"/> 405 405 </Unit27> 406 406 <Unit28> … … 409 409 <TopLine Value="16"/> 410 410 <CursorPos X="14" Y="58"/> 411 <UsageCount Value=" 13"/>411 <UsageCount Value="9"/> 412 412 </Unit28> 413 413 <Unit29> … … 416 416 <TopLine Value="87"/> 417 417 <CursorPos X="6" Y="103"/> 418 <UsageCount Value=" 13"/>418 <UsageCount Value="9"/> 419 419 </Unit29> 420 420 <Unit30> … … 423 423 <TopLine Value="372"/> 424 424 <CursorPos X="7" Y="384"/> 425 <UsageCount Value=" 10"/>425 <UsageCount Value="6"/> 426 426 </Unit30> 427 427 <Unit31> … … 430 430 <TopLine Value="82"/> 431 431 <CursorPos X="40" Y="94"/> 432 <UsageCount Value=" 10"/>432 <UsageCount Value="6"/> 433 433 </Unit31> 434 434 <Unit32> … … 438 438 <TopLine Value="301"/> 439 439 <CursorPos X="3" Y="305"/> 440 <UsageCount Value=" 10"/>440 <UsageCount Value="6"/> 441 441 </Unit32> 442 <Unit33> 443 <Filename Value="H:/Lazarus/0.9.31_2.5.1/lcl/dialogs.pp"/> 444 <UnitName Value="Dialogs"/> 445 <EditorIndex Value="6"/> 446 <WindowIndex Value="0"/> 447 <TopLine Value="487"/> 448 <CursorPos X="44" Y="500"/> 449 <UsageCount Value="29"/> 450 <Loaded Value="True"/> 451 </Unit33> 452 <Unit34> 453 <Filename Value="H:/Lazarus/0.9.31_2.5.1/lcl/controls.pp"/> 454 <UnitName Value="Controls"/> 455 <EditorIndex Value="5"/> 456 <WindowIndex Value="0"/> 457 <TopLine Value="44"/> 458 <CursorPos X="3" Y="56"/> 459 <UsageCount Value="29"/> 460 <Loaded Value="True"/> 461 </Unit34> 462 <Unit35> 463 <Filename Value="H:/PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericDictionary.inc"/> 464 <EditorIndex Value="4"/> 465 <WindowIndex Value="0"/> 466 <TopLine Value="1"/> 467 <CursorPos X="24" Y="11"/> 468 <UsageCount Value="11"/> 469 <Loaded Value="True"/> 470 </Unit35> 471 <Unit36> 472 <Filename Value="H:/PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 473 <EditorIndex Value="3"/> 474 <WindowIndex Value="0"/> 475 <TopLine Value="120"/> 476 <CursorPos X="1" Y="132"/> 477 <UsageCount Value="11"/> 478 <Loaded Value="True"/> 479 </Unit36> 442 480 </Units> 443 481 <JumpHistory Count="30" HistoryIndex="29"> 444 482 <Position1> 445 483 <Filename Value="USystem.pas"/> 446 <Caret Line=" 256" Column="10" TopLine="236"/>484 <Caret Line="101" Column="25" TopLine="92"/> 447 485 </Position1> 448 486 <Position2> 449 487 <Filename Value="USystem.pas"/> 450 <Caret Line="2 57" Column="11" TopLine="236"/>488 <Caret Line="274" Column="34" TopLine="274"/> 451 489 </Position2> 452 490 <Position3> 453 491 <Filename Value="USystem.pas"/> 454 <Caret Line=" 259" Column="10" TopLine="236"/>492 <Caret Line="102" Column="27" TopLine="100"/> 455 493 </Position3> 456 494 <Position4> 457 495 <Filename Value="USystem.pas"/> 458 <Caret Line="2 60" Column="12" TopLine="248"/>496 <Caret Line="291" Column="24" TopLine="277"/> 459 497 </Position4> 460 498 <Position5> 461 <Filename Value="Forms/U ItemEdit.pas"/>462 <Caret Line=" 92" Column="13" TopLine="89"/>499 <Filename Value="Forms/UMainForm.pas"/> 500 <Caret Line="389" Column="15" TopLine="375"/> 463 501 </Position5> 464 502 <Position6> 465 503 <Filename Value="USystem.pas"/> 466 <Caret Line=" 138" Column="36" TopLine="126"/>504 <Caret Line="316" Column="3" TopLine="318"/> 467 505 </Position6> 468 506 <Position7> 469 507 <Filename Value="USystem.pas"/> 470 <Caret Line=" 92" Column="14" TopLine="69"/>508 <Caret Line="31" Column="41" TopLine="20"/> 471 509 </Position7> 472 510 <Position8> 473 511 <Filename Value="USystem.pas"/> 474 <Caret Line=" 81" Column="50" TopLine="68"/>512 <Caret Line="290" Column="50" TopLine="278"/> 475 513 </Position8> 476 514 <Position9> 477 <Filename Value=" USystem.pas"/>478 <Caret Line="1 09" Column="37" TopLine="104"/>515 <Filename Value="Forms/UItemEdit.pas"/> 516 <Caret Line="141" Column="40" TopLine="134"/> 479 517 </Position9> 480 518 <Position10> 481 <Filename Value=" USystem.pas"/>482 <Caret Line="1 10" Column="6" TopLine="103"/>519 <Filename Value="Forms/UItemEdit.pas"/> 520 <Caret Line="133" Column="34" TopLine="129"/> 483 521 </Position10> 484 522 <Position11> 485 <Filename Value="Forms/U ItemEdit.pas"/>486 <Caret Line=" 92" Column="11" TopLine="89"/>523 <Filename Value="Forms/UMainForm.pas"/> 524 <Caret Line="374" Column="49" TopLine="357"/> 487 525 </Position11> 488 526 <Position12> 489 <Filename Value=" USystem.pas"/>490 <Caret Line=" 150" Column="20" TopLine="137"/>527 <Filename Value="Common/USqlDatabase.pas"/> 528 <Caret Line="221" Column="1" TopLine="209"/> 491 529 </Position12> 492 530 <Position13> 493 <Filename Value=" USystem.pas"/>494 <Caret Line=" 149" Column="23" TopLine="137"/>531 <Filename Value="Forms/UMainForm.pas"/> 532 <Caret Line="388" Column="16" TopLine="375"/> 495 533 </Position13> 496 534 <Position14> 497 535 <Filename Value="USystem.pas"/> 498 <Caret Line=" 37" Column="1" TopLine="27"/>536 <Caret Line="104" Column="53" TopLine="92"/> 499 537 </Position14> 500 538 <Position15> 501 539 <Filename Value="USystem.pas"/> 502 <Caret Line=" 149" Column="35" TopLine="137"/>540 <Caret Line="309" Column="69" TopLine="308"/> 503 541 </Position15> 504 542 <Position16> 505 543 <Filename Value="USystem.pas"/> 506 <Caret Line=" 81" Column="29" TopLine="74"/>544 <Caret Line="102" Column="27" TopLine="91"/> 507 545 </Position16> 508 546 <Position17> 509 <Filename Value="Forms/U ItemView.pas"/>510 <Caret Line=" 110" Column="44" TopLine="98"/>547 <Filename Value="Forms/UMainForm.pas"/> 548 <Caret Line="412" Column="50" TopLine="396"/> 511 549 </Position17> 512 550 <Position18> 513 <Filename Value=" Forms/UItemView.pas"/>514 <Caret Line=" 112" Column="39" TopLine="98"/>551 <Filename Value="Common/USqlDatabase.pas"/> 552 <Caret Line="221" Column="1" TopLine="209"/> 515 553 </Position18> 516 554 <Position19> 517 <Filename Value="U Core.pas"/>518 <Caret Line=" 13" Column="32" TopLine="3"/>555 <Filename Value="USystem.pas"/> 556 <Caret Line="322" Column="1" TopLine="312"/> 519 557 </Position19> 520 558 <Position20> 521 <Filename Value=" Forms/UMainForm.pas"/>522 <Caret Line=" 323" Column="8" TopLine="309"/>559 <Filename Value="Common/USqlDatabase.pas"/> 560 <Caret Line="221" Column="1" TopLine="209"/> 523 561 </Position20> 524 562 <Position21> 525 <Filename Value=" Forms/UMainForm.pas"/>526 <Caret Line=" 124" Column="8" TopLine="108"/>563 <Filename Value="USystem.pas"/> 564 <Caret Line="300" Column="27" TopLine="300"/> 527 565 </Position21> 528 566 <Position22> 529 567 <Filename Value="Forms/UMainForm.pas"/> 530 <Caret Line="3 24" Column="32" TopLine="312"/>568 <Caret Line="353" Column="34" TopLine="337"/> 531 569 </Position22> 532 570 <Position23> 533 <Filename Value=" Forms/USettingForm.pas"/>534 <Caret Line=" 3" Column="42" TopLine="10"/>571 <Filename Value="Common/USqlDatabase.pas"/> 572 <Caret Line="221" Column="1" TopLine="209"/> 535 573 </Position23> 536 574 <Position24> 537 <Filename Value="Forms/U SettingForm.pas"/>538 <Caret Line=" 22" Column="17" TopLine="10"/>575 <Filename Value="Forms/UMainForm.pas"/> 576 <Caret Line="353" Column="39" TopLine="337"/> 539 577 </Position24> 540 578 <Position25> 541 <Filename Value=" Forms/USettingForm.pas"/>542 <Caret Line="2 4" Column="20" TopLine="7"/>579 <Filename Value="Common/USqlDatabase.pas"/> 580 <Caret Line="221" Column="1" TopLine="209"/> 543 581 </Position25> 544 582 <Position26> 545 <Filename Value=" Forms/USettingForm.pas"/>546 <Caret Line=" 44" Column="12" TopLine="31"/>583 <Filename Value="USystem.pas"/> 584 <Caret Line="334" Column="20" TopLine="319"/> 547 585 </Position26> 548 586 <Position27> 549 <Filename Value=" Forms/USettingForm.pas"/>550 <Caret Line="4 6" Column="1" TopLine="23"/>587 <Filename Value="USystem.pas"/> 588 <Caret Line="409" Column="37" TopLine="391"/> 551 589 </Position27> 552 590 <Position28> 553 <Filename Value=" Forms/USettingForm.pas"/>554 <Caret Line=" 53" Column="34" TopLine="34"/>591 <Filename Value="H:/PascalClassLibrary/Generics/TemplateGenerics/Generic/GenericList.inc"/> 592 <Caret Line="132" Column="1" TopLine="120"/> 555 593 </Position28> 556 594 <Position29> 557 <Filename Value="Forms/U SettingForm.pas"/>558 <Caret Line=" 47" Column="8" TopLine="35"/>595 <Filename Value="Forms/UMainForm.pas"/> 596 <Caret Line="684" Column="1" TopLine="672"/> 559 597 </Position29> 560 598 <Position30> 561 <Filename Value="Forms/U SettingForm.pas"/>562 <Caret Line=" 59" Column="13" TopLine="47"/>599 <Filename Value="Forms/UMainForm.pas"/> 600 <Caret Line="625" Column="1" TopLine="613"/> 563 601 </Position30> 564 602 </JumpHistory>
Note:
See TracChangeset
for help on using the changeset viewer.