国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開發(fā) > 綜合 > 正文

用PB開發(fā)報(bào)表系統(tǒng)

2024-07-21 02:10:19
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

用pb開發(fā)web下報(bào)表系統(tǒng)作者:流方 主頁(yè):http://liulee.myrice.com
在建設(shè)某公司內(nèi)部信息網(wǎng)的過(guò)程中,涉及到大量的dbf文件直接轉(zhuǎn)換為html文件的應(yīng)用,其他的文件格式(excel,access,以及大型數(shù)據(jù)庫(kù)的查詢)也有這方面的要求,由此用pb實(shí)現(xiàn)了基于odbc查詢的psr文件生成工具。
此生成器的原理是:
1、通過(guò)取出表的結(jié)構(gòu),
2、生成查詢的sql語(yǔ)法,
3、syntaxfromsql()函數(shù)生成datawindow語(yǔ)法,
4、create()函數(shù)生成數(shù)據(jù)窗
5、將生成的數(shù)據(jù)窗進(jìn)行修飾,包括增加對(duì)象、刪除對(duì)象、修飾對(duì)象、布置對(duì)象等操作,進(jìn)行數(shù)據(jù)窗的美化工作。
6、將生成的數(shù)據(jù)窗用saveas()函數(shù)另寸為 psr 文件。
7、在html頁(yè)中使用插件方式或直接連接方式顯示該psr文件。
在實(shí)現(xiàn)過(guò)程中,使用了數(shù)據(jù)窗函數(shù)modify()的各種語(yǔ)法來(lái)實(shí)現(xiàn)對(duì)數(shù)據(jù)窗的修飾,如加入線條,加入文本、改變格式、顏色等。可修飾的內(nèi)容如下圖:



該工具主要有以下特點(diǎn):

1、自動(dòng)化

對(duì)某些部門而言,需要處理的數(shù)據(jù)是動(dòng)態(tài)變化的,如某銷售公司,每天處理十幾報(bào)表,報(bào)表的形式基本穩(wěn)定,因此只需將更新后的數(shù)據(jù)拷貝到指定的位置,或在形成sql語(yǔ)法時(shí)加入一定的條件,即可實(shí)現(xiàn)自動(dòng)化的報(bào)表處理。處理時(shí),將需要的報(bào)表循環(huán),自動(dòng)設(shè)置odbc連接參數(shù)(用寫注冊(cè)表的方法),自動(dòng)連接好數(shù)據(jù)庫(kù),打開報(bào)表對(duì)應(yīng)的數(shù)據(jù)窗,檢索記錄,然后另存為預(yù)定的psr文件即可。

2、實(shí)用性

該工具特別針對(duì)查詢而設(shè)計(jì),可擴(kuò)展到任何用odbc連接的數(shù)據(jù)源,只要該數(shù)據(jù)源支持標(biāo)準(zhǔn)sql查詢即可。特別對(duì)于oa中或信息發(fā)布中需要將一些沿用已久fox系統(tǒng)下的dbf文件發(fā)布而言,所做工作只要在一次定義后,按幾個(gè)按鈕即可完成。 特別是在notes中只要將 psr 文件作為附件直接插入到文檔中,在客戶端定義好plugin,即可實(shí)現(xiàn) web 發(fā)布。

【技術(shù)要點(diǎn)參考】

1、創(chuàng)建數(shù)據(jù)窗子對(duì)象

通過(guò)數(shù)據(jù)窗的modify()函數(shù)實(shí)現(xiàn),語(yǔ)法:

dw_report.modify('create text(name=uc_text_001 x="10" y="20" width="300" ....')

通過(guò)對(duì)具體對(duì)象(static text,picture,rectangle,line,compute等)的屬性賦值(注意括號(hào)的使用與匹配),如x,y,width,height,color,font,background.color,background.mode,expression,format等,即可實(shí)現(xiàn)對(duì)象的創(chuàng)建。創(chuàng)建對(duì)象時(shí)特別注意是加入 moveable=1 resizeable=1 語(yǔ)法,實(shí)際上是將對(duì)象設(shè)為可移動(dòng),可變大小,這對(duì)于對(duì)象的調(diào)整是比較重要的。

