uo_tv_sendmail.sru 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. $PBExportHeader$uo_tv_sendmail.sru
  2. forward
  3. global type uo_tv_sendmail from treeview
  4. end type
  5. end forward
  6. global type uo_tv_sendmail from treeview
  7. integer width = 640
  8. integer height = 564
  9. integer textsize = -9
  10. fontcharset fontcharset = gb2312charset!
  11. fontpitch fontpitch = variable!
  12. string facename = "宋体"
  13. end type
  14. global uo_tv_sendmail uo_tv_sendmail
  15. type variables
  16. private:
  17. DataStore _ds_tv
  18. Transaction _tran
  19. string ori_oldselect
  20. long empid
  21. long cusareaid[]
  22. long spttypeid[]
  23. end variables
  24. forward prototypes
  25. public function integer f_init (transaction arg_tran)
  26. public function integer f_retrieve (long arg_empid, long arg_cusareaid[], long arg_spttypeid_arr[])
  27. public function integer f_maketree ()
  28. public function s_tv_sendmail f_getcontent (long arg_index)
  29. public function integer f_filter (string arg_parm)
  30. public function integer uf_getreltype (string arg_mailaddress)
  31. end prototypes
  32. public function integer f_init (transaction arg_tran);this._tran = arg_tran
  33. connect using this._tran;
  34. if isvalid(_ds_tv) then
  35. destroy this._ds_tv
  36. end if
  37. this._ds_tv = Create DataStore
  38. this._ds_tv.dataobject = 'ddd_tv_sandmail'
  39. this._ds_tv.SetTrans(this._tran)
  40. this.ori_oldselect = this._ds_tv.Describe("DataWindow.Table.Select")
  41. return 1
  42. end function
  43. public function integer f_retrieve (long arg_empid, long arg_cusareaid[], long arg_spttypeid_arr[]);this._ds_tv.retrieve(arg_empid, arg_cusareaid, arg_spttypeid_arr)
  44. this.empid = arg_empid
  45. this.cusareaid = arg_cusareaid
  46. this.spttypeid = arg_spttypeid_arr
  47. this.f_maketree( )
  48. return 0
  49. end function
  50. public function integer f_maketree ();//wf_maketree()
  51. long ll_rep_hand, ll_cus_hand, ll_spt_hand
  52. long i, li_parent,li_hand
  53. //uo_deep=1
  54. long tvi_hdl = 0
  55. DO UNTIL this.FindItem(RootTreeItem!, 0) = -1
  56. this.DeleteItem(tvi_hdl)
  57. LOOP
  58. li_parent = this.insertitemlast(0,'[双击添加]', 1)
  59. ll_rep_hand = this.insertitemlast(li_parent,'通讯录',2)
  60. ll_cus_hand = this.insertitemlast(li_parent, '客户', 2)
  61. ll_spt_hand = this.insertitemlast(li_parent, '供应商', 2)
  62. TreeViewItem l_tvi
  63. for i = 1 to this._ds_tv.rowcount( )
  64. if this._ds_tv.object.GroupID[i] = 0 then
  65. li_hand = ll_rep_hand
  66. elseif this._ds_tv.object.GroupID[i] = 1 then
  67. li_hand = ll_cus_hand
  68. else
  69. li_hand = ll_spt_hand
  70. end if
  71. li_hand = this.insertitemlast(li_hand,this._ds_tv.object.mailname[i],3)
  72. if this.GetItem(li_hand, l_tvi) = 1 then
  73. l_tvi.label = this._ds_tv.object.mailname[i] + '<' + this._ds_tv.object.mailaddress[i] + '>'
  74. l_tvi.data = i
  75. this.SetItem(li_hand, l_tvi)
  76. end if
  77. next
  78. this.ExpandItem( li_parent )
  79. return 1
  80. end function
  81. public function s_tv_sendmail f_getcontent (long arg_index);s_tv_sendmail rslt
  82. if arg_index > 0 and arg_index < this._ds_tv.rowcount( ) then
  83. rslt.groupid = this._ds_tv.object.GroupID[arg_index]
  84. rslt.reltype = this._ds_tv.object.reltype[arg_index]
  85. rslt.relid = this._ds_tv.object.relid[arg_index]
  86. rslt.mailname = this._ds_tv.object.mailname[arg_index]
  87. rslt.mailaddress = this._ds_tv.object.mailaddress[arg_index]
  88. rslt.dscrp = this._ds_tv.object.dscrp[arg_index]
  89. else
  90. rslt.groupid = -1
  91. end if
  92. return rslt
  93. end function
  94. public function integer f_filter (string arg_parm);integer rslt = 1
  95. string ls_filter
  96. arg_parm =lower(arg_parm)
  97. if trim(arg_parm) = '' then
  98. ls_filter = ''
  99. else
  100. ls_filter = "(lower(mailname) like '%" + arg_parm + "%') OR (lower(mailaddress) like '%" + arg_parm + "%')"
  101. end if
  102. this.setredraw(false)
  103. this._ds_tv.setFilter(ls_filter)
  104. this._ds_tv.filter()
  105. this.f_maketree( )
  106. this.setredraw(true)
  107. return rslt
  108. end function
  109. public function integer uf_getreltype (string arg_mailaddress);long index
  110. index = this._ds_tv.find("lower(mailaddress)='" + trim(lower(arg_mailaddress)) + "'", 0, this._ds_tv.rowcount())
  111. if index > 0 then
  112. return this._ds_tv.object.reltype[index]
  113. end if
  114. return 3
  115. end function
  116. on uo_tv_sendmail.create
  117. end on
  118. on uo_tv_sendmail.destroy
  119. end on
  120. event destructor;if isvalid(this._ds_tv) then
  121. destroy this._ds_tv
  122. end if
  123. end event
  124. event constructor;setnull(this._ds_tv)
  125. end event