123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- $PBExportHeader$uo_tv_cusarea.sru
- forward
- global type uo_tv_cusarea from treeview
- end type
- end forward
- global type uo_tv_cusarea from treeview
- integer width = 549
- integer height = 452
- integer textsize = -12
- integer weight = 400
- fontcharset fontcharset = ansi!
- fontpitch fontpitch = variable!
- fontfamily fontfamily = swiss!
- string facename = "Arial"
- long textcolor = 33554432
- borderstyle borderstyle = stylelowered!
- string picturename[] = {"Application!","Continue!"}
- long picturemaskcolor = 536870912
- long statepicturemaskcolor = 536870912
- end type
- global uo_tv_cusarea uo_tv_cusarea
- type variables
- Long uo_deep = 0
- s_cusarea uo_cur_info
- datastore ds
- boolean if_power = false
- end variables
- forward prototypes
- public function integer f_maketree ()
- public function integer f_getinfo (long arg_cusareaid)
- protected function integer pf_treegrowth (long arg_handl, long arg_parentid)
- public function integer f_ds_add (long arg_cusareaid)
- end prototypes
- public function integer f_maketree ();//wf_maketree()
- Long ll_hand
- uo_deep = 1
- Long tvi_hdl = 0
- long arr_empty[]
- IF IsValid(ds) THEN
- Destroy ds
- END IF
- ds = Create datastore
- ds.DataObject = 'ds_cusarea'
- ds.SetTransObject(sqlca)
- IF if_power THEN //or sys_option_cusarea=1
- ds.Retrieve(sys_areaid)
- ELSE
- arr_empty[1] = 0
- ds.Retrieve(arr_empty)
- END IF
- DO UNTIL This.FindItem(RootTreeItem!, 0) = -1
- This.DeleteItem(tvi_hdl)
- LOOP
- ll_hand = This.InsertItemLast(0,'全部地区',1)
- pf_treegrowth(ll_hand,0)
- This.ExpandItem(ll_hand)
- RETURN 0
- end function
- public function integer f_getinfo (long arg_cusareaid);Int rslt = 1
- Long ll_row
- ll_row = ds.Find("Cusareaid = "+String(arg_Cusareaid), 1, ds.RowCount())
- IF ll_row > 0 THEN
- uo_cur_info.Cusareaid = ds.Object.Cusareaid[ll_row]
- uo_cur_info.Cusareaname = ds.Object.Cusareaname[ll_row]
- uo_cur_info.areaname = ds.Object.areaname[ll_row]
- uo_cur_info.sonflag = ds.Object.sonflag[ll_row]
- uo_cur_info.parentid = ds.Object.parentid[ll_row]
- uo_cur_info.typecode = ds.Object.typecode[ll_row]
- uo_cur_info.typecodestr = ds.Object.typecodestr[ll_row]
- uo_cur_info.parenthandtype = ds.Object.pareaname[ll_row]
- // uo_cur_info.parenttypecodestr = ds.Object.parenttypecodestr[ll_row]
- ELSE
- uo_cur_info.Cusareaid = 0
- uo_cur_info.Cusareaname = ''
- uo_cur_info.areaname = ''
- uo_cur_info.sonflag = 0
- uo_cur_info.parentid = 0
- uo_cur_info.typecode = ''
- uo_cur_info.typecodestr = ''
- uo_cur_info.parenthandtype = ''
- // uo_cur_info.parenttypecodestr = ''
- END IF
- //int rslt = 1
- //select Cusareaid,
- // Cusareaname,
- // areaname,
- // sonflag,
- // parentid,
- // typecode,
- // typecodestr
- //into :uo_cur_info.Cusareaid,
- // :uo_cur_info.Cusareaname,
- // :uo_cur_info.areaname,
- // :uo_cur_info.sonflag,
- // :uo_cur_info.parentid,
- // :uo_cur_info.typecode,
- // :uo_cur_info.typecodestr
- //from u_Cusarea
- //where Cusareaid = :arg_Cusareaid;
- //
- //if sqlca.sqlcode <> 0 then
- // uo_cur_info.Cusareaid=0
- // uo_cur_info.Cusareaname=''
- // uo_cur_info.areaname=''
- // uo_cur_info.sonflag=0
- // uo_cur_info.parentid=0
- // uo_cur_info.parenthandtype = ''
- // uo_cur_info.typecode = ''
- // uo_cur_info.typecodestr = ''
- // rslt = 0
- // goto ext
- //end if
- //
- //string ls_parenthandtype
- //long ll_parentid
- //
- //ll_parentid = uo_cur_info.parentid
- //
- //if uo_cur_info.parentid = 0 then
- // uo_cur_info.parenthandtype = ''
- //else
- // select areaname
- // into :ls_parenthandtype
- // from u_Cusarea
- // where Cusareaid=:ll_parentid;
- // if sqlca.sqlcode <> 0 then
- // uo_cur_info.parenthandtype = ''
- // else
- // uo_cur_info.parenthandtype = ls_parenthandtype
- // end if
- //end if
- //
- //ext:
- return rslt
- end function
- protected function integer pf_treegrowth (long arg_handl, long arg_parentid);//====================================================================
- // Function: pf_treegrowth()
- //--------------------------------------------------------------------
- // Description:
- //--------------------------------------------------------------------
- // Arguments:
- // long arg_handl
- // long arg_parentid
- //--------------------------------------------------------------------
- // Returns: integer
- //--------------------------------------------------------------------
- // Author: yyx Date: 2005.01.28
- //--------------------------------------------------------------------
- // Modify History:
- //
- //====================================================================
- Long rslt = 1
- Long ll_CusareaID,ll_count = 0,ll_i
- String ls_Cusareaname,ls_areaname
- Int li_sonflag
- s_cusarea l_s_pfmx[]
- Long li_handl
- TreeViewItem l_tvi
- uo_deep++
- IF uo_deep > 10000 THEN //防止死递归
- RETURN 0
- END IF
- Long ll_row
- ll_row = ds.Find("parentid = "+String(arg_parentid), 1, ds.RowCount())
- ll_count = 0
- DO WHILE ll_row > 0
- ll_count++
- l_s_pfmx[ll_count].CusareaID = ds.Object.CusareaID[ll_row]
- l_s_pfmx[ll_count].Cusareaname = ds.Object.Cusareaname[ll_row]
- l_s_pfmx[ll_count].areaname = ds.Object.areaname[ll_row]
- l_s_pfmx[ll_count].parentid = ds.Object.parentid[ll_row]
- l_s_pfmx[ll_count].typecode = ds.Object.typecode[ll_row]
- l_s_pfmx[ll_count].sonflag = ds.Object.sonflag[ll_row]
- l_s_pfmx[ll_count].typecodestr = ds.Object.typecodestr[ll_row]
-
-
- IF ll_row >= ds.RowCount() THEN EXIT
- ll_row = ds.Find("parentid = "+String(arg_parentid), ll_row + 1, ds.RowCount())
- LOOP
- //DECLARE pf_cur CURSOR FOR
- // SELECT u_Cusarea.CusareaID,
- // u_Cusarea.Cusareaname,
- // u_Cusarea.areaname,
- // u_Cusarea.sonflag,
- // u_Cusarea.typecode,
- // u_Cusarea.typecodestr
- // FROM u_Cusarea
- // WHERE ( u_Cusarea.parentid = :arg_parentid );
- //open pf_cur;
- //ll_count = 1
- //fetch pf_cur into :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
- // :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag,&
- // :l_s_pfmx[ll_count].typecode,&
- // :l_s_pfmx[ll_count].typecodestr;
- //
- //do while sqlca.sqlcode = 0
- // ll_count++
- // fetch pf_cur into :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
- // :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag,&
- // :l_s_pfmx[ll_count].typecode,&
- // :l_s_pfmx[ll_count].typecodestr;
- //loop
- //ll_count = ll_count - 1
- //close pf_cur;
- FOR ll_i = 1 To ll_count
- IF Not (sys_power_issuper Or sys_areastr = '0') THEN
- IF Pos(sys_areastr,','+String(l_s_pfmx[ll_i].CusareaID)+',') = 0 THEN CONTINUE
- END IF
-
- li_handl = This.InsertItemSort(arg_handl,l_s_pfmx[ll_i].Cusareaname,2)
-
- IF This.GetItem ( li_handl, l_tvi) = 1 THEN
- // l_tvi.Label = l_s_pfmx[ll_i].typecode + ' ' + l_s_pfmx[ll_i].Cusareaname
- IF l_s_pfmx[ll_i].typecode = '' THEN
- l_tvi.Label = l_s_pfmx[ll_i].Cusareaname
- ELSE
- l_tvi.Label = l_s_pfmx[ll_i].Cusareaname+"["+l_s_pfmx[ll_i].typecode +"]"
- END IF
- l_tvi.Data = l_s_pfmx[ll_i].CusareaID
- This.SetItem( li_handl, l_tvi )
- END IF
-
- pf_treegrowth(li_handl,l_s_pfmx[ll_i].CusareaID)
- NEXT
- RETURN 1
- end function
- public function integer f_ds_add (long arg_cusareaid);//==============================================================================
- // 函数: uo_tv_Cusareaname::f_ds_add()
- //------------------------------------------------------------------------------
- // 描述: //类别新增时,要刷新ds,如果ds的结构改变,这函数要相应调整
- //------------------------------------------------------------------------------
- // 参数:
- // value long arg_Cusareaid
- //------------------------------------------------------------------------------
- // 返回值: integer
- //------------------------------------------------------------------------------
- // 作者: HD Lee 日期: 2011.11.04
- //------------------------------------------------------------------------------
- // 修改历史:
- //
- //==============================================================================
- long ll_Cusareaid
- string ls_Cusareaname
- string ls_areaname
- int li_sonflag
- long ll_parentid
- string ls_typecode
- string ls_typecodestr
- string ls_parenthandtype
- string ls_parenttypecodestr
-
- Int rslt = 1
- Long ll_row
- ll_row = ds.Find("Cusareaid = "+String(arg_Cusareaid), 1, ds.RowCount())
- IF ll_row > 0 THEN return 1
-
- select u_Cusarea.Cusareaid,
- u_Cusarea.Cusareaname,
- u_Cusarea.areaname,
- u_Cusarea.sonflag,
- u_Cusarea.parentid,
- u_Cusarea.typecode,
- u_Cusarea.typecodestr,
- isnull(u_Cusarea_p.areaname,'') as parenthandtype,
- isnull(u_Cusarea_p.typecodestr,'') as parenttypecodestr
- into :ll_Cusareaid,
- :ls_Cusareaname,
- :ls_areaname,
- :li_sonflag,
- :ll_parentid,
- :ls_typecode,
- :ls_typecodestr,
- :ls_parenthandtype,
- :ls_parenttypecodestr
- from u_Cusarea left outer join u_Cusarea u_Cusarea_p
- on u_Cusarea.parentid = u_Cusarea_p.Cusareaid
- where u_Cusarea.Cusareaid = :arg_Cusareaid;
- ll_row = ds.insertrow(0)
- ds.object.Cusareaid[ll_row] = ll_Cusareaid
- ds.Object.Cusareaname[ll_row] = ls_Cusareaname
- ds.Object.areaname[ll_row] = ls_areaname
- ds.Object.sonflag[ll_row] = li_sonflag
- ds.Object.parentid[ll_row] = ll_parentid
- ds.Object.typecode[ll_row] = ls_typecode
- ds.Object.typecodestr[ll_row] = ls_typecodestr
- ds.Object.pareaname[ll_row] = ls_parenthandtype
- ds.Object.ptypecodestr[ll_row] = ls_parenttypecodestr
- return 1
- end function
- on uo_tv_cusarea.create
- end on
- on uo_tv_cusarea.destroy
- end on
- event constructor;f_maketree()
- end event
- event selectionchanged;long ll_hand
- long ll_cusareaid
- TreeViewItem l_tvi
- ll_hand = this.finditem(CurrentTreeItem!,0)
- if this.getitem(ll_hand,l_tvi) = 1 then
- if ll_hand = 1 then
- ll_cusareaid = 0
- else
- ll_cusareaid = l_tvi.data
- end if
- f_getinfo(ll_cusareaid)
- this.expanditem(ll_hand)
- end if
- end event
|