刪除對(duì)象只需用如下語(yǔ)法:

dw_report.modify('destroy uc_text_001')



如何實(shí)現(xiàn)象pb開發(fā)環(huán)境下的創(chuàng)建對(duì)象的方式呢?

1、建立菜單(將bar的toolbar的object type 設(shè)為menucascade方式,item項(xiàng)為各可創(chuàng)建對(duì)象),

2、各菜單item的clicked event中寫入:

parent.toolbaritemdown = false // 使該toolbaritem處于壓下狀態(tài)

mf_createobject('stop')

統(tǒng)一調(diào)用函數(shù)mf_create_object([對(duì)象類別]),[對(duì)象類別]可自定以好,如"text","line"等

3、mf_create_object函數(shù)如下(argument 為 string object_string)

window lw_sheet

lw_sheet = parentwindow.getactivesheet ()

if isvalid (lw_sheet) then

lw_sheet.triggerevent('ue_createobject',0,obj_string)

end if

該函數(shù)取得當(dāng)前打開的sheet窗口lw_sheet,然后調(diào)用該窗口下的ue_createobject自定義事件。

4、在主窗口下,自定義ue_createobject事件,該事件主要響應(yīng)如下:

string passedstring

passedstring = string(message.longparm, "address") // 取出創(chuàng)建類型

if isnull(passedstring) or passedstring = 'stop' then

m_main.m_objects.toolbaritemdown = false

ib_creatingobject = false

return

end if

ib_creatingobject = true // 等待dw_report的click事件來(lái)觸發(fā)

is_objectstring = passedstring // 告知當(dāng)前觸發(fā)對(duì)象

5、在dw_report的clicked事件中,寫入以下語(yǔ)法:

if not ib_creating_object then return // instance 變量,記錄是否處于創(chuàng)建狀態(tài)

m_main.m_objects.toolbaritemdown = false // 恢復(fù)toolbaritem狀態(tài)

if isnull(is_objectstring) then return // 意外判斷

ib_creatingobject = false // 停止創(chuàng)建

choose case is_objectstring

……

[具體創(chuàng)建語(yǔ)法]



2、選擇對(duì)象

產(chǎn)生windows風(fēng)格的選擇形式主要包括:?jiǎn)芜x,ctrl+單選,框選

單選:容易實(shí)現(xiàn),在datawindow的clicked事件中用getobjectatpointer()函數(shù)即可取得點(diǎn)取的對(duì)象,然后在該對(duì)象四周畫rectangle標(biāo)記即可(清除其他已選對(duì)象選中標(biāo)記);

多選:在clicked事件中判斷是否有ctrl按下

if keydown(keycontrol!) then …

增加選中對(duì)象列表(數(shù)組)

顯示選中標(biāo)記

框選:需要由3個(gè)事件協(xié)同工作

clicked: (鼠標(biāo)單擊)

記錄左鍵按下時(shí)的位置(pixels),同時(shí)考慮scrollhorizontal事件產(chǎn)生的位移量(unit)

ib_rect_select = true // 框選開始

ii_mousex = unitstopixels(ii_hscroll_offset,xunitstopixels!) + xpos

ii_mousey = unitstopixels(ii_vscroll_offset,yunitstopixels!) + ypos

ue_mousemove: (自定義事件,evend id = pbm_dwnmousemove)(鼠標(biāo)移動(dòng))

// 動(dòng)態(tài)創(chuàng)建框選的矩形框

if not ib_rectselect then return

int li_height,li_width,x2,y2,x1,y1

x1 = ii_mousex

y1 = ii_mousey

x2 = unitstopixels(ii_hscroll,xunitstopixels!) + xpos

y2 = unitstopixels(ii_vscroll,yunitstopixels!) + ypos

li_height = y2 - y1

li_width = x2 - x1

x1 = pixelstounits(x1,xpixelstounits!)

y1 = pixelstounits(y1,ypixelstounits!)

hh = pixelstounits(hh,ypixelstounits!)

