$PBExportHeader$w_saletaskmx_mod_enprice.srw forward global type w_saletaskmx_mod_enprice from w_publ_base end type type dw_1 from u_dw_rbtnfilter within w_saletaskmx_mod_enprice end type type cb_1 from uo_imflatbutton within w_saletaskmx_mod_enprice end type type st_msg from statictext within w_saletaskmx_mod_enprice end type type cbx_update_outware from checkbox within w_saletaskmx_mod_enprice end type end forward global type w_saletaskmx_mod_enprice from w_publ_base integer width = 3511 integer height = 2080 string title = "订单明细修改单价" boolean minbox = false windowtype windowtype = response! event ue_formula_price ( ) dw_1 dw_1 cb_1 cb_1 st_msg st_msg cbx_update_outware cbx_update_outware end type global w_saletaskmx_mod_enprice w_saletaskmx_mod_enprice type variables String ins_sqlerrtext Long arg_scid,taskid Long cusid,moneyid decimal mrate end variables event ue_formula_price();String setting //setting = dw_1.Describe("u_saletaskmx_enprice.Protect") // //IF setting = '1' THEN // MessageBox('系统提示','当前销售订单的单价不允许编辑') // RETURN //END IF // //Long ll_row //Decimal ld_price //String ls_formula // //ll_row = dw_1.GetRow() // //IF ll_row <= 0 THEN // MessageBox('系统提示','请选择要编辑单价公式的明细') // RETURN //END IF // //s_edit_index_tran s_formula,s_return // //s_formula.b_long = 2 // //OpenWithParm(w_formula_sale_edit,s_formula) // //s_return = Message.PowerObjectParm // //ld_price = s_return.c_decimal //ls_formula = s_return.c_string // //if ld_price < 0 then return // //dw_1.Object.u_saletaskmx_enprice[ll_row] = ld_price //dw_1.Object.u_saletaskmx_priceformula[ll_row] = ls_formula end event on w_saletaskmx_mod_enprice.create int iCurrent call super::create this.dw_1=create dw_1 this.cb_1=create cb_1 this.st_msg=create st_msg this.cbx_update_outware=create cbx_update_outware iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.dw_1 this.Control[iCurrent+2]=this.cb_1 this.Control[iCurrent+3]=this.st_msg this.Control[iCurrent+4]=this.cbx_update_outware end on on w_saletaskmx_mod_enprice.destroy call super::destroy destroy(this.dw_1) destroy(this.cb_1) destroy(this.st_msg) destroy(this.cbx_update_outware) end on event open;call super::open;s_edit_index_tran s_open s_open = Message.PowerObjectParm int lb_ifpower If f_power_ind(1766,sys_msg_pow) Then lb_ifpower = 1 Else lb_ifpower = 0 End If dw_1.SetTransObject(sqlca) dw_1.Retrieve(s_open.b_long,s_open.c_long, lb_ifpower) arg_scid = s_open.b_long taskid = s_open.c_long cusid = s_open.d_long moneyid = s_open.e_long mrate = s_open.b_decimal //If f_power_ind(3558,sys_msg_pow) Then // cbx_update_outware.Visible = True // st_msg.Text = '提示:相关销售发货单已财审的明细不能修改单价' //Else // cbx_update_outware.Visible = False // st_msg.Text = '提示:已有开单未审数或有已发货数的明细不能修改单价' //End If // end event type cb_func from w_publ_base`cb_func within w_saletaskmx_mod_enprice end type type cb_exit from w_publ_base`cb_exit within w_saletaskmx_mod_enprice integer x = 1929 integer y = 1828 string text = "取消" integer picsize = 16 end type type dw_1 from u_dw_rbtnfilter within w_saletaskmx_mod_enprice integer width = 3483 integer height = 1788 integer taborder = 20 boolean bringtotop = true string dataobject = "dw_saletaskmx_mod_enprice" boolean hscrollbar = true boolean vscrollbar = true boolean hsplitscroll = true end type event rowfocuschanged;call super::rowfocuschanged;IF currentrow <= 0 THEN RETURN THIS.SelectRow(0,FALSE) THIS.SelectRow(currentrow,TRUE) end event event dberror;call super::dberror;ins_sqlerrtext=sqlerrtext return 1 end event event doubleclicked;call super::doubleclicked;//If row > 0 Then // If dwo.Name = 'u_saletaskmx_priceformula' Or dwo.Name = 'u_saletaskmx_enprice' Then // Parent.TriggerEvent('ue_formula_price') // End If //End If // end event type cb_1 from uo_imflatbutton within w_saletaskmx_mod_enprice integer x = 1435 integer y = 1828 integer width = 311 integer height = 96 integer taborder = 20 boolean bringtotop = true string text = "保存" string normalpicname = "ok.bmp" integer picsize = 16 end type event clicked;call super::clicked;int rslt = 1 Long ll_i Int li_ifcheckprice String arg_pricetype Long arg_mtrlid String arg_mtrlcode,arg_status,arg_pcode,arg_woodcode Decimal arg_enprice,arg_rebate,arg_qty,arg_stopqty String arg_msg Decimal ld_enprice_ori,ld_rebate_ori Decimal ld_msttakeamt, lde_otheramt Long ll_scid,ll_taskid,ll_printid,ll_secflag String ls_taskcode String ls_msg Boolean lb_ifchange String ls_priceformula SELECT taskcode, otheramt INTO :ls_taskcode, :lde_otheramt FROM u_saletask WHERE scid = :arg_scid And taskid = :taskid; IF sqlca.SQLCode <> 0 THEN MessageBox('Error','查询销售订单信息失败,'+sqlca.SQLErrText) RETURN END IF uo_cusprice uo_price uo_price = Create uo_cusprice dw_1.AcceptText() FOR ll_i = 1 To dw_1.RowCount() // arg_pricetype = dw_1.Object.u_saletaskmx_pricetype[ll_i] arg_mtrlid = dw_1.Object.mtrlid[ll_i] arg_mtrlcode = dw_1.Object.u_mtrldef_mtrlcode[ll_i] arg_status = dw_1.Object.u_saletaskmx_status[ll_i] arg_pcode = dw_1.Object.u_saletaskmx_pcode[ll_i] arg_woodcode = dw_1.Object.u_saletaskmx_woodcode[ll_i] arg_enprice = dw_1.Object.u_saletaskmx_enprice[ll_i] arg_rebate = dw_1.Object.u_saletaskmx_rebate[ll_i] arg_qty = dw_1.Object.saleqty[ll_i] arg_stopqty = dw_1.Object.u_saletaskmx_stopqty[ll_i] ld_enprice_ori = dw_1.Object.u_saletaskmx_enprice_ori[ll_i] ld_rebate_ori = dw_1.Object.u_saletaskmx_rebate_ori[ll_i] ll_scid = dw_1.Object.u_saletaskmx_scid[ll_i] ll_taskid = dw_1.Object.taskid[ll_i] ll_printid = dw_1.Object.u_saletaskmx_printid[ll_i] ll_secflag = dw_1.Object.secflag[ll_i] // IF sys_option_if_pricetype = 1 And arg_pricetype <> '' THEN // // SELECT ifcheckprice // INTO :li_ifcheckprice // FROM u_pricetype // Where pricetype = :arg_pricetype ; // IF sqlca.SQLCode <> 0 THEN // ROLLBACK; // MessageBox('Error','查询价格分类是否属于赠送类型失败,'+sqlca.SQLErrText) // RETURN // END IF // // IF li_ifcheckprice = 2 THEN arg_rebate = 0 // IF li_ifcheckprice = 1 THEN // IF sys_option_checkprice_native = 1 THEN // IF uo_price.uof_check_price (cusid,arg_mtrlid,& // arg_mtrlcode,arg_status,arg_pcode,& // arg_woodcode,moneyid,arg_enprice * mrate * arg_rebate,arg_qty,arg_msg) = 0 THEN // MessageBox('Error',arg_msg) // RETURN // END IF // ELSE // IF uo_price.uof_check_price (cusid,arg_mtrlid,& // arg_mtrlcode,arg_status,arg_pcode,& // arg_woodcode,moneyid,arg_enprice * arg_rebate,arg_qty,arg_msg) = 0 THEN // MessageBox('Error',arg_msg) // RETURN // END IF // END IF // END IF // END IF lb_ifchange = False IF ld_enprice_ori <> arg_enprice And ld_rebate_ori <> arg_rebate THEN 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.#####') lb_ifchange = True ELSEIF ld_enprice_ori <> arg_enprice And ld_rebate_ori = arg_rebate THEN ls_msg = '明细行:'+String(ll_printid)+',原单价:'+String(ld_enprice_ori,'#,##0.00########')+',新单价:'+String(arg_enprice,'#,##0.00########') lb_ifchange = True ELSEIF ld_enprice_ori = arg_enprice And ld_rebate_ori <> arg_rebate THEN ls_msg = '明细行:'+String(ll_printid)+',原折扣:'+String(ld_rebate_ori,'#,##0.#####')+',新折扣:'+String(arg_rebate,'#,##0.#####') lb_ifchange = True END IF IF lb_ifchange THEN f_setsysoplog('销售订单','销售订单审核后价格变更,ID:'+String(taskid)+',code:'+ls_taskcode + ','+ls_msg,arg_msg,False) END IF IF cbx_update_outware.Checked And ll_secflag = 0 THEN UPDATE u_outwaremx SET enprice = :arg_enprice, //enacprice = :arg_enprice * :arg_rebate, rebate = :arg_rebate, fprice = :arg_enprice * u_outware.mrate, price = :arg_enprice * u_outware.mrate * :arg_rebate, priceformula = :ls_priceformula, enprice_notax=:arg_enprice / (1 + tax), enamt= :arg_enprice * :arg_rebate * uqty, bsamt= :arg_enprice * :arg_rebate * uqty, enamt_tax= (:arg_enprice * :arg_rebate * uqty ) - (:arg_enprice * :arg_rebate * uqty / (1 + tax) ), bsamt_tax= (:arg_enprice * :arg_rebate * uqty ) - (:arg_enprice * :arg_rebate * uqty / (1 + tax) ) FROM u_outware INNER JOIN u_outwaremx ON u_outware.scid = u_outwaremx.scid AND u_outware.outwareid = u_outwaremx.outwareid WHERE u_outwaremx.scid = :ll_scid AND u_outwaremx.relid = :ll_taskid AND u_outwaremx.relprintid = :ll_printid AND (u_outware.billtype = 1) And (u_outware.secflag = 0); IF sqlca.SQLCode <> 0 THEN string err_msg err_msg = sqlca.SQLErrText ROLLBACK; MessageBox('Error','第'+String(ll_i)+'行,更新相关销售发货单单价失败,'+err_msg) RETURN END IF END IF UPDATE u_saletaskmx SET enprice = :arg_enprice, enprice_notax = :arg_enprice / (1+tax), rebate = :arg_rebate, fprice = :arg_enprice * :mrate, price = :arg_enprice * :mrate * :arg_rebate, enamt = Round(:arg_enprice * usaleqty * :arg_rebate, 2), enamt_tax = Round((:arg_enprice * usaleqty * :arg_rebate) * tax / (1 + tax), 2), bsamt = Round(:arg_enprice * :mrate * usaleqty * :arg_rebate, 2), bsamt_tax = Round((:arg_enprice * :mrate * usaleqty * :arg_rebate) * tax / (1 + tax), 2) , ware_enprice = Round(:arg_enprice * usaleqty / saleqty, 10), ware_fprice = Round(:arg_enprice * usaleqty / saleqty, 10) * :mrate, ware_price = Round(:arg_enprice * usaleqty / saleqty, 10) * :mrate * :arg_rebate WHERE scid = :ll_scid AND taskid = :ll_taskid And printid = :ll_printid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('Error','第'+String(ll_i)+'行,更新失败,'+sqlca.SQLErrText) RETURN END IF IF sys_option_mst_multimoney = 1 THEN //使用多币种 ld_msttakeamt += round(arg_enprice * (arg_qty - arg_stopqty) * arg_rebate, 2) ELSE // 系统不使用多币种,转换为人民币 ld_msttakeamt += round(arg_enprice * mrate * (arg_qty - arg_stopqty) * arg_rebate, 2) END IF NEXT IF sys_option_mst_multimoney = 1 THEN //使用多币种 ld_msttakeamt -= round(lde_otheramt * arg_rebate, 2) ELSE // 系统不使用多币种,转换为人民币 ld_msttakeamt -= round(lde_otheramt * arg_rebate, 2) END IF UPDATE u_saletask SET msttakeamt = :ld_msttakeamt WHERE scid = :arg_scid And taskid = :taskid; IF sqlca.SQLCode <> 0 THEN ROLLBACK; MessageBox('Error','更新单据金额失败,'+sqlca.SQLErrText) RETURN END IF COMMIT; MessageBox('系统提示','更新成功!') Close(Parent) end event type st_msg from statictext within w_saletaskmx_mod_enprice integer x = 14 integer y = 1836 integer width = 1358 integer height = 48 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 255 long backcolor = 134217739 string text = "提示:已有开单未审数或有已发货数的明细不能修改单价" boolean focusrectangle = false end type type cbx_update_outware from checkbox within w_saletaskmx_mod_enprice integer x = 2414 integer y = 1844 integer width = 795 integer height = 60 boolean bringtotop = true integer textsize = -9 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long backcolor = 134217739 string text = "同时更新相关销售发货单单价" end type event clicked;int li_ifupdate IF THIS.Checked THEN li_ifupdate = 1 ELSE li_ifupdate = 0 END IF f_SetProfileString (sys_empid,dw_1.DATAOBJECT, "ifupdate", string(li_ifupdate)) end event event constructor;Int li_ifupdate li_ifupdate = Integer(f_ProfileString (sys_empid,dw_1.DataObject, "ifupdate", '0')) IF li_ifupdate = 0 THEN This.Checked = False ELSE This.Checked = True END IF end event