社区
PowerBuilder
帖子详情
新手请教数据窗口添加按钮的代码?
richgod
2007-12-16 04:14:12
新建了一个以GRID形式的数据窗口DW_1,一个窗口WIN1,把DW_1拖放到WIN1中,WIN1中有“添加”按钮,编写添加按钮代码:dw_1.insertrow(0),可是不能编辑,不知道是什么原因?另请教一下保存,修改,及查找按钮该如何写呢?新手刚学,不知道如何下手,多谢了
...全文
517
11
打赏
收藏
新手请教数据窗口添加按钮的代码?
新建了一个以GRID形式的数据窗口DW_1,一个窗口WIN1,把DW_1拖放到WIN1中,WIN1中有“添加”按钮,编写添加按钮代码:dw_1.insertrow(0),可是不能编辑,不知道是什么原因?另请教一下保存,修改,及查找按钮该如何写呢?新手刚学,不知道如何下手,多谢了
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
11 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
qq49628637
2011-01-20
打赏
举报
回复
database transaction information not availabla
liaomingyan520
2007-12-18
打赏
举报
回复
connect using sqlca;
if sqlca.sqlcode=0 then
open(w_login)
else
messagebox("prompt!!",sqlca.sqlerrtext)
end if
richgod
2007-12-18
打赏
举报
回复
已经写了,再一次提示“Database transaction information not available,
Call SetTrans or SetTransObject function. ”这样的语句呢?
dawugui
2007-12-17
打赏
举报
回复
没写
dw_1.Settransobject(sqlca)
dw_1.Retrieve()
richgod
2007-12-17
打赏
举报
回复
再一次请教一下,出现“database transaction information not available”这样的提示信息该怎么修改,数据库测试连接成功了啊,
richgod
2007-12-16
打赏
举报
回复
多谢DERSAK的帮助,的确好使
dawugui
2007-12-16
打赏
举报
回复
5、编写用户对象的Constructor事件:
String ls_Syntax
String ls_line
IF This.DataObject = '' Then Return
//创建Footer区
IF Integer(This.Describe("DataWindow.Footer.Height") ) < 120 Then
This.Object.DataWindow.Footer.Height='120'
End IF
//在Footer区添加线
ls_line = 'Create line(band=footer ' + &
'background.mode="2" background.color="16777215"' + &
'pen.style="0" pen.width="5" pen.color="0" x1="0" y1="2" ' + &
'x2="' + String(This.Width - 100) + '" y2="2" )~r~n'
this.modify( ls_line )
//获取设计时的数据窗口语法串
ls_Syntax = This.object.DataWindow.Syntax
//添加按钮语法串
ls_Syntax = uf_addbutton( ls_Syntax )
if this.Create( ls_Syntax ) <> 1 then
MessageBox('提示信息','创建数据窗口出错', StopSign!)
End If
6、从u_dw_button继承就可以了。如下图:
图贴不上来.
dawugui
2007-12-16
打赏
举报
回复
数据窗口中按钮的封装
在数据库的操作中,对数据表记录的检索、添加、删除和保存等操作是最基本和最常用的,可以说这些操作是数据表的标准操作。但PB并没有提供上述封装好的按钮对象,如果每次都要来添加命令按钮并编写脚本,工作是很繁琐的,而且还不能保证界面的一致性。
在PB的数据窗口对象中,可以直接放置按钮对象,而且开发人员既可以给这些按钮制定默认的操作,也可以自己定义按钮的功能。在可以指定的默认操作中就包含了上面提到的所有数据表的基本操作,这样一来在数据窗口需要相应的按钮时,只需要加入按钮对象然后指定其功能就行了。
实际上可以利用PB面向对象的编程技术,实现一个包含标准操作按钮的数据窗口对象,这样在需要用到标准操作的时候,只需要从该对象继承即可满足基本的数据应用需求。
实现过程如下(利用PB9自带数据库,EAS Demo DB V9):
1、建立一个工作空间(workspace),取名为:dwbutton。
2、建立一个应用(application),取名为:dwbutton。
3、建立一个标准的可视用户对象,类型为:datawindow,取名为:u_dw_button。
4、定义用户对象级私有函数uf_addbutton(string as_oldsyntax) return string
//功能:修改数据窗口语法串,为其增加常用功能按钮
//入口参数:as_OldSyntax 原有数据窗口语法串
//返回值: ls_NewSyntax 修改后的语法串
//应用条件:数据窗口中有Footer区, 高度>90的区域是按钮带区
String ls_AddButton
String ls_NewSyntax
Integer li_button_width
Integer li_button_x
//确定Button的位置参数
li_button_width = (This.Width + 20) / 10 - 40
IF li_button_width > 220 Then
li_button_width = 220
li_button_x = (This.Width - 240*10) / 2
IF li_button_x <=0 Then li_button_x = 10
Else
li_button_x = 20
End if
ls_NewSyntax = as_OldSyntax
//---------------添加按钮语法串------------------------------
//检索按钮
ls_AddButton = 'button(band=footer name=cb_retrieve text="检索" ' + &
'enabled=yes action="2" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//首页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_first text="首页" ' + &
'enabled=yes action="6" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//上页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_prior text="上页" ' + &
'enabled=yes action="5" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//下页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_next text="下页" ' + &
'enabled=yes action="4" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//末页按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_last text="末页" ' + &
'enabled=yes action="7" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//添加按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_append text="添加" ' + &
'enabled=yes action="11" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//插入按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_insert text="插入" ' + &
'enabled=yes action="12" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//删除按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_delete text="删除" ' + &
'enabled=yes action="10" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//保存按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_update text="保存" ' + &
'enabled=yes action="13" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
//打印按钮
li_button_x = li_button_x + li_button_width + 20
ls_AddButton = 'button(band=footer name=cb_print text="打印" ' + &
'enabled=yes action="15" border="1" color="8388608" ' + &
'x="' + string(li_button_x) + '" y="20" height="90" ' + &
'width="' + string(li_button_width) + '" ' + &
'vtextalign="0" htextalign="0" visible="1" ' + &
'font.charset="0" font.face="Arial" font.family="2" ' + &
'font.height="-9" font.pitch="2" font.weight="400" ' + &
'background.mode="2" background.color="12639424" )~r~n'
ls_NewSyntax = ls_NewSyntax + ls_AddButton
return ls_newsyntax
I_am_Z
2007-12-16
打赏
举报
回复
在数据窗口的constructor事件中加入语句绑定事务对象sqlca
this.settransobject(sqlca)
richgod
2007-12-16
打赏
举报
回复
Database transaction information not available,
Call SetTrans or SetTransObject function. 出现这样的错误语句怎么修正呢?多谢了
jlwei888
2007-12-16
打赏
举报
回复
这些可最简单的啊!
不能编辑,要看一下DW的Taborder的值,要大于0才能编辑
win1 open事件:
dw_1.settransobject(sqlca)
dw_1.retrieve()
添加:
int i
i = dw_1.insertrow(0)
dw_1.scrolltorow(i)
保存:
dw_1.accepttext()
if dw_1.update() = 1 then
commit;
//成功
else
//失败
rollback;
end if
修改没有用,缺省就是能修改
查找:
参考这个吧:
http://topic.csdn.net/u/20071216/11/720c410e-4dc2-48ec-9f9f-adeb3382e9a3.html
C#圆面积计算器及源码
- 对于初学者来说,良好的注释习惯非常重要,可以帮助理解
代码
的功能和目的,尤其是在向他人
请教
时。 总之,这个"C#圆面积计算器"项目是学习C#编程和Windows Forms应用开发的绝佳起点,它涵盖了基本的编程概念、...
DOS 软盘+光盘+U盘+硬盘+NTFS 想拥有更强大的DOS功能??
遇到问题不论大小马上就去
请教
“高手”不是明智之举,自己研究出来的答案远比你从“高手”那里得到的现成答案要记忆深刻,也更有利于你今后的学习。希望自己成为高手的人,从不会放弃自己独立思考问题的机会。 DOS...
android客户端通过无什么与后台服务信息传输??
请教
高人 我也是
新手
,这周刚开始看android.我目前是手机通过wifi联入网络,走http协议连接后台服务的的,书上说也可以走tcp/ip协议。 http协议就可以吧请问下增加
按钮
在哪写
代码
呢? 更改android默认系统语言 ...
c语言改变WIncc画面
窗口
画面,wincc菜单栏画面
窗口
切换的脚本应用
答侠们好,wincc
新手
,因为对编程知识的极度缺乏,故
请教
,我想用wincc的菜单栏实现一个功能:画面上放置有一个画面
窗口
,点击下拉菜单栏里的菜单名称,就在这个画面
窗口
上显示相应的趋势图,不知道脚本怎么写?画面切换的...
wincc c语言切换
窗口
,wincc菜单栏画面
窗口
切换的脚本应用-工业支持中心-西门子中国...
答侠们好,wincc
新手
,因为对编程知识的极度缺乏,故
请教
,我想用wincc的菜单栏实现一个功能:画面上放置有一个画面
窗口
,点击下拉菜单栏里的菜单名称,就在这个画面
窗口
上显示相应的趋势图,不知道脚本怎么写?画面切换的...
PowerBuilder
1,108
社区成员
66,453
社区内容
发帖
与我相关
我的任务
PowerBuilder
PowerBuilder 相关问题讨论
复制链接
扫一扫
分享
社区描述
PowerBuilder 相关问题讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章