w_saletaskmx_mod_enprice.srw 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. $PBExportHeader$w_saletaskmx_mod_enprice.srw
  2. forward
  3. global type w_saletaskmx_mod_enprice from w_publ_base
  4. end type
  5. type dw_1 from u_dw_rbtnfilter within w_saletaskmx_mod_enprice
  6. end type
  7. type cb_1 from uo_imflatbutton within w_saletaskmx_mod_enprice
  8. end type
  9. type st_msg from statictext within w_saletaskmx_mod_enprice
  10. end type
  11. type cbx_update_outware from checkbox within w_saletaskmx_mod_enprice
  12. end type
  13. end forward
  14. global type w_saletaskmx_mod_enprice from w_publ_base
  15. integer width = 3511
  16. integer height = 2080
  17. string title = "订单明细修改单价"
  18. boolean minbox = false
  19. windowtype windowtype = response!
  20. event ue_formula_price ( )
  21. dw_1 dw_1
  22. cb_1 cb_1
  23. st_msg st_msg
  24. cbx_update_outware cbx_update_outware
  25. end type
  26. global w_saletaskmx_mod_enprice w_saletaskmx_mod_enprice
  27. type variables
  28. String ins_sqlerrtext
  29. Long arg_scid,taskid
  30. Long cusid,moneyid
  31. decimal mrate
  32. end variables
  33. event ue_formula_price();String setting
  34. //setting = dw_1.Describe("u_saletaskmx_enprice.Protect")
  35. //
  36. //IF setting = '1' THEN
  37. // MessageBox('系统提示','当前销售订单的单价不允许编辑')
  38. // RETURN
  39. //END IF
  40. //
  41. //Long ll_row
  42. //Decimal ld_price
  43. //String ls_formula
  44. //
  45. //ll_row = dw_1.GetRow()
  46. //
  47. //IF ll_row <= 0 THEN
  48. // MessageBox('系统提示','请选择要编辑单价公式的明细')
  49. // RETURN
  50. //END IF
  51. //
  52. //s_edit_index_tran s_formula,s_return
  53. //
  54. //s_formula.b_long = 2
  55. //
  56. //OpenWithParm(w_formula_sale_edit,s_formula)
  57. //
  58. //s_return = Message.PowerObjectParm
  59. //
  60. //ld_price = s_return.c_decimal
  61. //ls_formula = s_return.c_string
  62. //
  63. //if ld_price < 0 then return
  64. //
  65. //dw_1.Object.u_saletaskmx_enprice[ll_row] = ld_price
  66. //dw_1.Object.u_saletaskmx_priceformula[ll_row] = ls_formula
  67. end event
  68. on w_saletaskmx_mod_enprice.create
  69. int iCurrent
  70. call super::create
  71. this.dw_1=create dw_1
  72. this.cb_1=create cb_1
  73. this.st_msg=create st_msg
  74. this.cbx_update_outware=create cbx_update_outware
  75. iCurrent=UpperBound(this.Control)
  76. this.Control[iCurrent+1]=this.dw_1
  77. this.Control[iCurrent+2]=this.cb_1
  78. this.Control[iCurrent+3]=this.st_msg
  79. this.Control[iCurrent+4]=this.cbx_update_outware
  80. end on
  81. on w_saletaskmx_mod_enprice.destroy
  82. call super::destroy
  83. destroy(this.dw_1)
  84. destroy(this.cb_1)
  85. destroy(this.st_msg)
  86. destroy(this.cbx_update_outware)
  87. end on
  88. event open;call super::open;s_edit_index_tran s_open
  89. s_open = Message.PowerObjectParm
  90. int lb_ifpower
  91. If f_power_ind(1766,sys_msg_pow) Then
  92. lb_ifpower = 1
  93. Else
  94. lb_ifpower = 0
  95. End If
  96. dw_1.SetTransObject(sqlca)
  97. dw_1.Retrieve(s_open.b_long,s_open.c_long, lb_ifpower)
  98. arg_scid = s_open.b_long
  99. taskid = s_open.c_long
  100. cusid = s_open.d_long
  101. moneyid = s_open.e_long
  102. mrate = s_open.b_decimal
  103. //If f_power_ind(3558,sys_msg_pow) Then
  104. // cbx_update_outware.Visible = True
  105. // st_msg.Text = '提示:相关销售发货单已财审的明细不能修改单价'
  106. //Else
  107. // cbx_update_outware.Visible = False
  108. // st_msg.Text = '提示:已有开单未审数或有已发货数的明细不能修改单价'
  109. //End If
  110. //
  111. end event
  112. type cb_func from w_publ_base`cb_func within w_saletaskmx_mod_enprice
  113. end type
  114. type cb_exit from w_publ_base`cb_exit within w_saletaskmx_mod_enprice
  115. integer x = 1929
  116. integer y = 1828
  117. string text = "取消"
  118. integer picsize = 16
  119. end type
  120. type dw_1 from u_dw_rbtnfilter within w_saletaskmx_mod_enprice
  121. integer width = 3483
  122. integer height = 1788
  123. integer taborder = 20
  124. boolean bringtotop = true
  125. string dataobject = "dw_saletaskmx_mod_enprice"
  126. boolean hscrollbar = true
  127. boolean vscrollbar = true
  128. boolean hsplitscroll = true
  129. end type
  130. event rowfocuschanged;call super::rowfocuschanged;IF currentrow <= 0 THEN RETURN
  131. THIS.SelectRow(0,FALSE)
  132. THIS.SelectRow(currentrow,TRUE)
  133. end event
  134. event dberror;call super::dberror;ins_sqlerrtext=sqlerrtext
  135. return 1
  136. end event
  137. event doubleclicked;call super::doubleclicked;//If row > 0 Then
  138. // If dwo.Name = 'u_saletaskmx_priceformula' Or dwo.Name = 'u_saletaskmx_enprice' Then
  139. // Parent.TriggerEvent('ue_formula_price')
  140. // End If
  141. //End If
  142. //
  143. end event
  144. type cb_1 from uo_imflatbutton within w_saletaskmx_mod_enprice
  145. integer x = 1435
  146. integer y = 1828
  147. integer width = 311
  148. integer height = 96
  149. integer taborder = 20
  150. boolean bringtotop = true
  151. string text = "保存"
  152. string normalpicname = "ok.bmp"
  153. integer picsize = 16
  154. end type
  155. event clicked;call super::clicked;int rslt = 1
  156. Long ll_i
  157. Int li_ifcheckprice
  158. String arg_pricetype
  159. Long arg_mtrlid
  160. String arg_mtrlcode,arg_status,arg_pcode,arg_woodcode
  161. Decimal arg_enprice,arg_rebate,arg_qty,arg_stopqty
  162. String arg_msg
  163. Decimal ld_enprice_ori,ld_rebate_ori
  164. Decimal ld_msttakeamt, lde_otheramt
  165. Long ll_scid,ll_taskid,ll_printid,ll_secflag
  166. String ls_taskcode
  167. String ls_msg
  168. Boolean lb_ifchange
  169. String ls_priceformula
  170. SELECT taskcode, otheramt
  171. INTO :ls_taskcode, :lde_otheramt
  172. FROM u_saletask
  173. WHERE scid = :arg_scid
  174. And taskid = :taskid;
  175. IF sqlca.SQLCode <> 0 THEN
  176. MessageBox('Error','查询销售订单信息失败,'+sqlca.SQLErrText)
  177. RETURN
  178. END IF
  179. uo_cusprice uo_price
  180. uo_price = Create uo_cusprice
  181. dw_1.AcceptText()
  182. FOR ll_i = 1 To dw_1.RowCount()
  183. // arg_pricetype = dw_1.Object.u_saletaskmx_pricetype[ll_i]
  184. arg_mtrlid = dw_1.Object.mtrlid[ll_i]
  185. arg_mtrlcode = dw_1.Object.u_mtrldef_mtrlcode[ll_i]
  186. arg_status = dw_1.Object.u_saletaskmx_status[ll_i]
  187. arg_pcode = dw_1.Object.u_saletaskmx_pcode[ll_i]
  188. arg_woodcode = dw_1.Object.u_saletaskmx_woodcode[ll_i]
  189. arg_enprice = dw_1.Object.u_saletaskmx_enprice[ll_i]
  190. arg_rebate = dw_1.Object.u_saletaskmx_rebate[ll_i]
  191. arg_qty = dw_1.Object.saleqty[ll_i]
  192. arg_stopqty = dw_1.Object.u_saletaskmx_stopqty[ll_i]
  193. ld_enprice_ori = dw_1.Object.u_saletaskmx_enprice_ori[ll_i]
  194. ld_rebate_ori = dw_1.Object.u_saletaskmx_rebate_ori[ll_i]
  195. ll_scid = dw_1.Object.u_saletaskmx_scid[ll_i]
  196. ll_taskid = dw_1.Object.taskid[ll_i]
  197. ll_printid = dw_1.Object.u_saletaskmx_printid[ll_i]
  198. ll_secflag = dw_1.Object.secflag[ll_i]
  199. // IF sys_option_if_pricetype = 1 And arg_pricetype <> '' THEN
  200. //
  201. // SELECT ifcheckprice
  202. // INTO :li_ifcheckprice
  203. // FROM u_pricetype
  204. // Where pricetype = :arg_pricetype ;
  205. // IF sqlca.SQLCode <> 0 THEN
  206. // ROLLBACK;
  207. // MessageBox('Error','查询价格分类是否属于赠送类型失败,'+sqlca.SQLErrText)
  208. // RETURN
  209. // END IF
  210. //
  211. // IF li_ifcheckprice = 2 THEN arg_rebate = 0
  212. // IF li_ifcheckprice = 1 THEN
  213. // IF sys_option_checkprice_native = 1 THEN
  214. // IF uo_price.uof_check_price (cusid,arg_mtrlid,&
  215. // arg_mtrlcode,arg_status,arg_pcode,&
  216. // arg_woodcode,moneyid,arg_enprice * mrate * arg_rebate,arg_qty,arg_msg) = 0 THEN
  217. // MessageBox('Error',arg_msg)
  218. // RETURN
  219. // END IF
  220. // ELSE
  221. // IF uo_price.uof_check_price (cusid,arg_mtrlid,&
  222. // arg_mtrlcode,arg_status,arg_pcode,&
  223. // arg_woodcode,moneyid,arg_enprice * arg_rebate,arg_qty,arg_msg) = 0 THEN
  224. // MessageBox('Error',arg_msg)
  225. // RETURN
  226. // END IF
  227. // END IF
  228. // END IF
  229. // END IF
  230. lb_ifchange = False
  231. IF ld_enprice_ori <> arg_enprice And ld_rebate_ori <> arg_rebate THEN
  232. ls_msg = '明细行:'+String(ll_printid)+',原单价:'+String(ld_enprice_ori,'#,##0.00########')+',新单价:'+String(arg_enprice,'#,##0.00########')+',原折扣:'+String(ld_rebate_ori,'#,##0.#####')+',新折扣:'+String(arg_rebate,'#,##0.#####')
  233. lb_ifchange = True
  234. ELSEIF ld_enprice_ori <> arg_enprice And ld_rebate_ori = arg_rebate THEN
  235. ls_msg = '明细行:'+String(ll_printid)+',原单价:'+String(ld_enprice_ori,'#,##0.00########')+',新单价:'+String(arg_enprice,'#,##0.00########')
  236. lb_ifchange = True
  237. ELSEIF ld_enprice_ori = arg_enprice And ld_rebate_ori <> arg_rebate THEN
  238. ls_msg = '明细行:'+String(ll_printid)+',原折扣:'+String(ld_rebate_ori,'#,##0.#####')+',新折扣:'+String(arg_rebate,'#,##0.#####')
  239. lb_ifchange = True
  240. END IF
  241. IF lb_ifchange THEN
  242. f_setsysoplog('销售订单','销售订单审核后价格变更,ID:'+String(taskid)+',code:'+ls_taskcode + ','+ls_msg,arg_msg,False)
  243. END IF
  244. IF cbx_update_outware.Checked And ll_secflag = 0 THEN
  245. UPDATE u_outwaremx
  246. SET enprice = :arg_enprice,
  247. //enacprice = :arg_enprice * :arg_rebate,
  248. rebate = :arg_rebate,
  249. fprice = :arg_enprice * u_outware.mrate,
  250. price = :arg_enprice * u_outware.mrate * :arg_rebate,
  251. priceformula = :ls_priceformula,
  252. enprice_notax=:arg_enprice / (1 + tax),
  253. enamt= :arg_enprice * :arg_rebate * uqty,
  254. bsamt= :arg_enprice * :arg_rebate * uqty,
  255. enamt_tax= (:arg_enprice * :arg_rebate * uqty ) - (:arg_enprice * :arg_rebate * uqty / (1 + tax) ),
  256. bsamt_tax= (:arg_enprice * :arg_rebate * uqty ) - (:arg_enprice * :arg_rebate * uqty / (1 + tax) )
  257. FROM u_outware INNER JOIN
  258. u_outwaremx ON u_outware.scid = u_outwaremx.scid AND
  259. u_outware.outwareid = u_outwaremx.outwareid
  260. WHERE u_outwaremx.scid = :ll_scid
  261. AND u_outwaremx.relid = :ll_taskid
  262. AND u_outwaremx.relprintid = :ll_printid
  263. AND (u_outware.billtype = 1)
  264. And (u_outware.secflag = 0);
  265. IF sqlca.SQLCode <> 0 THEN
  266. string err_msg
  267. err_msg = sqlca.SQLErrText
  268. ROLLBACK;
  269. MessageBox('Error','第'+String(ll_i)+'行,更新相关销售发货单单价失败,'+err_msg)
  270. RETURN
  271. END IF
  272. END IF
  273. UPDATE u_saletaskmx
  274. SET enprice = :arg_enprice,
  275. enprice_notax = :arg_enprice / (1+tax),
  276. rebate = :arg_rebate,
  277. fprice = :arg_enprice * :mrate,
  278. price = :arg_enprice * :mrate * :arg_rebate,
  279. enamt = Round(:arg_enprice * usaleqty * :arg_rebate, 2),
  280. enamt_tax = Round((:arg_enprice * usaleqty * :arg_rebate) * tax / (1 + tax), 2),
  281. bsamt = Round(:arg_enprice * :mrate * usaleqty * :arg_rebate, 2),
  282. bsamt_tax = Round((:arg_enprice * :mrate * usaleqty * :arg_rebate) * tax / (1 + tax), 2) ,
  283. ware_enprice = Round(:arg_enprice * usaleqty / saleqty, 10),
  284. ware_fprice = Round(:arg_enprice * usaleqty / saleqty, 10) * :mrate,
  285. ware_price = Round(:arg_enprice * usaleqty / saleqty, 10) * :mrate * :arg_rebate
  286. WHERE scid = :ll_scid
  287. AND taskid = :ll_taskid
  288. And printid = :ll_printid;
  289. IF sqlca.SQLCode <> 0 THEN
  290. ROLLBACK;
  291. MessageBox('Error','第'+String(ll_i)+'行,更新失败,'+sqlca.SQLErrText)
  292. RETURN
  293. END IF
  294. IF sys_option_mst_multimoney = 1 THEN //使用多币种
  295. ld_msttakeamt += round(arg_enprice * (arg_qty - arg_stopqty) * arg_rebate, 2)
  296. ELSE // 系统不使用多币种,转换为人民币
  297. ld_msttakeamt += round(arg_enprice * mrate * (arg_qty - arg_stopqty) * arg_rebate, 2)
  298. END IF
  299. NEXT
  300. IF sys_option_mst_multimoney = 1 THEN //使用多币种
  301. ld_msttakeamt -= round(lde_otheramt * arg_rebate, 2)
  302. ELSE // 系统不使用多币种,转换为人民币
  303. ld_msttakeamt -= round(lde_otheramt * arg_rebate, 2)
  304. END IF
  305. UPDATE u_saletask
  306. SET msttakeamt = :ld_msttakeamt
  307. WHERE scid = :arg_scid
  308. And taskid = :taskid;
  309. IF sqlca.SQLCode <> 0 THEN
  310. ROLLBACK;
  311. MessageBox('Error','更新单据金额失败,'+sqlca.SQLErrText)
  312. RETURN
  313. END IF
  314. COMMIT;
  315. MessageBox('系统提示','更新成功!')
  316. Close(Parent)
  317. end event
  318. type st_msg from statictext within w_saletaskmx_mod_enprice
  319. integer x = 14
  320. integer y = 1836
  321. integer width = 1358
  322. integer height = 48
  323. boolean bringtotop = true
  324. integer textsize = -9
  325. integer weight = 400
  326. fontcharset fontcharset = gb2312charset!
  327. fontpitch fontpitch = variable!
  328. string facename = "宋体"
  329. long textcolor = 255
  330. long backcolor = 134217739
  331. string text = "提示:已有开单未审数或有已发货数的明细不能修改单价"
  332. boolean focusrectangle = false
  333. end type
  334. type cbx_update_outware from checkbox within w_saletaskmx_mod_enprice
  335. integer x = 2414
  336. integer y = 1844
  337. integer width = 795
  338. integer height = 60
  339. boolean bringtotop = true
  340. integer textsize = -9
  341. integer weight = 400
  342. fontcharset fontcharset = gb2312charset!
  343. fontpitch fontpitch = variable!
  344. string facename = "宋体"
  345. long backcolor = 134217739
  346. string text = "同时更新相关销售发货单单价"
  347. end type
  348. event clicked;int li_ifupdate
  349. IF THIS.Checked THEN
  350. li_ifupdate = 1
  351. ELSE
  352. li_ifupdate = 0
  353. END IF
  354. f_SetProfileString (sys_empid,dw_1.DATAOBJECT, "ifupdate", string(li_ifupdate))
  355. end event
  356. event constructor;Int li_ifupdate
  357. li_ifupdate = Integer(f_ProfileString (sys_empid,dw_1.DataObject, "ifupdate", '0'))
  358. IF li_ifupdate = 0 THEN
  359. This.Checked = False
  360. ELSE
  361. This.Checked = True
  362. END IF
  363. end event