当前位置: 代码迷 >> PB >> 求解,关于检查数据窗口的输入的数据是否重复解决办法
  详细解决方案

求解,关于检查数据窗口的输入的数据是否重复解决办法

热度:87   发布时间:2016-04-29 08:57:59.0
求解,关于检查数据窗口的输入的数据是否重复
在窗口w_sfzhm中

有一数据窗口DW_1,里有其中一个编辑框
字段为 sfzhm

在哪个对象,哪个事件中写
:当输入的身份证号码回车后跳转到下个输入框之前,如何判断是否已经在表t_info(id,name,sex,sfzhm,phone)
中,如果表有记录则提示"身份证号码已经重复"

------解决方案--------------------
二楼,它说是在表中,而不是在dw中
itemchanged事里面 
if string(dwo.name)='sfzhm' and len(data)>0 then 
select count(*) into : li_row from t_info where sfzhm=:data
if li_row>0 then 
//li_row指定行有,可以用返回值,来控制对其是否再作编辑
 
end if 
end if
------解决方案--------------------
呵呵,走眼了,
不过你的程序还有个BUG,如果是是一个人修改的时候有时候会出错,
应该改为
itemchanged事里面 
string ls_id
if string(dwo.name)='sfzhm' and len(data)>0 then 
ls_id = this.getitemstring(1,'id')//假定id为关键字,且为字符型
if isnull(ls_id) then ls_id=''
select count(*) into : li_row from t_info where sfzhm=:data and id<>:ls_id
if li_row>0 then 
//li_row指定行有,可以用返回值,来控制对其是否再作编辑 

end if 
end if
  相关解决方案