procedure TZZS_ZY_PT_FPSYMX.Button1Click(Sender: TObject);
var
FRMFP:TFRM_FPSYBB;
strDySj,VG_Cnq,BN,EN:string;
i,rc:integer;
scale,cess:double;
RParam: TBizParam;
RBizURL: TBizURL;
RContextCurrent:TContextCurrent;
begin
if time1.Date>time2.Date then
begin
Dialogs.ShowMessage('日期出错!');
time1.SetFocus;
exit;
end;
RBizURL := TBizURL.Create;
RContextCurrent := TContextCurrent.Create(self.Context);
try
RBizURL.URL:='Biz:\BTSFXT\DICT\BTSFGGCSZ.ParamGroup\DQCNQ.param';
RParam := RContextCurrent.GetParam(RBizURL);
VG_Cnq:=Variants.VarToStr(RParam.Value);
finally
RBizURL.Free;
RContextCurrent.Free;
end;
with querytemp do
begin
close;
commandtext:='';
commandtext:='Select CSZ FROM SF_CS_t WHERE CNQ = ''' + VG_CNQ + ''' AND CSMC = ''价税合计''';
open;
end;
scale:=querytemp.fieldbyname('csz').AsFloat;
with querytemp do
begin
close;
commandtext:='';
commandtext:='Select CSZ FROM SF_CS_t WHERE CNQ = ''' + VG_CNQ + ''' AND CSMC = ''税率''';
open;
end;
cess:=querytemp.fieldbyname('csz').AsFloat;
with query1 do
begin
for i:=0 to params.Count-1 do
begin
if params.Items.Name = 'czy' then
begin
params.Items.DataType :=TFieldType.ftString;
if length(ComboBox_czy.Text) = 0 then
params.Items.Value := '%'
else
params.Items.Value := ComboBox_czy.Text;
Continue;
end;
if params.Items.Name = 'scale' then
begin
params.Items.DataType := TFieldType.ftfloat;
params.Items.Value := scale;
Continue;
end;
if params.Items.Name = 'cess' then
begin
params.Items.DataType := TFieldType.ftfloat;
params.Items.Value :=cess;
Continue;
end;
if params.Items.Name = 'begindate' then
begin
params.Items.DataType := TFieldType.ftdate;
params.Items.Value := time1.Date;
Continue;
end;
if params.Items.Name = 'enddate' then
begin
params.Items.DataType := TFieldType.ftdate;
params.Items.Value := time2.Date;
Continue;
end;
end;
close;
open;
BN:=query1.FieldByName('B').asstring;
EN:=query1.FieldByName('E').asstring;
end;
try
FRMFP:=TFRM_FPSYBB.Create(self.Context);
with FRMFP.InfoBrokerYWXX_FPSYBB.Info.DataSets.Find('FPSYBB') do
begin
for i := 0 to params.Count - 1 do
begin
if params.Items.Name = 'fgs' then
begin
params.Items.DataType := Tfieldtype.ftstring;
params.Items.Value:=trim(combobox1.Text)+'%';
Continue;
end;
if params.Items.Name = 'czy' then
begin
params.Items.DataType := Tfieldtype.ftString;
params.Items.Value := ComboBox_czy.Text+'%';
Continue;
end;
if params.Items.Name = 'scale' then
begin
params.Items.DataType := Tfieldtype.ftfloat;
params.Items.Value := scale;
Continue;
end;
if params.Items.Name = 'cess' then
begin
params.Items.DataType := Tfieldtype.ftfloat;
params.Items.Value := cess;
Continue;
end;
if params.Items.Name = 'begindate' then
begin
params.Items.DataType := Tfieldtype.ftDate;
params.Items.Value :=time1.Date;
Continue;
end;
if params.Items.Name = 'enddate' then
begin
params.Items.DataType := Tfieldtype.ftDate;
params.Items.Value :=time2.Date;
Continue;
end;
end;
try
close;
Open;
except
Dialogs.showmessage('查询失败,请检查增值税发票使用明细查询');
exit;
end;
rc := recordcount;
if rc = 0 then
begin
Forms.Application.MessageBox( '没有查询数据,请重新选择时间', '提示信息', 0);
exit;
end;
end;
Business.Model.TSheetDoc(FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc).Sheet.Values[2,1]:=FormatDateTime('yyyy-mm-dd',time1.Date)+'~'+Formatdatetime('yyyy-mm-dd',time2.Date)+'增值税(专用、普通)发票使用明细';
strDySj:=FormatDateTime('yyyymmdd hh:mm:ss',now);
Business.Model.TSheetDoc(FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc).Sheet.Values[2,2]:='打印日期:'+copy(strDysj,1,4)+'年'+copy(strDysj,5,2)+'月'+copy(strDysj,7,2)+'日'+copy(strDysj,10,8);
Business.Model.TSheetDoc(FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc).Sheet.Values[2,3]:='纳税人名称:'+ComboBox_taxpayer.text;
Business.Model.TSheetDoc(FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc).Sheet.Values[6,3]:='纳税登记号:'+ComboBox_code.text;
Business.Model.TSheetDoc(FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc).Sheet.Values[8,3]:='发票启止号码:'+BN+'~'+EN;
FRMFP.DocViewYWXX_FPSYBB_FPSY.Doc.Close;
FRMFP.DocViewYWXX_FPSYBB_FPSY.OpenView(TDocMode.dmView);
FRMFP.showmodal;
finally
FRMFP.free;
end;
end; |