unit txt;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, BusinessSkinForm, bsSkinCtrls, bsMessages, StdCtrls,
bsSkinShellCtrls, Mask, bsSkinBoxCtrls;
type
TForm_txt = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
bsSkinMessage1: TbsSkinMessage;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinCheckRadioBox3: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
bsSkinStdLabel1: TbsSkinStdLabel;
bsSkinDirectoryEdit1: TbsSkinDirectoryEdit;
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form_txt: TForm_txt;
implementation
uses main,Mydatabase;
{$R *.dfm}
{------------------------------------------------------------------------------}
//关闭窗体
{------------------------------------------------------------------------------}
procedure TForm_txt.bsSkinButton2Click(Sender: TObject);
begin
close
end;
{------------------------------------------------------------------------------}
//导出数据
{------------------------------------------------------------------------------}
procedure TForm_txt.bsSkinButton1Click(Sender: TObject);
var
txt:tstrings;
i:integer;
temp,savename:string;
begin
if bsskindirectoryedit1.Text='' then begin
bsskinmessage1.MessageDlg('请设置文件存放路径!',mtinformation,[mbok],0);
exit;
end;
{------------------------------------------------------------------------------}
if bsskincheckradiobox1.Checked =true then begin
try
temp:='';
savename:='';
savename:=bsskindirectoryedit1.Text+'\帐户信息.txt';
txt:=tstringlist.Create ;
for i:=0 to datamodule1.ADOTable1.FieldCount-1 do
temp:=temp+ datamodule1.ADOTable1.Fields[i].FieldName +#9; //读取字段名
txt.Add(temp);
txt.Add('');
temp:='';
datamodule1.ADOTable1.First ;
while not datamodule1.ADOTable1.Eof do begin
for i:=0 to datamodule1.ADOTable1.FieldCount -1 do
temp:=temp+ datamodule1.ADOTable1.Fields[i].AsString +#9;
txt.Add(temp);
temp:='';
datamodule1.ADOTable1.Next ;
end;
txt.SaveToFile(savename);
finally
txt.Clear ;
txt.Destroy ;
end
end;
{------------------------------------------------------------------------------}
if bsskincheckradiobox2.Checked =true then begin
try
temp:='';
savename:='';
savename:=bsskindirectoryedit1.Text+'\出帐信息.txt';
txt:=tstringlist.Create ;
for i:=0 to datamodule1.ADOTable2.FieldCount-1 do
temp:=temp+ datamodule1.ADOTable2.Fields[i].FieldName +#9; //读取字段名
txt.Add(temp);
txt.Add('');
temp:='';
datamodule1.ADOTable2.First ;
while not datamodule1.ADOTable2.Eof do begin
for i:=0 to datamodule1.ADOTable2.FieldCount-1 do
temp:=temp+ datamodule1.ADOTable2.Fields[i].AsString +#9;
txt.Add(temp);
temp:='';
datamodule1.ADOTable2.Next ;
end;
txt.SaveToFile(savename);
finally
txt.Clear ;
txt.Destroy ;
end;
end;
{------------------------------------------------------------------------------}
if bsskincheckradiobox3.Checked =true then begin
try
temp:='';
savename:='';
savename:=bsskindirectoryedit1.Text+'\入帐信息.txt';
txt:=tstringlist.Create ;
for i:=0 to datamodule1.ADOTable3.FieldCount-1 do
temp:=temp+ datamodule1.ADOTable3.Fields[i].FieldName +#9; //读取字段名
txt.Add(temp);
txt.Add('');
temp:='';
datamodule1.ADOTable3.First ;
while not datamodule1.ADOTable3.Eof do begin
for i:=0 to datamodule1.ADOTable3.FieldCount -1 do
temp:=temp+ datamodule1.ADOTable3.Fields[i].AsString +#9;
txt.Add(temp);
temp:='';
datamodule1.ADOTable3.Next ;
end;
txt.SaveToFile(savename);
finally
txt.Clear ;
txt.Destroy ;
temp:='';
savename:='';
end;
end;
{------------------------------------------------------------------------------}
bsskinmessage1.MessageDlg('文件导出完毕!'+#13+bsskindirectoryedit1.Text,mtinformation,[mbok],0);
close;
end;
end.