PB常用程序汇总1

//PB中标准调用sql语句
ls_sql = "select road_name from bb_data_wide_bus_temp_t where register_number = '" + ls_register_number + "'"
declare cur_get dynamic cursor for sqlsa ;
prepare sqlsa from :ls_sql ;
open dynamic cur_get;
fetch cur_get into :ls_value;
if sqlca.sqlcode <> 0 then
messagebox('操作信息','提取失败!',exclamation!)
end if
close cur_get;


//PB中标准循环调用sql语句
DECLARE cur_sql DYNAMIC CURSOR FOR SQLSA;
PREPARE SQLSA FROM :ls_sql;
OPEN DYNAMIC cur_sql;
do while sqlca.sqlcode = 0 
FETCH cur_sql INTO :ls_register_number,:ls_complete_note;
ll_sqlcode = sqlca.sqlcode
if ll_sqlcode < 0 then
CLOSE cur_sql;
af_disconnect()
messagebox('错误提示','检索受理编号错误!',StopSign!)
return
elseif ll_sqlcode = 100 then
exit
end if
ddlb_register_number.additem(trim(ls_register_number + '|' + ls_complete_note))
loop
CLOSE cur_sql;


//窗口open事件通用脚本
//置窗口居中
af_center_window(this)
//连接数据库
af_connect()
//定义变量
dataWindowChild dwc
//获取城市代码下拉列表并取值
dw_city_code.getChild('city_code',dwc)
dwc.setTransObject(sqlca)
dwc.Retrieve(gs_citycode,gi_citylevel)
dw_city_code.setTransObject(sqlca)
dw_city_code.Retrieve()
dw_city_code.setItem(1,'city_code',dwc.getItemString(1,'city_code'))
is_city_code = dw_city_code.getItemString(dw_city_code.getRow(),'city_code')
//获取业务类型下拉列表并取值
dw_service_kind.getChild('service_kind',dwc)
dwc.setTransObject(sqlca)
dwc.Retrieve()
dw_service_kind.setTransObject(sqlca)
dw_service_kind.Retrieve()
dw_service_kind.setItem(1,'service_kind',10)
ii_service_kind = dw_service_kind.getItemNumber(dw_service_kind.getRow(),'service_kind')
//获取申请事项下拉列表并取值
dw_apply_event.getChild('apply_event',dwc)
dwc.setTransObject(sqlca)
dwc.Retrieve(ii_service_kind)
dw_apply_event.setTransObject(sqlca)
dw_apply_event.Retrieve()
dw_apply_event.setItem(1,'apply_event',dwc.getItemNumber(1,'apply_event'))
ii_apply_event = dw_apply_event.getItemNumber(dw_apply_event.getRow(),'apply_event')
//激发查询事件
cb_query.TriggerEvent(clicked!)
//断开数据库
af_disconnect()


//查询按钮通用脚本
//连接数据库
af_connect()
//定义变量
dataWindowChild dwc
//dw_1检索数据
dw_1.setTransObject(sqlca)
dw_1.Retrieve(ii_service_kind)
//dw_2检索数据
int li_row,li_row_temp
dw_2.getChild('action',dwc)
dwc.setTransObject(sqlca)
dwc.Retrieve(ii_service_kind)
dw_2.setRowFocusIndicator(hand!)
dw_2.setTransObject(sqlca)
li_row_temp = dw_2.Retrieve(ii_apply_event,ii_service_kind,is_city_code)
dw_2.scrollToRow(li_row_temp)
//如果未检索到数据插入一空行,有数据就过滤
string ls_filter
int li_action
if li_row_temp = 0 then
dw_2.insertRow(0)
else
for li_row = 1 to dw_2.rowCount()
li_action = dw_2.getItemNumber(li_row,'action')
ls_filter = ' action <> ' + string(li_action)
dw_1.setFilter(ls_filter)
dw_1.filter()
next
end if
//断开数据库
af_disconnect()


