PB基本…

來源:互聯網
上載者:User

 

1.怎麼得到Group的count?

   A.cumulativeSum( if( 分組列名[-1] = 分組列名[0],0,1) for all )   

   B.GetRow() - First(GetRow() for Group 1) + 1

   C.count(分組的欄位   for all distinct)

2.怎麼得到Group的行號?  

   cumulativeSum(   1   for   group   1   )  

3.如何給一個子資料視窗傳參數?

   datawindowchild ldwc_name

   ldwc_name = dw_name.getchild( 'column', ldwc_name )

   //如果開始不知道dddw的檢索參數是什麼,可以欺騙dddw,讓他認為已有了資料:

   ldwc_name.insertrow( 0 )

   dw_name.retrieve()

   //如果你知道檢索參數了:

   ldwc_name.settransobject( sqlca )

   ldwc_name.retrieve( arguments )

   dw_name.settransobject( sqlca )

   dw_name.retrieve()

4.如何比較兩個時間(date)類型的資料之間的相差的天數?

   date ld_date1, ld_date2

   long ll_diff

   ll_diff = daysafter( ld_date1, ld_date2 )

5.DW中,各行資料用不同顏色來顯示

   background.color express:

   if( mod(getrow(),2)=0, rgb(0,255,0), rgb(255,255,255) )

6.視窗中控制項visible屬性的操作問題

   way1: 在視窗畫板的design菜單裡選option,點上show invisible複選框。

   way2:在edit菜單裡選control list,選擇你要找的按鈕,然後在property裡點 上visible複選框。

7.怎樣在dw中加計算資料行

   在summary帶放計算域,如sum( column for all )

8.如何取伺服器時間,更改本地時間?

   FUNCTION ulong SetLocalTime(any lpSystemTime) LIBRARY \"kernel32.dll\"

   結構str_systime(unsignedinteger: year,month,day,hour,minute,second)

   datetime dt_server

   str_systime lstr_tmp

   select getdate() into :dt_server from sysfiles;

   lstr_tmp.year=year(date(dt_server))

   lstr_tmp.month=month(date(dt_server))

   lstr_tmp.week=daynumber(date(dt_server)) - 1

   lstr_tmp.day=day(date(dt_server))

   lstr_tmp.hour=hour(time(dt_server))

   lstr_tmp.minute=minute(time(dt_server))

   lstr_tmp.second=second(time(dt_server))

   SetLocalTime(lstr_tmp)

9.怎麼屏蔽datewindow中的斷行符號按鍵?

   pbm_dwnprocessenter:return 1

10.dddw的增量查詢?

   datawindowchild ldwc_name

   dw_name.getchild( "column", ldwc_name )

   //dw_name:editchanged

   ldwc_name.setfilter( "column Like '%" + upper( data ) + "%'" )

   ldwc_name.filter()

11.如何動態改變dw的sql?

   string ls_sql, ls_new_sql

   ls_sql = dw_name.getsqlselect()

   ls_new_sql = ls_sql + 'statement'

   dw_name.setsqlselect( ls_new_sql )

   dw_name.settransobject( sqlca )

   dw_name.retrieve()

12.怎麼知道資料視窗中哪些行修改了?

   long i

   dwitemstatus lds_status

   for i = 1 to dw_name.rowcount()

     lds_status = dw_name.getitemstatus( i, 0, primary! )

     if lds_status <> notmodified! then

         //本行修改了

     end if

   next

13.如何動態修改資料視窗列的風格?

   dw_name.object.columnname.edit.style = 'dddw'//or other style

   dw_name.object.columnname.edit.case = 'any'//change back to edit

#2

1.資料視窗自動折行?

   detail 帶選autosize height

   column去掉auto horz scroll選auto vert scroll

2.如何動態地把一個資料視窗裡的欄位設為唯讀

   dw_name.object.column.protect = 1

   dw_name.object.column.edit.displayonly = 'yes'

   dw_name.object.column.teasequence = 0

