实现了一个大概...写的比较乱,呵呵!看到哪里写的有问题的提醒一下!
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if DayOfWeek(Now)=3 then //判断是不是星期二
begin
if FormatDateTime('hh:mm',Now)='15:00' then
begin
Form1.Button1Click(sender);
end;
end;
// ShowMessage(FormatDateTime('hh:mm',Now));
Timer1.Enabled := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Filename: String;
Str1,Str2,Str3,F1,F2,F3,F4: String;
VI1,VI2,VI3: Integer;
AList,FList: TStringList;
FADOQ: TADOQuery;
FSQL: String;
FFile: TextFile;
OutPutTxt: TStringList;
FStrTo:String;
I:Integer;
begin
// Edit1.Clear ;
Filename:=ExtractFilePath(ParamStr(0))+'Test.ini';
MyInifile:=TInifile.Create(Filename); //
AList:= TStringList.Create ;
MyInifile.ReadSections(AList);
For I:=1 to AList.Count do
Begin
FList:= TStringList.Create ; //
MyInifile.ReadSection('Filter'+IntToStr(I),FList);
// ListBox1.Items := FList;
// Edit1.Text := FList[0];
// VI1:= MyInifile.ReadInteger('Filter1','NUM',0);
VI2:= MyInifile.ReadInteger('Filter'+IntToStr(I),'ID',0);
VI3:= MyInifile.ReadInteger('Filter'+IntToStr(I),'Age',0);
// Edit1.Text := IntToStr(VI1)+','+IntToStr(VI2)+','+IntToStr(VI3);
FADOQ := TADOQuery.Create(nil) ;
FADOQ.Connection := ADOConnection1;
DataSource2.DataSet :=FADOQ;
DBGrid2.DataSource := DataSource2;
FSQL:= 'Select * from Test where '+FList[0]+'='+IntToStr(VI2)+ ' and '+FList[1]+'='+IntToStr(VI3);
with FADOQ do
begin
Close;
SQL.Clear ;
SQL.Add(FSQL);
Open ;
FStrTo :='';
if not IsEmpty then
begin
First;
While not Eof do
begin
F1:= IntToStr(FADOQ.FieldByName('id').AsInteger);
F2:= FADOQ.FieldByName('name').AsString;
FStrTo := 'ID: '+F1+' Name:'+F2 +#13+#10+FStrTo;
OutPutTxt := TStringList.Create;
OutPutTxt.Add(FStrTo);
Next;
end;
end;
AssignFile(FFile,ExtractFilePath(ParamStr(0))+'AA'+IntToStr(I)+'.txt');// ExtractFilePath(ParamStr(0))
try
Rewrite(FFile);
Write(FFile,OutPutTxt.Text);
finally
CloseFile(FFile);
OutPutTxt.Clear ;
end;
end;
end;
// if FADOQ <> NIL then FreeAndNil(FADOQ);
if FList <> nil then FreeAndNil(FList);
if MyInifile <> nil then FreeAndNil(MyInifile);
if OutPutTxt <> nil then FreeAndNil(OutPutTxt);
ShowMessage('导出成功!') ;
end;