1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
| unit UServeur;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, JvWizard, JvExControls, JvWizardRouteMapList, StdCtrls,
JvExStdCtrls, JvListBox, JvDriveCtrls, JvCombobox, IBDatabase, DB,
IBCustomDataSet, IBQuery;
type
TFrm_Serveur = class(TForm)
JvWizard1: TJvWizard;
JvWizardWelcomePage1: TJvWizardWelcomePage;
JvWizardRouteMapList1: TJvWizardRouteMapList;
Memo1: TMemo;
GroupBox1: TGroupBox;
RadioButton1: TRadioButton;
Dossier: TJvWizardInteriorPage;
C_Disque: TJvDriveCombo;
L_Dossier: TJvDirectoryListBox;
GroupBox2: TGroupBox;
E_Moniteur: TEdit;
Base: TJvWizardInteriorPage;
GroupBox3: TGroupBox;
M_MoniteurBase: TMemo;
Btn_Install: TButton;
IBDatabase: TIBDatabase;
IBTransaction: TIBTransaction;
IBQuery: TIBQuery;
procedure L_DossierChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
Procedure Init_DossierInstall;
Procedure DataBase_Cree;
Procedure TableClient_Cree;
procedure Btn_InstallClick(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Frm_Serveur: TFrm_Serveur;
BasePath : string;
BaseDirectory : string;
IBDataBase: TIBDatabase;
IBQuery: TIBQuery;
IBTransaction: TIBTransaction;
implementation
{$R *.dfm}
procedure TFrm_Serveur.L_DossierChange(Sender: TObject);
begin
Frm_serveur.Init_DossierInstall;
end;
procedure TFrm_Serveur.FormCreate(Sender: TObject);
begin
Frm_Serveur.Init_DossierInstall;
end;
Procedure TFrm_Serveur.Init_DossierInstall;
begin
If Frm_serveur.L_Dossier.Directory = (Frm_serveur.C_Disque.Drive + ':\' ) then
begin
Frm_Serveur.E_Moniteur.Text := Frm_Serveur.L_Dossier.Directory + 'GC_Datas\DB_GEST';
BaseDirectory := Frm_Serveur.L_Dossier.Directory;
end
else
begin
Frm_Serveur.E_Moniteur.Text := Frm_Serveur.L_Dossier.Directory + '\GC_Datas\DB_GEST';
BaseDirectory := Frm_Serveur.L_Dossier.Directory+'\'
end;
BasePath := Frm_Serveur.E_Moniteur.Text;
end;
Procedure TFrm_Serveur.DataBase_Cree;
begin
if not DirectoryExists(BaseDirectory+'GC_Datas') then
begin
try
CreateDir(BaseDirectory+'GC_Datas')
Except
showmessage('Impossible de créer le Dossier' +#13#10+ BaseDirectory+'GC_Datas !');
end;
end;
If FileExists(BasePath) then showmessage ('La Base De Données' + #13#10 + 'Existe Déjà !!')
else
begin
//Creation de la base de données
IBDataBase := TIBDatabase.Create(nil);
IBQuery := TIBQuery.Create(nil);
IBTransaction := TIBTransaction.Create(nil);
try
IBDataBase.DatabaseName := '127.0.0.1:'+BasePath;
IBDataBase.SQLDialect := 3;
IBDataBase.Params.Clear;
IBDataBase.Params.Add('USER "SYSDBA"');
IBDataBase.Params.Add('PASSWORD "masterkey"');
IBDataBase.Params.Add('PAGE_SIZE 4096');
IBDataBase.CreateDatabase;
IBDatabase.Connected := true;
IBTransaction.DefaultDatabase := IBDataBase;
IBQuery.Database := IBDatabase;
IBQuery.Transaction := IBTransaction;
try
IBQuery.SQL.Add('create table IODescriptorEx(IOId int not null,IOFileMask VarChar(30),'+
'AlternativeDesc VarChar(50));');
IBQuery.ExecSQL;
IBTransaction.Commit;
except
IBTransaction.Rollback;
ShowMessage ('Erreur !' + #13#10 + 'Le serveur est non fonctionnel !');
end;
IBDataBase.Connected := false;
finally
FreeAndNil(IBQuery);
FreeAndNil(IBTransaction);
FreeAndNil(IBDataBase);
end;
end;
end;
procedure TFrm_Serveur.Btn_InstallClick(Sender: TObject);
begin
Frm_Serveur.DataBase_Cree;
Frm_Serveur.TableClient_Cree;
end;
Procedure TFrm_Serveur.TableClient_Cree;
begin
IBDataBase := TIBDatabase.Create(nil);
IBQuery := TIBQuery.Create(nil);
IBTransaction := TIBTransaction.Create(nil);
try
IBDataBase.DatabaseName := '127.0.0.1:'+BasePath;
IBDataBase.SQLDialect := 3;
IBDataBase.Params.Clear;
IBDataBase.Params.Add('USER "SYSDBA"');
IBDataBase.Params.Add('PASSWORD "masterkey"');
IBDataBase.Params.Add('PAGE_SIZE 4096');
IBDatabase.Connected := true;
IBTransaction.DefaultDatabase := IBDataBase;
IBQuery.Database := IBDatabase;
IBQuery.Transaction := IBTransaction;
try
IBQuery.SQL.Add('create table T_Clients');
IBQuery.SQL.Add('(C_Id INTEGER,');
Ibquery.SQL.add('C_Code varchar(30),');
IbQuery.SQL.Add('C_Nom varchar,');
IbQuery.SQL.Add('C_Adresse1 varchar,');
IbQuery.SQL.Add('C_Adresse2 varchar,');
IbQuery.SQL.Add('C_CP varchar(30),');
IbQuery.SQL.Add('C_Ville varchar,');
IbQuery.SQL.Add('C_Telephone1 varchar,');
IbQuery.SQL.Add('C_Telephone2 varchar,');
IbQuery.SQL.Add('C_Fax varchar,');
IbQuery.SQL.Add('C_EMail varchar,');
IbQuery.SQL.Add('C_Internet varchar,');
IbQuery.SQL.Add('C_Commercial INTEGER,');
IbQuery.SQL.Add('C_Etat INTEGER,');
IbQuery.SQL.Add('C_Prospect BOOLEAN,');
IbQuery.SQL.Add('C_Reg_Mode varchar,');
IbQuery.SQL.Add('C_Reg_NbJours INTEGER,');
IbQuery.SQL.Add('C_Reg_Le INTEGER,');
IbQuery.SQL.Add('C_Reg_Compta varchar,');
IbQuery.SQL.Add('C_Reg_RIB varchar,');
IbQuery.SQL.Add('C_Reg_Banque varchar,');
IbQuery.SQL.Add('C_Reg_Siret varchar,');
IbQuery.SQL.Add('C_Reg_APE varchar,');
IbQuery.SQL.Add('C_Reg_TVA varchar,');
//IbQuery.SQL.Add('C_Notes BLOB,');
IbQuery.SQL.Add('C_DateCreation varchar,');
IbQuery.SQL.Add('C_DateModification varchar,');
IbQuery.SQL.Add('C_CreeParQui INTEGER,');
IbQuery.SQL.Add('C_ModifieParQui INTEGER);');
IBQuery.ExecSQL;
IBTransaction.Commit;
except
IBTransaction.Rollback;
ShowMessage ('Erreur !' + #13#10 + 'Le serveur est non fonctionnel !');
end;
IBDataBase.Connected := false;
finally
//IBDataBase.Connected := false;
FreeAndNil(IBQuery);
FreeAndNil(IBTransaction);
FreeAndNil(IBDataBase);
end;
end;
end. |
Partager