梯形动态数据窗口创建的源代码(如公交车梯形价格图)//pbdesigner

pbdesigner 2001-12-30 04:41:31
前几天我在坐公交车时看到他们的梯行价格图,想做一个梯型数据窗口,今天上午在PB版看到一位兄弟也提出这个问题(不知有没有解决)。下面只提供如何创建梯行数据窗口的原代码供参考,关于如何取数和更新等问题比较简单,不贴出(但需与动态数据窗口配套)。
//用于动态创建数据窗口(梯行)
//参数:as_bus_no(公汽编号)
//返回类型:integer (是否创建成功)
//返回值含义:1(成功) -1(失败)
long ll_qty_stop,i,ll_colcount,j,ll_pos1,ll_pos2,ll_row,ll_col,ll_width,ll_height,ll_x,ll_y
string ls_stoplist[]={'火车站','建设路','和平路口','鹿丹村','红岭大厦','荔枝公园','康泰娱乐城','园岭新村','八卦岭','体育馆'}
string ls_colname,ls_modify
string ls_sql,ls_error,ls_syntax,ls_collist
integer li_return
//站点名称及站点数可以从数据库中读取
//下列代码从数据库中读站点名称及站点数
//下列代码同时示范了用datastore彻底替换游标
//as_bus_no='1'
//datastore ds_stop
//long ll_rowcount
//string ls_stop_id
//ds_stop = create datastore
//ls_sql = "select stop_id " +&
// + " from tra_busstop "+&
// + " where bus_no = '"+as_bus_no +"'"+&
// + " order by stop_no"
//ls_syntax = SQLCA.SyntaxFromSQL(ls_sql,'Style(Type=Tabular)', ls_error)
//IF Len(ls_error) = 0 THEN
// ds_stop.Create(ls_syntax, ls_error)
//END IF
//ds_stop.settransobject(sqlca)
//ll_rowcount = ds_stop.retrieve()
//for i = 1 to ll_rowcount
// ls_stop_id = ds_stop.object.stop_id[i]
// select stop_name
// into :ls_stoplist[i]
// from tra_stop
// where stop_id = :ls_stop_id;
//next
//
//destroy ds_stop

//生成栏位
ll_qty_stop = upperbound(ls_stoplist[])
for i = 1 to ll_qty_stop
for j = i +1 to ll_qty_stop
ls_collist = ls_collist + 'price_'+string(i)+'_'+string(j)+'=1.0,'
next
next
ls_collist = left(ls_collist,len(ls_collist) - 1)
//创建数据窗口
ls_sql = "SELECT "+ls_collist
ls_syntax = SQLCA.SyntaxFromSQL(ls_sql,'Style(Type=Tabular)', ls_error)
IF Len(ls_error) = 0 THEN
li_return = dw_1.Create(ls_syntax, ls_error)
END IF