3.如何?跨資料庫的分散式查詢或更新?

   //與對方建立串連

   string ls_link, ls_login

   ls_link = "sp_addlinkedserver   ~'srv_lnk~',~'~',~'SQLOLEDB~',~'sws~'"

   ls_login = "sp_addlinkedsrvlogin ~'srv_lnk~',~'false~',null,~'sa~',~'newworld~'"

   sqlca.autocommit = true

   EXECUTE IMMEDIATE :ls_link;

   EXECUTE IMMEDIATE :ls_login;

   //這裡要注意修改ANSI_NULLS和ANSI_WARNINGS。因為在做分散式查詢時應將它麼都設定為ON。而企業管理中的ANSI_NULLS和ANSI_WARNINGS選項不對,但沒有方法改動。在查詢分析器可以設定ANSI_NULLS和ANSI_WARNINGS選項,而且預設值是對的。所以建立一個預存程序,

create proc 名 as SET ANSI_NULL_DFLT_ON on --注意 SET ANSI_WARNINGS on  

   declare procedure up_set for your_proc.....//在pb中掉用建立的著個預存程序

   //做資料操作

   insert into tableOfAnotherDB values('19','uuu','dd');

   //關閉串連

   string ls_drop  

   ls_drop = "sp_dropserver ~'srv_lnk~', ~'droplogins~'"

   EXECUTE IMMEDIATE :ls_drop;

   sqlca.autocommit = false

4.如何用pb實現讀寫圖片操作?

   //圖片欄位image

   string docname, named

   integer value,li_f,i

   integer li_fileptr,li_loops

   long ll_filelen,ll_bytes_read

   Blob lbb_Read,lbb_Total

   value = GetFileOpenName("選擇圖形檔案",   + docname, named, "BMP", + "Bmp Files (*.BMP),*.BMP,"   + "Jpeg Files (*.JPG),*.JPG")

   IF value = 1 THEN  

     //開啟影像檔

     ll_filelen = FileLength(docname) //擷取檔案長度, 必須在開啟之前

     li_fileptr = FileOpen(docname,STREAMMODE!,READ!,LOCKREAD!)

     If li_fileptr = -1 Then

       Beep(2)

       MessageBox("錯誤","圖形檔案開啟錯誤!")

       Return

     End If

     If ll_filelen > 32765 Then //一次只能讀32K

       If Mod(ll_filelen, 32765) = 0 Then

         li_loops = ll_filelen / 32765

       Else

         li_loops = (ll_filelen / 32765) + 1

       End If

     Else

       li_loops = 1

     End If

     //迴圈讀取圖片檔案

     For i = 1 to li_loops  

       ll_bytes_read = FileRead(li_fileptr,lbb_Read)

       lbb_Total = lbb_Total + lbb_Read

     Next

     FileClose(li_fileptr)

     SetPicture(p_1,lbb_Total)

     UPDATEBLOB table set column=:lbb_total where clause;

   end if  

   //顯示圖片

   blob lbb_blob

   selectblob column into :lbb_blob from table wher clause;

   setpicture( p_1,blob )

5.有像winamp中讓使用者選擇目錄的函數嗎?

   getfileopenname()

   getfilesavename()

   dirlist()

#3

在設計資料視窗報表時,由於將某欄位的寬度固定了,因而有部份資料不能顯示完全,因而想實現自動換行,同時為了節省紙張空間又要求該欄位的高度也是自動的,不知各位大俠有什麼高招?(請注意中英文似乎有一定的區別,現需要兩者皆可實現)   

---------------------------------------------------------------   

  

將資料視窗中相應列的auto   horz   scroll   為不選中,選中autosize   height   

將detail的autosize   height選中。在資料視窗retrieve   後調用下面函數即可   

  

uf_set_text(datawindow   adw_content,string           

                                        as_columns,boolean,ab_ignoreblank)   

/*************************************************************   

describe:   在資料視窗adw_content中,在as_columns中包含的列中插入空格   

      args:   

                    as_columns     要操作的多個列,列間用逗號隔開   

*************************************************************/   

if   (not   isvalid(adw_content))   or   isnull(as_columns)   or   len(as_columns)<1 or isnull(ab_ignoreblank) then return -1

n_cst_string lnv_string

string ls_column[] , ls_width ,as_source,as_replaced ,ls_temp

int li_upperbound , li_width , li_column , li_fontWidth, li_counter

long ll_rowcount , ll_row , ll_totalstep

int li_yield

