有商品信息不为空时才可以输入单位和默认税率
if (currentCol=3)and(stringgrid1.Cells[2,currentRow]<>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select distinct 单位 from 商品清单 where 货号='''+stringgrid1.Cells[1,currentRow]+'''');
adoquery1.Open;
stringgrid1.Cells[3,currentRow]:=adoquery1.FieldByName('单位').AsString;
stringgrid1.Cells[8,currentRow]:='17';
end;
//--------------------当商品信息,数量,单价不为空时,才能进行计算------------------------
if (currentRow<>0)and(stringgrid1.Cells[1,currentRow]<>'')and(stringgrid1.Cells[4,currentRow]<>'')and(stringgrid1.Cells[6,currentRow]<>'')and(stringgrid1.Cells[5,currentRow]<>'') then
begin
//-----------------计算某条销售单明细的进货金额,税额和不含税额-------------------------
//-----------------------这里开始添加的代码是判断出货量的------------------------
//------------------销售商品的数量不允许大于库存中的储存数量----------------------
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select 库存数量 from 库存库 where 货号='''+stringgrid1.Cells[1,currentRow]+'''');
adoquery1.Open;
if strtoint(stringgrid1.Cells[4,currentRow])>adoquery1.FieldByName('库存数量').AsInteger then
begin
showmessage('该库中此种商品的最大储量小于您的输入,将按照最大储量出货');
stringgrid1.Cells[4,currentRow]:=adoquery1.FieldByName('库存数量').AsString;
end;
//----------计算某条销售单明细的进货金额,税额和不含税额-----------------------
number:=strtofloat(stringgrid1.Cells[4,currentRow]);
price:=strtofloat(stringgrid1.Cells[6,currentRow]);
tax:=strtofloat(stringgrid1.Cells[8,currentRow])/100;
stringgrid1.Cells[7,currentRow]:=floattostr(number*price);
stringgrid1.Cells[9,currentRow]:=floattostrf(tax*number*price/(1+tax),ffFixed ,17,2);
stringgrid1.Cells[10,currentRow]:=floattostrf(number*price/(1+tax),ffFixed ,17,2);
//----------------统计合计金额-----------------------
sum:=0;
for j:=1 to 20 do
if stringgrid1.Cells[7,j]<>'' then
sum:=sum+strtofloat(stringgrid1.Cells[7,j]);
edit4.Text:=floattostr(sum);
//----------------统计合计税额-----------------------
sum:=0;
for j:=1 to 20 do
if stringgrid1.Cells[9,j]<>'' then
sum:=sum+strtofloat(stringgrid1.Cells[9,j]);
edit6.Text:=floattostr(sum);
//----------------统计合计不含税额-----------------------
sum:=0;
for j:=1 to 20 do
if stringgrid1.Cells[10,j]<>'' then
sum:=sum+strtofloat(stringgrid1.Cells[10,j]);
edit5.Text:=floattostr(sum);
end;
end;
//---------------在选取仓库条件满足时,显示仓库名下拉列表--------------
//-------------------并设置仓库名数据词典-------------------------------
procedure Toutput.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
rect:TRect;
begin
//------------------仓库名下拉列表框显示在鼠标附近-----------------
if (currentCol=5)and(stringgrid1.Cells[2,currentRow]<>'') then
begin
rect := StringGrid1.CellRect(currentCol, currentRow);
combobox3.Visible:=true;
combobox3.Left:=rect.Left ;
combobox3.Top:=StringGrid1.Top+rect.Top;
//------------------------添加数据词典-----------------------
//------------------注意和进货单的不同之处-------------------
//-------------这里是根据商品的编号来查询存有这个商品的仓库-------
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select distinct 仓库 from 库存库 where 货号='''+stringgrid1.Cells[1,currentRow]+'''');
adoquery1.Open;
combobox3.Items.Clear;
while not adoquery1.Eof do
begin
combobox3.Items.Add(adoquery1.FieldByName('仓库').AsString);
adoquery1.Next;
end;
end;
end;