dw_1.SetTransObject(SQLCA)
//修改题头带
dw_1.object.DataWindow.Header.color = '536870912'
dw_1.object.DataWindow.Header.Height='0'
ll_colcount = long(dw_1.object.datawindow.column.count)
//修改栏位属性
for i = 1 to ll_colcount
ls_colname = dw_1.describe("#"+string(i)+".name")
dw_1.settaborder(i,i*10)
ll_pos1 = pos(ls_colname,'_')
ll_pos2 = pos(ls_colname,'_',ll_pos1 + 1)
ll_row = long(mid(ls_colname,ll_pos1 + 1,ll_pos2 - ll_pos1 - 1))
ll_col = long(right(ls_colname,len(ls_colname) - ll_pos2))
ll_width = long(dw_1.describe("#"+string(i)+".width"))+10
ll_height = long(dw_1.describe("#"+string(i)+".height"))+20
dw_1.modify("#"+string(i)+".color='0'")
dw_1.modify("#"+string(i)+".border='5'")
dw_1.modify("#"+string(i)+".background.Mode=2")
dw_1.modify("#"+string(i)+".background.color='15793151'")
dw_1.modify("#"+string(i)+".x='"+string((ll_row - 1) * ll_width)+"'")
dw_1.modify("#"+string(i)+".y='"+string((ll_col - 1) * ll_height)+"'")
next
dw_1.object.DataWindow.Detail.Height=string(integer(dw_1.describe("#"+string(ll_colcount)+".y"))+integer(dw_1.describe("#"+string(ll_colcount)+".width")))
dw_1.object.DataWindow.Color='79741120'
//创建标签
for i = 1 to ll_qty_stop
//根据栏位的位置决定标签的位置
if i < ll_qty_stop then
ll_x = long(dw_1.describe("price_"+string(i)+"_"+string(i+1)+".x"))
ll_y = long(dw_1.describe("price_"+string(i)+"_"+string(i+1)+".y"))
ll_width = long(dw_1.describe("price_"+string(i)+"_"+string(i+1)+".width"))
ll_height = long(dw_1.describe("price_"+string(i)+"_"+string(i+1)+".height"))
ll_y = ll_y - ll_height
else
ll_x = long(dw_1.describe("#"+string(ll_colcount)+".x"))
ll_y = long(dw_1.describe("#"+string(ll_colcount)+".y"))
ll_width = long(dw_1.describe("#"+string(ll_colcount)+".width"))
ll_height = long(dw_1.describe("#"+string(ll_colcount)+".height"))
ll_x = ll_x + ll_width
end if
ll_x = ll_x + 10
ls_modify = "create text(band=Detail color='0' alignment='0' border='0'" + &
+ " x='"+string(ll_x)+"'" &
+ " y='"+string(ll_y)+"'" +&
+ " height='"+string(ll_height)+"'" +&
+ " width='"+string(ll_width)+"'" +&
+ " text='"+ls_stoplist[i]+"'" + &
+ " name="+ls_stoplist[i]+"_t" +&
+ " background.mode='1' background.color='536870912')"
dw_1.Modify(ls_modify)
next

dw_1.setredraw(true)
//新增一行
dw_1.insertrow(0)

return li_return
...全文
139 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
pbworm 2001-12-31
  • 打赏
  • 举报
回复
学习
pbdesigner 2001-12-31
  • 打赏
  • 举报
回复
更为简单的写法如下:
//用于动态创建数据窗口(梯行)
//参数:as_bus_no(公汽编号)
//返回类型:integer (是否创建成功)
//返回值含义:1(成功) -1(失败)
long ll_qty_stop,i,ll_colcount,j,ll_pos1,ll_pos2,ll_row,ll_col,ll_width,ll_height,ll_x,ll_y
string ls_stoplist[]={'火车站','建设路','和平路口','鹿丹村','红岭大厦','荔枝公园','康泰娱乐城','园岭新村','八卦岭','体育馆'}
string ls_colname,ls_modify
string ls_sql,ls_error,ls_syntax,ls_collist
integer li_return
//站点名称及站点数可以从数据库中读取
//下列代码从数据库中读站点名称及站点数
//下列代码同时示范了用datastore彻底替换游标
//as_bus_no='1'
//datastore ds_stop
//long ll_rowcount
//string ls_stop_id
//ds_stop = create datastore
//ls_sql = "select stop_id " +&
// + " from tra_busstop "+&
// + " where bus_no = '"+as_bus_no +"'"+&
// + " order by stop_no"
//ls_syntax = SQLCA.SyntaxFromSQL(ls_sql,'Style(Type=Tabular)', ls_error)
//IF Len(ls_error) = 0 THEN
// ds_stop.Create(ls_syntax, ls_error)
//END IF
//ds_stop.settransobject(sqlca)
//ll_rowcount = ds_stop.retrieve()
//for i = 1 to ll_rowcount
// ls_stop_id = ds_stop.object.stop_id[i]
// select stop_name
// into :ls_stoplist[i]
// from tra_stop
// where stop_id = :ls_stop_id;
//next
//
//destroy ds_stop

//生成栏位
ll_qty_stop = upperbound(ls_stoplist[])
for i = 1 to ll_qty_stop
ls_collist = ls_collist + 'price_'+string(i)+'=1.0,'
next
ls_collist = ls_collist + "stop_name=space(40)"

