比如你在edit1中输入,使用ADOQuery1连接的数据库,假设该字段为字符串,库存报警底线为5; tmp:=ADOQuery1.FieldByName('数量').AsString; if (StrToInt(edit1.text)-StrToInt(tmp))〈 5 then ShowMessage('库存不足!');
读出库存之后,进行判断呀。 if 输入库存量>100 then showmessage('库存不足!') else ……
首先应感谢大家!现本人已经解决。 var m:string; begin m:=ck.label12.Caption; with data.ADOQuery3 do begin if data.ADOQuery3.FieldByName('ywbm').AsString=(m) then begin if data.ADOQuery3.FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then begin showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!'); edit1.Clear; edit2.Clear; edit4.Clear; edit1.SetFocus; end else
var m:string; begin m:=ck.label12.Caption; with data.ADOQuery3 do begin if data.ADOQuery3.FieldByName('ywbm').AsString=(m) then begin if data.ADOQuery3.FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then begin showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!'); edit1.Clear; edit2.Clear; edit4.Clear; edit1.SetFocus; end else 这条语句为什么只能判断库中的一个编码对应的数量。其它的为什么不能判断。
得到库存量:select count(*) from 库存表 if 库存量<输入量 then 库存量不够
比如你在edit1中输入,加一个querey1 with query1 with query1 do begin if FieldByName('ywbm').AsString=(m) then begin if FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then begin showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!'); end else begin .... end;
为什么不放在后台处理,触发器中实现 if 库存<0 then 提示错误信息 end if
本人已成功解决这个问题 if data.ADOQuery3.FieldByName('ywbm').AsString=data.adoquery1.fieldbyname('ywbm').asstring; then
tmp:=ADOQuery1.FieldByName('数量').AsString;
if (StrToInt(edit1.text)-StrToInt(tmp))〈 5 then
ShowMessage('库存不足!');
if 输入库存量>100 then
showmessage('库存不足!')
else
……
有三个表,入库表、出库表、库存表。
库存表有:数量(100)件
出库时输入101件时判断库存不足。
帮朋友做的小软件就这个问题了,答对者另加100分对不起问题没有说明清楚,请原谅!
应该是在出库时输入edit1.text后判断库存中某一种编码的零件是否够,如不够则提示库存不足。
出库表字段:编码号、件数 库存表字段:编码号、件数
var m:string;
begin
m:=ck.label12.Caption;
with data.ADOQuery3 do
begin
if data.ADOQuery3.FieldByName('ywbm').AsString=(m) then
begin
if data.ADOQuery3.FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then
begin
showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!');
edit1.Clear;
edit2.Clear;
edit4.Clear;
edit1.SetFocus;
end
else
begin
m:=ck.label12.Caption;
with data.ADOQuery3 do
begin
if data.ADOQuery3.FieldByName('ywbm').AsString=(m) then
begin
if data.ADOQuery3.FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then
begin
showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!');
edit1.Clear;
edit2.Clear;
edit4.Clear;
edit1.SetFocus;
end
else
这条语句为什么只能判断库中的一个编码对应的数量。其它的为什么不能判断。
得到库存量:select count(*) from 库存表
if 库存量<输入量 then
库存量不够
with query1
with query1 do
begin
if FieldByName('ywbm').AsString=(m) then
begin
if FieldByName('sl').AsInteger<strtofloat(ck.Edit1.Text) then
begin
showmessage('你现在库里还有:'+data.ADOQuery3.fieldbyname('sl').AsString+'张卡,请重新输入!');
end
else
begin
....
end;
if 库存<0 then 提示错误信息 end if
if data.ADOQuery3.FieldByName('ywbm').AsString=data.adoquery1.fieldbyname('ywbm').asstring; then