w_cusarea_add.srw 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. $PBExportHeader$w_cusarea_add.srw
  2. forward
  3. global type w_cusarea_add from w_publ_base
  4. end type
  5. type dw_1 from datawindow within w_cusarea_add
  6. end type
  7. type cb_1 from uo_imflatbutton within w_cusarea_add
  8. end type
  9. type cbx_auto_code from checkbox within w_cusarea_add
  10. end type
  11. end forward
  12. global type w_cusarea_add from w_publ_base
  13. integer width = 1513
  14. integer height = 1036
  15. string title = "区域建立"
  16. boolean minbox = false
  17. windowtype windowtype = response!
  18. dw_1 dw_1
  19. cb_1 cb_1
  20. cbx_auto_code cbx_auto_code
  21. end type
  22. global w_cusarea_add w_cusarea_add
  23. type variables
  24. s_cusarea s_area
  25. long i_parentid
  26. string i_parent_handtype
  27. end variables
  28. forward prototypes
  29. public function integer wf_checkrand (long arg_cusareaid)
  30. public function integer wf_save ()
  31. public subroutine wf_set_typecode (integer arg_row, long arg_parentid)
  32. end prototypes
  33. public function integer wf_checkrand (long arg_cusareaid);Long ll_parentid
  34. Long ll_cusareaid_arr[],ll_cusareaid
  35. Long rt_b,rt_s,count,ls_i
  36. dw_1.accepttext()
  37. ll_parentid = dw_1.object.parentid[dw_1.getrow()]
  38. IF ll_parentid = arg_cusareaid THEN RETURN 1
  39. DECLARE area_cur CURSOR FOR
  40. SELECT u_cusarea.cusareaid
  41. FROM u_cusarea
  42. Where ( u_cusarea.parentid = :arg_cusareaid );
  43. OPEN area_cur;
  44. FETCH area_cur INTO :ll_cusareaid;
  45. DO WHILE sqlca.SQLCode = 0
  46. count++
  47. ll_cusareaid_arr[count] = ll_cusareaid
  48. FETCH area_cur INTO :ll_cusareaid;
  49. LOOP
  50. CLOSE area_cur;
  51. FOR ls_i = 1 TO count
  52. rt_b = wf_checkrand(ll_cusareaid_arr[ls_i])
  53. IF rt_b <> 0 THEN RETURN rt_b
  54. NEXT
  55. RETURN 0
  56. end function
  57. public function integer wf_save ();//Long ll_row
  58. //Long ll_cusareaid,ll_parentid
  59. //Int ls_cr_rsl
  60. //String ls_parent_handtype
  61. //
  62. //dw_1.AcceptText()
  63. //ll_row = dw_1.GetRow()
  64. //IF ll_row <= 0 THEN
  65. // MessageBox('提示','请选择资料', Information!, OK! )
  66. // RETURN
  67. //END IF
  68. //
  69. //dw_1.Object.cusareaname[ll_row] = Trim(dw_1.Object.cusareaname[ll_row])
  70. //
  71. //IF dw_1.Object.typecode[ll_row] = '' THEN
  72. // MessageBox('提示','请输入区域编号!', Information!, OK! )
  73. // dw_1.SetColumn('typecode')
  74. // dw_1.SetFocus()
  75. // RETURN
  76. //END IF
  77. //
  78. //IF dw_1.Object.cusareaname[ll_row] = '' THEN
  79. // MessageBox('提示','请输入区域名称!', Information!, OK! )
  80. // dw_1.SetColumn('cusareaname')
  81. // dw_1.SetFocus()
  82. // RETURN
  83. //END IF
  84. //
  85. //IF pos(dw_1.Object.cusareaname[ll_row],'>') > 0 THEN
  86. // MessageBox('提示','区域名称不能包含符号 > !', Information!, OK! )
  87. // dw_1.SetColumn('cusareaname')
  88. // dw_1.SetFocus()
  89. // RETURN
  90. //END IF
  91. //
  92. ////检查闭环
  93. //ll_cusareaid = dw_1.Object.cusareaid[dw_1.GetRow()]
  94. //ll_parentid = dw_1.Object.parentid[dw_1.GetRow()]
  95. //
  96. //IF ll_cusareaid > 0 THEN
  97. // IF ll_parentid <> i_parentid THEN
  98. // ls_cr_rsl = wf_checkrand(ll_cusareaid)
  99. // IF ls_cr_rsl = 1 THEN
  100. // MessageBox('提示',String(dw_1.Object.cusareaname[dw_1.GetRow()])+' 发现环,请核对!', Information!, OK! )
  101. // RETURN
  102. // ELSEIF ls_cr_rsl < 0 THEN
  103. // MessageBox('提示','因为网络或其他原因导致查环操作失败!['+String(dw_1.Object.cusareaname[dw_1.GetRow()])+']', Information!, OK! )
  104. // RETURN
  105. // END IF
  106. // END IF
  107. //END IF
  108. ////
  109. //
  110. //s_area.cusareaid = dw_1.Object.cusareaid[ll_row]
  111. //s_area.cusareaname = dw_1.Object.cusareaname[ll_row]
  112. //s_area.sonflag = dw_1.Object.sonflag[ll_row]
  113. //s_area.parentid = dw_1.Object.parentid[ll_row]
  114. //
  115. //IF ll_parentid <> i_parentid THEN
  116. // IF ll_parentid = 0 THEN
  117. // ls_parent_handtype = ''
  118. // ELSE
  119. // SELECT areaname INTO :ls_parent_handtype
  120. // FROM u_cusarea
  121. // Where cusareaid = :ll_parentid;
  122. // IF sqlca.SQLCode <> 0 THEN
  123. // MessageBox('提示','查询上级区域资料失败', Information!, OK! )
  124. // RETURN
  125. // END IF
  126. // END IF
  127. //ELSE
  128. // if ll_parentid = 0 then
  129. // ls_parent_handtype = ''
  130. // else
  131. // ls_parent_handtype = i_parent_handtype
  132. // end if
  133. //END IF
  134. //
  135. //
  136. //s_area.areaname = ls_parent_handtype + dw_1.Object.cusareaname[ll_row] + '>>'
  137. //
  138. //Close(PARENT)
  139. return 1
  140. end function
  141. public subroutine wf_set_typecode (integer arg_row, long arg_parentid);String ls_typecode, ls_typecodestr
  142. Int li_maxnum
  143. IF arg_row <= 0 THEN
  144. RETURN
  145. END IF
  146. SELECT count(*)
  147. INTO :li_maxnum
  148. FROM u_cusarea
  149. Where parentid = :arg_parentid;
  150. IF sqlca.SQLCode <> 0 THEN
  151. li_maxnum = 0
  152. END IF
  153. ls_typecode = String(li_maxnum + 1, "00")
  154. dw_1.Object.typecode[arg_row] = ls_typecode
  155. SELECT typecodestr
  156. INTO :ls_typecodestr
  157. FROM u_cusarea
  158. Where cusareaid = :arg_parentid;
  159. IF sqlca.SQLCode <> 0 THEN
  160. ls_typecodestr = ''
  161. END IF
  162. dw_1.Object.typecodestr[arg_row] = ls_typecodestr + ls_typecode
  163. end subroutine
  164. on w_cusarea_add.create
  165. int iCurrent
  166. call super::create
  167. this.dw_1=create dw_1
  168. this.cb_1=create cb_1
  169. this.cbx_auto_code=create cbx_auto_code
  170. iCurrent=UpperBound(this.Control)
  171. this.Control[iCurrent+1]=this.dw_1
  172. this.Control[iCurrent+2]=this.cb_1
  173. this.Control[iCurrent+3]=this.cbx_auto_code
  174. end on
  175. on w_cusarea_add.destroy
  176. call super::destroy
  177. destroy(this.dw_1)
  178. destroy(this.cb_1)
  179. destroy(this.cbx_auto_code)
  180. end on
  181. event close;call super::close;closewithreturn(this,s_area)
  182. end event
  183. event open;call super::open;dw_1.SetTransObject(sqlca)
  184. Long ll_row
  185. s_area = Message.PowerObjectParm
  186. IF s_area.cusareaid = 0 THEN
  187. ll_row = dw_1.InsertRow(0)
  188. dw_1.Object.cusareaid[ll_row] = s_area.cusareaid
  189. dw_1.Object.sonflag[ll_row] = s_area.sonflag
  190. dw_1.Object.parentid[ll_row] = s_area.parentid
  191. if cbx_auto_code.checked then
  192. wf_set_typecode(ll_row, s_area.parentid)
  193. end if
  194. ELSE
  195. dw_1.Retrieve(s_area.cusareaid)
  196. END IF
  197. ////
  198. //datawindowchild childdw
  199. //dw_1.GetChild("parentid",childdw)
  200. //childdw.SetTransObject (sqlca)
  201. //long li_row
  202. //li_row = childdw.insertrow(0)
  203. //
  204. dw_1.SetFocus()
  205. dw_1.SetColumn('cusareaname')
  206. i_parent_handtype = s_area.parenthandtype
  207. s_area.cusareaid = -1
  208. end event
  209. type cb_func from w_publ_base`cb_func within w_cusarea_add
  210. integer x = 617
  211. integer y = 736
  212. integer width = 311
  213. integer height = 96
  214. string text = "保存"
  215. boolean default = true
  216. string normalpicname = "ok.bmp"
  217. integer picsize = 0
  218. toolbaralignment pic_align = alignatleft!
  219. boolean border = true
  220. end type
  221. event cb_func::clicked;call super::clicked;Long ll_row
  222. Long ll_cusareaid,ll_parentid
  223. Int ls_cr_rsl
  224. String ls_parent_handtype
  225. dw_1.AcceptText()
  226. ll_row = dw_1.GetRow()
  227. IF ll_row <= 0 THEN
  228. MessageBox('提示','请选择资料', Information!, OK! )
  229. RETURN
  230. END IF
  231. dw_1.Object.cusareaname[ll_row] = Trim(dw_1.Object.cusareaname[ll_row])
  232. IF dw_1.Object.typecode[ll_row] = '' THEN
  233. MessageBox('提示','请输入区域编号!', Information!, OK! )
  234. dw_1.SetColumn('typecode')
  235. dw_1.SetFocus()
  236. RETURN
  237. END IF
  238. IF dw_1.Object.cusareaname[ll_row] = '' THEN
  239. MessageBox('提示','请输入区域名称!', Information!, OK! )
  240. dw_1.SetColumn('cusareaname')
  241. dw_1.SetFocus()
  242. RETURN
  243. END IF
  244. IF Pos(dw_1.Object.cusareaname[ll_row],'>') > 0 THEN
  245. MessageBox('提示','区域名称不能包含符号 > !', Information!, OK! )
  246. dw_1.SetColumn('cusareaname')
  247. dw_1.SetFocus()
  248. RETURN
  249. END IF
  250. //检查闭环
  251. ll_cusareaid = dw_1.Object.cusareaid[dw_1.GetRow()]
  252. ll_parentid = dw_1.Object.parentid[dw_1.GetRow()]
  253. IF ll_cusareaid > 0 THEN
  254. IF ll_parentid <> i_parentid THEN
  255. ls_cr_rsl = wf_checkrand(ll_cusareaid)
  256. IF ls_cr_rsl = 1 THEN
  257. MessageBox('提示',String(dw_1.Object.cusareaname[dw_1.GetRow()])+' 发现环,请核对!', Information!, OK! )
  258. RETURN
  259. ELSEIF ls_cr_rsl < 0 THEN
  260. MessageBox('提示','因为网络或其他原因导致查环操作失败!['+String(dw_1.Object.cusareaname[dw_1.GetRow()])+']', Information!, OK! )
  261. RETURN
  262. END IF
  263. END IF
  264. END IF
  265. //
  266. s_area.cusareaid = dw_1.Object.cusareaid[ll_row]
  267. s_area.cusareaname = dw_1.Object.cusareaname[ll_row]
  268. s_area.sonflag = dw_1.Object.sonflag[ll_row]
  269. s_area.parentid = dw_1.Object.parentid[ll_row]
  270. IF ll_parentid = 0 THEN
  271. ls_parent_handtype = ''
  272. ELSE
  273. IF ll_parentid <> i_parentid THEN
  274. SELECT areaname INTO :ls_parent_handtype
  275. FROM u_cusarea
  276. Where cusareaid = :ll_parentid;
  277. IF sqlca.SQLCode <> 0 THEN
  278. MessageBox('提示','查询上级区域资料失败', Information!, OK! )
  279. RETURN
  280. END IF
  281. ELSE
  282. ls_parent_handtype = i_parent_handtype
  283. END IF
  284. END IF
  285. s_area.areaname = ls_parent_handtype + dw_1.Object.cusareaname[ll_row] + '>>'
  286. string ls_typecode, ls_typecodestr
  287. ls_typecode = dw_1.Object.typecode[ll_row]
  288. //ls_typecodestr = dw_1.Object.typecodestr[ll_row]
  289. SELECT typecodestr
  290. INTO :ls_typecodestr
  291. FROM u_cusarea
  292. Where cusareaid = :s_area.parentid;
  293. IF sqlca.SQLCode <> 0 THEN
  294. ls_typecodestr = ''
  295. END IF
  296. s_area.typecode = ls_typecode
  297. //s_area.typecodestr = left(ls_typecodestr, len(ls_typecodestr) - len(ls_typecode))+ ls_typecode
  298. s_area.typecodestr = ls_typecodestr + ls_typecode
  299. Close(PARENT)
  300. end event
  301. type cb_exit from w_publ_base`cb_exit within w_cusarea_add
  302. integer x = 1120
  303. integer y = 736
  304. end type
  305. event cb_exit::clicked;s_area.cusareaid = -1
  306. close(parent)
  307. end event
  308. type dw_1 from datawindow within w_cusarea_add
  309. integer x = 133
  310. integer y = 108
  311. integer width = 1211
  312. integer height = 476
  313. integer taborder = 10
  314. boolean bringtotop = true
  315. string title = "none"
  316. string dataobject = "dw_cusarea_edit"
  317. boolean border = false
  318. boolean livescroll = true
  319. end type
  320. type cb_1 from uo_imflatbutton within w_cusarea_add
  321. integer x = 114
  322. integer y = 736
  323. integer width = 311
  324. integer height = 96
  325. integer taborder = 30
  326. boolean bringtotop = true
  327. string text = "查闭环"
  328. end type
  329. event clicked;call super::clicked;//检查有否环//
  330. Long ll_cusareaid,ll_parentid
  331. Int ls_cr_rsl
  332. dw_1.accepttext()
  333. IF dw_1.GetRow() <= 0 THEN RETURN
  334. ll_cusareaid = dw_1.Object.cusareaid[dw_1.GetRow()]
  335. ll_parentid = dw_1.Object.parentid[dw_1.GetRow()]
  336. IF ll_cusareaid <= 0 THEN RETURN
  337. IF ll_parentid = i_parentid THEN RETURN
  338. ls_cr_rsl = wf_checkrand(ll_cusareaid)
  339. IF ls_cr_rsl = 1 THEN
  340. MessageBox('提示',string(dw_1.Object.cusareaname[dw_1.GetRow()])+' 发现环,请核对!', Information!, OK! )
  341. RETURN
  342. ELSEIF ls_cr_rsl < 0 THEN
  343. MessageBox('提示','因为网络或其他原因导致查环操作失败!['+string(dw_1.Object.cusareaname[dw_1.GetRow()])+']', Information!, OK! )
  344. RETURN
  345. END IF
  346. MessageBox('提示','没有发现闭环!', Information!, OK! )
  347. end event
  348. type cbx_auto_code from checkbox within w_cusarea_add
  349. integer x = 133
  350. integer y = 624
  351. integer width = 457
  352. integer height = 72
  353. boolean bringtotop = true
  354. integer textsize = -9
  355. integer weight = 400
  356. fontcharset fontcharset = gb2312charset!
  357. fontpitch fontpitch = variable!
  358. string facename = "宋体"
  359. long textcolor = 33554432
  360. long backcolor = 134217739
  361. string text = "自动编号"
  362. end type
  363. event constructor;Int li_flag
  364. li_flag = Integer(f_ProfileString (sys_empid,this.classname(), "if_auto_code", '0'))
  365. IF li_flag = 0 THEN
  366. THIS.Checked = FALSE
  367. ELSE
  368. THIS.Checked = TRUE
  369. END IF
  370. end event
  371. event clicked;Int li_flag
  372. IF THIS.Checked THEN
  373. li_flag = 1
  374. wf_set_typecode(dw_1.GetRow(), s_area.parentid)
  375. ELSE
  376. li_flag = 0
  377. END IF
  378. f_SetProfileString (sys_empid,THIS.ClassName(), "if_auto_code", String(li_flag))
  379. end event