uo_tv_cusarea.sru 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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 textcolor = 33554432
  16. borderstyle borderstyle = stylelowered!
  17. string picturename[] = {"Application!","Continue!"}
  18. long picturemaskcolor = 536870912
  19. long statepicturemaskcolor = 536870912
  20. end type
  21. global uo_tv_cusarea uo_tv_cusarea
  22. type variables
  23. Long uo_deep = 0
  24. s_cusarea uo_cur_info
  25. datastore ds
  26. boolean if_power = false
  27. end variables
  28. forward prototypes
  29. public function integer f_maketree ()
  30. public function integer f_getinfo (long arg_cusareaid)
  31. protected function integer pf_treegrowth (long arg_handl, long arg_parentid)
  32. public function integer f_ds_add (long arg_cusareaid)
  33. end prototypes
  34. public function integer f_maketree ();//wf_maketree()
  35. Long ll_hand
  36. uo_deep = 1
  37. Long tvi_hdl = 0
  38. long arr_empty[]
  39. IF IsValid(ds) THEN
  40. Destroy ds
  41. END IF
  42. ds = Create datastore
  43. ds.DataObject = 'ds_cusarea'
  44. ds.SetTransObject(sqlca)
  45. IF if_power THEN //or sys_option_cusarea=1
  46. ds.Retrieve(sys_areaid)
  47. ELSE
  48. arr_empty[1] = 0
  49. ds.Retrieve(arr_empty)
  50. END IF
  51. DO UNTIL This.FindItem(RootTreeItem!, 0) = -1
  52. This.DeleteItem(tvi_hdl)
  53. LOOP
  54. ll_hand = This.InsertItemLast(0,'全部地区',1)
  55. pf_treegrowth(ll_hand,0)
  56. This.ExpandItem(ll_hand)
  57. RETURN 0
  58. end function
  59. public function integer f_getinfo (long arg_cusareaid);Int rslt = 1
  60. Long ll_row
  61. ll_row = ds.Find("Cusareaid = "+String(arg_Cusareaid), 1, ds.RowCount())
  62. IF ll_row > 0 THEN
  63. uo_cur_info.Cusareaid = ds.Object.Cusareaid[ll_row]
  64. uo_cur_info.Cusareaname = ds.Object.Cusareaname[ll_row]
  65. uo_cur_info.areaname = ds.Object.areaname[ll_row]
  66. uo_cur_info.sonflag = ds.Object.sonflag[ll_row]
  67. uo_cur_info.parentid = ds.Object.parentid[ll_row]
  68. uo_cur_info.typecode = ds.Object.typecode[ll_row]
  69. uo_cur_info.typecodestr = ds.Object.typecodestr[ll_row]
  70. uo_cur_info.parenthandtype = ds.Object.pareaname[ll_row]
  71. // uo_cur_info.parenttypecodestr = ds.Object.parenttypecodestr[ll_row]
  72. ELSE
  73. uo_cur_info.Cusareaid = 0
  74. uo_cur_info.Cusareaname = ''
  75. uo_cur_info.areaname = ''
  76. uo_cur_info.sonflag = 0
  77. uo_cur_info.parentid = 0
  78. uo_cur_info.typecode = ''
  79. uo_cur_info.typecodestr = ''
  80. uo_cur_info.parenthandtype = ''
  81. // uo_cur_info.parenttypecodestr = ''
  82. END IF
  83. //int rslt = 1
  84. //select Cusareaid,
  85. // Cusareaname,
  86. // areaname,
  87. // sonflag,
  88. // parentid,
  89. // typecode,
  90. // typecodestr
  91. //into :uo_cur_info.Cusareaid,
  92. // :uo_cur_info.Cusareaname,
  93. // :uo_cur_info.areaname,
  94. // :uo_cur_info.sonflag,
  95. // :uo_cur_info.parentid,
  96. // :uo_cur_info.typecode,
  97. // :uo_cur_info.typecodestr
  98. //from u_Cusarea
  99. //where Cusareaid = :arg_Cusareaid;
  100. //
  101. //if sqlca.sqlcode <> 0 then
  102. // uo_cur_info.Cusareaid=0
  103. // uo_cur_info.Cusareaname=''
  104. // uo_cur_info.areaname=''
  105. // uo_cur_info.sonflag=0
  106. // uo_cur_info.parentid=0
  107. // uo_cur_info.parenthandtype = ''
  108. // uo_cur_info.typecode = ''
  109. // uo_cur_info.typecodestr = ''
  110. // rslt = 0
  111. // goto ext
  112. //end if
  113. //
  114. //string ls_parenthandtype
  115. //long ll_parentid
  116. //
  117. //ll_parentid = uo_cur_info.parentid
  118. //
  119. //if uo_cur_info.parentid = 0 then
  120. // uo_cur_info.parenthandtype = ''
  121. //else
  122. // select areaname
  123. // into :ls_parenthandtype
  124. // from u_Cusarea
  125. // where Cusareaid=:ll_parentid;
  126. // if sqlca.sqlcode <> 0 then
  127. // uo_cur_info.parenthandtype = ''
  128. // else
  129. // uo_cur_info.parenthandtype = ls_parenthandtype
  130. // end if
  131. //end if
  132. //
  133. //ext:
  134. return rslt
  135. end function
  136. protected function integer pf_treegrowth (long arg_handl, long arg_parentid);//====================================================================
  137. // Function: pf_treegrowth()
  138. //--------------------------------------------------------------------
  139. // Description:
  140. //--------------------------------------------------------------------
  141. // Arguments:
  142. // long arg_handl
  143. // long arg_parentid
  144. //--------------------------------------------------------------------
  145. // Returns: integer
  146. //--------------------------------------------------------------------
  147. // Author: yyx Date: 2005.01.28
  148. //--------------------------------------------------------------------
  149. // Modify History:
  150. //
  151. //====================================================================
  152. Long rslt = 1
  153. Long ll_CusareaID,ll_count = 0,ll_i
  154. String ls_Cusareaname,ls_areaname
  155. Int li_sonflag
  156. s_cusarea l_s_pfmx[]
  157. Long li_handl
  158. TreeViewItem l_tvi
  159. uo_deep++
  160. IF uo_deep > 10000 THEN //防止死递归
  161. RETURN 0
  162. END IF
  163. Long ll_row
  164. ll_row = ds.Find("parentid = "+String(arg_parentid), 1, ds.RowCount())
  165. ll_count = 0
  166. DO WHILE ll_row > 0
  167. ll_count++
  168. l_s_pfmx[ll_count].CusareaID = ds.Object.CusareaID[ll_row]
  169. l_s_pfmx[ll_count].Cusareaname = ds.Object.Cusareaname[ll_row]
  170. l_s_pfmx[ll_count].areaname = ds.Object.areaname[ll_row]
  171. l_s_pfmx[ll_count].parentid = ds.Object.parentid[ll_row]
  172. l_s_pfmx[ll_count].typecode = ds.Object.typecode[ll_row]
  173. l_s_pfmx[ll_count].sonflag = ds.Object.sonflag[ll_row]
  174. l_s_pfmx[ll_count].typecodestr = ds.Object.typecodestr[ll_row]
  175. IF ll_row >= ds.RowCount() THEN EXIT
  176. ll_row = ds.Find("parentid = "+String(arg_parentid), ll_row + 1, ds.RowCount())
  177. LOOP
  178. //DECLARE pf_cur CURSOR FOR
  179. // SELECT u_Cusarea.CusareaID,
  180. // u_Cusarea.Cusareaname,
  181. // u_Cusarea.areaname,
  182. // u_Cusarea.sonflag,
  183. // u_Cusarea.typecode,
  184. // u_Cusarea.typecodestr
  185. // FROM u_Cusarea
  186. // WHERE ( u_Cusarea.parentid = :arg_parentid );
  187. //open pf_cur;
  188. //ll_count = 1
  189. //fetch pf_cur into :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
  190. // :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag,&
  191. // :l_s_pfmx[ll_count].typecode,&
  192. // :l_s_pfmx[ll_count].typecodestr;
  193. //
  194. //do while sqlca.sqlcode = 0
  195. // ll_count++
  196. // fetch pf_cur into :l_s_pfmx[ll_count].CusareaID,:l_s_pfmx[ll_count].Cusareaname,&
  197. // :l_s_pfmx[ll_count].areaname,:l_s_pfmx[ll_count].sonflag,&
  198. // :l_s_pfmx[ll_count].typecode,&
  199. // :l_s_pfmx[ll_count].typecodestr;
  200. //loop
  201. //ll_count = ll_count - 1
  202. //close pf_cur;
  203. FOR ll_i = 1 To ll_count
  204. IF Not (sys_power_issuper Or sys_areastr = '0') THEN
  205. IF Pos(sys_areastr,','+String(l_s_pfmx[ll_i].CusareaID)+',') = 0 THEN CONTINUE
  206. END IF
  207. li_handl = This.InsertItemSort(arg_handl,l_s_pfmx[ll_i].Cusareaname,2)
  208. IF This.GetItem ( li_handl, l_tvi) = 1 THEN
  209. // l_tvi.Label = l_s_pfmx[ll_i].typecode + ' ' + l_s_pfmx[ll_i].Cusareaname
  210. IF l_s_pfmx[ll_i].typecode = '' THEN
  211. l_tvi.Label = l_s_pfmx[ll_i].Cusareaname
  212. ELSE
  213. l_tvi.Label = l_s_pfmx[ll_i].Cusareaname+"["+l_s_pfmx[ll_i].typecode +"]"
  214. END IF
  215. l_tvi.Data = l_s_pfmx[ll_i].CusareaID
  216. This.SetItem( li_handl, l_tvi )
  217. END IF
  218. pf_treegrowth(li_handl,l_s_pfmx[ll_i].CusareaID)
  219. NEXT
  220. RETURN 1
  221. end function
  222. public function integer f_ds_add (long arg_cusareaid);//==============================================================================
  223. // 函数: uo_tv_Cusareaname::f_ds_add()
  224. //------------------------------------------------------------------------------
  225. // 描述: //类别新增时,要刷新ds,如果ds的结构改变,这函数要相应调整
  226. //------------------------------------------------------------------------------
  227. // 参数:
  228. // value long arg_Cusareaid
  229. //------------------------------------------------------------------------------
  230. // 返回值: integer
  231. //------------------------------------------------------------------------------
  232. // 作者: HD Lee 日期: 2011.11.04
  233. //------------------------------------------------------------------------------
  234. // 修改历史:
  235. //
  236. //==============================================================================
  237. long ll_Cusareaid
  238. string ls_Cusareaname
  239. string ls_areaname
  240. int li_sonflag
  241. long ll_parentid
  242. string ls_typecode
  243. string ls_typecodestr
  244. string ls_parenthandtype
  245. string ls_parenttypecodestr
  246. Int rslt = 1
  247. Long ll_row
  248. ll_row = ds.Find("Cusareaid = "+String(arg_Cusareaid), 1, ds.RowCount())
  249. IF ll_row > 0 THEN return 1
  250. select u_Cusarea.Cusareaid,
  251. u_Cusarea.Cusareaname,
  252. u_Cusarea.areaname,
  253. u_Cusarea.sonflag,
  254. u_Cusarea.parentid,
  255. u_Cusarea.typecode,
  256. u_Cusarea.typecodestr,
  257. isnull(u_Cusarea_p.areaname,'') as parenthandtype,
  258. isnull(u_Cusarea_p.typecodestr,'') as parenttypecodestr
  259. into :ll_Cusareaid,
  260. :ls_Cusareaname,
  261. :ls_areaname,
  262. :li_sonflag,
  263. :ll_parentid,
  264. :ls_typecode,
  265. :ls_typecodestr,
  266. :ls_parenthandtype,
  267. :ls_parenttypecodestr
  268. from u_Cusarea left outer join u_Cusarea u_Cusarea_p
  269. on u_Cusarea.parentid = u_Cusarea_p.Cusareaid
  270. where u_Cusarea.Cusareaid = :arg_Cusareaid;
  271. ll_row = ds.insertrow(0)
  272. ds.object.Cusareaid[ll_row] = ll_Cusareaid
  273. ds.Object.Cusareaname[ll_row] = ls_Cusareaname
  274. ds.Object.areaname[ll_row] = ls_areaname
  275. ds.Object.sonflag[ll_row] = li_sonflag
  276. ds.Object.parentid[ll_row] = ll_parentid
  277. ds.Object.typecode[ll_row] = ls_typecode
  278. ds.Object.typecodestr[ll_row] = ls_typecodestr
  279. ds.Object.pareaname[ll_row] = ls_parenthandtype
  280. ds.Object.ptypecodestr[ll_row] = ls_parenttypecodestr
  281. return 1
  282. end function
  283. on uo_tv_cusarea.create
  284. end on
  285. on uo_tv_cusarea.destroy
  286. end on
  287. event constructor;f_maketree()
  288. end event
  289. event selectionchanged;long ll_hand
  290. long ll_cusareaid
  291. TreeViewItem l_tvi
  292. ll_hand = this.finditem(CurrentTreeItem!,0)
  293. if this.getitem(ll_hand,l_tvi) = 1 then
  294. if ll_hand = 1 then
  295. ll_cusareaid = 0
  296. else
  297. ll_cusareaid = l_tvi.data
  298. end if
  299. f_getinfo(ll_cusareaid)
  300. this.expanditem(ll_hand)
  301. end if
  302. end event