22-12-2014, 04:18 PM
PHP كود :
procedure TForm1.mniImporter1Click(Sender: TObject);
var
i : Integer;
StrArr :TArrayString;
begin
sGauge1.Visible :=True;
if not DirectoryExists(CurrentDir+'database\') then CreateDir(CurrentDir+'database\') ;
sOpenDialog1.InitialDir:=CurrentDir+'database\';
sOpenDialog1.FileName:='Exporte_'+FormatDateTime('yyyy_mm_dd', Now)+'.txt';
if sOpenDialog1.Execute then
with TStringList.Create do begin
try
LoadFromFile(sOpenDialog1.FileName);
sGauge1.MaxValue:=Count-1;
for i:=0 to Count-1 do begin
StrArr := Split(Strings[i] ,'|' );
if high(StrArr)>10 then
if not Form2._exist(StrArr[7]) then begin
tbl1.Insert;
tbl1.FieldByName('Wilaya').Value:=StrArr[0];
tbl1.FieldByName('Type').Value:=StrArr[1];
tbl1.FieldByName('Organisme').Value:=StrArr[2];
tbl1.FieldByName('NOCCP').Value:=StrArr[3];
tbl1.FieldByName('Ncontrat').Value:=StrArr[4];
tbl1.FieldByName('Datecontrat').Value:=StrArr[5];
tbl1.FieldByName('Adresse').Value:=StrArr[6];
tbl1.FieldByName('Nom_et_Prenom').Value:=StrArr[7];
tbl1.FieldByName('Poste_occupe').Value:=StrArr[8];
tbl1.FieldByName('Tel').Value:=StrArr[9];
tbl1.FieldByName('Fax').Value:=StrArr[10];
tbl1.FieldByName('Email').Value:=StrArr[11];
tbl1.Post;
Application.ProcessMessages;
sGauge1.Progress:=i;
sGauge1.Suffix:='% , Importation de '+StrArr[7]+' ( '+inttostr(i+1)+'/'+inttostr(Count)+' enregistrements terminées )';
//Sleep(10);
end;
end;
finally
Free;
sGauge1.Visible:=False;
end;
end;
end