//创建数据窗口
ls_sql = "SELECT "+ls_collist
ls_syntax = SQLCA.SyntaxFromSQL(ls_sql,'Style(Type=Tabular)', ls_error)
IF Len(ls_error) = 0 THEN
li_return = dw_1.Create(ls_syntax, ls_error)
END IF

dw_1.SetTransObject(SQLCA)
//修改数据窗口属性
dw_1.object.DataWindow.Color='79741120'
dw_1.Object.DataWindow.Grid.Lines='1'
//修改题头带属性
dw_1.object.DataWindow.Header.Height='0'
ll_colcount = long(dw_1.object.datawindow.column.count)
//修改栏位属性
for i = 1 to ll_colcount - 1
dw_1.settaborder(i,i*10)
ls_colname = dw_1.describe("#"+string(i)+".name")
ls_modify = ls_colname+'.visible="1~tif('+string(i)+' >= getrow(),0,1)"'+&
+ "~t"+ls_colname+".color='0'"+&
+ "~t"+ls_colname+".border='5'"+&
+ "~t"+ls_colname+".background.Mode=2"+&
+ "~t"+ls_colname+".background.color='15793151'"
dw_1.modify(ls_modify)
next
ls_colname = dw_1.describe("#"+string(ll_colcount)+".name")
ls_modify = ls_colname+'.x="0~tinteger(describe(~'#~'+string(getrow())+~'.x~'))+20"'
dw_1.modify(ls_modify)

dw_1.setredraw(true)
//新增ll_qty_stop行
for i = 1 to ll_qty_stop
dw_1.insertrow(0)
dw_1.object.stop_name[i] = ls_stoplist[i]
next

return li_return
smartdraw 2001-12-30
  • 打赏
  • 举报
回复
■■热烈欢迎pbdesigner师兄归位!!■■
■■热烈欢迎pbdesigner师兄归位!!■■
■■热烈欢迎pbdesigner师兄归位!!■■
■■热烈欢迎pbdesigner师兄归位!!■■
■■热烈欢迎pbdesigner师兄归位!!■■
■■热烈欢迎pbdesigner师兄归位!!■■

goalitaly 2001-12-30
  • 打赏
  • 举报
回复
hehe!!
tiantianpb 2001-12-30
  • 打赏
  • 举报
回复
这个东西其实很简单的只要在pb的datawindow用modify做比较复杂的品质统计图,都可以做的
killerdanny 2001-12-30
  • 打赏
  • 举报
回复
厉害!!呵呵1
于2024年4月-2025年9月期间,研究团队在贵州习水国家级自然保护区制定39条样线,涵盖灌木林、常绿阔叶林、针叶林、常绿落叶阔叶混交林、针阔混交林等不同植被类型,每条样线分春夏秋冬4个季节采集样品,用真菌采集软件记录经纬度、海拔、采集地点、时间、生境等信息,使用佳能相机(R6 mark Ⅱ)对大型真菌进行拍照,并采集标本,标本存放于贵州省生物研究所大型真菌标本馆(HGAMF)。 通过形态学初步鉴定,结合分子生物学最终鉴定,参考已]报道的中国毒蘑菇名录开展毒蘑菇的认定。 调查到保护区内有毒真菌7目25科64种,导致中毒的主要类型有急性肾衰竭型、神经精神型和胃肠炎型。最终形成贵州习水国家级自然保护区大型有毒真菌片数据集,它由以下2个部分组成。 (1)附件1包含78张原始照片(.JPG),照片名字包括了大型有毒真菌的拉丁名和中文名,若无中文名的直接用拉丁名。 (2)附件2是一个压缩文件,包含了2张工作表,其中一张表是大型有毒真菌39条样线的信息,另一张表是大型有毒真菌的中毒类型。 照片采用佳能相机R6 mark Ⅱ拍摄,物种鉴定通过多种文献核实,并经两位以上专家鉴定确认。该数据集可为研究地及周边的普通人识别有毒大型真菌提供参考,通过及时的片对比,能有效避免误采误食大型有毒真菌,同时为因误食大型真菌可能引发的身体损伤进行了总结,能为患者及时治疗提供参考。

1,110

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