- Timestamp:
- May 30, 2010, 6:09:55 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 1 1 lib 2 Config.xml 3 chronis
-
- Property svn:ignore
-
trunk/UMainForm.lfm
r1 r2 1 1 object MainForm: TMainForm 2 Left = 3 262 Left = 359 3 3 Height = 445 4 Top = 1 644 Top = 124 5 5 Width = 649 6 6 ActiveControl = ListView1 … … 8 8 ClientHeight = 445 9 9 ClientWidth = 649 10 OnClose = FormClose 10 11 OnCreate = FormCreate 12 OnShow = FormShow 11 13 LCLVersion = '0.9.29' 12 14 object TreeView1: TTreeView … … 16 18 Width = 171 17 19 Anchors = [akTop, akLeft, akBottom] 18 DefaultItemHeight = 19 20 DefaultItemHeight = 15 21 ReadOnly = True 19 22 TabOrder = 0 23 OnChange = TreeView1Change 24 Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw] 20 25 end 21 26 object ListView1: TListView 22 Left = 18 727 Left = 184 23 28 Height = 417 24 Top = 1 929 Top = 16 25 30 Width = 453 26 31 Anchors = [akTop, akLeft, akRight, akBottom] 27 32 Columns = <> 28 33 ItemIndex = -1 34 ReadOnly = True 35 RowSelect = True 29 36 TabOrder = 1 30 37 ViewStyle = vsReport … … 32 39 object Label1: TLabel 33 40 Left = 7 34 Height = 1 841 Height = 14 35 42 Top = 4 36 Width = 5743 Width = 47 37 44 Caption = 'Skupiny:' 38 45 ParentColor = False … … 40 47 object Label2: TLabel 41 48 Left = 187 42 Height = 1 849 Height = 14 43 50 Top = 4 44 Width = 4951 Width = 38 45 52 Caption = 'Výpisy:' 46 53 ParentColor = False -
trunk/UMainForm.pas
r1 r2 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 StdCtrls, USqlDatabase; 9 StdCtrls, USqlDatabase, DOM, XMLRead, XMLWrite, UPersistentForm; 10 11 const 12 ConfigFileName = 'Config.xml'; 10 13 11 14 type … … 18 21 ListView1: TListView; 19 22 TreeView1: TTreeView; 23 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 20 24 procedure FormCreate(Sender: TObject); 25 procedure FormShow(Sender: TObject); 26 procedure TreeView1Change(Sender: TObject; Node: TTreeNode); 21 27 private 22 { private declarations }28 procedure LoadConfiguration; 23 29 public 30 PersistentForm: TPersistentForm; 24 31 Database: TSQLDatabase; 25 32 procedure LoadTree; … … 35 42 { TMainForm } 36 43 44 procedure TMainForm.LoadConfiguration; 45 var 46 Config: TXMLDocument; 47 I1: Integer; 48 I2: Integer; 49 I3: Integer; 50 begin 51 if FileExists(ConfigFileName) then begin 52 ReadXMLFile(Config, ConfigFileName); 53 for I1 := 0 to Config.ChildNodes.Count - 1 do 54 with Config.ChildNodes[I1] do begin 55 if NodeName = 'configuration' then 56 for I2 := 0 to ChildNodes.Count - 1 do 57 with ChildNodes[I2] do begin 58 if NodeName = 'database' then 59 for I3 := 0 to ChildNodes.Count - 1 do 60 with ChildNodes[I3] do begin 61 if NodeName = 'hostname' then 62 Database.HostName := TextContent; 63 if NodeName = 'schema' then 64 Database.Schema := TextContent; 65 if NodeName = 'username' then 66 Database.UserName := TextContent; 67 if NodeName = 'password' then 68 Database.Password := TextContent; 69 end; 70 end; 71 end; 72 Config.Destroy; 73 end; 74 end; 75 37 76 procedure TMainForm.FormCreate(Sender: TObject); 38 77 begin 39 78 Database := TSqlDatabase.Create; 40 with Database do begin41 Hostname := 'localhost';42 Schema := 'chronis_system';43 UserName := 'root';79 LoadConfiguration; 80 Database.Connect; 81 PersistentForm := TPersistentForm.Create; 82 end; 44 83 84 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 85 begin 86 PersistentForm.Save(Self); 87 end; 88 89 procedure TMainForm.FormShow(Sender: TObject); 90 begin 91 PersistentForm.Load(Self); 92 LoadTree; 93 end; 94 95 procedure TMainForm.TreeView1Change(Sender: TObject; Node: TTreeNode); 96 var 97 DbRows: TDbRows; 98 Properties: TDbRows; 99 Values: TDbRows; 100 I: Integer; 101 C: Integer; 102 NewItem: TListItem; 103 NewColumn: TListColumn; 104 begin 105 if Assigned(TreeView1.Selected) then 106 with ListView1, Items do begin 107 Clear; 108 DbRows := Database.Query('SELECT * FROM `Object` WHERE `Id`=' + IntToStr(TreeView1.Selected.ImageIndex)); 109 if DbRows.Count = 1 then begin 110 // Load column names 111 Properties := Database.Query('SELECT * FROM `Property` WHERE `Object`=' + 112 DbRows[0].Values['Id']); 113 Columns.Clear; 114 NewColumn := Columns.Add; 115 NewColumn.Caption := 'Id'; 116 for I := 0 to Properties.Count - 1 do begin 117 NewColumn := Columns.Add; 118 NewColumn.Caption := DbRows[I].Values['Name']; 119 end; 120 121 // Load items 122 Values := Database.Query('SELECT * FROM `' + DbRows[0].Values['Schema'] + '`.`' + 123 DbRows[0].Values['Table'] + '`'); 124 for I := 0 to Values.Count - 1 do begin 125 NewItem := Items.Add; 126 NewItem.Caption := Values[I].Values['Id']; 127 for C := 0 to Properties.Count - 1 do begin 128 NewItem.SubItems.Add(Values[I].Values[Properties[C].Values['ColumnName']]); 129 end; 130 end; 131 Values.Destroy; 132 Properties.Destroy; 133 end; 134 DbRows.Destroy; 45 135 end; 46 136 end; 47 137 48 138 procedure TMainForm.LoadTree; 139 var 140 DbRows: TDbRows; 141 ObjectDbRows: TDbRows; 142 I: Integer; 143 O: Integer; 144 NewNode: TTreeNode; 145 NewObjectNode: TTreeNode; 49 146 begin 50 147 with TreeView1, Items do begin 148 Clear; 149 AddChild(nil, 'Skupiny'); 150 DbRows := Database.Query('SELECT * FROM `MenuGroup`'); 151 for I := 0 to DbRows.Count - 1 do begin 152 NewNode := AddChild(TopItem, DbRows[I].Values['Name']); 153 ObjectDbRows := Database.Query('SELECT * FROM `Object` WHERE `MenuGroup`=' + DbRows[I].Values['Id']); 154 for O := 0 to ObjectDbRows.Count - 1 do begin 155 NewObjectNode := AddChild(NewNode, ObjectDbRows[O].Values['Name']); 156 NewObjectNode.ImageIndex := StrToInt(ObjectDbRows[O].Values['Id']); 157 end; 158 ObjectDbRows.Destroy; 159 end; 160 TopItem.Expand(True); 161 DbRows.Destroy; 162 end; 51 163 end; 52 164 -
trunk/chronis.lpi
r1 r2 37 37 </Item1> 38 38 </RequiredPackages> 39 <Units Count=" 6">39 <Units Count="15"> 40 40 <Unit0> 41 41 <Filename Value="chronis.lpr"/> 42 42 <IsPartOfProject Value="True"/> 43 43 <UnitName Value="chronis"/> 44 <EditorIndex Value=" 0"/>45 <WindowIndex Value="0"/> 46 <TopLine Value="1"/> 47 <CursorPos X=" 18" Y="15"/>48 <UsageCount Value=" 27"/>44 <EditorIndex Value="3"/> 45 <WindowIndex Value="0"/> 46 <TopLine Value="1"/> 47 <CursorPos X="59" Y="20"/> 48 <UsageCount Value="30"/> 49 49 <Loaded Value="True"/> 50 50 </Unit0> … … 71 71 <Unit3> 72 72 <Filename Value="USqlDatabase.pas"/> 73 <IsPartOfProject Value="True"/>74 73 <UnitName Value="USqlDatabase"/> 75 <EditorIndex Value=" 1"/>76 <WindowIndex Value="0"/> 77 <TopLine Value="3 7"/>78 <CursorPos X="1 6" Y="4"/>79 <UsageCount Value="2 3"/>74 <EditorIndex Value="4"/> 75 <WindowIndex Value="0"/> 76 <TopLine Value="330"/> 77 <CursorPos X="1" Y="347"/> 78 <UsageCount Value="26"/> 80 79 <Loaded Value="True"/> 81 80 </Unit3> … … 88 87 <UnitName Value="UMainForm"/> 89 88 <IsVisibleTab Value="True"/> 90 <EditorIndex Value=" 3"/>91 <WindowIndex Value="0"/> 92 <TopLine Value=" 19"/>93 <CursorPos X="5 " Y="44"/>94 <UsageCount Value="2 0"/>89 <EditorIndex Value="0"/> 90 <WindowIndex Value="0"/> 91 <TopLine Value="84"/> 92 <CursorPos X="51" Y="100"/> 93 <UsageCount Value="23"/> 95 94 <Loaded Value="True"/> 96 95 </Unit4> … … 102 101 <ResourceBaseClass Value="Form"/> 103 102 <UnitName Value="ULoginForm"/> 103 <WindowIndex Value="0"/> 104 <TopLine Value="1"/> 105 <CursorPos X="24" Y="14"/> 106 <UsageCount Value="23"/> 107 </Unit5> 108 <Unit6> 109 <Filename Value="../../../lazarus/trunk/lcl/comctrls.pp"/> 110 <UnitName Value="ComCtrls"/> 111 <WindowIndex Value="0"/> 112 <TopLine Value="2651"/> 113 <CursorPos X="3" Y="2669"/> 114 <SyntaxHighlighter Value="FreePascal"/> 115 <UsageCount Value="10"/> 116 <DefaultSyntaxHighlighter Value="Text"/> 117 </Unit6> 118 <Unit7> 119 <Filename Value="../../../lazarus/trunk/lcl/include/customform.inc"/> 120 <WindowIndex Value="0"/> 121 <TopLine Value="819"/> 122 <CursorPos X="1" Y="838"/> 123 <SyntaxHighlighter Value="FreePascal"/> 124 <UsageCount Value="11"/> 125 <DefaultSyntaxHighlighter Value="Text"/> 126 </Unit7> 127 <Unit8> 128 <Filename Value="Common/UPersistentForm.pas"/> 129 <IsPartOfProject Value="True"/> 130 <UnitName Value="UPersistentForm"/> 131 <EditorIndex Value="1"/> 132 <WindowIndex Value="0"/> 133 <TopLine Value="1"/> 134 <CursorPos X="36" Y="19"/> 135 <SyntaxHighlighter Value="FreePascal"/> 136 <UsageCount Value="21"/> 137 <Loaded Value="True"/> 138 <DefaultSyntaxHighlighter Value="Text"/> 139 </Unit8> 140 <Unit9> 141 <Filename Value="Common/USqlDatabase.pas"/> 142 <IsPartOfProject Value="True"/> 143 <UnitName Value="USqlDatabase"/> 144 <UsageCount Value="21"/> 145 <DefaultSyntaxHighlighter Value="Text"/> 146 </Unit9> 147 <Unit10> 148 <Filename Value="../../../lazarus/trunk/lcl/forms.pp"/> 149 <UnitName Value="Forms"/> 150 <WindowIndex Value="0"/> 151 <TopLine Value="579"/> 152 <CursorPos X="15" Y="596"/> 153 <SyntaxHighlighter Value="FreePascal"/> 154 <UsageCount Value="10"/> 155 <DefaultSyntaxHighlighter Value="Text"/> 156 </Unit10> 157 <Unit11> 158 <Filename Value="Common/URegistry.pas"/> 159 <IsPartOfProject Value="True"/> 160 <UnitName Value="URegistry"/> 104 161 <EditorIndex Value="2"/> 105 162 <WindowIndex Value="0"/> 106 <TopLine Value="1"/> 107 <CursorPos X="24" Y="14"/> 163 <TopLine Value="32"/> 164 <CursorPos X="21" Y="13"/> 165 <SyntaxHighlighter Value="FreePascal"/> 108 166 <UsageCount Value="20"/> 109 167 <Loaded Value="True"/> 110 </Unit5> 168 <DefaultSyntaxHighlighter Value="Text"/> 169 </Unit11> 170 <Unit12> 171 <Filename Value="/usr/share/fpcsrc/packages/fcl-registry/src/registry.pp"/> 172 <UnitName Value="registry"/> 173 <WindowIndex Value="0"/> 174 <TopLine Value="1"/> 175 <CursorPos X="5" Y="14"/> 176 <SyntaxHighlighter Value="FreePascal"/> 177 <UsageCount Value="10"/> 178 <DefaultSyntaxHighlighter Value="Text"/> 179 </Unit12> 180 <Unit13> 181 <Filename Value="/usr/share/fpcsrc/packages/fcl-registry/src/regdef.inc"/> 182 <WindowIndex Value="0"/> 183 <TopLine Value="4"/> 184 <CursorPos X="17" Y="21"/> 185 <SyntaxHighlighter Value="FreePascal"/> 186 <UsageCount Value="10"/> 187 <DefaultSyntaxHighlighter Value="Text"/> 188 </Unit13> 189 <Unit14> 190 <Filename Value="/usr/share/fpcsrc/rtl/objpas/sysutils/sysutilh.inc"/> 191 <WindowIndex Value="0"/> 192 <TopLine Value="17"/> 193 <CursorPos X="4" Y="34"/> 194 <SyntaxHighlighter Value="FreePascal"/> 195 <UsageCount Value="10"/> 196 <DefaultSyntaxHighlighter Value="Text"/> 197 </Unit14> 111 198 </Units> 112 <JumpHistory Count=" 8" HistoryIndex="7">199 <JumpHistory Count="26" HistoryIndex="25"> 113 200 <Position1> 114 <Filename Value=" chronis.lpr"/>115 <Caret Line="1 " Column="16" TopLine="1"/>201 <Filename Value="UMainForm.pas"/> 202 <Caret Line="110" Column="3" TopLine="100"/> 116 203 </Position1> 117 204 <Position2> 118 <Filename Value=" chronis.lpr"/>119 <Caret Line="11 " Column="39" TopLine="1"/>205 <Filename Value="UMainForm.pas"/> 206 <Caret Line="115" Column="1" TopLine="100"/> 120 207 </Position2> 121 208 <Position3> 122 <Filename Value="U SqlDatabase.pas"/>123 <Caret Line="1 2" Column="35" TopLine="1"/>209 <Filename Value="UMainForm.pas"/> 210 <Caret Line="116" Column="1" TopLine="100"/> 124 211 </Position3> 125 212 <Position4> 126 213 <Filename Value="UMainForm.pas"/> 127 <Caret Line=" 23" Column="24" TopLine="1"/>214 <Caret Line="114" Column="29" TopLine="100"/> 128 215 </Position4> 129 216 <Position5> 130 217 <Filename Value="USqlDatabase.pas"/> 131 <Caret Line=" 3" Column="44" TopLine="1"/>218 <Caret Line="182" Column="11" TopLine="168"/> 132 219 </Position5> 133 220 <Position6> 134 <Filename Value="U MainForm.pas"/>135 <Caret Line=" 23" Column="28" TopLine="12"/>221 <Filename Value="USqlDatabase.pas"/> 222 <Caret Line="392" Column="26" TopLine="370"/> 136 223 </Position6> 137 224 <Position7> 138 225 <Filename Value="UMainForm.pas"/> 139 <Caret Line=" 9" Column="17" TopLine="1"/>226 <Caret Line="120" Column="49" TopLine="100"/> 140 227 </Position7> 141 228 <Position8> 142 <Filename Value="U SqlDatabase.pas"/>143 <Caret Line=" 83" Column="54" TopLine="68"/>229 <Filename Value="UMainForm.pas"/> 230 <Caret Line="45" Column="41" TopLine="17"/> 144 231 </Position8> 232 <Position9> 233 <Filename Value="UMainForm.pas"/> 234 <Caret Line="80" Column="18" TopLine="75"/> 235 </Position9> 236 <Position10> 237 <Filename Value="Common/UPersistentForm.pas"/> 238 <Caret Line="8" Column="47" TopLine="1"/> 239 </Position10> 240 <Position11> 241 <Filename Value="Common/UPersistentForm.pas"/> 242 <Caret Line="29" Column="24" TopLine="12"/> 243 </Position11> 244 <Position12> 245 <Filename Value="UMainForm.pas"/> 246 <Caret Line="77" Column="15" TopLine="75"/> 247 </Position12> 248 <Position13> 249 <Filename Value="Common/UPersistentForm.pas"/> 250 <Caret Line="37" Column="12" TopLine="12"/> 251 </Position13> 252 <Position14> 253 <Filename Value="Common/UPersistentForm.pas"/> 254 <Caret Line="44" Column="15" TopLine="21"/> 255 </Position14> 256 <Position15> 257 <Filename Value="Common/UPersistentForm.pas"/> 258 <Caret Line="46" Column="21" TopLine="29"/> 259 </Position15> 260 <Position16> 261 <Filename Value="Common/UPersistentForm.pas"/> 262 <Caret Line="29" Column="69" TopLine="25"/> 263 </Position16> 264 <Position17> 265 <Filename Value="Common/UPersistentForm.pas"/> 266 <Caret Line="51" Column="71" TopLine="33"/> 267 </Position17> 268 <Position18> 269 <Filename Value="Common/UPersistentForm.pas"/> 270 <Caret Line="52" Column="23" TopLine="37"/> 271 </Position18> 272 <Position19> 273 <Filename Value="Common/UPersistentForm.pas"/> 274 <Caret Line="54" Column="98" TopLine="37"/> 275 </Position19> 276 <Position20> 277 <Filename Value="Common/UPersistentForm.pas"/> 278 <Caret Line="74" Column="53" TopLine="46"/> 279 </Position20> 280 <Position21> 281 <Filename Value="Common/UPersistentForm.pas"/> 282 <Caret Line="75" Column="19" TopLine="54"/> 283 </Position21> 284 <Position22> 285 <Filename Value="Common/URegistry.pas"/> 286 <Caret Line="8" Column="9" TopLine="1"/> 287 </Position22> 288 <Position23> 289 <Filename Value="Common/UPersistentForm.pas"/> 290 <Caret Line="8" Column="49" TopLine="1"/> 291 </Position23> 292 <Position24> 293 <Filename Value="Common/UPersistentForm.pas"/> 294 <Caret Line="84" Column="28" TopLine="54"/> 295 </Position24> 296 <Position25> 297 <Filename Value="Common/UPersistentForm.pas"/> 298 <Caret Line="84" Column="10" TopLine="54"/> 299 </Position25> 300 <Position26> 301 <Filename Value="UMainForm.pas"/> 302 <Caret Line="25" Column="15" TopLine="7"/> 303 </Position26> 145 304 </JumpHistory> 146 305 </ProjectOptions> … … 153 312 <IncludeFiles Value="$(ProjOutDir)/"/> 154 313 <Libraries Value="/usr/lib/mysql/;/usr/lib64/mysql/"/> 314 <OtherUnitFiles Value="Common/"/> 155 315 <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> 156 316 </SearchPaths> … … 160 320 </SyntaxOptions> 161 321 </Parsing> 322 <CodeGeneration> 323 <Checks> 324 <IOChecks Value="True"/> 325 <RangeChecks Value="True"/> 326 <OverflowChecks Value="True"/> 327 <StackChecks Value="True"/> 328 </Checks> 329 </CodeGeneration> 162 330 <Linking> 331 <Debugging> 332 <GenerateDebugInfo Value="True"/> 333 </Debugging> 163 334 <Options> 164 335 <Win32> -
trunk/chronis.lpr
r1 r2 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, U SqlDatabase, UMainForm, ULoginForm10 Forms, UMainForm, ULoginForm, UPersistentForm, URegistry, USqlDatabase 11 11 { you can add units after this }; 12 12 … … 15 15 begin 16 16 Application.Initialize; 17 Application.CreateForm(TMainForm, MainForm); 17 18 Application.Run; 18 19 end.
Note:
See TracChangeset
for help on using the changeset viewer.