uo_ljnc_listbox.sru 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. $PBExportHeader$uo_ljnc_listbox.sru
  2. forward
  3. global type uo_ljnc_listbox from listbox
  4. end type
  5. type datastore_1 from datastore within uo_ljnc_listbox
  6. end type
  7. type ljnc_lisbox_update_timer from timing within uo_ljnc_listbox
  8. end type
  9. type ljnc_lisbox_display_timer from timing within uo_ljnc_listbox
  10. end type
  11. end forward
  12. global type uo_ljnc_listbox from listbox
  13. integer width = 549
  14. integer height = 476
  15. integer textsize = -9
  16. integer weight = 400
  17. fontcharset fontcharset = gb2312charset!
  18. fontpitch fontpitch = variable!
  19. string facename = "宋体"
  20. long textcolor = 33554432
  21. borderstyle borderstyle = stylelowered!
  22. event ue_lbuttondblclk pbm_lbuttondblclk
  23. datastore_1 datastore_1
  24. ljnc_lisbox_update_timer ljnc_lisbox_update_timer
  25. ljnc_lisbox_display_timer ljnc_lisbox_display_timer
  26. end type
  27. global uo_ljnc_listbox uo_ljnc_listbox
  28. type variables
  29. int display_count = 2 //默认2条
  30. int display_time = 5 //listbox刷新周期
  31. int update_time = 30//数据库请求更新周期
  32. private int update_seconds = 0;
  33. private int display_seconds =0 ;
  34. private int c_display_row=0 //记录滚动到哪一条
  35. private OLEObject o_ljnc_program
  36. end variables
  37. forward prototypes
  38. public subroutine getdata ()
  39. public subroutine showdata ()
  40. public subroutine sync_db (string arg_version)
  41. end prototypes
  42. event ue_lbuttondblclk;string ls_selecttext
  43. ls_selecttext = selecteditem()
  44. s_edit_index_tran ss_edit_index_tran
  45. ss_edit_index_tran.arg_string_code = ls_selecttext
  46. ss_edit_index_tran.ds_share=datastore_1
  47. openwithparm(w_ljnc_preview,ss_edit_index_tran)
  48. if ls_selecttext = '' then return
  49. String lnc_title
  50. long ll_row,ll_rowcount
  51. lnc_title = left(ss_edit_index_tran.arg_string_code,pos(ss_edit_index_tran.arg_string_code,'[') -1)
  52. ll_rowcount= datastore_1.rowcount( )
  53. FOR ll_row=1 TO ll_rowcount
  54. IF datastore_1.getitemstring( ll_row,1) =lnc_title THEN
  55. datastore_1.deleterow(ll_row)
  56. END IF
  57. NEXT
  58. end event
  59. public subroutine getdata ();datastore_1.retrieve(publ_userid)
  60. end subroutine
  61. public subroutine showdata ();long ll_row,ll_row_count,i
  62. reset( )
  63. ll_row=c_display_row + 1
  64. ll_row_count=c_display_row + display_count
  65. IF ll_row_count>=datastore_1.rowcount() THEN
  66. ll_row_count =datastore_1.rowcount()
  67. c_display_row=0
  68. ELSE
  69. c_display_row=ll_row_count
  70. END IF
  71. FOR i=ll_row to ll_row_count
  72. additem(datastore_1.getitemstring( i , 1)+ '['+ String(datastore_1.getitemdatetime( i, 2),'yyyy-mm-dd')+ ']')
  73. NEXT
  74. end subroutine
  75. public subroutine sync_db (string arg_version);// 同步数据到本地
  76. String lnc_type
  77. DateTime lastmodifydt
  78. IF Not IsNull(o_ljnc_program) THEN
  79. lnc_type = arg_version
  80. SELECT
  81. Max(dbo.lnc_notice.modifydt)
  82. Into :lastmodifydt
  83. From
  84. dbo.lnc_notice;
  85. IF IsNull(lastmodifydt) THEN lastmodifydt = DateTime(Date('1900-01-01'),Time('00:00:00'))
  86. o_ljnc_program.GetNoticeList(lnc_type,lastmodifydt) //调用LJNCProxy类方法GetNoticeList获取数据
  87. END IF
  88. end subroutine
  89. on uo_ljnc_listbox.create
  90. this.datastore_1=create datastore_1
  91. this.ljnc_lisbox_update_timer=create ljnc_lisbox_update_timer
  92. this.ljnc_lisbox_display_timer=create ljnc_lisbox_display_timer
  93. end on
  94. on uo_ljnc_listbox.destroy
  95. destroy(this.datastore_1)
  96. destroy(this.ljnc_lisbox_update_timer)
  97. destroy(this.ljnc_lisbox_display_timer)
  98. end on
  99. event constructor;
  100. //注册LJNC.DLL
  101. o_ljnc_program = Create oleobject
  102. uo_reghelper uo_reg
  103. uo_reg = Create uo_reghelper
  104. String arg_msg = ''
  105. IF FileExists('LJNC.dll') THEN
  106. IF uo_reg.ConnectToNewObject("LJNC.LJNCProxy", "LJNC.dll", Ref o_ljnc_program, Ref arg_msg) <> 1 THEN
  107. Destroy o_ljnc_program
  108. SetNull(o_ljnc_program)
  109. else
  110. o_ljnc_program.init(sqlca.ServerName, sqlca.Database, sqlca.LogID, sqlca.LogPass)
  111. END IF
  112. else
  113. Destroy o_ljnc_program
  114. SetNull(o_ljnc_program)
  115. END IF
  116. Destroy uo_reg
  117. datastore_1.settransobject(sqlca)
  118. GetData( ) //装入数据库记录
  119. showdata() //显示记录
  120. end event
  121. event destructor;f_del_file(f_ljnc_get_path()+'fjtemp\',this) //删除临时目录下的所有临时文件
  122. end event
  123. type datastore_1 from datastore within uo_ljnc_listbox descriptor "pb_nvo" = "true"
  124. string dataobject = "dw_ljnc_unread_list"
  125. end type
  126. on datastore_1.create
  127. call super::create
  128. TriggerEvent( this, "constructor" )
  129. end on
  130. on datastore_1.destroy
  131. TriggerEvent( this, "destructor" )
  132. call super::destroy
  133. end on
  134. type ljnc_lisbox_update_timer from timing within uo_ljnc_listbox descriptor "pb_nvo" = "true"
  135. end type
  136. on ljnc_lisbox_update_timer.create
  137. call super::create
  138. TriggerEvent( this, "constructor" )
  139. end on
  140. on ljnc_lisbox_update_timer.destroy
  141. TriggerEvent( this, "destructor" )
  142. call super::destroy
  143. end on
  144. event timer;update_seconds = update_seconds +update_time
  145. IF update_seconds = update_time * 60 THEN
  146. sync_db(sys_cur_production_code)
  147. getdata()
  148. update_seconds=0
  149. END IF
  150. end event
  151. event constructor;this.start(update_time)
  152. end event
  153. type ljnc_lisbox_display_timer from timing within uo_ljnc_listbox descriptor "pb_nvo" = "true"
  154. end type
  155. on ljnc_lisbox_display_timer.create
  156. call super::create
  157. TriggerEvent( this, "constructor" )
  158. end on
  159. on ljnc_lisbox_display_timer.destroy
  160. TriggerEvent( this, "destructor" )
  161. call super::destroy
  162. end on
  163. event timer;showdata( )
  164. end event
  165. event constructor;this.start( display_time)
  166. end event