w_cusarea_def.srw 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. $PBExportHeader$w_cusarea_def.srw
  2. forward
  3. global type w_cusarea_def from w_publ_base
  4. end type
  5. type cb_ok from uo_imflatbutton within w_cusarea_def
  6. end type
  7. type tv_1 from uo_tv_cusarea within w_cusarea_def
  8. end type
  9. type r_bar from rectangle within w_cusarea_def
  10. end type
  11. type ln_bar from line within w_cusarea_def
  12. end type
  13. type ln_bar2 from line within w_cusarea_def
  14. end type
  15. type cb_del from uo_imflatbutton within w_cusarea_def
  16. end type
  17. type cb_mod from uo_imflatbutton within w_cusarea_def
  18. end type
  19. type cb_add_next from uo_imflatbutton within w_cusarea_def
  20. end type
  21. type cb_add from uo_imflatbutton within w_cusarea_def
  22. end type
  23. type cb_refresh from uo_imflatbutton within w_cusarea_def
  24. end type
  25. type cb_help from uo_imflatbutton within w_cusarea_def
  26. end type
  27. type cb_choice from uo_imflatbutton within w_cusarea_def
  28. end type
  29. end forward
  30. global type w_cusarea_def from w_publ_base
  31. integer width = 2176
  32. integer height = 2380
  33. string title = "客户区域"
  34. event ue_help ( )
  35. cb_ok cb_ok
  36. tv_1 tv_1
  37. r_bar r_bar
  38. ln_bar ln_bar
  39. ln_bar2 ln_bar2
  40. cb_del cb_del
  41. cb_mod cb_mod
  42. cb_add_next cb_add_next
  43. cb_add cb_add
  44. cb_refresh cb_refresh
  45. cb_help cb_help
  46. cb_choice cb_choice
  47. end type
  48. global w_cusarea_def w_cusarea_def
  49. type variables
  50. long il_hand
  51. s_cusarea s_rst
  52. end variables
  53. forward prototypes
  54. public function integer wf_cnt_dot (string arg_mtrltype)
  55. end prototypes
  56. event ue_help();Int i
  57. i = htmlhelpA(Handle(THIS), sys_help_chm, 0, THIS.Title+".html")
  58. end event
  59. public function integer wf_cnt_dot (string arg_mtrltype);long rst_cnt
  60. string ls_mtrltype
  61. long pos_dot
  62. ls_mtrltype = arg_mtrltype
  63. again:
  64. pos_dot = pos(ls_mtrltype,'>>')
  65. if pos_dot > 0 then
  66. rst_cnt++
  67. ls_mtrltype = mid( ls_mtrltype,pos_dot + 2 )
  68. goto again
  69. else
  70. goto ext
  71. end if
  72. ext:
  73. return rst_cnt
  74. end function
  75. on w_cusarea_def.create
  76. int iCurrent
  77. call super::create
  78. this.cb_ok=create cb_ok
  79. this.tv_1=create tv_1
  80. this.r_bar=create r_bar
  81. this.ln_bar=create ln_bar
  82. this.ln_bar2=create ln_bar2
  83. this.cb_del=create cb_del
  84. this.cb_mod=create cb_mod
  85. this.cb_add_next=create cb_add_next
  86. this.cb_add=create cb_add
  87. this.cb_refresh=create cb_refresh
  88. this.cb_help=create cb_help
  89. this.cb_choice=create cb_choice
  90. iCurrent=UpperBound(this.Control)
  91. this.Control[iCurrent+1]=this.cb_ok
  92. this.Control[iCurrent+2]=this.tv_1
  93. this.Control[iCurrent+3]=this.r_bar
  94. this.Control[iCurrent+4]=this.ln_bar
  95. this.Control[iCurrent+5]=this.ln_bar2
  96. this.Control[iCurrent+6]=this.cb_del
  97. this.Control[iCurrent+7]=this.cb_mod
  98. this.Control[iCurrent+8]=this.cb_add_next
  99. this.Control[iCurrent+9]=this.cb_add
  100. this.Control[iCurrent+10]=this.cb_refresh
  101. this.Control[iCurrent+11]=this.cb_help
  102. this.Control[iCurrent+12]=this.cb_choice
  103. end on
  104. on w_cusarea_def.destroy
  105. call super::destroy
  106. destroy(this.cb_ok)
  107. destroy(this.tv_1)
  108. destroy(this.r_bar)
  109. destroy(this.ln_bar)
  110. destroy(this.ln_bar2)
  111. destroy(this.cb_del)
  112. destroy(this.cb_mod)
  113. destroy(this.cb_add_next)
  114. destroy(this.cb_add)
  115. destroy(this.cb_refresh)
  116. destroy(this.cb_help)
  117. destroy(this.cb_choice)
  118. end on
  119. event resize;call super::resize;ln_bar.endx = this.width
  120. ln_bar2.endx = this.width
  121. r_bar.width = this.width
  122. tv_1.height = this.height - tv_1.y - 100
  123. end event
  124. event close;call super::close;CloseWithReturn(THIS,s_rst)
  125. end event
  126. type cb_func from w_publ_base`cb_func within w_cusarea_def
  127. boolean visible = false
  128. integer x = 242
  129. integer y = 768
  130. end type
  131. type cb_exit from w_publ_base`cb_exit within w_cusarea_def
  132. integer x = 1138
  133. integer width = 151
  134. integer height = 172
  135. integer picsize = 16
  136. toolbaralignment pic_align = alignattop!
  137. boolean border = false
  138. end type
  139. event cb_exit::clicked;close(parent)
  140. end event
  141. type cb_ok from uo_imflatbutton within w_cusarea_def
  142. boolean visible = false
  143. integer x = 553
  144. integer y = 764
  145. integer width = 279
  146. integer height = 96
  147. integer taborder = 70
  148. string text = "选定"
  149. end type
  150. event clicked;call super::clicked;//string ls_handtype
  151. //long ls_mtrltypeid
  152. //
  153. //select mtrltypeid,handtype into :ls_mtrltypeid,:ls_handtype from u_mtrltype
  154. //where mtrltype = :cur_mtrltype;
  155. //
  156. //if sqlca.sqlcode = -1 then
  157. // messagebox("系统提示","查询类别失败")
  158. // return
  159. //end if
  160. //
  161. //if cur_mtrltype = '+++物料类别+++' then
  162. // rst_mtrltype.mtrltypeid = -1
  163. // rst_mtrltype.handtype = ''
  164. //else
  165. // rst_mtrltype.mtrltypeid = ls_mtrltypeid
  166. // rst_mtrltype.handtype = ls_handtype
  167. //end if
  168. //
  169. //close(parent)
  170. //
  171. //
  172. end event
  173. type tv_1 from uo_tv_cusarea within w_cusarea_def
  174. integer y = 192
  175. integer width = 2153
  176. integer height = 1864
  177. integer taborder = 30
  178. boolean bringtotop = true
  179. integer textsize = -9
  180. fontcharset fontcharset = gb2312charset!
  181. fontfamily fontfamily = anyfont!
  182. string facename = "宋体"
  183. end type
  184. event selectionchanged;call super::selectionchanged;il_hand = newhandle
  185. end event
  186. event doubleclicked;call super::doubleclicked;IF cb_choice.Enabled THEN
  187. cb_choice.TriggerEvent(Clicked!)
  188. END IF
  189. end event
  190. type r_bar from rectangle within w_cusarea_def
  191. long linecolor = 16777215
  192. long fillcolor = 1073741824
  193. integer x = 1454
  194. integer width = 73
  195. integer height = 172
  196. end type
  197. event constructor;this.fillcolor = 14215660
  198. this.linecolor = 14215660
  199. this.x = -1
  200. this.y = -1
  201. this.height = ln_bar2.beginy
  202. end event
  203. type ln_bar from line within w_cusarea_def
  204. long linecolor = 268435456
  205. integer linethickness = 4
  206. integer beginy = 176
  207. integer endx = 2098
  208. integer endy = 176
  209. end type
  210. type ln_bar2 from line within w_cusarea_def
  211. long linecolor = 16777215
  212. integer linethickness = 4
  213. integer beginy = 180
  214. integer endx = 2098
  215. integer endy = 180
  216. end type
  217. type cb_del from uo_imflatbutton within w_cusarea_def
  218. integer x = 686
  219. integer width = 151
  220. integer height = 172
  221. integer taborder = 100
  222. string text = "删除"
  223. string normalpicname = "delete.bmp"
  224. integer picsize = 16
  225. toolbaralignment pic_align = alignattop!
  226. boolean border = false
  227. end type
  228. event clicked;call super::clicked;if not f_power_ind(19) then
  229. messagebox('提示','你没有使用权限!', Information!, OK! )
  230. return
  231. end if
  232. if MessageBox('询问','是否要确定删除当前地区', question!, YesNo!, 2)=2 then
  233. return
  234. end if
  235. if tv_1.uo_cur_info.sonflag = 0 then
  236. messagebox('提示','不是明细地区,不能删除', Information!, OK! )
  237. return
  238. end if
  239. long cnt
  240. select count(*) into :cnt from u_cust where Cusareaid = :tv_1.uo_cur_info.Cusareaid;
  241. if sqlca.sqlcode <> 0 then
  242. messagebox('提示','查询地区是否已用失败,不能删除', Information!, OK! )
  243. return
  244. end if
  245. if cnt > 0 then
  246. messagebox('提示','地区已用于客户定义,不能删除', Information!, OK! )
  247. return
  248. end if
  249. cnt = 0
  250. select count(*) into :cnt from u_cusarea where parentid = :tv_1.uo_cur_info.parentid;
  251. if sqlca.sqlcode <> 0 then
  252. messagebox('提示','查询地区资料失败,不能删除', Information!, OK! )
  253. return
  254. end if
  255. if cnt = 1 then
  256. update u_cusarea set sonflag = 1 where cusareaid = :tv_1.uo_cur_info.parentid;
  257. if sqlca.sqlcode <> 0 then
  258. messagebox('提示','更新上级地区资料失败,不能删除', Information!, OK! )
  259. rollback;
  260. return
  261. end if
  262. end if
  263. delete from u_Cusarea where Cusareaid = :tv_1.uo_cur_info.Cusareaid;
  264. if sqlca.sqlcode <> 0 then
  265. messagebox('提示','删除地区失败>>'+sqlca.sqlerrtext, Information!, OK! )
  266. rollback;
  267. return
  268. end if
  269. commit;
  270. messagebox('提示','删除地区成功', Information!, OK! )
  271. tv_1.f_maketree()
  272. end event
  273. type cb_mod from uo_imflatbutton within w_cusarea_def
  274. integer x = 535
  275. integer width = 151
  276. integer height = 172
  277. integer taborder = 90
  278. string text = "修改"
  279. string normalpicname = "open.bmp"
  280. integer picsize = 16
  281. toolbaralignment pic_align = alignattop!
  282. boolean border = false
  283. end type
  284. event clicked;call super::clicked;IF NOT f_power_ind(19) THEN
  285. MessageBox('提示','你没有使用权限!', Information!, OK! )
  286. RETURN
  287. END IF
  288. IF tv_1.uo_cur_info.cusareaid = 0 THEN
  289. MessageBox('提示','请选择当前地区!', Information!, OK! )
  290. RETURN
  291. END IF
  292. Long cnt
  293. String ls_new_Cusareaname
  294. String ls_new_handtype
  295. String ls_old_handtype
  296. String ls_update_handtype
  297. Long ll_old_parentid
  298. Long ll_new_parentid
  299. Long ll_cusareaid
  300. Long li_sonflag
  301. s_cusarea s_area,s_r_area
  302. ll_cusareaid = tv_1.uo_cur_info.cusareaid
  303. ll_old_parentid = tv_1.uo_cur_info.parentid
  304. ls_old_handtype = tv_1.uo_cur_info.areaname
  305. ls_update_handtype = tv_1.uo_cur_info.areaname + '%'
  306. s_area.cusareaid = tv_1.uo_cur_info.cusareaid
  307. s_area.cusareaname = tv_1.uo_cur_info.cusareaname
  308. s_area.sonflag = tv_1.uo_cur_info.sonflag
  309. s_area.parentid = tv_1.uo_cur_info.parentid
  310. s_area.parenthandtype = tv_1.uo_cur_info.areaname
  311. OpenWithParm(w_cusarea_add,s_area)
  312. s_r_area = Message.PowerObjectParm
  313. IF s_r_area.cusareaid = -1 THEN RETURN
  314. ls_new_Cusareaname = s_r_area.cusareaname
  315. ls_new_handtype = s_r_area.areaname
  316. ll_new_parentid = s_r_area.parentid
  317. li_sonflag = s_r_area.sonflag
  318. UPDATE u_Cusarea
  319. SET Cusareaname = :ls_new_Cusareaname,
  320. areaname = :ls_new_handtype,
  321. parentid = :ll_new_parentid,
  322. typecode = :s_r_area.typecode,
  323. typecodestr = :s_r_area.typecodestr
  324. Where (cusareaid = :ll_cusareaid ) ;
  325. IF sqlca.SQLCode <> 0 THEN
  326. ROLLBACK;
  327. MessageBox('错误','修改名称操作错误,可能是新名称已经存在或网络故障!', StopSign!, OK! )
  328. RETURN
  329. END IF
  330. UPDATE u_Cusarea
  331. SET areaname = replace(areaname,:ls_old_handtype,:ls_new_handtype)
  332. Where areaname Like :ls_update_handtype;
  333. IF sqlca.SQLCode <> 0 THEN
  334. ROLLBACK;
  335. MessageBox('错误','修改名称操作错误,可能是新名称已经存在或网络故障!', StopSign!, OK! )
  336. RETURN
  337. END IF
  338. UPDATE u_cust
  339. SET Cusareaname = :ls_new_Cusareaname
  340. Where cusareaid = :ll_cusareaid;
  341. IF sqlca.SQLCode <> 0 THEN
  342. ROLLBACK;
  343. MessageBox('错误','修改地区操作错误,可能是新名称已经存在或网络故障!', StopSign!, OK! )
  344. RETURN
  345. END IF
  346. UPDATE u_cust
  347. SET areaname = replace(areaname,:ls_old_handtype,:ls_new_handtype)
  348. Where areaname Like :ls_update_handtype;
  349. IF sqlca.SQLCode <> 0 THEN
  350. ROLLBACK;
  351. MessageBox('错误','修改地区操作错误,可能是新名称已经存在或网络故障!', StopSign!, OK! )
  352. RETURN
  353. END IF
  354. UPDATE u_Cusarea
  355. SET sonflag = 0
  356. Where u_Cusarea.cusareaid = :ll_new_parentid;
  357. IF sqlca.SQLCode <> 0 THEN
  358. ROLLBACK;
  359. MessageBox('错误','新建地区"'+ls_new_Cusareaname+'"上级地区资料错误', StopSign!, OK! )
  360. RETURN
  361. END IF
  362. IF ll_old_parentid <> ll_new_parentid THEN
  363. SELECT count(*) INTO :cnt
  364. FROM u_cusarea
  365. Where parentid = :ll_old_parentid;
  366. IF sqlca.SQLCode <> 0 THEN
  367. ROLLBACK;
  368. MessageBox('错误','查询上级区域是否还存在下级区域错误', StopSign!, OK! )
  369. RETURN
  370. END IF
  371. IF cnt = 0 THEN
  372. UPDATE u_cusarea SET sonflag = 1
  373. Where cusareaid = :ll_old_parentid;
  374. IF sqlca.SQLCode <> 0 THEN
  375. ROLLBACK;
  376. MessageBox('错误','更新上级区域资料错误', StopSign!, OK! )
  377. RETURN
  378. END IF
  379. END IF
  380. END IF
  381. COMMIT;
  382. MessageBox('提示','区域修改成功!', Information!, OK! )
  383. TreeViewItem l_tvi
  384. IF tv_1.GetItem(il_hand,l_tvi) > 0 THEN
  385. l_tvi.Label = ls_new_Cusareaname
  386. l_tvi.Data = ll_cusareaid
  387. tv_1.SetItem(il_hand, l_tvi)
  388. tv_1.SetFocus()
  389. tv_1.SelectItem ( il_hand )
  390. END IF
  391. end event
  392. type cb_add_next from uo_imflatbutton within w_cusarea_def
  393. integer x = 343
  394. integer width = 192
  395. integer height = 172
  396. integer taborder = 90
  397. string text = "增下级"
  398. string normalpicname = "mx2.bmp"
  399. integer picsize = 16
  400. toolbaralignment pic_align = alignattop!
  401. boolean border = false
  402. end type
  403. event clicked;call super::clicked;IF NOT f_power_ind(19) THEN
  404. MessageBox('提示','你没有使用权限!', Information!, OK! )
  405. RETURN
  406. END IF
  407. String ls_Cusareaname
  408. String ls_areaname
  409. Long ll_parentid
  410. Long ll_cusareaid
  411. Int li_sonflag
  412. String arg_msg
  413. s_cusarea s_area,s_r_area
  414. s_area.cusareaid = 0
  415. s_area.cusareaname = ''
  416. s_area.sonflag = 1
  417. IF tv_1.uo_cur_info.cusareaid = 0 THEN
  418. s_area.parentid = 0
  419. s_area.parenthandtype = ''
  420. ELSE
  421. s_area.parentid = tv_1.uo_cur_info.cusareaid
  422. s_area.parenthandtype = tv_1.uo_cur_info.areaname
  423. END IF
  424. OpenWithParm(w_cusarea_add,s_area)
  425. s_r_area = Message.PowerObjectParm
  426. IF s_r_area.cusareaid = -1 THEN RETURN
  427. ll_cusareaid = f_sys_scidentity(0,"u_Cusarea","Cusareaid",arg_msg,TRUE,sqlca)
  428. IF ll_cusareaid <= 0 THEN
  429. MessageBox('提示',arg_msg, Information!, OK! )
  430. ROLLBACK;
  431. END IF
  432. ls_Cusareaname = s_r_area.cusareaname
  433. ls_areaname = s_r_area.areaname
  434. ll_parentid = s_r_area.parentid
  435. li_sonflag = s_r_area.sonflag
  436. INSERT INTO u_Cusarea
  437. (Cusareaid,
  438. Cusareaname,
  439. areaname,
  440. sonflag,
  441. parentid,
  442. typecode,
  443. typecodestr )
  444. VALUES
  445. (:ll_cusareaid,
  446. :ls_Cusareaname,
  447. :ls_areaname,
  448. :li_sonflag,
  449. :ll_parentid,
  450. :s_r_area.typecode,
  451. :s_r_area.typecodestr ) ;
  452. IF sqlca.SQLCode <> 0 THEN
  453. ROLLBACK;
  454. MessageBox('错误','新建地区"'+ls_Cusareaname+'"失败,可能是名称已经存在或网络故障!', StopSign!, OK! )
  455. RETURN
  456. END IF
  457. UPDATE u_Cusarea
  458. SET sonflag = 0
  459. Where u_Cusarea.cusareaid = :ll_parentid;
  460. IF sqlca.SQLCode <> 0 THEN
  461. ROLLBACK;
  462. MessageBox('错误','新建地区"'+ls_Cusareaname+'"失败,可能是名称已经存在或网络故障!', StopSign!, OK! )
  463. RETURN
  464. END IF
  465. COMMIT;
  466. MessageBox('提示','新建地区操作成功!', Information!, OK! )
  467. //第一个孩子将祖先的客户收入自己
  468. Long cnt
  469. SELECT count(*)
  470. INTO :cnt
  471. FROM u_Cusarea
  472. Where u_Cusarea.parentid = :ll_parentid;
  473. IF sqlca.SQLCode <> 0 THEN cnt = 0
  474. IF cnt = 1 THEN
  475. UPDATE u_cust
  476. SET cusareaid = :ll_cusareaid,
  477. cusareaname = :ls_Cusareaname,
  478. areaname = :ls_areaname
  479. Where cusareaid = :ll_parentid;
  480. IF sqlca.SQLCode <> 0 THEN
  481. ROLLBACK;
  482. MessageBox('错误','更新客户的区域'+ls_Cusareaname+'"失败!', StopSign!, OK! )
  483. RETURN
  484. END IF
  485. COMMIT;
  486. END IF
  487. Long ll_handl
  488. TreeViewItem l_tvi
  489. ll_handl = tv_1.InsertItemSort(il_hand,ls_Cusareaname,2)
  490. IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN
  491. l_tvi.Label = ls_Cusareaname
  492. l_tvi.Data = ll_cusareaid
  493. //增加新行
  494. tv_1.f_ds_add(ll_cusareaid)
  495. tv_1.SetItem(ll_handl, l_tvi)
  496. tv_1.SetFocus()
  497. tv_1.SelectItem ( ll_handl )
  498. END IF
  499. end event
  500. type cb_add from uo_imflatbutton within w_cusarea_def
  501. integer x = 151
  502. integer width = 192
  503. integer height = 172
  504. integer taborder = 80
  505. string text = "增同级"
  506. string normalpicname = "mx1.bmp"
  507. integer picsize = 16
  508. toolbaralignment pic_align = alignattop!
  509. boolean border = false
  510. end type
  511. event clicked;call super::clicked;IF NOT f_power_ind(19) THEN
  512. MessageBox(publ_operator,'你没有使用权限!')
  513. RETURN
  514. END IF
  515. String ls_Cusareaname
  516. String ls_areaname
  517. Long ll_parentid
  518. Long ll_cusareaid
  519. Int li_sonflag
  520. String arg_msg
  521. String ls_parent_handtype
  522. s_cusarea s_area,s_r_area
  523. IF tv_1.uo_cur_info.Cusareaid = 0 THEN
  524. MessageBox("系统提示",'不能建立地区')
  525. RETURN
  526. END IF
  527. s_area.Cusareaid = 0
  528. s_area.cusareaname = ''
  529. s_area.sonflag = 1
  530. s_area.parentid = tv_1.uo_cur_info.parentid
  531. IF tv_1.uo_cur_info.parentid = 0 THEN
  532. s_area.parenthandtype = ''
  533. ELSE
  534. SELECT areaname INTO :ls_parent_handtype
  535. FROM u_cusarea
  536. Where Cusareaid = :tv_1.uo_cur_info.parentid;
  537. IF sqlca.SQLCode <> 0 THEN
  538. MessageBox('系统提示','查询上级区域资料失败')
  539. RETURN
  540. END IF
  541. s_area.parenthandtype = ls_parent_handtype
  542. END IF
  543. OpenWithParm(w_cusarea_add,s_area)
  544. s_r_area = Message.PowerObjectParm
  545. IF s_r_area.Cusareaid = -1 THEN RETURN
  546. ll_cusareaid = f_sys_scidentity(0,"u_Cusarea","Cusareaid",arg_msg,TRUE,sqlca)
  547. IF ll_cusareaid <= 0 THEN
  548. MessageBox(publ_operator,arg_msg)
  549. ROLLBACK;
  550. END IF
  551. ls_Cusareaname = s_r_area.cusareaname
  552. ls_areaname = s_r_area.areaname
  553. ll_parentid = s_r_area.parentid
  554. li_sonflag = s_r_area.sonflag
  555. INSERT INTO u_Cusarea
  556. (Cusareaid,
  557. Cusareaname,
  558. areaname,
  559. sonflag,
  560. parentid ,
  561. typecode,
  562. typecodestr)
  563. VALUES
  564. (:ll_cusareaid,
  565. :ls_Cusareaname,
  566. :ls_areaname,
  567. :li_sonflag,
  568. :ll_parentid,
  569. :s_r_area.typecode,
  570. :s_r_area.typecodestr) ;
  571. IF sqlca.SQLCode <> 0 THEN
  572. ROLLBACK;
  573. MessageBox('失败','新建地区"'+ls_Cusareaname+'"失败,可能是名称已经存在或网络故障!')
  574. RETURN
  575. END IF
  576. UPDATE u_Cusarea
  577. SET sonflag = 0
  578. Where u_cusarea.Cusareaid = :ll_parentid;
  579. IF sqlca.SQLCode <> 0 THEN
  580. ROLLBACK;
  581. MessageBox('失败','新建地区"'+ls_Cusareaname+'"失败,可能是名称已经存在或网络故障!')
  582. RETURN
  583. END IF
  584. COMMIT;
  585. MessageBox('成功','新建地区操作成功!')
  586. Long ll_hand,ll_handl
  587. TreeViewItem l_tvi
  588. ll_hand = tv_1.FindItem(parenttreeitem!,il_hand)
  589. ll_handl = tv_1.InsertItemSort(ll_hand,ls_Cusareaname,2)
  590. IF tv_1.GetItem ( ll_handl, l_tvi) = 1 THEN
  591. l_tvi.Label = ls_Cusareaname
  592. l_tvi.Data = ll_cusareaid
  593. //增加新行
  594. tv_1.f_ds_add(ll_cusareaid)
  595. tv_1.SetItem(ll_handl, l_tvi)
  596. tv_1.SetFocus()
  597. tv_1.SelectItem ( ll_handl )
  598. END IF
  599. end event
  600. type cb_refresh from uo_imflatbutton within w_cusarea_def
  601. integer width = 151
  602. integer height = 172
  603. integer taborder = 80
  604. string text = "重查"
  605. string normalpicname = "refresh.bmp"
  606. integer picsize = 16
  607. toolbaralignment pic_align = alignattop!
  608. boolean border = false
  609. end type
  610. event clicked;call super::clicked;
  611. tv_1.f_maketree()
  612. end event
  613. type cb_help from uo_imflatbutton within w_cusarea_def
  614. string tag = "帮助[F1]"
  615. integer x = 987
  616. integer width = 151
  617. integer height = 172
  618. integer taborder = 110
  619. boolean bringtotop = true
  620. string text = "帮助"
  621. string normalpicname = "help.bmp"
  622. integer picsize = 16
  623. toolbaralignment pic_align = alignattop!
  624. boolean border = false
  625. end type
  626. event clicked;call super::clicked;PARENT.TriggerEvent('ue_help')
  627. end event
  628. type cb_choice from uo_imflatbutton within w_cusarea_def
  629. integer x = 837
  630. integer width = 151
  631. integer height = 172
  632. integer taborder = 110
  633. boolean bringtotop = true
  634. boolean enabled = false
  635. string text = "选定"
  636. string normalpicname = "ok.bmp"
  637. integer picsize = 16
  638. toolbaralignment pic_align = alignattop!
  639. boolean border = false
  640. end type
  641. event clicked;call super::clicked;IF tv_1.uo_cur_info.cusareaid = 0 THEN
  642. MessageBox('提示','请选择当前区域!', Information!, OK! )
  643. RETURN
  644. END IF
  645. IF tv_1.uo_cur_info.sonflag = 0 THEN
  646. MessageBox('提示','不是明细区域,不能选择!', Information!, OK! )
  647. RETURN
  648. END IF
  649. s_rst.cusareaid = tv_1.uo_cur_info.cusareaid
  650. s_rst.cusareaname = tv_1.uo_cur_info.cusareaname
  651. s_rst.areaname = tv_1.uo_cur_info.areaname
  652. Close(PARENT)
  653. end event