lnv_string.of_parsetoarray(as_columns,',',ls_column)

li_upperbound = upperbound(ls_column)

ll_rowcount = adw_content.rowcount()

if li_upperbound<1 or ll_rowcount<1 then return -1

openwithparm(w_waiting,this)

ib_cancel = false

iw_frame.enabled = false

ll_totalstep = ll_rowcount * li_upperbound

w_waiting.uf_register(ll_totalstep)

for li_column = 1 to li_upperbound

ls_width = adw_content.describe(ls_column[li_column]+".width")

li_width = integer(ls_width)

if ls_width='!' or ls_width='?' or li_width=0 then

continue

end if

//ls_temp = adw_content.describe(ls_column[li_column]+".Font.property { = 'width' }")

//messagebox(ls_column[li_column]+".Font.property { = 'width' }",ls_temp)

//return 1

li_fontwidth = 27

li_counter = li_width / li_fontWidth

for ll_row=1 to ll_rowcount

if ib_cancel then

iw_frame.enabled = true

return 0 //pressed cancel button

end if

as_source = adw_content.getitemstring(ll_row,ls_column[li_column])

as_replaced = uf_insertstring(as_source,li_counter,' ',false)

if as_replaced<>as_source   then   

                                    adw_content.setitem(ll_row,ls_column[li_column],as_replaced)   

                        end   if   

                        w_waiting.uf_stepit()                           

            next   

next   

close(w_waiting)   

iw_frame.enabled   =   true   

  

return   1

#4

在資料視窗中如何使游標所在儲存格改變顏色?   

  

我想判斷當前游標所在列號,由此使游標所在“儲存格”背景色變化一下。   

(注意:在datawindow的itemfocuschanged事件中可以用   

                dw_1.modify(dwo.background.color=\"顏色值\")改變。但是它改變   

                的是整個列的顏色。現在我要的是使游標所在的儲存格改變顏色。)   

我所要的是:   

    1,     游標在某行某列的儲存格上時是一種顏色,游標離開此儲存格,比如游標移動到左邊或右邊一列時,原來的儲存格恢複本來顏色,而被移動到的一列儲存格顏色又改變(注意:此時游標在同一行)   

    2,       當游標移動到下一行時,同一列之間只能是光表所在儲存格變色,其他上下儲存格保持原樣   

---------------------------------------------------------------    

在DW的ITEMFOCUSCHANGED事件,注意是ITEMFOCUSCHANGED事件:   

  

//此處聲明所用到的相關變數;  

Long   ll_col,ll_pos,ll_cols

String   modstring,ls_colnam,ls_color_1,ls_color_2

//此處給兩個顏色變數賦值;  

ls_color_1 = String(RGB(0,   255,   0))

ls_color_2 = String(RGB(255,0,0))

//此處擷取當前列號和總列數;  

ll_col = dw_1.GetColumn()

ll_cols = Long(dw_1.Object.DataWindow.Column.Count)

//此處將所有列的BACKGROUND的MODE屬性設為不透明;(註:下面兩句其實可以放到FORM的OPEN事件或DW的CONSTRUCTOR裡面執行,可以提高效率;)  

FOR   ll_pos = 1   TO   ll_cols

ls_colnam = dw_1.Describe("#"+String(ll_pos)+".Name")

dw_1.Modify(ls_colnam+".Background.Mode='0'")

NEXT

//此處將所操作列的Background.Color屬性設為帶IF判斷的運算式,而除此之外的各列的背景運算式均設為恒值;  

FOR   ll_pos = 1   TO   ll_cols

ls_colnam = dw_1.Describe("#"+String(ll_pos)+".Name")

IF   ll_pos <>   ll_col   THEN

   modstring = ls_colnam+".Background.Color='"+ls_color_1+"'"

ELSE

   modstring = ls_colnam+".Background.Color='"+ls_color_1+"   ~t   if   (getrow()=currentrow(),"+ls_color_2+","+ls_color_1+")'"

END   IF

//此處執行背景顏色修改;  

dw_1.Modify(modstring)

//重新整理顯示新的背景顏色;  

dw_1.SetRedraw(TRUE)

NEXT

  

最後的運行效果是當前ITEM為紅色,其他均為綠色。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.