w_item_cust_spt_edit.srw 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. $PBExportHeader$w_item_cust_spt_edit.srw
  2. forward
  3. global type w_item_cust_spt_edit from w_publ_edit_choice
  4. end type
  5. type cb_1 from uo_imflatbutton within w_item_cust_spt_edit
  6. end type
  7. type dw_1 from u_dw_rbtnfilter within w_item_cust_spt_edit
  8. end type
  9. type cb_addmx from uo_imflatbutton within w_item_cust_spt_edit
  10. end type
  11. type cb_delmx from uo_imflatbutton within w_item_cust_spt_edit
  12. end type
  13. end forward
  14. global type w_item_cust_spt_edit from w_publ_edit_choice
  15. integer width = 3611
  16. integer height = 2380
  17. string title = "客户及供应商辅助项目"
  18. boolean minbox = true
  19. windowtype windowtype = popup!
  20. event retrieve_mx ( )
  21. cb_1 cb_1
  22. dw_1 dw_1
  23. cb_addmx cb_addmx
  24. cb_delmx cb_delmx
  25. end type
  26. global w_item_cust_spt_edit w_item_cust_spt_edit
  27. forward prototypes
  28. public subroutine wf_face ()
  29. end prototypes
  30. event retrieve_mx();Long ll_row,ll_itemid
  31. ll_row = dw_uc.GetRow()
  32. IF ll_row <= 0 THEN
  33. dw_1.Reset()
  34. ELSE
  35. ll_itemid = dw_uc.Object.itemid[ll_row]
  36. dw_1.Retrieve(ll_itemid)
  37. END IF
  38. end event
  39. public subroutine wf_face ();cb_addmx.Enabled = NOT dw_edit_mode
  40. cb_delmx.Enabled = NOT dw_edit_mode
  41. end subroutine
  42. on w_item_cust_spt_edit.create
  43. int iCurrent
  44. call super::create
  45. this.cb_1=create cb_1
  46. this.dw_1=create dw_1
  47. this.cb_addmx=create cb_addmx
  48. this.cb_delmx=create cb_delmx
  49. iCurrent=UpperBound(this.Control)
  50. this.Control[iCurrent+1]=this.cb_1
  51. this.Control[iCurrent+2]=this.dw_1
  52. this.Control[iCurrent+3]=this.cb_addmx
  53. this.Control[iCurrent+4]=this.cb_delmx
  54. end on
  55. on w_item_cust_spt_edit.destroy
  56. call super::destroy
  57. destroy(this.cb_1)
  58. destroy(this.dw_1)
  59. destroy(this.cb_addmx)
  60. destroy(this.cb_delmx)
  61. end on
  62. event ue_before_open;call super::ue_before_open;dw_1.SetTransObject(sqlca)
  63. end event
  64. type cb_func from w_publ_edit_choice`cb_func within w_item_cust_spt_edit
  65. end type
  66. type cb_exit from w_publ_edit_choice`cb_exit within w_item_cust_spt_edit
  67. integer x = 1454
  68. end type
  69. type cb_add from w_publ_edit_choice`cb_add within w_item_cust_spt_edit
  70. end type
  71. event cb_add::clicked;call super::clicked;IF Not (f_power_ind(1274) OR f_power_ind(1276)) THEN
  72. MessageBox('提示','你没有使用权限!',information!,ok!)
  73. RETURN
  74. END IF
  75. Long ll_newid,i
  76. String errmsg
  77. IF dw_edit_mode THEN
  78. dw_uc.AcceptText()
  79. IF dw_uc.GetNextModified(0, Primary!) = 0 THEN
  80. MessageBox('提示','没有任何修改,不可以保存!',information!,ok!)
  81. RETURN
  82. END IF
  83. dw_uc.Object.itemcode[dw_uc.GetRow()] = Trim(dw_uc.Object.itemcode[dw_uc.GetRow()])
  84. dw_uc.Object.itemname[dw_uc.GetRow()] = Trim(dw_uc.Object.itemname[dw_uc.GetRow()])
  85. IF dw_uc.Object.itemcode[dw_uc.GetRow()] = '' THEN
  86. MessageBox('提示','请输入项目编号!',information!,ok!)
  87. RETURN
  88. END IF
  89. IF dw_uc.Object.itemname[dw_uc.GetRow()] = '' THEN
  90. MessageBox('提示','请输入项目名称!',information!,ok!)
  91. RETURN
  92. END IF
  93. IF dw_uc.Object.itemid[dw_uc.GetRow()] = 0 THEN
  94. ll_newid = f_sys_scidentity(0,"u_item_cust_spt_def","itemid",errmsg,FALSE,sqlca)
  95. IF ll_newid <= 0 THEN
  96. MessageBox('错误',errmsg,stopsign!,ok!)
  97. RETURN
  98. ELSE
  99. dw_uc.Object.itemid[dw_uc.GetRow()] = ll_newid
  100. END IF
  101. END IF
  102. END IF
  103. IF dw_edit_mode THEN
  104. String ls_errmsg
  105. IF dw_uc.Update() = -1 THEN
  106. IF Pos(ins_sqlerrtext,"Cannot insert duplicate key row") > 0 THEN
  107. ls_errmsg = "关键内容重复"
  108. ELSE
  109. ls_errmsg = "因为网络或其他原因>"+ins_sqlerrtext
  110. END IF
  111. ROLLBACK;
  112. MessageBox ('错误',ls_errmsg+",保存操作失败!",stopsign!,OK!)
  113. LS_UPDATE_FLAG = FALSE
  114. RETURN
  115. ELSE
  116. COMMIT;
  117. FOR i = 1 TO 6
  118. dw_uc.SetTabOrder ( i, 0 )
  119. NEXT
  120. LS_UPDATE_FLAG = TRUE
  121. END IF
  122. ins_sqlerrtext = ""
  123. ELSE
  124. Long li_row, li_cur_row
  125. li_cur_row = dw_uc.GetRow()
  126. li_row = dw_uc.InsertRow (0)
  127. FOR i = 1 TO 6
  128. dw_uc.SetTabOrder ( i, i*10 )
  129. NEXT
  130. dw_uc.SelectRow(0,FALSE)
  131. dw_uc.ScrollToRow (li_row)
  132. dw_uc.SelectRow(li_row,TRUE)
  133. dw_uc.SetFocus()
  134. modifyrow_no = li_row
  135. END IF
  136. dw_edit_mode = NOT dw_edit_mode
  137. WF_FACE_CHANGE()
  138. wf_face()
  139. end event
  140. type cb_edit from w_publ_edit_choice`cb_edit within w_item_cust_spt_edit
  141. end type
  142. event cb_edit::clicked;call super::clicked;IF Not (f_power_ind(1274) OR f_power_ind(1276)) THEN
  143. MessageBox('提示','你没有使用权限!',information!,ok!)
  144. RETURN
  145. END IF
  146. Long i
  147. IF dw_edit_mode THEN
  148. IF dw_uc.GetItemStatus(dw_uc.GetRow(), 0, Primary!) = NewModified! OR dw_uc.GetItemStatus(dw_uc.GetRow(), 0, Primary!) = New! THEN
  149. dw_uc.DeleteRow(dw_uc.GetRow())
  150. ELSE
  151. dw_uc.ReselectRow(dw_uc.GetRow())
  152. END IF
  153. FOR i = 1 TO 6
  154. dw_uc.SetTabOrder ( i, 0 )
  155. NEXT
  156. modifyrow_no = 0
  157. ELSE
  158. modifyrow_no = dw_uc.GetRow()
  159. FOR i = 1 TO 6
  160. dw_uc.SetTabOrder ( i, i*10 )
  161. NEXT
  162. dw_uc.SetFocus()
  163. dw_uc.SelectRow(0,FALSE)
  164. dw_uc.ScrollToRow (modifyrow_no)
  165. dw_uc.SelectRow(modifyrow_no,TRUE)
  166. END IF
  167. dw_edit_mode = NOT dw_edit_mode
  168. WF_FACE_CHANGE()
  169. wf_face()
  170. end event
  171. type cb_delet from w_publ_edit_choice`cb_delet within w_item_cust_spt_edit
  172. end type
  173. event cb_delet::clicked;call super::clicked;IF Not (f_power_ind(1274) OR f_power_ind(1276)) THEN
  174. MessageBox('提示','你没有使用权限!',information!,ok!)
  175. RETURN
  176. END IF
  177. String arg_msg
  178. IF DW_UC.GetRow() <= 0 THEN
  179. MessageBox('提示','没有操作目标记录!',information!,ok!)
  180. RETURN
  181. END IF
  182. IF MessageBox ('询问',"是否确定要删除当前记录?(选择确定后记录将不可恢复)",Question!,YesNo! ) = 2 THEN
  183. RETURN
  184. END IF
  185. Long LS_LONG,ll_itemid
  186. ll_itemid = DW_UC.Object.itemid[DW_UC.GetRow()]
  187. LS_LONG = 0
  188. SELECT COUNT(*) INTO :LS_LONG FROM u_item_cust_spt Where itemid = :ll_itemid ;
  189. IF SQLCA.SQLCode <> 0 THEN
  190. MessageBox ("错误","数据查询操作失败!(请重试!)",stopsign!,OK!)
  191. RETURN
  192. END IF
  193. IF LS_LONG > 0 THEN
  194. IF MessageBox ('询问',"该资料已用于客户或供应商资料,删除时会将相关资料删除,是否确定要删除当前记录?(选择确定后记录将不可恢复)",Question!,YesNo! ) = 2 THEN
  195. RETURN
  196. END IF
  197. END IF
  198. DELETE FROM u_item_cust_spt
  199. Where itemid = :ll_itemid;
  200. IF SQLCA.SQLCode <> 0 THEN
  201. MessageBox ("错误","删除操作失败(客户供应商)!~n"+SQLCA.SQLErrText,stopsign!,OK!)
  202. ROLLBACK;
  203. RETURN
  204. END IF
  205. DELETE FROM u_item_cust_spt_def_mx
  206. Where itemid = :ll_itemid;
  207. IF SQLCA.SQLCode <> 0 THEN
  208. MessageBox ("错误","删除操作失败(项目明细)!~n"+SQLCA.SQLErrText,stopsign!,OK!)
  209. ROLLBACK;
  210. RETURN
  211. END IF
  212. DW_UC.SetRedraw (FALSE)
  213. DW_UC.DeleteRow (0)
  214. DW_UC.TriggerEvent (RowFocusChanged!)
  215. IF DW_UC.Update() = -1 THEN
  216. ROLLBACK;
  217. MessageBox ("错误","删除记录操作失败!",stopsign!,OK!)
  218. ELSE
  219. COMMIT;
  220. END IF
  221. DW_UC.SetRedraw (TRUE)
  222. end event
  223. type cb_choice from w_publ_edit_choice`cb_choice within w_item_cust_spt_edit
  224. boolean visible = false
  225. integer x = 1806
  226. integer width = 165
  227. boolean enabled = false
  228. end type
  229. type dw_uc from w_publ_edit_choice`dw_uc within w_item_cust_spt_edit
  230. integer width = 2062
  231. integer height = 2064
  232. string dataobject = "dw_item_cust_spt_def"
  233. end type
  234. event dw_uc::rowfocuschanged;call super::rowfocuschanged;PARENT.TriggerEvent('retrieve_mx')
  235. end event
  236. type cb_rtr from w_publ_edit_choice`cb_rtr within w_item_cust_spt_edit
  237. end type
  238. event cb_rtr::clicked;call super::clicked;PARENT.TriggerEvent('retrieve_mx')
  239. end event
  240. type cb_help from w_publ_edit_choice`cb_help within w_item_cust_spt_edit
  241. integer x = 1303
  242. end type
  243. type ln_bar from w_publ_edit_choice`ln_bar within w_item_cust_spt_edit
  244. end type
  245. type ln_bar2 from w_publ_edit_choice`ln_bar2 within w_item_cust_spt_edit
  246. end type
  247. type r_bar from w_publ_edit_choice`r_bar within w_item_cust_spt_edit
  248. integer x = 2043
  249. end type
  250. type cb_1 from uo_imflatbutton within w_item_cust_spt_edit
  251. integer x = 837
  252. integer width = 466
  253. integer height = 164
  254. integer taborder = 30
  255. boolean bringtotop = true
  256. string text = "加入客户/供应商"
  257. string normalpicname = "mx.bmp"
  258. integer picsize = 16
  259. toolbaralignment pic_align = alignattop!
  260. boolean border = false
  261. end type
  262. event clicked;call super::clicked;IF Not (f_power_ind(1274) OR f_power_ind(1276)) THEN
  263. MessageBox('提示','你没有使用权限!',information!,ok!)
  264. RETURN
  265. END IF
  266. String arg_msg
  267. IF DW_UC.GetRow() <= 0 THEN
  268. MessageBox('提示','没有操作目标记录!',information!,ok!)
  269. RETURN
  270. END IF
  271. IF MessageBox ('询问',"是否确定要当前记录加入到客户或供应商资料?",Question!,YesNo! ) = 2 THEN
  272. RETURN
  273. END IF
  274. Long LS_LONG,ll_itemid
  275. Int li_itemtype
  276. ll_itemid = DW_UC.Object.itemid[DW_UC.GetRow()]
  277. li_itemtype = DW_UC.Object.itemtype[DW_UC.GetRow()]
  278. IF li_itemtype = 0 THEN
  279. INSERT INTO u_item_cust_spt
  280. (itemid,relid,reltype,dscrp)
  281. SELECT :ll_itemid,cusid,0,''
  282. FROM u_cust
  283. WHERE inuse = 1
  284. and cusid NOT IN
  285. (SELECT relid FROM u_item_cust_spt
  286. Where reltype = 0 and itemid = :ll_itemid );
  287. IF SQLCA.SQLCode <> 0 THEN
  288. MessageBox ("错误","数据加入客户资料失败!~n"+SQLCA.SQLErrText,stopsign!,OK!)
  289. ROLLBACK;
  290. RETURN
  291. END IF
  292. ELSE
  293. INSERT INTO u_item_cust_spt
  294. (itemid,relid,reltype,dscrp)
  295. SELECT :ll_itemid,sptid,1,''
  296. FROM u_spt WHERE inuse = 1
  297. and sptid NOT IN
  298. (SELECT relid FROM u_item_cust_spt
  299. Where reltype = 1 and itemid = :ll_itemid );
  300. IF SQLCA.SQLCode <> 0 THEN
  301. MessageBox ("错误","数据加入供应商资料失败!~n"+SQLCA.SQLErrText,stopsign!,OK!)
  302. ROLLBACK;
  303. RETURN
  304. END IF
  305. END IF
  306. COMMIT;
  307. MessageBox ("提示","操作成功",information!,ok!)
  308. end event
  309. type dw_1 from u_dw_rbtnfilter within w_item_cust_spt_edit
  310. integer x = 2062
  311. integer y = 176
  312. integer width = 1477
  313. integer height = 2064
  314. integer taborder = 20
  315. boolean bringtotop = true
  316. string dataobject = "dw_item_cust_spt_def_mx"
  317. boolean hscrollbar = true
  318. boolean vscrollbar = true
  319. end type
  320. event rowfocuschanged;call super::rowfocuschanged;IF currentrow <= 0 THEN RETURN
  321. THIS.SelectRow(0,FALSE)
  322. THIS.SelectRow(currentrow,TRUE)
  323. end event
  324. type cb_addmx from uo_imflatbutton within w_item_cust_spt_edit
  325. integer x = 2075
  326. integer width = 233
  327. integer height = 164
  328. integer taborder = 60
  329. boolean bringtotop = true
  330. string text = "增项目"
  331. string normalpicname = "mx1.bmp"
  332. integer picsize = 16
  333. toolbaralignment pic_align = alignattop!
  334. boolean border = false
  335. end type
  336. event clicked;call super::clicked;IF Not (f_power_ind(1067) OR f_power_ind(1069)) THEN
  337. MessageBox('提示','你没有使用权限!',information!,ok!)
  338. RETURN
  339. END IF
  340. IF DW_UC.GetRow() <= 0 THEN
  341. MessageBox('提示','没有操作目标记录!',information!,ok!)
  342. RETURN
  343. END IF
  344. Int li_inputtype
  345. Long ll_itemid
  346. ll_itemid = DW_UC.Object.itemid[DW_UC.GetRow()]
  347. li_inputtype = DW_UC.Object.inputtype[DW_UC.GetRow()]
  348. IF li_inputtype <> 0 THEN
  349. MessageBox('提示','不是选项类型的项目不能增加明细项目!',information!,ok!)
  350. RETURN
  351. END IF
  352. OpenWithParm(w_item_cust_spt_mx_add,ll_itemid)
  353. PARENT.TriggerEvent('retrieve_mx')
  354. end event
  355. type cb_delmx from uo_imflatbutton within w_item_cust_spt_edit
  356. integer x = 2309
  357. integer width = 233
  358. integer height = 164
  359. integer taborder = 70
  360. boolean bringtotop = true
  361. string text = "删项目"
  362. string normalpicname = "mx2.bmp"
  363. integer picsize = 16
  364. toolbaralignment pic_align = alignattop!
  365. boolean border = false
  366. end type
  367. event clicked;call super::clicked;IF Not (f_power_ind(1067) OR f_power_ind(1069)) THEN
  368. MessageBox('提示','你没有使用权限!',information!,ok!)
  369. RETURN
  370. END IF
  371. String arg_msg
  372. IF dw_1.GetRow() <= 0 THEN
  373. MessageBox('提示','没有操作目标记录!',information!,ok!)
  374. RETURN
  375. END IF
  376. IF MessageBox ('询问',"是否确定要删除当前记录?(选择确定后记录将不可恢复)",Question!,YesNo! ) = 2 THEN
  377. RETURN
  378. END IF
  379. Long ll_mxid
  380. ll_mxid = dw_1.Object.mxid[dw_1.GetRow()]
  381. DELETE FROM u_item_cust_spt_def_mx
  382. Where mxid = :ll_mxid;
  383. IF SQLCA.SQLCode <> 0 THEN
  384. MessageBox ("错误","删除操作失败(项目明细)!~n"+SQLCA.SQLErrText,stopsign!,OK!)
  385. ROLLBACK;
  386. RETURN
  387. END IF
  388. COMMIT;
  389. PARENT.TriggerEvent('retrieve_mx')
  390. end event