w_set_email_move.srw 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. $PBExportHeader$w_set_email_move.srw
  2. forward
  3. global type w_set_email_move from window
  4. end type
  5. type st_2 from statictext within w_set_email_move
  6. end type
  7. type st_1 from statictext within w_set_email_move
  8. end type
  9. type cb_2 from commandbutton within w_set_email_move
  10. end type
  11. type cb_1 from commandbutton within w_set_email_move
  12. end type
  13. type ddlb_1 from dropdownlistbox within w_set_email_move
  14. end type
  15. type s_box from structure within w_set_email_move
  16. end type
  17. end forward
  18. type s_box from structure
  19. long boxid
  20. long parentid
  21. string boxname
  22. end type
  23. global type w_set_email_move from window
  24. integer width = 1353
  25. integer height = 416
  26. boolean titlebar = true
  27. string title = "设置收件分类"
  28. boolean controlmenu = true
  29. windowtype windowtype = response!
  30. long backcolor = 67108864
  31. string icon = "AppIcon!"
  32. boolean center = true
  33. st_2 st_2
  34. st_1 st_1
  35. cb_2 cb_2
  36. cb_1 cb_1
  37. ddlb_1 ddlb_1
  38. end type
  39. global w_set_email_move w_set_email_move
  40. type variables
  41. private:
  42. s_box ss_box[]
  43. public:
  44. s_edit_index_tran ss_tran
  45. boolean bool_existence=false
  46. long ll_ex_boxid
  47. string ls_ex_filter,ls_ex_boxname
  48. end variables
  49. forward prototypes
  50. public function integer wf_init_file ()
  51. public function string of_globalreplace (string as_source, string as_old, string as_new)
  52. end prototypes
  53. public function integer wf_init_file ();
  54. //游标读收费项目
  55. //String arry_sql[]
  56. Integer i
  57. String ls_boxname,ls_b_string
  58. DECLARE readitem_sql CURSOR FOR
  59. SELECT boxid,parentid,boxname
  60. FROM u_email_box
  61. WHERE mailid = :ss_tran.b_long AND boxtype = '新邮箱' AND parentid <> 0
  62. Using sqlca;
  63. OPEN readitem_sql;
  64. i++
  65. FETCH readitem_sql Into :ss_box[i].boxid,:ss_box[i].parentid,:ss_box[i].boxname;
  66. DO WHILE sqlca.SQLCode = 0
  67. i++
  68. FETCH readitem_sql Into :ss_box[i].boxid,:ss_box[i].parentid,:ss_box[i].boxname;
  69. LOOP
  70. CLOSE readitem_sql;
  71. FOR i = 1 To UpperBound(ss_box) - 1
  72. SELECT boxname
  73. INTO :ls_boxname
  74. FROM u_email_box
  75. WHERE boxid = :ss_box[i].parentid
  76. Using sqlca;
  77. IF ls_boxname = "收件箱" THEN
  78. ddlb_1.AddItem (ss_box[i].boxname)
  79. ls_boxname = ""
  80. END IF
  81. NEXT
  82. ls_boxname = ""
  83. ls_b_string = "%" + ss_tran.b_string + "%"
  84. SELECT boxname,boxid,filter
  85. INTO :ls_boxname,:ll_ex_boxid,:ls_ex_filter
  86. FROM u_email_box
  87. WHERE mailid = :ss_tran.b_long AND filter LIKE : ls_b_string
  88. Using sqlca;
  89. IF ls_boxname <> "" THEN
  90. ddlb_1.Text = ls_boxname
  91. ls_ex_boxname = ls_boxname
  92. bool_existence = True
  93. END IF
  94. RETURN 1
  95. end function
  96. public function string of_globalreplace (string as_source, string as_old, string as_new);long ll_oldlen, ll_newlen, ll_pos
  97. as_source=trim(as_source)
  98. as_old=trim(as_old)
  99. ll_pos = Pos(as_source,as_old)
  100. IF ll_pos > 0 Then
  101. ll_oldlen = Len(as_old)
  102. ll_newlen = Len(as_new)
  103. DO WHILE ll_pos > 0
  104. as_source = Replace(as_source,ll_pos,ll_oldlen,as_new)
  105. ll_pos = Pos(as_source,as_old,ll_pos + ll_newlen)
  106. LOOP
  107. END IF
  108. RETURN as_source
  109. end function
  110. on w_set_email_move.create
  111. this.st_2=create st_2
  112. this.st_1=create st_1
  113. this.cb_2=create cb_2
  114. this.cb_1=create cb_1
  115. this.ddlb_1=create ddlb_1
  116. this.Control[]={this.st_2,&
  117. this.st_1,&
  118. this.cb_2,&
  119. this.cb_1,&
  120. this.ddlb_1}
  121. end on
  122. on w_set_email_move.destroy
  123. destroy(this.st_2)
  124. destroy(this.st_1)
  125. destroy(this.cb_2)
  126. destroy(this.cb_1)
  127. destroy(this.ddlb_1)
  128. end on
  129. event open;
  130. ss_tran = message.powerobjectparm
  131. st_2.text=ss_tran.b_string
  132. wf_init_file()
  133. //messagebox(string(ss_tran.b_long),ss_tran.b_string)
  134. end event
  135. type st_2 from statictext within w_set_email_move
  136. integer x = 46
  137. integer y = 8
  138. integer width = 1253
  139. integer height = 84
  140. integer textsize = -9
  141. integer weight = 400
  142. fontcharset fontcharset = gb2312charset!
  143. fontpitch fontpitch = variable!
  144. string facename = "宋体"
  145. long textcolor = 33554432
  146. long backcolor = 67108864
  147. boolean focusrectangle = false
  148. end type
  149. type st_1 from statictext within w_set_email_move
  150. integer x = 46
  151. integer y = 96
  152. integer width = 512
  153. integer height = 84
  154. integer textsize = -9
  155. integer weight = 400
  156. fontcharset fontcharset = gb2312charset!
  157. fontpitch fontpitch = variable!
  158. string facename = "宋体"
  159. long textcolor = 33554432
  160. long backcolor = 67108864
  161. string text = "请选择收件文件夹"
  162. boolean focusrectangle = false
  163. end type
  164. type cb_2 from commandbutton within w_set_email_move
  165. integer x = 791
  166. integer y = 200
  167. integer width = 402
  168. integer height = 104
  169. integer taborder = 30
  170. integer textsize = -9
  171. integer weight = 400
  172. fontcharset fontcharset = gb2312charset!
  173. fontpitch fontpitch = variable!
  174. string facename = "宋体"
  175. string text = "取消"
  176. end type
  177. event clicked;close(parent)
  178. end event
  179. type cb_1 from commandbutton within w_set_email_move
  180. integer x = 123
  181. integer y = 204
  182. integer width = 402
  183. integer height = 104
  184. integer taborder = 20
  185. integer textsize = -9
  186. integer weight = 400
  187. fontcharset fontcharset = gb2312charset!
  188. fontpitch fontpitch = variable!
  189. string facename = "宋体"
  190. string text = "确定"
  191. end type
  192. event clicked;String ls_boxname,ls_sqlstring,ls_sqlstring_check,ls_sqlstring_old,ls_sqlstring_old1,ls_sqlstring_new
  193. Integer i,j, L1,L2,ll_boxid,ll_parentid
  194. ls_sqlstring = "update u_email_msg set boxid=#new_boxid# where (sendaddress in ( #3s#3e )) and mailtype ='收件'and boxid=#old_boxid#"
  195. IF Trim(ddlb_1.Text) = "" THEN
  196. MessageBox("提示","请选择文件夹")
  197. RETURN
  198. END IF
  199. ls_boxname = Trim(ddlb_1.Text)
  200. IF bool_existence = True And ls_ex_boxname = ls_boxname THEN
  201. MessageBox("成功","保存规则成功")
  202. Close(Parent)
  203. RETURN
  204. END IF
  205. IF bool_existence = True And ls_ex_boxname <> ls_boxname THEN //替换原来的邮箱
  206. Long ll_tmp1,ll_tmp2
  207. String ls_tmp
  208. IF MessageBox ("询问","是否确定要替换文件夹!!!由" + ls_ex_boxname +"转为" + ls_boxname,Question!,YesNo! ) = 2 THEN
  209. RETURN
  210. END IF
  211. FOR j = 1 To 100
  212. ll_tmp1 = Pos(ls_ex_filter,"'" + ss_tran.b_string + "'")
  213. // MessageBox("",String(ll_tmp))
  214. IF ll_tmp1 <> 0 THEN
  215. FOR i = ll_tmp1 To 1 Step -1
  216. IF Mid(ls_ex_filter,i,1) = "," THEN
  217. ll_tmp2 = i
  218. EXIT
  219. END IF
  220. NEXT //i
  221. IF ll_tmp2 <> 0 THEN
  222. ls_tmp = Mid(ls_ex_filter,ll_tmp2 , ll_tmp1 - ll_tmp2 )
  223. // MessageBox("",String(ls_tmp))
  224. // MessageBox("",String(ls_ex_filter))
  225. ls_ex_filter = of_globalreplace(ls_ex_filter, ls_tmp + "'" + ss_tran.b_string + "'" ,"")
  226. ELSE
  227. ls_ex_filter = of_globalreplace(ls_ex_filter, ss_tran.b_string ,"")
  228. END IF
  229. END IF
  230. NEXT //j
  231. // MessageBox("",String(ls_ex_filter))
  232. UPDATE u_email_box Set Filter = :ls_ex_filter,if_Filter = 1 Where boxid = :ll_ex_boxid Using sqlca;
  233. IF sqlca.SQLCode <> 0 THEN
  234. MessageBox("错误" , "保存规则失败~n"+sqlca.SQLErrText)
  235. GOTO ext
  236. END IF
  237. END IF
  238. //更新替换后的邮箱
  239. FOR i = 1 To UpperBound(ss_box) - 1
  240. IF ss_box[i].boxname = ls_boxname THEN
  241. ll_boxid = ss_box[i].boxid
  242. ll_parentid = ss_box[i].parentid
  243. EXIT
  244. END IF
  245. NEXT
  246. SELECT Filter Into :ls_sqlstring_check From u_email_box Where boxid = :ll_boxid Using sqlca;
  247. IF IsNull(ls_sqlstring_check) Or ls_sqlstring_check = "" Or Pos(ls_sqlstring_check,"#3s") <= 0 THEN
  248. ls_sqlstring_check = ls_sqlstring
  249. END IF
  250. L1 = Pos(ls_sqlstring_check,"#3s")
  251. L2 = Pos(ls_sqlstring_check,"#3e")
  252. ls_sqlstring_old = Mid(ls_sqlstring_check,L1 + 3 ,L2 - L1 - 3)
  253. IF Trim(ls_sqlstring_old) = "" THEN
  254. ls_sqlstring_new = "#3s'" + ss_tran.b_string + "'#3e"
  255. ls_sqlstring_check = of_globalreplace(ls_sqlstring_check,"#3s" + ls_sqlstring_old + "#3e",ls_sqlstring_new)
  256. ELSE
  257. ls_sqlstring_old1 = ls_sqlstring_old
  258. ls_sqlstring_old = of_globalreplace(ls_sqlstring_old,"sendaddress in"," ")
  259. ls_sqlstring_old = of_globalreplace(ls_sqlstring_old,"("," ")
  260. ls_sqlstring_old = of_globalreplace(ls_sqlstring_old,")"," ")
  261. ls_sqlstring_old = Trim(ls_sqlstring_old)
  262. ls_sqlstring_new = ls_sqlstring_old + " , " + "'" + ss_tran.b_string + "'"
  263. ls_sqlstring_check = of_globalreplace(ls_sqlstring_check, ls_sqlstring_old ,ls_sqlstring_new)
  264. END IF
  265. ls_sqlstring_check = of_globalreplace(ls_sqlstring_check, Char(13) + Char(10) ,"")
  266. ls_sqlstring_check = of_globalreplace(ls_sqlstring_check, "#new_boxid#" ,String(ll_boxid))
  267. ls_sqlstring_check = of_globalreplace(ls_sqlstring_check, "#old_boxid#" ,String(ll_parentid))
  268. UPDATE u_email_box Set Filter = :ls_sqlstring_check ,if_Filter = 1 Where boxid = :ll_boxid Using sqlca;
  269. IF sqlca.SQLCode <> 0 THEN
  270. MessageBox("错误" , "保存规则失败~n"+sqlca.SQLErrText)
  271. GOTO ext
  272. END IF
  273. COMMIT;
  274. MessageBox("成功","保存规则成功")
  275. Close(Parent)
  276. ext:
  277. end event
  278. type ddlb_1 from dropdownlistbox within w_set_email_move
  279. integer x = 617
  280. integer y = 96
  281. integer width = 608
  282. integer height = 700
  283. integer taborder = 10
  284. integer textsize = -9
  285. integer weight = 400
  286. fontcharset fontcharset = gb2312charset!
  287. fontpitch fontpitch = variable!
  288. string facename = "宋体"
  289. long textcolor = 33554432
  290. boolean autohscroll = true
  291. boolean hscrollbar = true
  292. boolean vscrollbar = true
  293. borderstyle borderstyle = stylelowered!
  294. end type