Changeset 6 for trunk


Ignore:
Timestamp:
Jan 20, 2015, 12:31:24 AM (10 years ago)
Author:
chronos
Message:
  • Added: Allow to create multiple database connections and set their parmaters.
  • Added: Defined database engines to support various database backends. Each supports different set of field data types.
Location:
trunk
Files:
11 added
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormRecord.lfm

    r5 r6  
    1919    Align = alTop
    2020    BorderSpacing.Around = 4
     21    BevelOuter = bvNone
    2122    TabOrder = 0
    2223  end
  • trunk/Forms/UFormTables.lfm

    r4 r6  
    1 object FormMain: TFormMain
    2   Left = 644
     1object FormTables: TFormTables
     2  Left = 659
    33  Height = 660
    4   Top = 420
     4  Top = 342
    55  Width = 978
    6   Caption = 'MyData'
     6  Caption = 'Tables'
    77  ClientHeight = 660
    88  ClientWidth = 978
  • trunk/Forms/UFormTables.pas

    r4 r6  
    1111type
    1212
    13   { TFormMain }
     13  { TFormTables }
    1414
    15   TFormMain = class(TForm)
     15  TFormTables = class(TForm)
    1616    AAdd: TAction;
    1717    AShowFields: TAction;
     
    5353
    5454var
    55   FormMain: TFormMain;
     55  FormTables: TFormTables;
    5656
    5757implementation
     
    6262{$R *.lfm}
    6363
    64 { TFormMain }
     64{ TFormTables }
    6565
    66 procedure TFormMain.ListView1Data(Sender: TObject; Item: TListItem);
     66procedure TFormTables.ListView1Data(Sender: TObject; Item: TListItem);
    6767begin
    6868  if (Item.Index >= 0) and (Item.Index < Database.Tables.Count) then
     
    7474end;
    7575
    76 procedure TFormMain.ListView1SelectItem(Sender: TObject; Item: TListItem;
     76procedure TFormTables.ListView1SelectItem(Sender: TObject; Item: TListItem;
    7777  Selected: Boolean);
    7878begin
     
    8080end;
    8181
    82 procedure TFormMain.UpdateInterface;
     82procedure TFormTables.UpdateInterface;
    8383begin
    8484  AModify.Enabled := Assigned(ListView1.Selected);
     
    8888end;
    8989
    90 procedure TFormMain.AAddExecute(Sender: TObject);
     90procedure TFormTables.AAddExecute(Sender: TObject);
    9191var
    9292  NewTable: TTable;
     
    102102end;
    103103
    104 procedure TFormMain.AModifyExecute(Sender: TObject);
     104procedure TFormTables.AModifyExecute(Sender: TObject);
    105105begin
    106106  if Assigned(ListView1.Selected) then begin
     
    113113end;
    114114
    115 procedure TFormMain.ARemoveExecute(Sender: TObject);
     115procedure TFormTables.ARemoveExecute(Sender: TObject);
    116116begin
    117117  if Assigned(ListView1.Selected) then begin
     
    124124end;
    125125
    126 procedure TFormMain.AShowFieldsExecute(Sender: TObject);
     126procedure TFormTables.AShowFieldsExecute(Sender: TObject);
    127127var
    128128  NewRecords: TRecords;
     
    166166end;
    167167
    168 procedure TFormMain.AShowRecordsExecute(Sender: TObject);
     168procedure TFormTables.AShowRecordsExecute(Sender: TObject);
    169169begin
    170170  if Assigned(ListView1.Selected) then begin
     
    175175end;
    176176
    177 procedure TFormMain.FormActivate(Sender: TObject);
     177procedure TFormTables.FormActivate(Sender: TObject);
    178178begin
    179   Core.Init;
    180179end;
    181180
    182 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
     181procedure TFormTables.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    183182begin
    184   Core.Done;
     183  Database.Save;
    185184end;
    186185
    187 procedure TFormMain.FormShow(Sender: TObject);
     186procedure TFormTables.FormShow(Sender: TObject);
    188187begin
    189   Database := Core.Database;
    190188  ReloadList;
    191189end;
    192190
    193 procedure TFormMain.ReloadList;
     191procedure TFormTables.ReloadList;
    194192begin
    195193  ListView1.Items.Count := Database.Tables.Count;
    196194  ListView1.Repaint;
    197   FormMain.UpdateInterface;
     195  UpdateInterface;
    198196end;
    199197
  • trunk/MyData.lpi

    r4 r6  
    7878      </Item3>
    7979    </RequiredPackages>
    80     <Units Count="11">
     80    <Units Count="16">
    8181      <Unit0>
    8282        <Filename Value="MyData.lpr"/>
     
    8686        <Filename Value="Forms/UFormTables.pas"/>
    8787        <IsPartOfProject Value="True"/>
    88         <ComponentName Value="FormMain"/>
     88        <ComponentName Value="FormTables"/>
    8989        <HasResources Value="True"/>
    9090        <ResourceBaseClass Value="Form"/>
     
    105105      </Unit3>
    106106      <Unit4>
    107         <Filename Value="UDatabaseXML.pas"/>
    108         <IsPartOfProject Value="True"/>
    109         <UnitName Value="UDatabaseXML"/>
     107        <Filename Value="DbEngines/UEngineXML.pas"/>
     108        <IsPartOfProject Value="True"/>
     109        <UnitName Value="UEngineXML"/>
    110110      </Unit4>
    111111      <Unit5>
     
    154154        <UnitName Value="UDataTypes"/>
    155155      </Unit10>
     156      <Unit11>
     157        <Filename Value="DbEngines/UEngineMySQL.pas"/>
     158        <IsPartOfProject Value="True"/>
     159        <UnitName Value="UEngineMySQL"/>
     160      </Unit11>
     161      <Unit12>
     162        <Filename Value="DbEngines/UEngineSQLite.pas"/>
     163        <IsPartOfProject Value="True"/>
     164        <UnitName Value="UEngineSQLite"/>
     165      </Unit12>
     166      <Unit13>
     167        <Filename Value="Forms/UFormMain.pas"/>
     168        <IsPartOfProject Value="True"/>
     169        <ComponentName Value="FormMain"/>
     170        <ResourceBaseClass Value="Form"/>
     171        <UnitName Value="UFormMain"/>
     172      </Unit13>
     173      <Unit14>
     174        <Filename Value="Forms/UFormConnect.pas"/>
     175        <IsPartOfProject Value="True"/>
     176        <ComponentName Value="FormConnect"/>
     177        <ResourceBaseClass Value="Form"/>
     178        <UnitName Value="UFormConnect"/>
     179      </Unit14>
     180      <Unit15>
     181        <Filename Value="Forms/UFormDatabases.pas"/>
     182        <IsPartOfProject Value="True"/>
     183        <ComponentName Value="FormDatabases"/>
     184        <ResourceBaseClass Value="Form"/>
     185        <UnitName Value="UFormDatabases"/>
     186      </Unit15>
    156187    </Units>
    157188  </ProjectOptions>
     
    163194    <SearchPaths>
    164195      <IncludeFiles Value="$(ProjOutDir)"/>
    165       <OtherUnitFiles Value="Forms"/>
     196      <OtherUnitFiles Value="Forms;DbEngines"/>
    166197      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
    167198    </SearchPaths>
  • trunk/MyData.lpr

    r4 r6  
    88  {$ENDIF}{$ENDIF}
    99  Interfaces, // this includes the LCL widgetset
    10   Forms, UFormTables, UDatabase, UCore, Common, UDatabaseXML, UFormTable,
    11 UFormRecords, UFormRecord, UFormFields, UFormField, UDataTypes
    12   { you can add units after this };
     10  Forms, UFormTables, UDatabase, UCore, Common, UEngineXML, UFormTable,
     11  UFormRecords, UFormRecord, UFormFields, UFormField, UDataTypes, UEngineMySQL,
     12  UEngineSQLite, UFormMain, UFormConnect, UFormDatabases;
    1313
    1414{$R *.res}
     
    1919  Application.CreateForm(TCore, Core);
    2020  Application.CreateForm(TFormMain, FormMain);
     21  Application.CreateForm(TFormTables, FormTables);
    2122  Application.CreateForm(TFormTable, FormTable);
    2223  Application.CreateForm(TFormRecords, FormRecords);
     
    2425  Application.CreateForm(TFormFields, FormFields);
    2526  Application.CreateForm(TFormField, FormField);
     27  Application.CreateForm(TFormConnect, FormConnect);
     28  Application.CreateForm(TFormDatabases, FormDatabases);
    2629  Application.Run;
    2730end.
  • trunk/UCore.lfm

    r4 r6  
    1313    top = 136
    1414    Bitmap = {
    15       4C6908000000200000002000000061C66E0061C66E0061C66E0061C66E0061C6
     15      4C6909000000200000002000000061C66E0061C66E0061C66E0061C66E0061C6
    1616      6E0061C66E0061C66E0061C66E0061C66E0061C66E0061C56E0048B05E0947AF
    1717      5D4E47AE5C7946AD5B9A47AD5BB046AC5AB045AA589A44A9577944A7564E43A6
     
    10371037      FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FDFDFDFFFDFDFDFFFDFDFDFFFFFF
    10381038      FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FDFDFDFFFDFD
    1039       FDFFFDFDFDFFFFFFFF00FFFFFF00
     1039      FDFFFDFDFDFFFFFFFF00FFFFFF0000000000000000000000000000000001A099
     1040      8F37A69F9385A9A196D2A9A195E2AAA296FFAAA296FFAAA296FFAAA296FFAAA2
     1041      96FFAAA296FFAAA296FFAAA296FFAAA296FFAAA296FFA9A195E2A9A196D2A69F
     1042      9385A0998F370000000100000000000000000000000000000000000000000000
     1043      00000000000000000000000000000000000000000003A79F9489AAA396FFB7AE
     1044      A3FFC8BFB4FFD9D1C6FFDDD5CAFFF1E9DFFFF0E8DEFFF0E8DEFFF0E8DEFFF0E8
     1045      DEFFF0E8DEFFF0E8DEFFF0E8DEFFF0E8DEFFF1E9DFFFDDD5CAFFD9D1C6FFC8BF
     1046      B4FFB7AEA3FFAAA296FFA79F9489000000030000000000000000000000000000
     1047      000000000000000000000000000000000004A69E93B2B5ADA1FFDED5CBFFE9E1
     1048      D7FFE7DFD5FFE6DED4FFE5DDD3FFE5DDD3FFE4DCD2FFE4DCD2FFE4DCD2FFE4DC
     1049      D2FFE4DCD2FFE4DCD2FFE4DCD2FFE4DCD2FFE5DDD3FFE5DDD3FFE6DED4FFE7DF
     1050      D5FFE9E1D7FFE2DAD0FFB5ADA1FFA69E93B20000000400000000000000000000
     1051      00000000000000000000000000000000000DA9A296FFE0D6CDFFE0D6CCFFDED5
     1052      CBFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4
     1053      CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4CAFFDDD4
     1054      CAFFDED5CBFFDFD6CCFFE0D6CDFFA9A296FF0000000D00000000000000000000
     1055      000000000000000000000000000000000015A69F93FFECE5DDFFD5CCC2FFD5CC
     1056      C2FFD6CDC3FFD7CEC3FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CE
     1057      C4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC4FFD7CEC3FFD6CD
     1058      C3FFD5CCC2FFD5CCC2FFECE5DDFFA69F93FF0000001500000000000000000000
     1059      000000000000000000000000000000000016A69E93FFFFFCF5FFEAE3DBFFD3C9
     1060      C0FFCDC3B9FFCEC5BAFFCEC5BBFFCFC6BBFFCFC6BCFFCFC6BCFFCFC6BCFFCFC6
     1061      BCFFCFC6BCFFCFC6BCFFCFC6BCFFCFC6BCFFCFC6BBFFCEC5BBFFCEC5BAFFCDC3
     1062      B9FFD3C9C0FFEAE3DBFFFFFCF5FFABA499FF0000001600000000000000000000
     1063      000000000000000000000000000000000016A69F93FFCFC8BFFFF8F4ECFFFFFA
     1064      F4FFF8F2EBFFE9E2DAFFE3DAD3FFD7CFC6FFD4CBC2FFD4CBC2FFD4CBC2FFD4CB
     1065      C2FFD4CBC2FFD4CBC2FFD4CBC2FFD4CBC2FFD7CFC6FFE3DAD3FFE9E2DAFFF8F2
     1066      EBFFFFFAF4FFF4F0E8FFCFC8BFFFA69F93FF0000001600000000000000000000
     1067      000000000000000000000000000000000016A7A093FFC7BEB6FFC6BFB4FFD2CB
     1068      C2FFE2DBD3FFF0EAE2FFF3EEE7FFFDFAF3FFFDF9F2FFFDF8F2FFFCF8F1FFFCF8
     1069      F1FFFCF8F1FFFCF8F1FFFDF8F2FFFDF9F2FFFDF9F3FFF3EEE7FFEFEAE2FFE2DC
     1070      D3FFD3CCC3FFC7BFB6FFC8BFB7FFA7A093FF0000001600000000000000000000
     1071      000000000000000000000000000000000016A69F94FFC8C0B8FFC9C2B8FFCCC3
     1072      BAFFCEC6BDFFD2C8BFFFD5CBC3FFD9CEC6FFDCD2CAFFE0D6CEFFE3D9D2FFE8DD
     1073      D6FFEADED7FFE5DAD3FFE1D7CFFFDDD4CCFFDACFC7FFD6CCC4FFD3C9C0FFCFC7
     1074      BEFFCDC4BBFFCAC2B9FFCAC1B9FFA69F94FF0000001600000000000000000000
     1075      000000000000000000000000000000000016A59E93FFC9C1B9FFCAC3B9FFCDC5
     1076      BCFFD0C8BFFFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFE9DE
     1077      D7FFEADFD8FFE6DCD5FFE3D9D1FFDFD6CEFFDCD2CAFFD8CFC7FFD5CCC3FFD1C9
     1078      C0FFCEC6BDFFCBC3BAFFCBC3BAFFA69F93FF0000001600000000000000000000
     1079      000000000000000000000000000000000014918B80B8B6AEA4FFCBC4BAFFCEC6
     1080      BDFFD1C9C0FFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFE9DE
     1081      D7FFEBDFD8FFE6DCD5FFE3D9D1FFDFD6CEFFDCD2CAFFD8CFC7FFD5CCC3FFD1C9
     1082      C0FFCFC7BEFFCDC5BCFFBFB7ADFF928C80B40000001400000000000000000000
     1083      000000000000000000000000000000000010928C82B5B4ACA3FFB5ADA2FFC9C1
     1084      B8FFD3CBC2FFD6CDC4FFD9D0C8FFDDD3CBFFDFD6CFFFE3D9D1FFE6DCD5FFEADF
     1085      D8FFECE0D9FFE7DDD6FFE4DAD2FFE0D7D0FFDDD4CCFFDAD1CAFFD7CEC5FFD3CC
     1086      C2FFD3CBC1FFC6BDB3FF7A7B7DFF7F8081FF0000001200000000000000000000
     1087      000000000000000000000000000000000010A29A8FFFF1EBE4FFB7AFA6FFA59C
     1088      91FFABA298FFBBB2A9FFC5BAB1FFD1C8BFFFD5CBC2FFE1D7CFFFE8DED7FFECE1
     1089      DAFFEEE2DBFFE9DFD8FFE6DDD5FFD9D1CBFFD2CDC7FFCFC8C4FFBFB7B0FFB8AE
     1090      A5FFB3A99FFF787A7BFFC4C2C0FFB4B2AFFF777777FF00000006000000000000
     1091      000000000000000000000000000000000014A09A8EFFD3CBC3FFF6F1EAFFEFE9
     1092      E3FFDAD5CDFFCAC2BAFFBCB3ABFFB4ABA1FFB4AAA1FFB6ACA3FFB8AEA6FFBAB0
     1093      A6FFBBB0A8FFB9AEA6FFB8AEA8FFB8B2AFFFB3772CFFB3772CFFCECCC9FFE4DF
     1094      D9FF78797BFFC2C1BFFFAFADABFFA19E9CFF777778FF00000011000000000000
     1095      000000000000000000000000000000000016A09A8FFFC8C0B7FFC7C0B6FFD4CD
     1096      C4FFE4DDD6FFF2EDE5FFF6F1EAFFFFFCF5FFFFFBF4FFFFFBF4FFFEFAF3FFFDFA
     1097      F3FFFDFAF3FFFFFBF5FFFFFFFFFFB1752BFFFFEECCFFFFEAC7FFB4782EFF737B
     1098      83FFC1C1C2FFAFADABFF9F9B9AFF737375FF0000003700000011000000000000
     1099      000000000000000000000000000000000016A09A8EFFC9C1B8FFC9C2B8FFCCC4
     1100      BBFFCEC6BDFFD2C9C0FFD5CCC4FFD9CFC7FFDCD3CBFFE1D6CEFFE4D9D2FFE9DD
     1101      D6FFEADFD8FFE6DEDAFFE5E1E0FFAF762EFFFFD699FFFFD093FFFBDAB3FFB77A
     1102      31FFAAAEB3FF9C9B9CFF6E7073FFA8A094FF0000002200000006000000000000
     1103      000000000000000000000000000000000016A0998FFFCAC2B9FFCAC3B9FFCDC5
     1104      BCFFD0C8BFFFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFE9DE
     1105      D8FFECE2DDFFE9E3E3FFAD7229FFFFECC8FFAB7431FFFFD296FFFFCC8CFFF6D4
     1106      A8FFB87C33FF686F78FFD3CCC4FFA39C92FF0000001600000000000000068888
     1107      88FF8A8A8AFF0000000600000000000000148B867CB8B7AFA4FFCBC5BAFFCEC6
     1108      BDFFD1C9C0FFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFEADF
     1109      D9FFEDE5E3FFAF7329FFFFE3BAFFFFCD8FFFFFE9CBFFAA7431FFFFCF90FFFDC8
     1110      86FFF2CC9DFFB87C34FFBEBBB9FF8B877FB60000001400000006858686FFC6C3
     1111      C1FFB4B2B0FF777778FF00000006000000108D877DB5B5ACA4FFB5ADA2FFC9C1
     1112      B8FFD3CBC2FFD6CDC4FFD9D0C8FFDDD3CBFFDFD6CEFFE3D9D1FFE6DCD5FFEBE0
     1113      DAFFEFE7E6FFB0762EFFFFDCAEFFFCC887FFFCC988FFFFE5C0FFAB7533FFFECB
     1114      8BFFFBC580FFEBC390FFB77C35FF888883AD00000015858586FFC4C2C0FFB0AE
     1115      ABFFA29E9CFF787878FF00000011000000109B958BFFF2ECE4FFB8AFA6FFA59C
     1116      91FFABA298FFBBB2A9FFC5BAB1FFD1C8BFFFD5CBC2FFE5DBD3FFE8DED7FFEDE3
     1117      DDFFF0EAE8FFB07730FFFED6A2FFF8C481FFF7C482FFF9C582FFFFDFB5FFAC76
     1118      35FFFBC885FFF7C079FFEFC48DFFBA7F37FF7F868FFFC3C3C4FFAFAEACFFA09D
     1119      9BFF767676FF0000003700000011000000149A958AFFD3CCC3FFF6F1EAFFEFE9
     1120      E3FFDAD5CDFFCAC2BAFFBCB3ABFFB4ABA1FFB4AAA1FFB6ACA2FFB8AEA6FFBBB1
     1121      A8FFBEB6B4FFB17832FFFCCF96FFF6C17DFFF5C17EFFF5C17DFFF7C27DFFFDD8
     1122      A9FFAC7737FFF9C37EFFF4BD72FFDCAF74FFB97F37FFABB0B6FF9E9D9EFF7576
     1123      78FF0000003D0000001C00000006000000169A9589FFC8C0B7FFC7C0B6FFD4CD
     1124      C4FFE4DDD6FFF2EDE5FFF6F1EAFFFFFCF5FFFFFBF4FFFFFBF4FFFEFAF3FFFEFB
     1125      F5FFFFFFFFFFB07731FFFAC888FFF4BE79FFF3BE79FFF3BE79FFF3BE79FFF5BF
     1126      79FFFBD19CFFAD7939FFF7C078FFF3BA6DFFD29E57DFBB813AFF6D7580FF0000
     1127      003D0000001C0000000600000000000000169A948AFFC9C1B8FFC9C2B8FFCCC4
     1128      BBFFCEC6BDFFD2C9C0FFD5CCC4FFD9CFC7FFDCD3CBFFE1D6CEFFE4D9D2FFE9DE
     1129      D9FFEEE7E6FFB17832FFF6C27BFFF1BC73FFF0BB73FFF0BB73FFF0BB73FFF0BB
     1130      73FFF2BC73FFF7CB8EFFAD7A3BFFF4BD72FFEFB667FFCF994DE1BB8441FF0000
     1131      002200000006000000000000000000000016999389FFCAC2B9FFCAC3B9FFCDC5
     1132      BCFFD0C8BFFFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFEAE0
     1133      D9FFEFE7E5FFB37830FFF6BC6EFFF0B96FFFEEB76EFFEEB76EFFEEB76EFFEEB7
     1134      6EFFEEB76EFFF0B86EFFF5C380FFAE7B3EFFF2B96EFFECB360FFD09645E4B985
     1135      45FF00000006000000000000000000000016999489FFC8C1B7FFCBC4BAFFCEC6
     1136      BDFFD0C8BFFFD4CBC2FFD7CEC6FFDBD1C9FFDED5CDFFE2D8D0FFE5DBD4FFECE1
     1137      DAFFF3E8E3FF8C9196FFB47A33FFF2B766FFEEB668FFECB468FFECB468FFECB4
     1138      68FFECB468FFECB468FFEEB668FFF1BB72FFB07D40FFECB15DFFEEB15BFFB885
     1139      46FF0000001100000000000000000000001588847BC1A09B91FFC8C1B7FFD2CA
     1140      C1FFD3CBC2FFD7CEC5FFD9D0C8FFDDD3CBFFDFD6CEFFE3D9D1FFE7DDD6FFF0E4
     1141      DDFF8C8C8AFFE3E4E6FFD0D4DDFFB57A34FFEFB562FFEBB363FFEAB263FFEAB2
     1142      63FFEAB263FFEAB263FFEAB263FFECB465FFF1B868FFB58244FFB88445FF0000
     1143      00370000001100000000000000000000000D0000002E78736BA8979187FFA19B
     1144      91FFB1AAA1FFC5BCB4FFCBC3BAFFE3D8D0FFE5DCD4FFEADFD7FFEEE3DCFFF7EA
     1145      E3FF8E8D8BFFD6D4D4FFC1C2C4FFB0B5BBFFB97F39FFEFB35DFFECB25FFFECB2
     1146      5FFFECB25FFFECB25FFFECB25FFFEEB460FFB68244FF00000048000000370000
     1147      001C00000006000000000000000000000004000000130000002B0000003E4745
     1148      406D737068A78B877DDF8E8980EA948F85FF938E84FF928E83FF928D83FF938E
     1149      83FF8F8C8AFF8A8785FFB7B6B4FFA6A5A6FF777C84FFBB8440FFB78344FFB683
     1150      45FFB68345FFB68345FFB68345FFB88445FF0000003D00000022000000110000
     1151      000600000000000000000000000000000000000000030000000B000000160000
     1152      00200000002D000000370000003E000000410000004300000043000000488F8C
     1153      8BFFD7D5D4FF878682FF84837FFF7F7D7DFF0000004800000043000000430000
     1154      0043000000430000004300000043000000370000001C00000006000000000000
     1155      0000000000000000000000000000000000000000000000000000000000010000
     1156      00050000000B000000110000001400000016000000160000001600000025ABA8
     1157      A7C6868481FF0000004800000043000000370000002200000016000000160000
     1158      0016000000160000001600000016000000110000000600000000000000000000
     1159      0000000000000000000000000000000000000000000000000000000000000000
     1160      00000000000000000000000000000000000000000000000000000000000D0000
     1161      002B000000340000002200000016000000110000000600000000000000000000
     1162      0000000000000000000000000000000000000000000000000000000000000000
     1163      0000000000000000000000000000000000000000000000000000000000000000
     1164      0000000000000000000000000000000000000000000000000000000000040000
     1165      000D0000000F0000000600000000000000000000000000000000000000000000
     1166      0000000000000000000000000000000000000000000000000000000000000000
     1167      0000000000000000000000000000
    10401168    }
    10411169  end
  • trunk/UCore.pas

    r3 r6  
    2222  private
    2323    Initialized: Boolean;
     24    procedure InitEngines;
    2425  public
    25     Database: TDatabase;
     26    Databases: TDatabases;
     27    Engines: TDatabaseEngines;
    2628    procedure LoadConfig;
    2729    procedure SaveConfig;
     
    3638
    3739uses
    38   UDatabaseXML, UFormTables;
     40  UEngineXML, UEngineMySQL, UEngineSQLite, UFormTables, UFormConnect, UFormDatabases;
    3941
    4042{$R *.lfm}
     
    4446procedure TCore.DataModuleCreate(Sender: TObject);
    4547begin
    46   Database := TDatabaseXML.Create;
     48  Databases := TDatabases.Create;
     49  Engines := TDatabaseEngines.Create;
    4750end;
    4851
    4952procedure TCore.AExitExecute(Sender: TObject);
    5053begin
    51   FormMain.Close;
     54  FormTables.Close;
    5255end;
    5356
    5457procedure TCore.DataModuleDestroy(Sender: TObject);
    5558begin
    56   Database.Free;
     59  Engines.Free;
     60  Databases.Free;
     61end;
     62
     63procedure TCore.InitEngines;
     64var
     65  NewEngine: TDatabaseEngine;
     66begin
     67  Engines.Clear;
     68
     69  NewEngine := Engines.RegisterEngine('XML file', TDatabaseXML);
     70  with NewEngine.DataTypes do begin
     71    RegisterType('String', ftString);
     72    RegisterType('Integer', ftInteger);
     73    RegisterType('Date and time', ftDateTime);
     74    RegisterType('Boolean', ftBoolean);
     75    RegisterType('Float', ftFloat);
     76  end;
     77
     78  NewEngine := Engines.RegisterEngine('MySQL', TDatabaseMySQL);
     79  with NewEngine.DataTypes do begin
     80    RegisterType('String', ftString);
     81    RegisterType('Integer', ftInteger);
     82    RegisterType('Date and time', ftDateTime);
     83    RegisterType('Boolean', ftBoolean);
     84    RegisterType('Float', ftFloat);
     85  end;
     86
     87  NewEngine := Engines.RegisterEngine('SQLite', TDatabaseSQLite);
     88  with NewEngine.DataTypes do begin
     89    RegisterType('String', ftString);
     90    RegisterType('Integer', ftInteger);
     91    RegisterType('Date and time', ftDateTime);
     92    RegisterType('Boolean', ftBoolean);
     93    RegisterType('Float', ftFloat);
     94  end;
    5795end;
    5896
    5997procedure TCore.LoadConfig;
     98var
     99  I: Integer;
     100  NewDatabase: TDatabase;
    60101begin
    61   Database.ConnectionString := XMLConfig1.GetValue('ConnectionString', 'file://' + ExtractFileDir(Application.ExeName) + '/data.xml');
     102  Databases.Count := XMLConfig1.GetValue('Database/Count', 0);
     103  for I := 0 to Databases.Count - 1 do begin
     104    NewDatabase := TDatabase.Create;
     105    NewDatabase.Name := XMLConfig1.GetValue('Database/Item' + IntToStr(I) + '/Name', '');
     106    NewDatabase.ConnectionString := XMLConfig1.GetValue('Database/Item' + IntToStr(I) + '/ConnectionString', '');
     107    NewDatabase.Engine := Core.Engines.FindByName(XMLConfig1.GetValue('Database/Item' + IntToStr(I) + '/Engine', ''));
     108    Databases[I] := NewDatabase;
     109  end;
     110  //Databases.ConnectionString := XMLConfig1.GetValue('ConnectionString', 'file://' + ExtractFileDir(Application.ExeName) + '/data.xml');
    62111end;
    63112
    64113procedure TCore.SaveConfig;
     114var
     115  I: Integer;
    65116begin
    66   XMLConfig1.SetValue('ConnectionString', Database.ConnectionString);
     117  XMLConfig1.SetValue('Database/Count', Databases.Count);
     118  for I := 0 to Databases.Count - 1 do begin
     119    XMLConfig1.SetValue('Database/Item' + IntToStr(I) + '/Name', TDatabase(Databases[I]).Name);
     120    XMLConfig1.SetValue('Database/Item' + IntToStr(I) + '/ConnectionString', TDatabase(Databases[I]).ConnectionString);
     121    XMLConfig1.SetValue('Database/Item' + IntToStr(I) + '/Engine', TDatabase(Databases[I]).Engine.Name);
     122  end;
    67123end;
    68124
     
    70126begin
    71127  if not Initialized then begin
     128    InitEngines;
     129    FormConnect.Init;
    72130    Initialized := True;
    73131    LoadConfig;
    74     Database.Load;
    75     FormMain.ReloadList;
     132    FormDatabases.ReloadList;
    76133  end;
    77134end;
     
    79136procedure TCore.Done;
    80137begin
    81   Database.Save;
    82138  SaveConfig;
    83139end;
  • trunk/UDataTypes.pas

    r4 r6  
    66
    77uses
    8   Classes, SysUtils, UDatabase;
     8  Classes, SysUtils, UDatabase, Contnrs;
    99
    1010type
     
    111111  TFieldMapPosition = class(TFieldTypeSpecific)
    112112  end;
    113 
    114113
    115114const
     
    263262end;
    264263
    265 
    266 
    267264end.
    268265
  • trunk/UDatabase.pas

    r4 r6  
    1010type
    1111  TTable = class;
     12  TDatabaseEngine = class;
    1213
    1314  TFieldType = (ftString, ftInteger, ftDateTime, ftBoolean, ftFloat, ftImage,
     
    109110    Tables: TTables;
    110111    ConnectionString: string;
     112    Engine: TDatabaseEngine;
    111113    constructor Create;
    112114    destructor Destroy; override;
     
    115117  end;
    116118
     119  TDatabases = class(TObjectList)
     120
     121  end;
     122
     123  TDatabaseClass = class of TDatabase;
     124
     125  { TDataType }
     126
     127  TDataType = class
     128    Name: string;
     129    FieldType: TFieldType;
     130  end;
     131
     132  TDataTypes = class(TObjectList)
     133    function RegisterType(Name: string; FieldType: TFieldType): TDataType;
     134  end;
     135
     136  { TDatabaseEngine }
     137
     138  TDatabaseEngine = class
     139    Name: string;
     140    DataTypes: TDataTypes;
     141    DatabaseClass: TDatabaseClass;
     142    constructor Create;
     143    destructor Destroy; override;
     144  end;
     145
     146  { TDatabaseEngines }
     147
     148  TDatabaseEngines = class(TObjectList)
     149    function RegisterEngine(Name: string; DatabaseClass: TDatabaseClass): TDatabaseEngine;
     150    function FindByName(Name: string): TDatabaseEngine;
     151  end;
     152
    117153
    118154implementation
     
    120156uses
    121157  UDataTypes;
     158
     159{ TDatabaseEngines }
     160
     161function TDatabaseEngines.RegisterEngine(Name: string;
     162  DatabaseClass: TDatabaseClass): TDatabaseEngine;
     163begin
     164  Result := TDatabaseEngine.Create;
     165  Result.Name := Name;
     166  Result.DatabaseClass := DatabaseClass;
     167  Add(Result);
     168end;
     169
     170function TDatabaseEngines.FindByName(Name: string): TDatabaseEngine;
     171var
     172  I: Integer;
     173begin
     174  I := 0;
     175  while (I < Count) and (TDatabaseEngine(Items[I]).Name <> Name) do Inc(I);
     176  if I < Count then Result := TDatabaseEngine(Items[I])
     177    else Result := nil;
     178end;
     179
     180{ TDataTypes }
     181
     182function TDataTypes.RegisterType(Name: string; FieldType: TFieldType): TDataType;
     183begin
     184  Result := TDataType.Create;
     185  Result.Name := Name;
     186  Result.FieldType := FieldType;
     187  Add(Result);
     188end;
     189
     190{ TDatabaseEngine }
     191
     192constructor TDatabaseEngine.Create;
     193begin
     194  DataTypes := TDataTypes.Create;
     195end;
     196
     197destructor TDatabaseEngine.Destroy;
     198begin
     199  DataTypes.Free;
     200  inherited Destroy;
     201end;
    122202
    123203{ TValues }
Note: See TracChangeset for help on using the changeset viewer.