$PBExportHeader$f_update_planprice.srf global type f_update_planprice from function_object end type forward prototypes global function integer f_update_planprice (long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, integer arg_buildtype, decimal arg_fprice, ref string arg_msg, boolean arg_ifcommit, transaction commit_transaction) end prototypes global function integer f_update_planprice (long arg_mtrlid, string arg_status, string arg_woodcode, string arg_pcode, integer arg_buildtype, decimal arg_fprice, ref string arg_msg, boolean arg_ifcommit, transaction commit_transaction);Int rslt = 1 String ls_status,ls_woodcode,ls_pcode Int li_pricepztype String ls_mtrlcode IF arg_fprice <= 0 THEN rslt = 1 GOTO ext END IF SELECT pricepztype,mtrlcode INTO :li_pricepztype,:ls_mtrlcode FROM u_mtrldef Where mtrlid = :arg_mtrlid Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询物料计划成本价配置模式失败,'+commit_transaction.SQLErrText GOTO ext END IF CHOOSE CASE li_pricepztype CASE 0 ls_status = '' ls_woodcode = '' ls_pcode = '' CASE 1 ls_status = arg_status ls_woodcode = '' ls_pcode = '' CASE 2 ls_status = '' ls_woodcode = arg_woodcode ls_pcode = '' CASE 3 ls_status = '' ls_woodcode = '' ls_pcode = arg_pcode CASE 4 ls_status = arg_status ls_woodcode = arg_woodcode ls_pcode = '' CASE 5 ls_status = '' ls_woodcode = arg_woodcode ls_pcode = arg_pcode CASE 6 ls_status = arg_status ls_woodcode = '' ls_pcode = arg_pcode CASE 7 ls_status = arg_status ls_woodcode = arg_woodcode ls_pcode = arg_pcode END CHOOSE UPDATE u_mtrldef_planprice SET planprice = :arg_fprice WHERE mtrlid = :arg_mtrlid AND status = :ls_status AND woodcode = :ls_woodcode And pcode = :ls_pcode Using commit_transaction; IF commit_transaction.SQLCode = 0 THEN IF commit_transaction.SQLNRows = 0 THEN INSERT INTO u_mtrldef_planprice (mtrlid, status, woodcode, pcode, planprice) VALUES (:arg_mtrlid, :ls_status, :ls_woodcode, :ls_pcode, :arg_fprice) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '插入物料'+ls_mtrlcode+'计划成本价资料失败,'+commit_transaction.SQLErrText GOTO ext END IF END IF INSERT INTO u_mtrl_planprice_his (mtrlid, cmpldate, planprice, buildtype, status, woodcode, pcode) VALUES (:arg_mtrlid, getdate(), :arg_fprice, :arg_buildtype, :ls_status, :ls_woodcode, :ls_pcode) Using commit_transaction; IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '建立'+ls_mtrlcode+'产品计划成本价历史记录失败 '+commit_transaction.SQLErrText GOTO ext END IF ELSE IF commit_transaction.SQLCode <> 0 THEN rslt = 0 arg_msg = '更新物料'+ls_mtrlcode+'计划成本价资料失败,'+commit_transaction.SQLErrText GOTO ext END IF END IF ext: IF rslt = 0 THEN ROLLBACK Using commit_transaction; ELSEIF rslt = 1 And arg_ifcommit THEN COMMIT Using commit_transaction; END IF RETURN rslt end function