qlixes

ModelDbSettings

May 6th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.35 KB | None | 0 0
  1. unit ModelDbSettings;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, IniSettings, ModelPath;
  9.  
  10. {$I const.inc}
  11.  
  12. type
  13.  
  14.   { TModelDbSettings }
  15.  
  16.   TModelDbSettings = class
  17.   private
  18.     FIniSettings:TIniSettings;
  19.     FPath:TModelPath;
  20.     FDbDriver:String;
  21.     FDbUser:String;
  22.     FDbPassword:String;
  23.     FDbLibrary:String;
  24.   public
  25.     Constructor Create;
  26.     procedure DbSettings;
  27.   published
  28.     property DbDriver:String read FDbDriver;
  29.     property DbUser:String read FDbUser;
  30.     property DbPassword:String read FDbPassword;
  31.     property DbLibrary:String read FDbLibrary;
  32.     property FDbIni:TIniSettings read FIniSettings;
  33.   end;
  34.  
  35. implementation
  36.  
  37. { TModelDbSettings }
  38.  
  39. constructor TModelDbSettings.Create;
  40. begin
  41.   FIniSettings:=TIniSettings.Create(Company+'.ini');
  42.   //bug masih blm bisa utk cek bila ada files
  43.   if FIniSettings.IsExists then
  44.     FIniSettings.Save
  45.   else
  46.     begin
  47.       FIniSettings.Save;
  48.       DbSettings;
  49.     end;
  50.   FPath:=TModelPath.Create;
  51.   FPath.Add('lib');
  52.   FDbLibrary:=FPath.Get('lib')+DS;
  53.   FDbUser:=DB_USER;
  54.   FDbPassword:=DB_PASSWORD;
  55. end;
  56.  
  57. procedure TModelDbSettings.DbSettings;
  58. begin
  59.   with FIniSettings do
  60.   begin
  61.     Header('$Database$');
  62.     Write('Server');
  63.     //Write('Port');
  64.     Write('Path');
  65.     Write('Name');
  66.     //Write('Protocol');
  67.   end;
  68. end;
  69.  
  70. end.
Advertisement
Add Comment
Please, Sign In to add comment