procedure TForm2.Button1Click(Sender: TObject);
begin
D1:=datetimepicker1.DateTime;
D11:=datetimepicker1.DateTime;
D2:=datetimepicker2.DateTime;
D21:=datetimepicker2.DateTime;
L:=TStringList.Create;
S:=TStringList.Create;
if FileExists(ExtractFilePath(Application.ExeName)+'IVRResults1.txt') then
begin
Screen.Cursor:= crHourGlass;
L.LoadFromFile(ExtractFilePath(Application.ExeName)+'IVRResults1.txt');
I:=0;
Appels_444:=0;Demande_Transfert:=0;Transfert_OTA:=0;
Time_O_OTA:=0;No_chanel_OTA:=0;
repeat
table1.Open;
table1.Insert;
table1.FieldByName('Date').AsDateTime:=D11;
table1.FieldByName('Appels_444').AsInteger:=0;
table1.FieldByName('Demande_Transfert').AsInteger:=0;
table1.FieldByName('Transfert_OTA').AsInteger:=0;
table1.FieldByName('No_chanel_OTA').AsInteger:=0;
table1.FieldByName('Time_O_OTA').AsInteger:=0;
table1.Post;
D11:=D11+1;
until D11=D21;
application.ProcessMessages;
L1:=L.Strings[0];
s.Delimiter:=',';
s.DelimitedText:=L1;
K:=s[0];
Date:=K[4]+K[5]+K[3]+K[1]+K[2]+K[6]+'20'+K[7]+K[8];
D3:=strtodate(Date);
if (FormatDateTime('dd/mm/yyyy',D3) = FormatDateTime('dd/mm/yyyy',D1)) or (D3>D1) then
begin
repeat
L1:=L.Strings[i];
s.Delimiter:=',';
s.DelimitedText:=L1;
K:=s[0];
Date:=K[4]+K[5]+K[3]+K[1]+K[2]+K[6]+'20'+K[7]+K[8];
Hour:=S[1];
Subno:=S[8];
Apl_Name:=S[3];
Stat1:=copy(L1,Length(L1)-103,50);
Stat1_1 :=copy(Stat1,Length(Stat1)-49,1);
if Stat1_1=',' then Stat1:=copy(L1,Length(L1)-102,50) else
Stat1:=copy(L1,Length(L1)-103,50);
Stat1_1:=copy(Stat1,Length(Stat1)-49,1);
Stat4_1:=copy(Stat1,Length(Stat1)-46,1);
Stat46_1:=copy(Stat1,Length(Stat1)-4,1);
Stat47_1:=copy(Stat1,Length(Stat1)-3,1);
Stat48_1:=copy(Stat1,Length(Stat1)-2,1);
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date)) = FormatDateTime('dd/mm/yyyy',D1))
and (Apl_Name='LOYALTY.Oxy')
and (Stat1_1='1')
then Appels_444:=Appels_444+1;
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date)) = FormatDateTime('dd/mm/yyyy',D1))
and (Apl_Name='LOYALTY.Oxy')
and (Stat4_1='1')
then Demande_Transfert:=Demande_Transfert+1;
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date)) = FormatDateTime('dd/mm/yyyy',D1))
and (Apl_Name='LOYALTY.Oxy')
and (Stat46_1='1')
then No_chanel_OTA:=No_chanel_OTA+1;
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date)) = FormatDateTime('dd/mm/yyyy',D1))
and (Apl_Name='LOYALTY.Oxy')
and (Stat47_1='1')
then Transfert_OTA:=Transfert_OTA+1;
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date)) = FormatDateTime('dd/mm/yyyy',D1))
and (Apl_Name='LOYALTY.Oxy')
and (Stat48_1='1')
then Time_O_OTA:=Time_O_OTA+1;
if (FormatDateTime('dd/mm/yyyy',StrToDate(Date))<> FormatDateTime('dd/mm/yyyy',D1)) then
begin
if Table1.Locate('Date',D1,[]) then table1.Edit;
table1.FieldByName('Date').AsDateTime:=D1;
table1.FieldByName('Appels_444').AsInteger:=Appels_444;
table1.FieldByName('Demande_Transfert').AsInteger:=Demande_Transfert;
table1.FieldByName('Transfert_OTA').AsInteger:=Transfert_OTA;
table1.FieldByName('No_chanel_OTA').AsInteger:=No_chanel_OTA;
table1.FieldByName('Time_O_OTA').AsInteger:=Time_O_OTA;
table1.Post;
D1:=D1+1;
Appels_444:=0;Demande_Transfert:=0;Transfert_OTA:=0;
Time_O_OTA:=0;No_chanel_OTA:=0;Billing:=0;
end
else
i:=i+1;
until i=L.Count ;
l.Free;
s.Free;
if Table1.Locate('Date',D1,[]) then table1.Edit ;
table1.FieldByName('Date').AsDateTime:=D1;
table1.FieldByName('Appels_444').AsInteger:=Appels_444;
table1.FieldByName('Demande_Transfert').AsInteger:=Demande_Transfert;
table1.FieldByName('Transfert_OTA').AsInteger:=Transfert_OTA;
table1.FieldByName('No_chanel_OTA').AsInteger:=No_chanel_OTA;
table1.FieldByName('Time_O_OTA').AsInteger:=Time_O_OTA;
table1.Post;
Screen.Cursor:=crDefault ;
button1.Enabled:=false;
BitBtn2.Enabled:=true;
end;