我刚完成的源代码,绝对好用,没出任何错误!
procedure TForm3.FlatButton2Click(Sender: TObject);
begin
query1.edit;
query1.post;
query1.first;
while Not query1.Eof do
begin
if query5.locate('品名',query1.Fieldbyname('品名').Asstring,[]) then
begin
query5.edit;
query5.FieldValues['shu']:= query5.FieldValues['shu']+query1.FieldValues['shu'];
query5.Post;
query1.Next;
end;
if not query5.locate('品名',query1.Fieldbyname('品名').Asstring,[]) then
begin
query5.insert;
query5.Fieldbyname('品名').value:=query1.Fieldbyname('品名').value;
query5.FieldValues['shu']:=query1.FieldValues['shu'];
query1.Next;
end;
end; //收货单数据提交库存表,有则数值相加,无则增加记录。
if edit6.text<>label30.caption then
begin
query8.insert;
query8.FieldByName('单号').value:=edit1.text;
query8.fieldbyname('ying').asstring:=label30.caption;
query8.fieldbyname('shi').asstring:=edit6.Text;
query8.fieldbyname('类型').value:='未付款项';
query8.fieldbyname('期限').value:=datetimepicker7.date;
query8.fieldbyname('客户名').value:=dblookupcombobox2.Text;
query8.post;
edit6.text:='';
end;
query1.sql.clear;
end;