uo_tv_cusarea.sru 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. $PBExportHeader$uo_tv_cusarea.sru
  2. forward
  3. global type uo_tv_cusarea from treeview
  4. end type
  5. end forward
  6. global type uo_tv_cusarea from treeview
  7. integer width = 549
  8. integer height = 452
  9. integer textsize = -12
  10. integer weight = 400
  11. fontcharset fontcharset = ansi!
  12. fontpitch fontpitch = variable!
  13. fontfamily fontfamily = swiss!
  14. string facename = "Arial"
  15. long backcolor = 16777215
  16. borderstyle borderstyle = stylelowered!
  17. boolean hideselection = false
  18. string picturename[] = {"Application!","LibraryList5!"}
  19. long picturemaskcolor = 553648127
  20. long statepicturemaskcolor = 536870912
  21. end type
  22. global uo_tv_cusarea uo_tv_cusarea
  23. type variables
  24. Long uo_deep = 0
  25. s_cusarea uo_cur_info
  26. datastore ds_area
  27. end variables
  28. forward prototypes
  29. public function integer pf_treegrowth (long arg_handl, long arg_parentid)
  30. public function integer f_maketree ()
  31. public function integer f_getinfo (long arg_cusareaid)
  32. end prototypes
  33. public function integer pf_treegrowth (long arg_handl, long arg_parentid);Int rslt = 1
  34. Long ll_CusareaID,ll_count = 0,ll_i
  35. String ls_Cusareaname,ls_areaname
  36. Int li_sonflag
  37. s_cusarea l_s_pfmx[]
  38. Long li_handl
  39. TreeViewItem l_tvi
  40. uo_deep++
  41. IF uo_deep > 10000 THEN //防止死递归
  42. RETURN 0
  43. END IF
  44. DECLARE pf_cur CURSOR FOR
  45. SELECT u_Cusarea.CusareaID,
  46. u_Cusarea.Cusareaname,
  47. u_Cusarea.areaname,
  48. u_Cusarea.sonflag
  49. FROM u_Cusarea
  50. Where ( u_Cusarea.parentid = :arg_parentid );
  51. OPEN pf_cur;
  52. ll_count = 1
  53. FETCH pf_cur INTO :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
  54. :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag;
  55. DO WHILE sqlca.SQLCode = 0
  56. ll_count++
  57. FETCH pf_cur INTO :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
  58. :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag;
  59. LOOP
  60. ll_count = ll_count - 1
  61. CLOSE pf_cur;
  62. //
  63. // //yyx 2011-2-15
  64. //ds_area.Retrieve(arg_parentid,sys_areaid)
  65. //ds_area.AcceptText()
  66. //FOR ll_i = 1 TO ds_area.rowcount()
  67. // ll_count++
  68. // l_s_pfmx[ll_count].CusareaID = ds_area.Object.CusareaID[ll_i]
  69. // l_s_pfmx[ll_count].Cusareaname = ds_area.Object.Cusareaname[ll_i]
  70. // l_s_pfmx[ll_count].areaname = ds_area.Object.areaname[ll_i]
  71. // l_s_pfmx[ll_count].sonflag = ds_area.Object.sonflag[ll_i]
  72. //NEXT
  73. ////
  74. FOR ll_i = 1 To ll_count
  75. IF Not (sys_power_issuper Or sys_areastr = '0') THEN
  76. IF Pos(sys_areastr,','+String(l_s_pfmx[ll_i].CusareaID)+',') = 0 THEN CONTINUE
  77. END IF
  78. li_handl = This.InsertItemSort(arg_handl,l_s_pfmx[ll_i].Cusareaname,2)
  79. IF This.GetItem ( li_handl, l_tvi) = 1 THEN
  80. l_tvi.Label = l_s_pfmx[ll_i].Cusareaname
  81. l_tvi.Data = l_s_pfmx[ll_i].CusareaID
  82. This.SetItem( li_handl, l_tvi )
  83. END IF
  84. pf_treegrowth(li_handl,l_s_pfmx[ll_i].CusareaID)
  85. NEXT
  86. RETURN 1
  87. end function
  88. public function integer f_maketree ();//wf_maketree()
  89. Long ll_hand
  90. uo_deep = 1
  91. Long tvi_hdl = 0
  92. This.SetRedraw(False)
  93. DO UNTIL This.FindItem(RootTreeItem!, 0) = -1
  94. This.DeleteItem(tvi_hdl)
  95. LOOP
  96. ll_hand = This.InsertItemLast(0,'全部地区',1)
  97. pf_treegrowth(ll_hand,0)
  98. This.ExpandItem(ll_hand)
  99. This.SetRedraw(True)
  100. RETURN 0
  101. end function
  102. public function integer f_getinfo (long arg_cusareaid);Int rslt = 1
  103. SELECT Cusareaid,
  104. Cusareaname,
  105. areaname,
  106. sonflag,
  107. parentid
  108. INTO :uo_cur_info.Cusareaid,
  109. :uo_cur_info.Cusareaname,
  110. :uo_cur_info.areaname,
  111. :uo_cur_info.sonflag,
  112. :uo_cur_info.parentid
  113. FROM u_Cusarea
  114. Where Cusareaid = :arg_Cusareaid;
  115. IF sqlca.SQLCode <> 0 THEN
  116. uo_cur_info.Cusareaid = 0
  117. uo_cur_info.Cusareaname = ''
  118. uo_cur_info.areaname = ''
  119. uo_cur_info.sonflag = 0
  120. uo_cur_info.parentid = 0
  121. uo_cur_info.parenthandtype = ''
  122. rslt = 0
  123. GOTO ext
  124. END IF
  125. String ls_parenthandtype
  126. Long ll_parentid
  127. ll_parentid = uo_cur_info.parentid
  128. IF uo_cur_info.parentid = 0 THEN
  129. uo_cur_info.parenthandtype = ''
  130. ELSE
  131. SELECT areaname
  132. INTO :ls_parenthandtype
  133. FROM u_Cusarea
  134. Where Cusareaid = :ll_parentid;
  135. IF sqlca.SQLCode <> 0 THEN
  136. uo_cur_info.parenthandtype = ''
  137. ELSE
  138. uo_cur_info.parenthandtype = ls_parenthandtype
  139. END IF
  140. END IF
  141. ext:
  142. RETURN rslt
  143. end function
  144. on uo_tv_cusarea.create
  145. end on
  146. on uo_tv_cusarea.destroy
  147. end on
  148. event constructor;ds_area = CREATE datastore
  149. ds_area.DataObject = 'ds_uo_tv_cusarea'
  150. ds_area.SetTransObject(sqlca)
  151. f_maketree()
  152. end event
  153. event selectionchanged;Long ll_hand
  154. Long ll_cusareaid
  155. TreeViewItem l_tvi
  156. ll_hand = THIS.FindItem(CurrentTreeItem!,0)
  157. IF THIS.GetItem(ll_hand,l_tvi) = 1 THEN
  158. IF ll_hand = 1 THEN
  159. ll_cusareaid = 0
  160. ELSE
  161. ll_cusareaid = l_tvi.Data
  162. END IF
  163. f_getinfo(ll_cusareaid)
  164. THIS.ExpandItem(ll_hand)
  165. END IF
  166. end event
  167. event destructor;DESTROY ds_area
  168. end event