procedure Twh_kfbm.DBGrid1ColExit(Sender: TObject);
var
sp : string ;
i : integer ;
begin
if (DBGrid1.SelectedIndex =0) then
begin
if trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) = '' then
begin
application.MessageBox('库房编码不能为空!' , '系统提示:',48) ;
abort;
end
else begin
//判断库房编号是否已经加过的了
whdata.kfbm_temp.Edit ;
whdata.kfbm_temp.Post ;
whdata.kfbm_temp.Edit ;
sp := trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) ;
i := 0 ;
if whdata.kfbm_temp.RecNo <> -1 then
i := whdata.kfbm_temp.RecNo ;
whdata.kfbm_temp.DisableControls ;
whdata.kfbm_temp.First ;
while not (whdata.kfbm_temp.Eof) do
begin
if (trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) = sp) and (whdata.kfbm_temp.RecNo <> i) then
begin
application.MessageBox('已经有相同的商品编号,请重新输入!','系统提示:',48) ;
abort;
end ;
whdata.kfbm_temp.Next ; end ;
whdata.kfbm_temp.EnableControls ; if i <> 0 then
whdata.kfbm_temp.RecNo := i
else
whdata.kfbm_temp.Last ;
end ;
whdata.kfbm_temp.Edit;
end
else if (DBGrid1.SelectedIndex =1) then
begin
if trim(whdata.kfbm_temp.FieldByName('whouse_name').AsString) = ''then
begin
application.MessageBox('该记录没有输入库房名称,请补入!!' , '系统提示:',48) ;
abort ;
end;
end;
end;
不知怎的,每次运行有重复编码时,想修改这个重复编码,总是出现这样一个错误:数据集不在编辑或插入模式。我试着把这个语句加入程序里(dbgrid1.datasource.dataset.edit),但总是不成功。希望大家能帮我看一下,应该加到哪个位置。谢谢你们了。
var
sp : string ;
i : integer ;
begin
if (DBGrid1.SelectedIndex =0) then
begin
if trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) = '' then
begin
application.MessageBox('库房编码不能为空!' , '系统提示:',48) ;
abort;
end
else begin
//判断库房编号是否已经加过的了
whdata.kfbm_temp.Edit ;
whdata.kfbm_temp.Post ;
whdata.kfbm_temp.Edit ;
sp := trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) ;
i := 0 ;
if whdata.kfbm_temp.RecNo <> -1 then
i := whdata.kfbm_temp.RecNo ;
whdata.kfbm_temp.DisableControls ;
whdata.kfbm_temp.First ;
while not (whdata.kfbm_temp.Eof) do
begin
if (trim(whdata.kfbm_temp.FieldByName('whouse_no').AsString) = sp) and (whdata.kfbm_temp.RecNo <> i) then
begin
application.MessageBox('已经有相同的商品编号,请重新输入!','系统提示:',48) ;
abort;
end ;
whdata.kfbm_temp.Next ; end ;
whdata.kfbm_temp.EnableControls ; if i <> 0 then
whdata.kfbm_temp.RecNo := i
else
whdata.kfbm_temp.Last ;
end ;
whdata.kfbm_temp.Edit;
end
else if (DBGrid1.SelectedIndex =1) then
begin
if trim(whdata.kfbm_temp.FieldByName('whouse_name').AsString) = ''then
begin
application.MessageBox('该记录没有输入库房名称,请补入!!' , '系统提示:',48) ;
abort ;
end;
end;
end;
不知怎的,每次运行有重复编码时,想修改这个重复编码,总是出现这样一个错误:数据集不在编辑或插入模式。我试着把这个语句加入程序里(dbgrid1.datasource.dataset.edit),但总是不成功。希望大家能帮我看一下,应该加到哪个位置。谢谢你们了。
解决方案 »
- RadioButton事件
- mdichild的窗体可否showmodule另外一个窗体?
- 向高手营救.我做了一个程序是在网格里面输入数据出错.请帮我指点.100分酬谢
- 动态链接库
- 怎么根据一个ACCESS数据库中的一表创建一个DBF表,并把数据放到新表中?
- 在程序中用到exit,出现了想不到的错误“[Error] ctxs.pas(170): '.' expected but ';' found”,代码如下
- 如何取出数据库中所有表名?
- 用mediaplay控件播放一个avi,mpg文件,如何才能不在新窗口中打开
- 又送分罗!!!
- 请问做出象outlook左边那种象下拉菜单的那种可以翻页的东西是什么控件啊?
- 求教,关于socket!up者有分!
- 请给出错误提示
if dbgrid1.datasource.dataset.state= dsedit then
dbgrid1.datasource.dataset.edit;