我做了一个小数据库,
在删除数据的时候我想要实现以下功能,
在点删除按钮的时候,先弹出是否确定删除的对话框,
上面有是,否和取消三个按钮,当点是的时候,如果数据库中还有数据,则删除,否则弹出数据库已空的对话框,当点击否和取消的时候退出.
代码我是这么写的:
if (application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idyes) and (table1.record>0)
then
table1.delete
else if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idno
then
exit
else if if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idcancel
then
exit;
else
showmessage('表已空')
可结果并不是我所想的,
那个确定删除的对话框弹出好几次,
这是怎么回事呢?大家帮我看看,
要想实现我说的功能,
应该怎么写呢?
在删除数据的时候我想要实现以下功能,
在点删除按钮的时候,先弹出是否确定删除的对话框,
上面有是,否和取消三个按钮,当点是的时候,如果数据库中还有数据,则删除,否则弹出数据库已空的对话框,当点击否和取消的时候退出.
代码我是这么写的:
if (application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idyes) and (table1.record>0)
then
table1.delete
else if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idno
then
exit
else if if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idcancel
then
exit;
else
showmessage('表已空')
可结果并不是我所想的,
那个确定删除的对话框弹出好几次,
这是怎么回事呢?大家帮我看看,
要想实现我说的功能,
应该怎么写呢?
解决方案 »
- delphi怎样遍历form1中的所有button控件
- [Fatal Error] Project1.dpr(1): File not found: 'System.pas'如何解决?
- 在数据集中,如何精确定位一条记录---**(千万不要认为很简单)**-
- 什么地方能下载到具有和数据库绑定的Treeview控件及增强的DBGrid控件。
- 为什么我用clipboard.clear;时编译出错?
- 向各位朋友请教一个关于“权限管理”的问题!!(谢谢不吝赐教)
- 如何去掉twebbrowser右边恼人的ScrollBar ?
- 我想在数据集中查找s_zlm字段的值每一个字母等于A的记录'该怎么写代码啊?
- 如何将秒换成时间,比如 xxxxxxxxx秒换成自1900年起的时间
- Dll中的函数重载处理
- gb--big
- 怎么实现文本拖动。
then
exit
else
table1.delete;
showmessage('表已空');
case (application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation) of
idyes:
begin
if table1.recordcount>1 then
table1.delete
else
showmessage('表已空!');
exit;
end;
IDno:
exit;
idcancel:
exit;
end;呵呵,我这里没有机器,我觉得至少这个思路是比你的那个要好一点点了。
then
table1.delete
else exit;showmessage('表已空')
else if (application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idyes)
then
table1.delete
Back:Integer;
.....
Back:=application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation);
if Back=idYes then
if table1.record>0 then
table1.delete
else
showmessage('表已空');
end
else
exit;
end;
else if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idno
then
exit
else if if application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation)=idcancel
then
exit;
else
showmessage('表已空')
正确的应该是:
我想应该是这样,提醒这位老兄,写代码注意不能太乱!!!!!!!var
Back:Integer;
.....
Back:=application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation);
if Back=idYes then
if table1.record>0 then
table1.delete
else
showmessage('表已空');
end
else
exit;
end;
正确的应该是:
我想应该是这样,提醒这位老兄,写代码注意不能太乱!!!!!!!var
Back:Integer;
.....
Back:=application.messagebox('确定删除?','提示',mb_yesnocancel+mb_icominformation);
if Back=idYes then
if table1.record>0 then
table1.delete
else
showmessage('表已空')
else
exit;
抱歉!我太粗心,上面的代码中多了两个End;