ww = pixelstounits(ww,xpixelstounits!)

string ls_mstring

ls_mstring =' create rectangle(band=foreground name=uc_rect_select x="'+string(x1)+&

'" y="'+string(y1)+ '" width="'+string(ww)+'" height="'+string(hh)+'" '+&

'brush.hatch="7" brush.color="553648127" pen. pen.width="5" '+&

'pen.color="1090519039" background.mode="2" background.color="255" )'

dw_pre.setredraw(false)

dw_pre.modify('destroy uc_rect_select') // 先刪除舊的矩形框

dw_pre.modify(ls_mstring) // 再創(chuàng)建新的矩形框

dw_pre.setredraw(true)

ue_leftbuttonup: (自定義事件,evend id = pbm_lbuttonup) 鼠標(biāo)左鍵抬起

//鼠標(biāo)左鍵抬起,如果處于ib_rectselect狀態(tài),則結(jié)束選擇狀態(tài)

if not ib_rectselect then return

dw_pre.setredraw(false)

dw_pre.modify('destroy uc_rect_select')

dw_pre.setredraw(true)

ib_rectselect = false

…… // 處理選擇對(duì)象

通過(guò)以上三個(gè)事件的協(xié)同工作,就可實(shí)現(xiàn)多對(duì)象的框選。

3、自動(dòng)連接odbc

自動(dòng)連接odbc是指不需要用戶自己定義odbc連接參數(shù),通過(guò)程序自動(dòng)實(shí)現(xiàn)連接,一方面簡(jiǎn)化了用戶的操作,另一方面,使批量定制報(bào)表成為可能。

自動(dòng)連接odbc的實(shí)現(xiàn)是通過(guò)寫注冊(cè)表來(lái)實(shí)現(xiàn)的,主要用到的函數(shù)有兩個(gè):

registryset()

registryget()

通過(guò)registryset()函數(shù),改寫注冊(cè)表主鍵及相關(guān)鍵值:

hkey_current_user oftware/odbc/odbc.ini/[odbc源名稱]

hkey_current_user oftware/odbc/odbc.ini/odbc data sources

[odbc源名稱] 即要?jiǎng)?chuàng)建或修改的odbc source,如

hkey_current_user oftware/odbc/odbc.ini ystem

該主鍵下有若干鍵值記錄了該連接的參數(shù),如sybase sql anyway 5.0 的典型設(shè)置:


鍵值名



含義

autostop

yes

程序調(diào)用結(jié)束后自動(dòng)終止連接

databasefile

c:/program files/dbf自動(dòng)報(bào)表 ystem.db

數(shù)據(jù)庫(kù)文件

databasename

system

連接名稱

description

自動(dòng)生成odbc

描述

driver

c:/program files/dbf自動(dòng)報(bào)表/wod50t.dll

驅(qū)動(dòng)程序語(yǔ)法解釋

pws

sql

用戶口令

start

c:/program files/dbf自動(dòng)報(bào)表/dbeng50 -c8192

驅(qū)動(dòng)程序及參數(shù) -c8192表示用8192k內(nèi)存做cache

uid

dba

數(shù)據(jù)庫(kù)用戶名





為使其他程序可用該odbc源,在主鍵:

hkey_current_user oftware/odbc/odbc.ini/odbc data sources

下加入相應(yīng)鍵值:


鍵值名



含義

system

sybase sql anywhere 5.0

odbc源名及分類

做好如上手腳后,在程序中即可直接連接了。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴化市| 苏尼特左旗| 和顺县| 铁岭市| 合水县| 西乌| 天柱县| 施秉县| 西林县| 漳浦县| 雷山县| 鄂温| 延川县| 乌什县| 赤峰市| 五常市| 旬邑县| 正宁县| 桓台县| 磴口县| 新和县| 湖口县| 吉木萨尔县| 长春市| 徐闻县| 隆化县| 繁峙县| 阳东县| 四子王旗| 昆山市| 永川市| 彰化市| 荥经县| 措美县| 景谷| 安西县| 余江县| 林周县| 阜新市| 商城县| 四川省|