//增加按钮通用脚本
//变量定义
int li_step,li_action,li_auto_status,li_row
//确认选择要增加的记录
if dw_1.getSelectedRow(0) = 0 then
MessageBox('提示信息','请选择要添加的记录!',exclamation!)
return
end if
//取出要增加的信息
li_step = dw_2.getItemNumber(dw_2.getRow(),'step')
li_action = dw_1.getItemNumber(dw_1.getSelectedRow(0),'action')
li_auto_status = dw_1.getItemNumber(dw_1.getSelectedRow(0),'auto_status') 
//添加信息
li_row = dw_2.insertRow(0)
dw_2.setItem(li_row,'step',li_step)
dw_2.setItem(li_row,'action',li_action)
dw_2.setItem(li_row,'auto_status',li_auto_status)
dw_2.scrollToRow(li_row)


//删除按钮通用脚本
//删除前先确认
IF dw_2.GetRow() = 0 THEN
MessageBox('提示信息','请选择要删除的记录!',exclamation!)
Return
ELSE
IF MessageBox("提示信息","确实要删除指定的记录?",Question!,YesNo!,2) = 2 THEN Return
dw_2.DeleteRow(dw_2.getRow())
END IF


//保存按钮通用脚本
//连接数据库
af_connect()
//定义变量
string ls_city_code,ls_error
int li_service_kind,li_apply_event,li_row,li_step
dataWindowChild dwc
//检测数据是否发生变化
dw_2.AcceptText()
IF dw_2.ModifiedCount() + dw_2.DeletedCount() = 0 THEN
MessageBox("操作提示","数据未发生变化,无需保存!",exclamation!)
return
END IF
//检测是否为空或零
dw_2.setSort('step a')
dw_2.sort()
FOR li_row = 1 TO dw_2.RowCount()
li_step = dw_2.GetItemNumber(li_row,'step')
IF IsNull(li_step) OR li_step = 0 THEN
MessageBox('操作提示','步骤不能为空或零,请重新输入!',exclamation!)
dw_2.setRow(li_row)
Return
END IF
NEXT
//保存
dw_2.SetTransObject(sqlca) 
if dw_2.update() = 1 then
commit;
messagebox("提示信息","保存成功!")
dw_2.ScrollToRow(dw_2.RowCount())
else
ls_error = sqlca.sqlErrText
rollback;
messagebox("提示信息","保存失败!" + char(13) + ls_error,stopSign!)
return
end if
//断开数据库
af_disconnect()


//打印按钮通用脚本
if dw_1.rowCount() > 0 then
if PrintSetup() = -1 then 
messagebox('提示信息','打印机设置出错!',Exclamation!)
return
else
if dw_1.print(true) = 1 then //显示可以取消打印的对话框
Messagebox('提示信息',"打印成功!")
else
Messagebox('提示信息',"打印失败!",stopSign!)
end if
end if
else
Messagebox('提示信息',"没有数据可以打印,请先查询数据!",exclamation!)
return
end if


//导出按钮通用脚本
if dw_1.rowcount() <= 0 then
messageBox('提示信息','没有数据可以导出,请先查询!',exclamation!)
return
end if
if dw_1.SaveAS('',text!,true) = 1 then
messageBox('提示信息','导出成功!')
end if


//导入按钮通用脚本
//变量定义
string ls_pathfile,ls_file,ls_title,ls_ext,ls_filter
int li_pos,li_fileid
long ll_buffer
//变量赋值
ls_title = "请选择数据文件"
ls_ext = "txt"
ls_filter = "文本文件(*.txt),*.txt,全部文件(*.*),*.*"
li_fileid = GetFileOpenName(ls_title,ls_pathfile,ls_file,ls_ext,ls_filter)
if(li_fileid = 0 or ls_file = "") then
return
end if
sle_file_name.text = ls_pathfile
cb_ok.enabled = true


//退出按钮通用脚本
close(parent) 或 closeWithReturn(parent,returnvalue)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值