源程序窗体中按保存按扭过程代码如下:
{table5:出货记录库}
{table3:主仓库}
{table4:分仓库}
{功能:将出货情况记录到出货记录中;从主仓库去掉出货,分仓库增加出货}
{修改table5时没问题,修改table4时出错}
procedure Tckdj.Button1Click(Sender: TObject);
begin
//修改出货记录
table5.Active :=true;
table5.Append;
table5.FieldByName('单据编号').AsString:=edit1.text;
table5.FieldByName('商场专柜').AsString:=ComboBox1.Items[ComboBox1.ItemIndex];
table5.FieldByName('出货日期').AsDatetime:=datetimepicker1.Date;
table5.FieldByName('货号').AsString:=huohao;
table5.FieldByName('颜色').AsString:=yanse;
table5.FieldByName('单价').AsInteger:=strtoint(edit3.text);
jine:=strtoint(edit3.text)*strtoint(edit4.text);
Table5.FieldByName('金额').AsInteger:=jine;
table5.FieldByName('数量').AsInteger:=strtoint(edit4.text);
table5.Post ;
table5.active:=false;
//修改分仓库库存
table4.Active :=false;
table4.tablename:='zgkc';
table4.Active :=true;
table4.Edit;
if table4.Locate('商场专柜;货号;颜色',VarArrayof([zhuangui,huohao,yanse]),[]) then
begin
ysl:=table4.fieldbyname('数量').Asinteger;
yjine:=Table4.FieldByName('金额').AsInteger;
Table4.FieldByName('数量').Asinteger:=ysl+strtoint(edit4.text);
Table4.FieldByName('金额').AsInteger:=yjine+jine;
end
else
begin
table4.Append;
table4.FieldByName('商场专柜').AsString:=zhuangui;
table4.FieldByName('进货日期').AsDatetime:=datetimepicker1.Date;
table4.FieldByName('货号').AsString:=huohao;
table4.FieldByName('单价').AsInteger:=strtoint(edit3.text);
table4.FieldByName('颜色').AsString:=yanse;
table4.FieldByName('数量').AsInteger:=strtoint(edit4.text);
Table4.FieldByName('金额').AsInteger:=jine;
end;
if table4.State=dsEdit then table4.Post;
// table4.Post ;
table4.active:=false;
//修改总仓库
table3.active:=false;
table3.tablename:='kck';
table3.active:=true;
if table3.locate('货号;颜色',VarArrayof([huohao,yanse]),[]) then
begin
ysl:=table3.FieldByName('数量').AsInteger;
ysl:=ysl-strtoint(edit4.text);
if ysl=0 then
Table3.Delete
else
table3.FieldByName('数量').AsInteger:=ysl;
table3.Post ;
end;
Table3.active:=false;
Table3.Active:=true;
//为下一输入记录置空
ComboBox3.text:='';
ComboBox4.text:='';
edit3.text:='';
edit4.text:='';
edit5.Text:='0';
end;