📄 fxswldz.pas
字号:
unit Fxswldz;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Fbase, DB, ADODB, Grids, ExtCtrls, Buttons, ToolWin, ComCtrls;
type
TF_xswldz = class(TF_base)
StringGrid1: TStringGrid;
ADOQuery1: TADOQuery;
ADOQuery2: TADOQuery;
Panel1: TPanel;
procedure FormShow(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
F_xswldz: TF_xswldz;
implementation
uses Fdm, Fygysdz, Fyxssdz;
{$R *.dfm}
procedure TF_xswldz.FormShow(Sender: TObject);
var
grow,xh,hs:integer;
hj,jhgrow,bh:integer;
fy:real;
begin
inherited;
fy:=0;
panel1.Caption:='往来单位:'+F_yxssdz.ADOQuery1.Fields[1].AsString;
with stringgrid1 do
begin
cells[1,0]:='日期';
cells[2,0]:='编号';
cells[3,0]:='摘要';
cells[4,0]:='应收增加';
cells[5,0]:='应收减少';
cells[6,0]:='应收余额';
end;
with Adoquery1 do //查找符合条件的记录
begin
Close;
SQL.Clear;
SQL.Add('select billdate,billcode,summary,addgathering,reducegathering,balance');
SQL.Add(' from tb_currentaccount where ');
SQL.Add(' units='+''''+F_yxssdz.ADOQuery1.Fields[1].AsString+''''+'and');
SQL.Add(' billdate>='+''''+datetostr(F_yxssdz.DateTimePicker1.Date)+''''+'and');
SQL.Add(' billdate<='+''''+datetostr(F_yxssdz.DateTimePicker2.Date)+''''+' order by billcode');
Open;
end;
if Adoquery1.RecordCount=0 then
begin
Application.MessageBox('此段时间无往来记录','提示',mb_ok);
close;
end;
Adoquery1.First;
hs:=1;
xh:=1;
bh:=0;
with stringgrid1 do
begin
for grow:=1 to adoquery1.RecordCount do
begin
with Adoquery2 do //根据表单编号查找进货详细记录
begin
Close;
SQL.Clear;
SQL.Add('select billcode,qty*price,qty,price,fullname as tt from tb_warehouse_detailed where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,xh]:=adoquery1.Fields[0].Value;
for jhgrow:=xh to xh+adoquery2.RecordCount-1 do //查找进货详单数据
begin
cells[2,jhgrow]:=adoquery2.Fields[0].Value;
cells[3,jhgrow]:='进货:'+Adoquery2.Fields[4].AsString+''+floattostr(Adoquery2.Fields[2].Value)+'*'+floattostr(Adoquery2.Fields[3].Value) ;
cells[5,jhgrow]:=floattostr(Adoquery2.Fields[1].Value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
with Adoquery2 do //根据表单编号查找进货付款金额
begin
Close;
SQL.Clear;
SQL.Add('select payment from tb_warehouse_main where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
cells[3,hs]:='付款:现 金';
cells[4,hs]:=floattostr(Adoquery2.Fields[0].value);
hs:=hs+1;
xh:=hs;
end;
with Adoquery2 do //根据表单编号查找进货退货详细记录
begin
Close;
SQL.Clear;
SQL.Add('select billcode,qty*price,qty,price,fullname as tt from tb_rewarehouse_detailed where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,hs]:=adoquery1.Fields[0].Value;
for jhgrow:=hs to hs+adoquery2.RecordCount-1 do //查找进货退货详单数据
begin
cells[2,jhgrow]:=adoquery2.Fields[0].Value;
cells[3,jhgrow]:='进货退货:'+Adoquery2.Fields[4].AsString+''+floattostr(Adoquery2.Fields[2].Value)+'*'+floattostr(Adoquery2.Fields[3].Value) ;
cells[4,jhgrow]:=floattostr(Adoquery2.Fields[1].Value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
xh:=hs;
with Adoquery2 do //根据表单编号查找收款金额
begin
Close;
SQL.Clear;
SQL.Add('select gathering from tb_rewarehouse_main where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
cells[3,xh]:='收款:现 金';
cells[5,xh]:=floattostr(Adoquery2.Fields[0].value);
hs:=hs+1;
xh:=hs;
end;
/////////////////////////////////////////////////////////////////////
with Adoquery2 do //根据表单编号查找销售详细记录
begin
Close;
SQL.Clear;
SQL.Add('select billcode,qty*price,qty,price,fullname as tt from tb_sell_detailed where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,xh]:=adoquery1.Fields[0].Value;
for jhgrow:=xh to xh+adoquery2.RecordCount-1 do //查找销售详单数据
begin
cells[2,jhgrow]:=adoquery2.Fields[0].Value;
cells[3,jhgrow]:='销售:'+Adoquery2.Fields[4].AsString+''+floattostr(Adoquery2.Fields[2].Value)+'*'+floattostr(Adoquery2.Fields[3].Value) ;
cells[4,jhgrow]:=floattostr(Adoquery2.Fields[1].Value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
with Adoquery2 do //根据表单编号查找销售收款金额
begin
Close;
SQL.Clear;
SQL.Add('select gathering from tb_sell_main where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
cells[3,hs]:='收款:现 金';
cells[5,hs]:=floattostr(Adoquery2.Fields[0].value);
hs:=hs+1;
xh:=hs;
end;
with Adoquery2 do //根据表单编号查找销售退货详细记录
begin
Close;
SQL.Clear;
SQL.Add('select billcode,qty*price,qty,price,fullname as tt from tb_resell_detailed where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,hs]:=adoquery1.Fields[0].Value;
for jhgrow:=hs to hs+adoquery2.RecordCount-1 do //查找销售退货详单数据
begin
cells[2,jhgrow]:=adoquery2.Fields[0].Value;
cells[3,jhgrow]:='销售退货:'+Adoquery2.Fields[4].AsString+''+floattostr(Adoquery2.Fields[2].Value)+'*'+floattostr(Adoquery2.Fields[3].Value) ;
cells[5,jhgrow]:=floattostr(Adoquery2.Fields[1].Value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
xh:=hs;
with Adoquery2 do //根据表单编号查找销售退货付款金额
begin
Close;
SQL.Clear;
SQL.Add('select payment from tb_resell_main where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
cells[3,xh]:='付款:现 金';
cells[4,xh]:=floattostr(Adoquery2.Fields[0].value);
hs:=hs+1;
xh:=hs;
end;
//收款单记录
with Adoquery2 do //根据表单编号查找收款详细记录
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_gathering where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,hs]:=adoquery1.Fields[0].Value;
for jhgrow:=hs to hs+adoquery2.RecordCount-1 do //查找收款金额
begin
cells[2,jhgrow]:=adoquery2.Fields[1].Value;
cells[3,jhgrow]:='收款:现金';
cells[4,jhgrow]:=floattostr(Adoquery2.Fields[3].value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
xh:=hs;
end;
//付款
with Adoquery2 do //根据表单编号查找付款详细记录
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_payment where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,hs]:=adoquery1.Fields[0].Value;
for jhgrow:=hs to hs+adoquery2.RecordCount-1 do
begin
cells[2,jhgrow]:=adoquery2.Fields[1].Value;
cells[3,jhgrow]:='付款:现金';
cells[5,jhgrow]:=floattostr(Adoquery2.Fields[3].value);
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
xh:=hs;
end;
//一般费用
with Adoquery2 do //根据表单编号查找一般费用详细记录
begin
Close;
SQL.Clear;
SQL.Add('select * from tb_cf where billcode='+''''+Adoquery1.Fields[1].Value+'''');
Open;
end;
if adoquery2.RecordCount<>0 then
begin
inc(bh);
Cells[0,xh]:=inttostr(bh); //标记记录个数
cells[1,xh]:=adoquery1.Fields[0].Value;
for jhgrow:=xh to xh+adoquery2.RecordCount-1 do //查找一般费用详单数据
begin
cells[2,jhgrow]:=adoquery2.Fields[1].Value;
cells[3,jhgrow]:='费用:'+Adoquery2.Fields[4].AsString ;
cells[5,jhgrow]:=floattostr(Adoquery2.Fields[6].Value);
fy:=Adoquery2.Fields[7].Value;
Adoquery2.Next;
end;
hs:=hs+adoquery2.RecordCount;
xh:=hs;
cells[3,xh]:='付款一般费用:现金';
cells[4,xh]:=floattostr(fy);
hs:=hs+1;
xh:=hs;
end;
Adoquery1.Next;
end;
rowcount:=xh+1;
if cells[4,1]<>'' then
cells[6,1]:=cells[4,1]
else
cells[6,1]:='-'+cells[5,1];
for hj:=2 to xh-1 do
begin
if cells[4,hj]<>'' then
cells[6,hj]:=floattostr(strtofloat(cells[4,hj])+strtofloat(cells[6,hj-1]))
else
cells[6,hj]:=floattostr(strtofloat('-'+cells[5,hj])+strtofloat(cells[6,hj-1]));
end;
end;
end;
procedure TF_xswldz.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
inherited;
if Application.MessageBox('是否退出?','提示',mb_yesno)=Id_no then
Canclose:=False;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -