W
windlee
Unregistered / Unconfirmed
GUEST, unregistred user!
我是用delphi7+access2000写的一个库存系统,在月结盘点时,出问题,用sum统计出来的当月入库数和当月出库数,想保存到pandian这个表里,但是运行了之后,当月没入库或没出库的物品都不是等于0,而且是数字是乱填入的。
代码如下,初学者写得很乱,不好意思:
var
c1,c2,str1,str2:string;
begin
if (trim(combobox1.text)<>'') or (trim(combobox2.Text)<>'') then
begin
str1:=combobox1.Text+'-'+combobox2.Text+'-01';
str2:=combobox1.Text+'-'+inttostr(strtoint(combobox2.Text)+1)+'-01';
with adoquery3 do
begin
adoquery3.Close;
adoquery3.SQL.Clear;
adoquery3.SQL.add('select code,sum(count) as c1 from income where day>d and day<:nd group by code');
adoquery3.parameters.parambyname('pd').value:=strtodate(str1);
adoquery3.parameters.parambyname('nd').value:=strtodate(str2);
adoquery3.Open;
adoquery3.First;
if adoquery3.fieldbyname('c1').AsString='' then
c1:='0'
else c1:=adoquery3.fieldbyname('c1').AsString;
with adoquery4 do
begin
adoquery4.close;
adoquery4.sql.clear;
adoquery4.SQL.add('select code,sum(count) as c2 from outcome where day>d and day<:nd group by code');
adoquery4.parameters.parambyname('pd').value:=strtodate(str1);
adoquery4.parameters.parambyname('nd').value:=strtodate(str2);
adoquery4.Open;
adoquery4.First;
if adoquery4.fieldbyname('c2').asstring='' then
c2:='0'
else c2:=adoquery4.Fieldbyname('c2').AsString;
adoquery1.close;
adoquery2.Close;
adoquery1.SQL.Clear;
adoquery2.SQL.clear;
ADOQuery1.SQL.Text:='select * from pandian';
adoquery2.sql.Text:='select * from store';
adoquery1.Open;
adoquery2.Open;
adoquery2.First;
while not adoquery2.Eof do
begin
adoquery1.Edit;
adoquery1.Append;
adoquery1.FieldByName('code').AsString:=adoquery2.fieldbyname('code').AsString;
adoquery1.FieldByName('name').AsString:=adoquery2.fieldbyname('name').AsString;
adoquery1.FieldByName('type').AsString:=adoquery2.fieldbyname('type').AsString;
adoquery1.FieldByName('qms').ascurrency:=adoquery2.fieldbyname('count').ascurrency;
adoquery1.FieldByName('qcs').ascurrency:=adoquery1.fieldbyname('qms').ascurrency;
adoquery1.FieldByName('day').AsDateTime:=date();
adoquery1.FieldByName('rks').ascurrency:=adoquery3.FieldByName('c1').ascurrency;
adoquery1.FieldByName('cks').ascurrency:=adoquery4.FieldByName('c2').ascurrency;
adoquery1.Post;
adoquery3.Next;
adoquery4.Next;
adoquery2.Next;
adoquery1.Next;
end;
messagebox(handle,'月结完成!','提示',mb_iconinformation);
end;
end;
end;
end;
end.
代码如下,初学者写得很乱,不好意思:
var
c1,c2,str1,str2:string;
begin
if (trim(combobox1.text)<>'') or (trim(combobox2.Text)<>'') then
begin
str1:=combobox1.Text+'-'+combobox2.Text+'-01';
str2:=combobox1.Text+'-'+inttostr(strtoint(combobox2.Text)+1)+'-01';
with adoquery3 do
begin
adoquery3.Close;
adoquery3.SQL.Clear;
adoquery3.SQL.add('select code,sum(count) as c1 from income where day>d and day<:nd group by code');
adoquery3.parameters.parambyname('pd').value:=strtodate(str1);
adoquery3.parameters.parambyname('nd').value:=strtodate(str2);
adoquery3.Open;
adoquery3.First;
if adoquery3.fieldbyname('c1').AsString='' then
c1:='0'
else c1:=adoquery3.fieldbyname('c1').AsString;
with adoquery4 do
begin
adoquery4.close;
adoquery4.sql.clear;
adoquery4.SQL.add('select code,sum(count) as c2 from outcome where day>d and day<:nd group by code');
adoquery4.parameters.parambyname('pd').value:=strtodate(str1);
adoquery4.parameters.parambyname('nd').value:=strtodate(str2);
adoquery4.Open;
adoquery4.First;
if adoquery4.fieldbyname('c2').asstring='' then
c2:='0'
else c2:=adoquery4.Fieldbyname('c2').AsString;
adoquery1.close;
adoquery2.Close;
adoquery1.SQL.Clear;
adoquery2.SQL.clear;
ADOQuery1.SQL.Text:='select * from pandian';
adoquery2.sql.Text:='select * from store';
adoquery1.Open;
adoquery2.Open;
adoquery2.First;
while not adoquery2.Eof do
begin
adoquery1.Edit;
adoquery1.Append;
adoquery1.FieldByName('code').AsString:=adoquery2.fieldbyname('code').AsString;
adoquery1.FieldByName('name').AsString:=adoquery2.fieldbyname('name').AsString;
adoquery1.FieldByName('type').AsString:=adoquery2.fieldbyname('type').AsString;
adoquery1.FieldByName('qms').ascurrency:=adoquery2.fieldbyname('count').ascurrency;
adoquery1.FieldByName('qcs').ascurrency:=adoquery1.fieldbyname('qms').ascurrency;
adoquery1.FieldByName('day').AsDateTime:=date();
adoquery1.FieldByName('rks').ascurrency:=adoquery3.FieldByName('c1').ascurrency;
adoquery1.FieldByName('cks').ascurrency:=adoquery4.FieldByName('c2').ascurrency;
adoquery1.Post;
adoquery3.Next;
adoquery4.Next;
adoquery2.Next;
adoquery1.Next;
end;
messagebox(handle,'月结完成!','提示',mb_iconinformation);
end;
end;
end;
end;
end.