【正文】
lestring(cfgfile,profile czy,dbms, )//數(shù)據(jù)庫類型 =profilestring(cfgfile,profile czy,database, )//數(shù)據(jù)庫名稱 =profilestring(cfgfile,profile czy,logid, )//登錄名稱 =profilestring(cfgfile,profile czy,logpassword, )//密碼 =profilestring(cfgfile,profile czy,servername, )//服務器名稱//讀取接入操作員庫數(shù)據(jù)庫參數(shù)connect using Tczy。//與操作員庫數(shù)據(jù)庫連接if 0 then cfgfile= =profilestring(cfgfile,profile czy,dbms, ) =profilestring(cfgfile,profile czy,dbparm, ) connect using Tczy。//如果連接失敗則以ODBC數(shù)據(jù)源方式再次試連接 if 0 then messagebox(警告!,不能接入操作員庫) halt。//如果還不能成功連接,系統(tǒng)中止運行 else idle(screensave_time) close(w_sbgl_wele) open(w_sbgl_login)//如果成功連接,關閉歡迎界面,打開登錄窗口,并設置屏保時間 end ifelse idle(screensave_time) close(w_sbgl_wele) open(w_sbgl_login)//如果首次連接成功,關閉歡迎界面,打開登錄窗口,并設置屏保時間end if為登錄窗口的登錄按鈕編寫代碼如下:environment envstring cfgfile,tmpif(GetEnvironment(env)1) Then MessageBox (Application: Open, Unable to get environment ifomation. ~nHalting...) Halt。 end ifchoose case case windows!,WindowsNT! if =39。ODBC39。 then cfgfile= end if if =39。Microsoft SQL 39。 then cfgfile= end if case Sol2!,AIX!,OSF1!,HPUX! cfgfile=. case Macintosh! cfgfile=PowerBuilder Preferences case Else messageBox(Application: Open,Unrecognized operating system. ~nHalting...) haltend choose//////////////////////////////////////////disconnect using tczy。connect using tczy。 SELECT , INTO :tmp, :password FROM czy WHERE = : ORDER BY ASC using Tczy。 //取得當前操作員的實際密碼 if len(trim(password))=0 then password=noword end if //如該操作員未設置密碼,則默認為nowordif = 0 then if string(password)=string() then disconnect using Tczy。 else messagebox(用戶登錄,口令錯誤, 重新輸入!,StopSign!) return。 end if else if = 1 then messagebox(警告,無此用戶, 重新輸入!) return。 else messagebox(警告,對不起,未知的錯誤,請重新輸入用戶名和密碼再試一次!) return。 end if end if ///////////////////////////////////////////if =39。ODBC39。 then =profilestring(cfgfile,profile sbgl,dbms, ) =profilestring(cfgfile,profile sbgl,dbparm, )end if//如選取ODBC方式接入數(shù)據(jù)庫,則設定相應參數(shù)if =39。Microsoft SQL 39。 then =profilestring(cfgfile,profile sbgl,dbms, ) =profilestring(cfgfile,profile sbgl,logid, ) =profilestring(cfgfile,profile sbgl,logpassword, ) =trim() =trim()end if //如選取Microsoft SQL ,則設定相應參數(shù)connect using sqlca。if 0 then messagebox(警告!,不能接入設備管理系統(tǒng)數(shù)據(jù)庫)else SELECT INTO :s_gdno FROM xtcs 。//取得系統(tǒng)所產(chǎn)生的最大工單序號 close(w_sbgl_login) open(w_sbgl_main) ds_ls= create datastore curczy=trim(tmp) =建湖縣郵政局設備管理系統(tǒng) 操作: +tmp + +string(today(),yyyy年mm月dd日) if trim(tmp)=管理員 then//只有管理員才具有系統(tǒng)操作員表的全部權限 =true else =false end if end if在登錄界面的管理員密碼是111111,操作員張成密碼是1,且只有管理員才具有系統(tǒng)操作員表的全部權限,其他人只能修改自己的密碼及自己的其它信息。4.3.2 定義全局函數(shù)及擴展函數(shù)ansaction Tczy//定義操作員庫的連接事務全局變量string password, pre_col,s_tybh,curczy//以上為字符串型變量,其中://password當前登錄的密碼//s_tybh當前設備的統(tǒng)一編號//pre_col前一次單擊的列名//curczy當前登錄的用戶名datastore ds_ls//定義臨時數(shù)據(jù)存儲全局變量integer deletenew,s_gdno,cur_row,screensave_time//deletenew刪除行與新行的行數(shù)//s_gdno當前最大的工單序號//cur_row當前行數(shù)//screen_savetime啟動屏保的時間dwobject mydwo//定義一個數(shù)據(jù)窗口對象u_tooltips u_tooltips//自定義的即時提示對象變量//nc_wallpaper inv_wallpaperu_timer my_timer//自定義的定時器變量擴展函數(shù)如下FUNCTION int GetSytemMetrics (int indexnum) LIBRARY function boolean AnimateWindow(long lhWnd,long lTm,long iFlags) library 39。user3239。//動態(tài)顯示窗口subroutine keybd_event(uint bVk,uint bScan,long dwFlags,long dwExtraInfo) library //鍵定義轉化子過程設備管理模塊功能是通過以下代碼行以實現(xiàn)的,設計好的設備進庫窗體是作為一個模板來使用的。event:resizecode:= 5=17*(+2, 100)//當該窗口發(fā)生大小變化時,相應調整數(shù)據(jù)窗口控件的大步與位置event:closecode:disconnect。//關閉時斷開連接檢索功能實現(xiàn)的代碼event:code:integer i_totalrow(sqlca)(sqlca)//指定數(shù)據(jù)窗口dw_sbjk的連接對象i_totalrow=()//檢索數(shù)據(jù)if i_totalrow= 1 then =從數(shù)據(jù)庫中檢索數(shù)據(jù)失敗! ()//顯示提示else =從數(shù)據(jù)庫中檢索出了+string(i_totalrow)+條記錄! ()//顯示提示end if()//設置焦點到數(shù)據(jù)窗口dw_sbjk裝載功能實現(xiàn)的代碼event:code:integer i_reli_rel=()//檢索數(shù)據(jù)if i_rel0 then //檢索不到數(shù)據(jù)=在裝載之前不能從數(shù)據(jù)庫中檢索數(shù)據(jù)!()()return //結束本次操作end ifi_rel=messagebox(數(shù)據(jù)裝載,需要清空數(shù)據(jù)再裝載嗎?,question!,yesnocancel!)if i_rel=1 then do while ()0 (0) loop //刪除所有記錄 i_rel=()//保存修改 if i_rel1 then =在裝載之前不能從數(shù)據(jù)庫中刪除數(shù)據(jù)! () () return //如不能刪除數(shù)據(jù),結束本次操作 end ifelseif i_rel=3 then return //用戶選擇取消本次操作end if long i_rowcountstring spath,sfilei_rel=getfileopenname(裝載數(shù)據(jù)文件,spath,sfile,txt,xls,dbf, 文本文件(txt),*.txt,EXCEL5文件(xls),*.xls,foxpro(dbf) 文件,*.dbf)//打開要裝載的數(shù)據(jù)文件i_rowcount=(spath,2)//導入數(shù)據(jù)到數(shù)據(jù)窗口對象中i_rel=()//試圖保存if i_rel=1 then mit using sqlca。//沒有問題則提交更改 =成功地從文件中裝入了!+string(i_rowcount)+條記錄! ()//顯示提示else rollback using sqlca。//試保存失敗則回滾數(shù)據(jù)的修改 =不能從指定的文件中載入數(shù)據(jù)! ()//顯示提示end if()//設置焦點到數(shù)據(jù)窗口dw_sbjk//integer iopenfile,importfile//iopenfile=getfileopenname(導入數(shù)據(jù)文件,spath,sfile,txt,xls,dbf, 文本文件(txt),*.txt,EXCEL5文件(xls),*.xls,DebaseIII(dbf) 文件,*.dbf) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++event:code:integer i_rownumberi_rownumber=(0)//增加一條記錄if i_rownumber0 then (i_rownumber)//滾動屏幕到新錄所在處 (1)//設置焦點到第一列// (i_rownumber,true) =成功地在數(shù)據(jù)窗口的最后插入一條新記錄! ()//顯示成功提示else =不能在數(shù)據(jù)窗口的最后插入一條新記錄! ()//顯示失敗提示end if()//設置焦點到數(shù)據(jù)窗口dw_sbjk刪除記錄的代碼event:cb_deletecode:integer i_deletei_delete=(0)//刪除當前記錄if i_delete=1 then =成功刪除當前行! ()else =刪除當前行時出錯! ()end if//顯示相關提示()//指定焦點到dw_sbjk保存記錄的代碼event:code:integer i_updatei_update=()//保存數(shù)據(jù)修改if i_update=1 then mit using sqlca。//保存成功則提交修改 =成功保存了數(shù)據(jù)庫數(shù)據(jù)的修改! ()//顯示提示else rollback using sqlca。//保存不成功則回滾修改 =在保存對數(shù)據(jù)庫的修改時出錯,回滾數(shù)據(jù) ()//顯示提示end if()重置功能的實現(xiàn)event:code:integer i_reseti_reset=()//清空當前數(shù)據(jù)窗口if i_reset=1 then =已經(jīng)成功地重置了數(shù)據(jù)窗口! ()else =不能正確地重置了數(shù)據(jù)窗口! ()end if//顯示提示 打印功能的實現(xiàn)event:code:string datanamedataname==dataname(sqlca)(sqlca)//設置數(shù)據(jù)存儲ds_ls的數(shù)據(jù)窗口對象為dw_sbjk的數(shù)據(jù)窗口對象//(cur_row)(ds_ls)//共享數(shù)據(jù)openwithparm(print,)//帶參數(shù)打開通用打印窗口