123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- $PBExportHeader$f_cmpl_qty.srf
- global type f_cmpl_qty from function_object
- end type
- forward prototypes
- global function integer f_cmpl_qty (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg)
- end prototypes
- global function integer f_cmpl_qty (s_cmpl_qty arg_cmpl, ref decimal arg_qty, ref string arg_msg);Int rslt = 1
- datastore ds_cmp
- Decimal{5} ls_number
- String ls_exp
- String ls_rs
- Decimal ld_temp
- string ls_temp
- string ls_mtrlmode
- ls_exp = arg_cmpl.formula
- IF ls_exp = '' THEN GOTO ext
- ds_cmp = CREATE datastore
- ds_cmp.DataObject = "ds_cmp_qty"
- ds_cmp.SetTransObject(sqlca)
- ds_cmp.Retrieve()
- ds_cmp.InsertRow(0)
- DO WHILE Pos(ls_exp,'[辅数]') > 0 OR Pos(ls_exp,'[单价]') > 0 OR Pos(ls_exp,'[折扣]') > 0 OR Pos(ls_exp,'[价格表单价]') > 0 OR &
- Pos(ls_exp,'[配置]') > 0 OR Pos(ls_exp,'[配置1]') > 0 OR Pos(ls_exp,'[配置2]') > 0 OR &
- Pos(ls_exp,'[自定义1]') > 0 OR Pos(ls_exp,'[自定义2]') > 0 OR Pos(ls_exp,'[包装数]') > 0 OR &
- Pos(ls_exp,'[明细备注]') > 0 OR Pos(ls_exp,'[明细备注2]') > 0 or Pos(ls_exp,'[明细备注3]') > 0 OR Pos(ls_exp,'[明细备注4]') > 0
- IF Pos(ls_exp,'[规格]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[规格]'),len('[规格]'),arg_cmpl.mtrlmode)
- END IF
- IF Pos(ls_exp,'[辅数]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[辅数]'),len('[辅数]'),String(arg_cmpl.addqty,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[单价]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[单价]'),len('[单价]'),String(arg_cmpl.price,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[价格表单价]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[价格表单价]'),len('[价格表单价]'),String(arg_cmpl.cusprice,'######0.00####'))
- END IF
- IF Pos(ls_exp,'[折扣]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[折扣]'),len('[折扣]'),String(arg_cmpl.rebate,'######0.00####'))
- END IF
-
- IF Pos(ls_exp,'[包装数]') > 0 THEN
- ls_exp = Replace(ls_exp,Pos(ls_exp,'[包装数]'),len('[包装数]'),String(arg_cmpl.packqty,'######0.00####'))
- END IF
-
- ls_temp ='[配置1]' // '['+ sys_option_change_woodcode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.woodcode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[配置]' // '['+ sys_option_change_status + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.status,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[配置2]' // '['+ sys_option_change_pcode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.pcode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[自定义1]' // '['+ sys_option_change_mtrlsectype + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mtrlsectype,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[自定义2]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.zxmtrlmode,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
- ls_temp = '[明细备注]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mxdscrp,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
- ls_temp = '[明细备注2]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mxdscrp2,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
- ls_temp = '[明细备注3]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mxdscrp3,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
-
- ls_temp = '[明细备注4]' // '['+ sys_option_change_zxmtrlmode + ']'
- IF Pos(ls_exp,ls_temp) > 0 THEN
- ld_temp = 0
- IF f_cmpl_qty_son(arg_cmpl.mxdscrp4,ld_temp,arg_msg) = 0 THEN
- rslt = 0
- GOTO ext
- END IF
- ls_exp = Replace(ls_exp,Pos(ls_exp,ls_temp),Len(ls_temp),String(ld_temp,'######0.00####'))
- END IF
- LOOP
-
- ls_rs = ds_cmp.Modify("cmp.Expression='"+ ls_exp+"'")
- IF ls_rs = '' THEN
- ds_cmp.AcceptText()
- ls_number = ds_cmp.Object.cmp[ds_cmp.GetRow()]
-
- IF arg_cmpl.flag THEN
- ls_number = ls_number * Dec(arg_cmpl.addvalue)
- ELSE
- ls_number = ls_number / Dec(arg_cmpl.addvalue)
- END IF
-
- ls_number = Round(ls_number,arg_cmpl.num)
-
- ELSE
- arg_msg = '非法格式,不能计算!'+ls_exp
- rslt = 0
- GOTO ext
- END IF
- arg_qty = ls_number
- ext:
- RETURN rslt
- end function
|