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
| var
Fcreer: TFcreer;
MQ,Q1,Q2:String;
MINSTALLATION,MCHEMIN,MBASE:String;
MMOIS,MJOURS:String;
XMOIS,XJOURS,MINDEX:Integer;
NB_JOURS:array [1..12] of integer;
const
MTABLE='CE.sdb';
MNOUVELLE='JOURS';
implementation
{$R *.lfm}
{ TFcreer }
procedure TFcreer.FormActivate(Sender: TObject);
begin
// préparation de l'environnement
defaultFormatSettings.ShortDateFormat:='DD/MM/YYYY';
defaultFormatSettings.DateSeparator:='/';
defaultFormatSettings.DecimalSeparator:=',';
Preparation;
end;
procedure TFcreer.BquitterClick(Sender: TObject);
begin
close;
end;
procedure TFcreer.Preparation;
begin
MINSTALLATION:=ExtractFilePath(Application.ExeName);
MINDEX:=Pos('sources',MINSTALLATION);
MCHEMIN:=Copy(MINSTALLATION,1,MINDEX-1);
MINDEX:=Pos('\',MINSTALLATION);
if MINDEX<>0 then MSEPARATEUR:='\' //WINDOWS
else
begin
MINDEX:=Pos('/',MINSTALLATION);
if MINDEX<>0 then MSEPARATEUR:='/' //LINUX
else
begin
MMESSAGE:='Erreur de détection système d''exploitation';
MessageErreur;
Close;
end;
end;
MBASE:=MCHEMIN+'tables'+MSEPARATEUR+MTABLE;
// déclaration des valeurs jours du mois
NB_JOURS[1]:=31; // janvier
NB_JOURS[2]:=27; // février
NB_JOURS[3]:=31; // mars
NB_JOURS[4]:=30; // avril
NB_JOURS[5]:=31; // mai
NB_JOURS[6]:=30; // juin
NB_JOURS[7]:=31; // juillet
NB_JOURS[8]:=31; // août
NB_JOURS[9]:=30; // septembre
NB_JOURS[10]:=31; // octobre
NB_JOURS[11]:=30; // novembre
NB_JOURS[12]:=31; // décembre
end;
procedure TFcreer.Bcreer_suppClick(Sender: TObject);
begin
Sqlite3Dataset1.FileName:=MBASE;
if Sqlite3Dataset1.TableExists=True then
begin
ShowMessage('la table JOURS existe elle va être supprimée');
Sqlite3Dataset1.ExecSQL('DROP TABLE '+Sqlite3Dataset1.TableName+';');
end
else
begin
ShowMessage('La table JOURS n''existe pas dans la base, elle va être créée');
MQ:=('CREATE TABLE JOURS (K_JOURS INTEGER PRIMARY KEY, MOIS char(2), JOURS char(2))');
Sqlite3Dataset1.SQL:=MQ;
Sqlite3Dataset1.ExecSQL;
XMOIS:=1;
while XMOIS<13 do
begin
MMOIS:=Trim(IntTostr(XMOIS));
if Length(MMOIS)=1 then MMOIS:='0'+MMOIS;
XJOURS:=NB_JOURS[XMOIS];
MJOURS:=Trim(IntToStr(XJOURS));
Q1:=quotedstr(MMOIS);
Q2:=quotedstr(MJOURS);
MQ:=('INSERT INTO JOURS (K_JOURS,MOIS,JOURS) VALUES(NULL,'+Q1+','+Q2+')');
Sqlite3Dataset1.SQL:=MQ;
Sqlite3Dataset1.ExecSQL;
Inc(XMOIS);
end;
end;
end; |
Partager