w_fx_address.srw 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. $PBExportHeader$w_fx_address.srw
  2. forward
  3. global type w_fx_address from w_publ_base_style
  4. end type
  5. type cb_add from uo_imflatbutton within w_fx_address
  6. end type
  7. type cb_edit from uo_imflatbutton within w_fx_address
  8. end type
  9. type cb_del from uo_imflatbutton within w_fx_address
  10. end type
  11. type dw_1 from datawindow within w_fx_address
  12. end type
  13. type cb_default from uo_imflatbutton within w_fx_address
  14. end type
  15. end forward
  16. global type w_fx_address from w_publ_base_style
  17. integer width = 1847
  18. integer height = 1508
  19. string title = "地址管理"
  20. cb_add cb_add
  21. cb_edit cb_edit
  22. cb_del cb_del
  23. dw_1 dw_1
  24. cb_default cb_default
  25. end type
  26. global w_fx_address w_fx_address
  27. type variables
  28. long ins_modcol = 3
  29. long modifyrow_no=0,crl_row //当前行记录
  30. end variables
  31. forward prototypes
  32. public subroutine wf_refresh ()
  33. public function integer wf_face_change ()
  34. end prototypes
  35. public subroutine wf_refresh ();string arg_msg
  36. oleobject req, rsp
  37. req = FxAppCom.CreatePbDictionary()
  38. req.setString('token', app_token_fx)
  39. rsp = FxAppCom.DoExecute('GetCusAddressList', req)
  40. arg_msg = rsp.getString('ErrMsg')
  41. if arg_msg <> '' then
  42. messagebox('错误', '获取地址信息失败:' + arg_msg)
  43. return
  44. end if
  45. oleobject addressList,item
  46. long cnt, i
  47. addressList = rsp.getPbArray('addressList')
  48. cnt = addressList.count
  49. dw_1.reset()
  50. dw_1.setRedraw(false)
  51. for i = 1 to cnt
  52. item = FxAppCom.CreatePbDictionary()
  53. item = addressList.GetPBDictionary(i - 1)
  54. dw_1.insertRow(0)
  55. dw_1.Object.addressid[i] = item.getInt('addressid')
  56. dw_1.Object.cus_rep[i] = item.getString('cus_rep')
  57. dw_1.Object.cus_tele[i] = item.getString('cus_tele')
  58. dw_1.Object.cus_address[i] = item.getString('cus_address')
  59. dw_1.Object.freight[i] = item.getString('freight')
  60. dw_1.Object.freight_tele[i] = item.getString('freight_tele')
  61. dw_1.Object.ifdefault[i] = item.getInt('ifdefault')
  62. next
  63. dw_1.setRedraw(true)
  64. end subroutine
  65. public function integer wf_face_change ();IF dw_edit_mode THEN
  66. cb_func.Enabled = FALSE
  67. cb_del.Enabled = FALSE
  68. cb_edit.Text = "放弃&E"
  69. cb_add.Text = "保存&S"
  70. cb_edit.normalpicname = 'Undo.bmp'
  71. cb_add.normalpicname = 'Save.bmp'
  72. ELSE
  73. cb_func.Enabled = TRUE
  74. cb_del.Enabled = TRUE
  75. cb_edit.Text = "修改&E"
  76. cb_add.Text = "新建&S"
  77. cb_edit.normalpicname = 'OPEN.bmp'
  78. cb_add.normalpicname = 'new.bmp'
  79. END IF
  80. cb_edit.of_init_draw()
  81. cb_add.of_init_draw()
  82. cb_edit.of_paint()
  83. cb_add.of_paint()
  84. cb_add.TriggerEvent('ue_textchange')
  85. cb_edit.TriggerEvent('ue_textchange')
  86. RETURN 1
  87. end function
  88. on w_fx_address.create
  89. int iCurrent
  90. call super::create
  91. this.cb_add=create cb_add
  92. this.cb_edit=create cb_edit
  93. this.cb_del=create cb_del
  94. this.dw_1=create dw_1
  95. this.cb_default=create cb_default
  96. iCurrent=UpperBound(this.Control)
  97. this.Control[iCurrent+1]=this.cb_add
  98. this.Control[iCurrent+2]=this.cb_edit
  99. this.Control[iCurrent+3]=this.cb_del
  100. this.Control[iCurrent+4]=this.dw_1
  101. this.Control[iCurrent+5]=this.cb_default
  102. end on
  103. on w_fx_address.destroy
  104. call super::destroy
  105. destroy(this.cb_add)
  106. destroy(this.cb_edit)
  107. destroy(this.cb_del)
  108. destroy(this.dw_1)
  109. destroy(this.cb_default)
  110. end on
  111. event open;call super::open;wf_refresh()
  112. end event
  113. event resize;call super::resize;dw_1.width = newwidth
  114. end event
  115. type cb_func from w_publ_base_style`cb_func within w_fx_address
  116. integer x = 512
  117. integer width = 165
  118. string text = "刷新"
  119. end type
  120. type cb_exit from w_publ_base_style`cb_exit within w_fx_address
  121. integer x = 960
  122. end type
  123. type ln_bar from w_publ_base_style`ln_bar within w_fx_address
  124. end type
  125. type ln_bar2 from w_publ_base_style`ln_bar2 within w_fx_address
  126. end type
  127. type r_bar from w_publ_base_style`r_bar within w_fx_address
  128. end type
  129. type cb_add from uo_imflatbutton within w_fx_address
  130. integer width = 165
  131. integer height = 164
  132. integer taborder = 20
  133. boolean bringtotop = true
  134. string text = "新增"
  135. string normalpicname = "New.bmp"
  136. integer picsize = 16
  137. toolbaralignment pic_align = alignattop!
  138. boolean border = false
  139. end type
  140. event clicked;call super::clicked;long row, i
  141. string arg_msg
  142. row = dw_1.getRow()
  143. if dw_edit_mode then
  144. dw_1.AcceptText()
  145. if dw_1.Object.cus_rep[row] = '' then
  146. messagebox('error', '收货人不能为空')
  147. return
  148. elseif dw_1.Object.cus_tele[row] = '' then
  149. messagebox('error', '收货人电话不能为空')
  150. return
  151. elseif dw_1.Object.cus_address[row] = '' then
  152. messagebox('error', '收货地址不能为空')
  153. return
  154. end if
  155. oleobject address
  156. address = FxAppCom.CreatePbDictionary()
  157. if ISNULL(dw_1.Object.addressid[row]) then
  158. address.setInt('addressid', 0)
  159. else
  160. address.setInt('addressid', dw_1.Object.addressid[row])
  161. end if
  162. address.setString('cus_rep', dw_1.Object.cus_rep[row])
  163. address.setString('cus_tele', dw_1.Object.cus_tele[row])
  164. address.setString('cus_address', dw_1.Object.cus_address[row])
  165. address.setString('freight', dw_1.Object.freight[row])
  166. address.setString('freight_tele', dw_1.Object.freight_tele[row])
  167. oleobject req, rsp
  168. req = FXAppCom.CreatePbDictionary()
  169. req.setString('token', app_token_fx)
  170. req.setObject('address', address)
  171. rsp = FXAppCom.DoExecute('SaveCusAddress', req)
  172. arg_msg = rsp.GetString('ErrMsg')
  173. if arg_msg <> '' then
  174. messagebox('error', arg_msg)
  175. else
  176. messagebox('success', '保存成功')
  177. For i = 1 To ins_modcol
  178. dw_1.SetTabOrder ( i, 0 )
  179. Next
  180. end if
  181. wf_refresh()
  182. else
  183. Long li_row, li_cur_row
  184. li_cur_row = dw_1.GetRow()
  185. li_row = dw_1.InsertRow (0)
  186. For i = 1 To ins_modcol
  187. dw_1.SetTabOrder ( i, i*10 )
  188. Next
  189. dw_1.SelectRow(0,False)
  190. dw_1.ScrollToRow (li_row)
  191. dw_1.SelectRow(li_row,True)
  192. dw_1.SetFocus()
  193. modifyrow_no = li_row
  194. end if
  195. dw_edit_mode = Not dw_edit_mode
  196. WF_FACE_CHANGE()
  197. end event
  198. type cb_edit from uo_imflatbutton within w_fx_address
  199. integer x = 174
  200. integer width = 165
  201. integer height = 164
  202. integer taborder = 10
  203. boolean bringtotop = true
  204. string text = "修改"
  205. string normalpicname = "Open.bmp"
  206. integer picsize = 16
  207. toolbaralignment pic_align = alignattop!
  208. boolean border = false
  209. end type
  210. event clicked;call super::clicked;long i
  211. If dw_edit_mode Then
  212. If dw_1.GetItemStatus(dw_1.GetRow(), 0, Primary!) = New! Then
  213. dw_1.DeleteRow(dw_1.GetRow())
  214. End If
  215. For i = 1 To ins_modcol
  216. dw_1.SetTabOrder ( i, 0 )
  217. Next
  218. modifyrow_no = 0
  219. wf_refresh()
  220. Else
  221. modifyrow_no = dw_1.GetRow()
  222. For i = 1 To ins_modcol
  223. dw_1.SetTabOrder ( i, i*10)
  224. Next
  225. dw_1.SetFocus()
  226. dw_1.SelectRow(0,False)
  227. dw_1.ScrollToRow (modifyrow_no)
  228. dw_1.SelectRow(modifyrow_no,True)
  229. End If
  230. dw_edit_mode = Not dw_edit_mode
  231. WF_FACE_CHANGE()
  232. end event
  233. type cb_del from uo_imflatbutton within w_fx_address
  234. integer x = 343
  235. integer width = 165
  236. integer height = 164
  237. integer taborder = 10
  238. boolean bringtotop = true
  239. string text = "删除"
  240. string normalpicname = "Delete.bmp"
  241. integer picsize = 16
  242. toolbaralignment pic_align = alignattop!
  243. boolean border = false
  244. end type
  245. event clicked;call super::clicked;long row
  246. row = dw_1.getRow()
  247. if row <= 0 then
  248. return
  249. end if
  250. string arg_msg
  251. oleobject req,rsp
  252. req = FxAppCom.CreatePbDictionary()
  253. req.setString('token', app_token_fx)
  254. req.setInt('addressid', dw_1.Object.addressid[row])
  255. rsp = FxAppCom.DoExecute('DelCusAddress', req)
  256. arg_msg = rsp.getString('ErrMsg')
  257. if arg_msg <> '' then
  258. messagebox('错误', '删除地址失败:' + arg_msg)
  259. else
  260. messagebox('成功', '删除地址成功')
  261. end if
  262. wf_refresh()
  263. end event
  264. type dw_1 from datawindow within w_fx_address
  265. integer y = 176
  266. integer width = 1833
  267. integer height = 1252
  268. integer taborder = 20
  269. boolean bringtotop = true
  270. string title = "none"
  271. string dataobject = "dw_fx_address"
  272. boolean hscrollbar = true
  273. boolean vscrollbar = true
  274. boolean livescroll = true
  275. borderstyle borderstyle = stylelowered!
  276. end type
  277. event rowfocuschanged;IF modifyrow_no >0 AND dw_edit_mode THEN
  278. THIS.SETROW(modifyrow_no)
  279. THIS.ScrollToRow(modifyrow_no)
  280. else
  281. this.selectrow(0,false)
  282. this.selectrow(currentrow,true)
  283. END IF
  284. end event
  285. type cb_default from uo_imflatbutton within w_fx_address
  286. integer x = 681
  287. integer width = 274
  288. integer height = 164
  289. integer taborder = 20
  290. boolean bringtotop = true
  291. string text = "设为默认"
  292. string normalpicname = "Delete.bmp"
  293. integer picsize = 16
  294. toolbaralignment pic_align = alignattop!
  295. boolean border = false
  296. end type
  297. event clicked;call super::clicked;long row
  298. row = dw_1.getRow()
  299. if row <= 0 then
  300. return
  301. end if
  302. string arg_msg
  303. oleobject req,rsp
  304. req = FxAppCom.CreatePbDictionary()
  305. req.setString('token', app_token_fx)
  306. req.setInt('addressid', dw_1.Object.addressid[row])
  307. rsp = FxAppCom.DoExecute('SetDefaultAddress', req)
  308. arg_msg = rsp.getString('ErrMsg')
  309. if arg_msg <> '' then
  310. messagebox('错误', '设置默认地址失败:' + arg_msg)
  311. else
  312. messagebox('成功', '设默认地址成功')
  313. end if
  314. wf_refresh()
  315. end event