uo_tv_aifmb_class.sru 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. $PBExportHeader$uo_tv_aifmb_class.sru
  2. forward
  3. global type uo_tv_aifmb_class from treeview
  4. end type
  5. end forward
  6. global type uo_tv_aifmb_class from treeview
  7. integer width = 773
  8. integer height = 1024
  9. integer textsize = -9
  10. integer weight = 400
  11. fontcharset fontcharset = gb2312charset!
  12. fontpitch fontpitch = variable!
  13. string facename = "宋体"
  14. long textcolor = 33554432
  15. borderstyle borderstyle = stylelowered!
  16. boolean hideselection = false
  17. string picturename[] = {"Application!","Structure5!","UserObject5!"}
  18. long picturemaskcolor = 536870912
  19. long statepicturemaskcolor = 536870912
  20. event ue_retrieve_all ( )
  21. event ue_retrieve ( )
  22. end type
  23. global uo_tv_aifmb_class uo_tv_aifmb_class
  24. type variables
  25. private:
  26. datastore ds_classgroup
  27. datastore ds_classnode
  28. datastore ds_relation
  29. long ins_root = 0
  30. end variables
  31. forward prototypes
  32. public subroutine uf_build_tree ()
  33. private subroutine pf_build_child (long arg_handle)
  34. public function s_aifmb_tvi pf_getdata (long arg_handle)
  35. public subroutine pf_getnodeid (long arg_handle, ref long arg_nodeid_arr[])
  36. end prototypes
  37. event ue_retrieve_all();uo_aifmb = Create uo_aifmb
  38. String ls_msg
  39. IF uo_aifmb.uf_sync_node(ls_msg) <> 1 THEN
  40. MessageBox('ERROR', ls_msg)
  41. GOTO ext
  42. END IF
  43. uf_build_tree()
  44. ext:
  45. Destroy uo_aifmb
  46. end event
  47. event ue_retrieve();uo_aifmb = Create uo_aifmb
  48. String ls_msg
  49. IF uo_aifmb.uf_sync_node_bytime(ls_msg) <> 1 THEN
  50. MessageBox('ERROR', ls_msg)
  51. GOTO ext
  52. END IF
  53. uf_build_tree()
  54. ext:
  55. Destroy uo_aifmb
  56. end event
  57. public subroutine uf_build_tree ();IF ins_root > 0 THEN
  58. This.DeleteItem(ins_root)
  59. END IF
  60. ds_classgroup.SetTransObject(sqlca)
  61. ds_classnode.SetTransObject(sqlca)
  62. ds_relation.SetTransObject(sqlca)
  63. ds_classgroup.Retrieve()
  64. ds_classnode.Retrieve()
  65. ds_relation.Retrieve()
  66. pf_build_child(0)
  67. ExpandAll(ins_root)
  68. SetFirstVisible(ins_root)
  69. end subroutine
  70. private subroutine pf_build_child (long arg_handle);s_aifmb_tvi s_data
  71. treeviewitem tvi
  72. Long ll_handles[]
  73. Long ll_cnt = 0, ll_handle
  74. Long i, j
  75. IF arg_handle = 0 THEN
  76. s_data.reltype = 1
  77. s_data.relid = 0
  78. tvi.Data = s_data
  79. tvi.PictureIndex = 1
  80. tvi.SelectedPictureIndex = 1
  81. tvi.Label = '全部类别'
  82. ll_handle = This.InsertItemLast(arg_handle, tvi)
  83. IF ll_handle > 0 THEN
  84. ll_cnt++
  85. ll_handles[ll_cnt] = ll_handle
  86. ins_root = ll_handle
  87. END IF
  88. ELSE
  89. s_data = pf_getdata(arg_handle)
  90. IF s_data.reltype = 1 THEN
  91. ds_classgroup.SetFilter("parentid = " + String(s_data.relid))
  92. ds_classgroup.Filter()
  93. ds_relation.SetFilter("classid = " + String(s_data.relid))
  94. ds_relation.Filter()
  95. FOR i = 1 To ds_classgroup.RowCount()
  96. s_data.reltype = 1
  97. s_data.relid = ds_classgroup.Object.classid[i]
  98. tvi.Data = s_data
  99. tvi.PictureIndex = 2
  100. tvi.SelectedPictureIndex = 2
  101. tvi.Label = ds_classgroup.Object.ClassName[i]
  102. ll_handle = This.InsertItemLast(arg_handle, tvi)
  103. IF ll_handle > 0 THEN
  104. ll_cnt++
  105. ll_handles[ll_cnt] = ll_handle
  106. END IF
  107. NEXT
  108. FOR i = 1 To ds_relation.RowCount()
  109. j = ds_classnode.Find("nodeid = " + String(ds_relation.Object.nodeid[i]), 1, ds_classnode.RowCount())
  110. IF j > 0 THEN
  111. s_data.reltype = 2
  112. s_data.relid = ds_relation.Object.nodeid[i]
  113. tvi.Data = s_data
  114. tvi.PictureIndex = 3
  115. tvi.SelectedPictureIndex = 3
  116. tvi.Label = ds_classnode.Object.nodename[j] + '['+ds_classnode.Object.nodecode[j]+']'
  117. ll_handle = This.InsertItemLast(arg_handle, tvi)
  118. END IF
  119. NEXT
  120. END IF
  121. END IF
  122. FOR i = 1 To ll_cnt
  123. pf_build_child(ll_handles[i])
  124. NEXT
  125. end subroutine
  126. public function s_aifmb_tvi pf_getdata (long arg_handle);s_aifmb_tvi rslt
  127. rslt.reltype = 0
  128. rslt.relid = 0
  129. treeviewitem tvi
  130. IF arg_handle > 0 THEN
  131. IF This.GetItem(arg_handle, tvi) = 1 THEN
  132. IF Not IsNull(tvi.Data) THEN
  133. rslt = tvi.Data
  134. END IF
  135. END IF
  136. END IF
  137. RETURN rslt
  138. end function
  139. public subroutine pf_getnodeid (long arg_handle, ref long arg_nodeid_arr[]);s_aifmb_tvi s_data
  140. s_data = pf_getdata(arg_handle)
  141. Long i, j
  142. i = UpperBound(arg_nodeid_arr)
  143. IF s_data.reltype = 0 THEN
  144. arg_nodeid_arr[1] = 0
  145. ELSEIF s_data.reltype = 1 THEN
  146. Long ll_first
  147. ll_first = FindItem(ChildTreeItem!, arg_handle)
  148. DO WHILE ll_first > 0
  149. pf_getnodeid(ll_first, arg_nodeid_arr)
  150. ll_first = FindItem(NextTreeItem!, ll_first)
  151. LOOP
  152. ELSEIF s_data.reltype = 2 THEN
  153. FOR j = 1 To i
  154. IF arg_nodeid_arr[j] = s_data.relid THEN
  155. RETURN
  156. END IF
  157. NEXT
  158. arg_nodeid_arr[j] = s_data.relid
  159. END IF
  160. end subroutine
  161. on uo_tv_aifmb_class.create
  162. end on
  163. on uo_tv_aifmb_class.destroy
  164. end on
  165. event constructor;ds_classgroup = Create datastore
  166. ds_classnode = Create datastore
  167. ds_relation = Create datastore
  168. ds_classgroup.DataObject = 'ds_aifmb_classgroup'
  169. ds_classnode.DataObject = 'ds_aifmb_classnode'
  170. ds_relation.DataObject = 'ds_aifmb_relation'
  171. uf_build_tree()
  172. end event
  173. event destructor;Destroy ds_classgroup
  174. Destroy ds_classnode
  175. Destroy ds_relation
  176. end event