w_add_sptmtrlname.srw 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. $PBExportHeader$w_add_sptmtrlname.srw
  2. forward
  3. global type w_add_sptmtrlname from w_publ_choice
  4. end type
  5. type cb_1 from uo_imflatbutton within w_add_sptmtrlname
  6. end type
  7. type st_2 from statictext within w_add_sptmtrlname
  8. end type
  9. end forward
  10. global type w_add_sptmtrlname from w_publ_choice
  11. integer width = 2331
  12. integer height = 1408
  13. string title = "供应商物料别名"
  14. boolean controlmenu = true
  15. event ue_f7 ( )
  16. cb_1 cb_1
  17. st_2 st_2
  18. end type
  19. global w_add_sptmtrlname w_add_sptmtrlname
  20. type variables
  21. Long cur_mtrlid = 0
  22. end variables
  23. forward prototypes
  24. public function integer wf_add_sptmtrlname (long arg_mtrlid, long arg_sptid, string arg_sptmtrlname, string arg_sptmtrlcode, string arg_sptmtrlmode, ref string arg_msg, boolean arg_ifcommit)
  25. end prototypes
  26. event ue_f7();IF NOT dw_edit_mode THEN RETURN
  27. Long uc_row
  28. uc_row = dw_ch.GetRow()
  29. IF uc_row = 0 THEN
  30. MessageBox('提示','请选定单据!',information!,ok!)
  31. RETURN
  32. END IF
  33. dw_ch.AcceptText()
  34. IF NOT IsValid(W_spt_edit) THEN
  35. s_edit_index_tran s_ch_tran //传递参数使用
  36. s_ch_tran.if_retrieve_all = FALSE //是否一次RETRIEVE所有行
  37. s_ch_tran.work_mode = 1 //0-单纯编辑模式 1-选择\编辑模式
  38. s_ch_tran.arg_pkid = 0 //目标定位PKID (备用)
  39. //查询列(物料编码)部分内容,用于初步筛选
  40. s_ch_tran.arg_string_code = Upper(Trim(dw_ch.Object.u_spt_sptcode[dw_ch.GetRow()]))
  41. OpenWithParm(W_spt_edit,s_ch_tran) //调用
  42. S_spt S_INSCUST
  43. S_INSCUST = Message.PowerObjectParm //接受返回结构
  44. IF S_INSCUST.sptid > 0 THEN //正常返回值则可以取以下值
  45. dw_ch.SetRedraw(FALSE)
  46. dw_ch.Object.u_sptmtrlname_sptid[uc_row] = S_INSCUST.sptid
  47. dw_ch.Object.u_spt_name[uc_row] = S_INSCUST.Name
  48. dw_ch.Object.u_spt_sptcode[uc_row] = S_INSCUST.sptcode
  49. dw_ch.SetRedraw(TRUE)
  50. dw_ch.SetColumn("u_sptmtrlname_sptmtrlname")
  51. END IF
  52. END IF
  53. end event
  54. public function integer wf_add_sptmtrlname (long arg_mtrlid, long arg_sptid, string arg_sptmtrlname, string arg_sptmtrlcode, string arg_sptmtrlmode, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1
  55. Long cnt = 0
  56. IF IsNull(arg_sptmtrlname) THEN arg_sptmtrlname = ''
  57. SELECT count(*) INTO :cnt
  58. FROM u_spt
  59. Where u_spt.sptid = :arg_sptid;
  60. IF sqlca.SQLCode <> 0 THEN
  61. rslt = 0
  62. arg_msg = '因网络或其它原因导致查询供应商资料失败'+sqlca.SQLErrText
  63. GOTO ext
  64. END IF
  65. IF cnt = 0 THEN
  66. rslt = 0
  67. arg_msg = "供应商不存在"
  68. GOTO ext
  69. END IF
  70. cnt = 0
  71. SELECT count(*) INTO :cnt
  72. FROM u_mtrldef
  73. Where u_mtrldef.mtrlid = :arg_mtrlid;
  74. IF sqlca.SQLCode <> 0 THEN
  75. rslt = 0
  76. arg_msg = '因网络和其他原因查询失败'+sqlca.SQLErrText
  77. GOTO ext
  78. END IF
  79. IF cnt = 0 THEN
  80. rslt = 0
  81. arg_msg = '物料资料不存在'
  82. GOTO ext
  83. END IF
  84. cnt = 0
  85. SELECT count(*) INTO :cnt
  86. FROM u_sptmtrlname
  87. WHERE u_sptmtrlname.sptid = :arg_sptid
  88. AND u_sptmtrlname.mtrlid = :arg_mtrlid;
  89. IF sqlca.SQLCode <> 0 THEN
  90. rslt = 0
  91. arg_msg = '因网络或其他原因查询供应商物料别名失败'+sqlca.SQLErrText
  92. GOTO ext
  93. END IF
  94. IF cnt > 0 THEN
  95. UPDATE u_sptmtrlname
  96. SET sptmtrlname = :arg_sptmtrlname,
  97. sptmtrlcode = :arg_sptmtrlcode,
  98. sptmtrlmode = :arg_sptmtrlmode
  99. WHERE u_sptmtrlname.sptid = :arg_sptid
  100. AND u_sptmtrlname.mtrlid = :arg_mtrlid;
  101. IF sqlca.SQLCode <> 0 THEN
  102. rslt = 0
  103. arg_msg = '因网络或其它原因,供应商物料别名更新失败'+sqlca.SQLErrText
  104. GOTO ext
  105. END IF
  106. ELSEIF cnt = 0 THEN
  107. INSERT INTO u_sptmtrlname
  108. (sptid,
  109. mtrlid,
  110. sptmtrlname,
  111. sptmtrlcode,
  112. sptmtrlmode)
  113. VALUES
  114. (:arg_sptid,
  115. :arg_mtrlid,
  116. :arg_sptmtrlname,
  117. :arg_sptmtrlcode,
  118. :arg_sptmtrlmode);
  119. IF sqlca.SQLCode <> 0 THEN
  120. rslt = 0
  121. arg_msg = '因网络或其他原因,新增供应商物料别名失败'
  122. GOTO ext
  123. END IF
  124. END IF
  125. ext:
  126. IF rslt = 0 THEN
  127. ROLLBACK;
  128. ELSEIF arg_ifcommit AND rslt = 1 THEN
  129. COMMIT;
  130. END IF
  131. RETURN rslt
  132. end function
  133. on w_add_sptmtrlname.create
  134. int iCurrent
  135. call super::create
  136. this.cb_1=create cb_1
  137. this.st_2=create st_2
  138. iCurrent=UpperBound(this.Control)
  139. this.Control[iCurrent+1]=this.cb_1
  140. this.Control[iCurrent+2]=this.st_2
  141. end on
  142. on w_add_sptmtrlname.destroy
  143. call super::destroy
  144. destroy(this.cb_1)
  145. destroy(this.st_2)
  146. end on
  147. event open;this.triggerevent('ue_before_open')
  148. wf_movetocenter()
  149. dw_edit_mode=true
  150. dw_CH.SetTransObject (sqlca)
  151. cur_mtrlid=message.DoubleParm
  152. dw_CH.retrieve(cur_mtrlid)
  153. dw_ch.InsertRow (0)
  154. end event
  155. type cb_func from w_publ_choice`cb_func within w_add_sptmtrlname
  156. boolean visible = false
  157. integer x = 1513
  158. integer y = 1644
  159. end type
  160. type cb_exit from w_publ_choice`cb_exit within w_add_sptmtrlname
  161. integer x = 1975
  162. integer y = 1208
  163. integer width = 311
  164. integer height = 96
  165. integer picsize = 0
  166. toolbaralignment pic_align = alignatleft!
  167. boolean border = true
  168. end type
  169. type sle_ch from w_publ_choice`sle_ch within w_add_sptmtrlname
  170. boolean visible = false
  171. integer x = 754
  172. integer y = 1668
  173. end type
  174. type dw_ch from w_publ_choice`dw_ch within w_add_sptmtrlname
  175. integer y = 0
  176. integer width = 2290
  177. integer height = 1196
  178. string dataobject = "dw_add_sptmtrlname"
  179. end type
  180. event dw_ch::dwnkey;IF dw_edit_mode THEN
  181. String ls_sptcode,ls_sptname
  182. Long li_row,ll_sptid
  183. dw_ch.AcceptText()
  184. li_row = dw_ch.GetRow()
  185. IF dw_ch.GetColumnName ( ) = 'u_spt_sptcode' AND Key = keyenter! THEN
  186. ls_sptcode = Trim(dw_ch.Object.u_spt_sptcode[li_row])
  187. SELECT sptid,Name INTO :ll_sptid,:ls_sptname FROM u_spt Where sptcode = :ls_sptcode;
  188. dw_ch.SetRedraw(FALSE)
  189. IF sqlca.SQLCode <> 0 THEN
  190. PARENT.TriggerEvent('ue_f7')
  191. RETURN 1
  192. ELSE
  193. dw_ch.Object.u_sptmtrlname_sptid[li_row] = ll_sptid
  194. dw_ch.Object.u_spt_name[li_row] = ls_sptname
  195. END IF
  196. dw_ch.SetRedraw(TRUE)
  197. dw_ch.SetColumn("u_sptmtrlname_sptmtrlname")
  198. RETURN 1
  199. ElseIf (dw_ch.GetColumnName ( ) = 'u_sptmtrlname_sptmtrlname' AND Key = keyenter!) Or ( KeyDown(Keydownarrow!)) THEN
  200. dw_ch.InsertRow(0)
  201. END IF
  202. END IF
  203. end event
  204. event dw_ch::doubleclicked;IF dw_edit_mode AND dw_ch.GetColumnName() = 'u_spt_sptcode' THEN
  205. PARENT.TriggerEvent('ue_f7')
  206. END IF
  207. end event
  208. type st_1 from w_publ_choice`st_1 within w_add_sptmtrlname
  209. boolean visible = false
  210. integer x = 1294
  211. integer y = 1676
  212. end type
  213. type cb_retrieve from w_publ_choice`cb_retrieve within w_add_sptmtrlname
  214. boolean visible = false
  215. integer x = 549
  216. integer y = 1660
  217. end type
  218. type cb_choice from w_publ_choice`cb_choice within w_add_sptmtrlname
  219. integer x = 1527
  220. integer y = 1208
  221. integer width = 311
  222. integer height = 96
  223. string text = "确定"
  224. integer picsize = 0
  225. toolbaralignment pic_align = alignatleft!
  226. boolean border = true
  227. end type
  228. event cb_choice::clicked;call super::clicked;String err_msg = ''
  229. Long l_sptid
  230. DateTime d_indate
  231. SetNull(d_indate)
  232. dw_ch.AcceptText()
  233. Long ll_rowcount
  234. Long ls_i
  235. String ls_sptmtrlname,ls_unit,ls_sptmtrlcode,ls_sptmtrlmode
  236. ll_rowcount = dw_ch.RowCount()
  237. FOR ls_i = 1 TO ll_rowcount
  238. ls_sptmtrlname = dw_ch.Object.u_sptmtrlname_sptmtrlname[ls_i]
  239. ls_sptmtrlcode =dw_ch.Object.u_sptmtrlname_sptmtrlcode[ls_i]
  240. ls_sptmtrlmode =dw_ch.Object.u_sptmtrlname_sptmtrlmode[ls_i]
  241. l_sptid = dw_ch.Object.u_sptmtrlname_sptid[ls_i]
  242. IF l_sptid <= 0 OR IsNull(l_sptid) THEN CONTINUE
  243. Boolean ifcommit = FALSE
  244. IF ls_i = ll_rowcount THEN ifcommit = TRUE
  245. IF wf_add_sptmtrlname(cur_mtrlid,l_sptid,ls_sptmtrlname,ls_sptmtrlcode,ls_sptmtrlmode,err_msg,ifcommit) = 0 THEN
  246. MessageBox('错误',err_msg,stopsign!,ok!)
  247. RETURN
  248. END IF
  249. NEXT
  250. MessageBox('提示','添加成功',information!,ok!)
  251. dw_edit_mode = FALSE
  252. Close(PARENT)
  253. end event
  254. type ln_bar from w_publ_choice`ln_bar within w_add_sptmtrlname
  255. end type
  256. type ln_bar2 from w_publ_choice`ln_bar2 within w_add_sptmtrlname
  257. end type
  258. type r_bar from w_publ_choice`r_bar within w_add_sptmtrlname
  259. end type
  260. type ln_1 from w_publ_choice`ln_1 within w_add_sptmtrlname
  261. end type
  262. type ln_2 from w_publ_choice`ln_2 within w_add_sptmtrlname
  263. end type
  264. type cb_1 from uo_imflatbutton within w_add_sptmtrlname
  265. integer x = 23
  266. integer y = 1208
  267. integer height = 96
  268. integer taborder = 50
  269. boolean bringtotop = true
  270. string text = "选供应商"
  271. end type
  272. event clicked;call super::clicked;parent.triggerevent('ue_f7')
  273. end event
  274. type st_2 from statictext within w_add_sptmtrlname
  275. integer x = 375
  276. integer y = 1232
  277. integer width = 507
  278. integer height = 48
  279. boolean bringtotop = true
  280. integer textsize = -9
  281. integer weight = 400
  282. fontcharset fontcharset = gb2312charset!
  283. fontpitch fontpitch = variable!
  284. string facename = "宋体"
  285. long textcolor = 16711680
  286. long backcolor = 134217739
  287. string text = "也可双击选择供应商"
  288. boolean focusrectangle = false
  289. end type