$PBExportHeader$uo_workprice_change.sru forward global type uo_workprice_change from nonvisualobject end type end forward global type uo_workprice_change from nonvisualobject end type global uo_workprice_change uo_workprice_change type variables long uo_billid string uo_billcode long audit_buildtype string oppreason = '' end variables forward prototypes public function integer updatebegin (long arg_billid, ref string arg_msg) public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit) public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit) public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer getinfo (long arg_billid, ref s_workprice_changemx arg_ref_mx[], ref long arg_arr_cnt, ref string arg_msg) public function integer save (s_workprice_change arg_s_workprice, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer uof_mod_rsltflag (long arg_billid, long arg_printid, integer arg_rsltflag, ref string arg_msg, boolean arg_ifcommit) public function integer priceaudit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit) public function integer c_priceaudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit) public function integer p_getflag (long arg_billid, ref integer arg_flag, ref integer arg_priceflag, ref string arg_msg) end prototypes public function integer updatebegin (long arg_billid, ref string arg_msg);Int rslt = 1 Int li_flag,li_priceflag Long cnt IF arg_billid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF IF p_getflag(arg_billid,li_flag,li_priceflag,arg_msg) = 0 THEN rslt = 0 GOTO ext END IF if li_priceflag = 1 then rslt = 0 arg_msg = '单据已经确认,不可以再修改' GOTO ext END IF IF li_flag = 1 THEN rslt = 0 arg_msg = '单据已经审核,不可以再修改' GOTO ext END IF ext: RETURN rslt end function public function integer del (long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag,li_priceflag Long cnt If arg_billid <= 0 Then rslt = 0 arg_msg = '错误单据唯一码' Goto ext End If If p_getflag(arg_billid,li_flag,li_priceflag,arg_msg) = 0 Then rslt = 0 Goto ext End If If li_priceflag = 1 Then rslt = 0 arg_msg = '单据已经确认,不可以删除' Goto ext End If If li_flag = 1 Then rslt = 0 arg_msg = '单据不是在待审状态,不可以删除' Goto ext End If s_workprice_changemx s_workprice_mx[] Long ll_arr_cnt,ll_i If getinfo(arg_billid,s_workprice_mx,ll_arr_cnt,arg_msg) = 0 Then rslt = 0 Goto ext End If Delete From u_workprice_change Where billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除单据操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Delete From u_workprice_changemx Where billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除单据明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If For ll_i = 1 To ll_arr_cnt If s_workprice_mx[ll_i].editflag = 0 Then //变更 If s_workprice_mx[ll_i].workqty > 0 Then Select count(*) Into :cnt From u_workprice_changemx Where (editflag = 0) And (workqty > 0) and (rsltflag = 0) And (mtrlid = :s_workprice_mx[ll_i].mtrlid) And (procode = :s_workprice_mx[ll_i].procode) And (wpcode = :s_workprice_mx[ll_i].wpcode); If sqlca.SQLCode <> 0 Then cnt = 0 If cnt = 0 Then Update u_sc_workprice Set ifchangebill = 0 Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows = 0 Then rslt = 0 arg_msg = '更新工价表是否有相关变更单字段失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If End If End If Next ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Return rslt end function public function integer add_dscrp (long arg_billid, string arg_newdescppart, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag,li_priceflag IF arg_newdescppart = '' THEN rslt = 0 arG_MSG = "要添加内容为空,操作取消" GOTO ext END IF IF p_getflag(arg_billid,li_flag,li_priceflag,arG_MSG) = 0 THEN rslt = 0 GOTO ext END IF if li_priceflag = 0 then rslt = 0 arG_MSG = "待审核状态下不可用" GOTO ext END IF IF li_flag = 0 THEN rslt = 0 arG_MSG = "待审核状态下不可用" GOTO ext END IF UPDATE u_workprice_change SET DSCRP = DSCRP+' '+:arg_newdescppart WHERE u_workprice_change.billid = :arg_billid; IF SQLCA.SQLCode <> 0 THEN rslt = 0 arG_MSG = "因网络或其它原因导致添加备注操作失败"+"~n"+SQLCA.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 AND arg_ifcommit THEN COMMIT; END IF Return (rslt) end function public function integer audit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag, li_priceflag Long ll_scid String ls_billcode Int li_rsltflag DateTime ldt_nulldt Int li_ifchangebill SetNull(ldt_nulldt) uo_workpricetable uo_workprice uo_workprice = Create uo_workpricetable If arg_billid <= 0 Then rslt = 0 ARG_MSG = '错误单据唯一码' Goto ext End If If p_getflag(arg_billid,li_flag,li_priceflag,ARG_MSG) = 0 Then rslt = 0 Goto ext End If Select scid,billcode Into :ll_scid,:ls_billcode From u_workprice_change Where billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '查询单据信息失败,'+sqlca.SQLErrText Goto ext End If If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 And audit_buildtype = 0 Then If f_check_if_oaflow(ll_scid,arg_billid,1494,ARG_MSG ) = 0 Then rslt = 0 Goto ext End If End If If li_flag <> 0 Then rslt = 0 ARG_MSG = '单据不是在待审核状态,不可以审核' Goto ext End If If sys_option_workprice_change_secaudit = 1 Then If li_priceflag <> 1 Then rslt = 0 ARG_MSG = '系统选项控制,单据使用二级审核,不是在已确认状态,不可以审核' Goto ext End If End If //更新工价表 Long ll_sonmtrlid s_workprice_changemx s_workprice_mx[] Long ll_arr_cnt,ll_i Long cnt DateTime serdate Select Top 1 getdate() Into :serdate From u_user; If sqlca.SQLCode <> 0 Then ARG_MSG = '查询服务器时间失败' rslt = 0 Goto ext End If If getinfo(arg_billid,s_workprice_mx,ll_arr_cnt,ARG_MSG) = 0 Then rslt = 0 Goto ext End If For ll_i = 1 To ll_arr_cnt If s_workprice_mx[ll_i].iffinishoa = 1 Then Continue //结束审批的明细不处理 If (s_workprice_mx[ll_i].editflag = 1 And s_workprice_mx[ll_i].rsltflag <> 0) Then Continue //无效变更的,不处理; 如果是新增类且不是同意,不处理 //如果是无效并且类型为变更,更新工价表开单标记 20140729 If s_workprice_mx[ll_i].rsltflag = 2 Then If s_workprice_mx[ll_i].editflag = 0 Then Select count(*) Into :cnt From u_workprice_changemx Inner JOIN u_workprice_change ON u_workprice_changemx.billid = u_workprice_change.billid Where (u_workprice_changemx.editflag = 0) And (u_workprice_changemx.workqty > 0) And (u_workprice_changemx.rsltflag = 0) And (u_workprice_change.flag = 0) And (u_workprice_changemx.mtrlid = :s_workprice_mx[ll_i].mtrlid) And (u_workprice_changemx.procode = :s_workprice_mx[ll_i].procode) And (u_workprice_changemx.wpcode = :s_workprice_mx[ll_i].wpcode) And (u_workprice_changemx.billid <> :arg_billid) ; If sqlca.SQLCode <> 0 Then cnt = 0 If cnt = 0 Then li_ifchangebill = 0 Else li_ifchangebill = 1 End If Update u_sc_workprice Set ifchangebill = :li_ifchangebill Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '更新工价表开单标记失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If Continue End If ///////// If s_workprice_mx[ll_i].wrkid = 0 Then rslt = 0 ARG_MSG = '第'+String(ll_i)+'行,请先选择车间' Goto ext End If li_rsltflag = s_workprice_mx[ll_i].rsltflag If IsNull(s_workprice_mx[ll_i].ifgroup) Then s_workprice_mx[ll_i].ifgroup = 0 If s_workprice_mx[ll_i].editflag = 0 Then //变更 Select count(*) Into :cnt From u_workprice_changemx Inner JOIN u_workprice_change ON u_workprice_changemx.billid = u_workprice_change.billid Where (u_workprice_changemx.editflag = 0) And (u_workprice_changemx.workqty > 0) And (u_workprice_changemx.rsltflag = 0) And (u_workprice_change.flag = 0) And (u_workprice_changemx.mtrlid = :s_workprice_mx[ll_i].mtrlid) And (u_workprice_changemx.procode = :s_workprice_mx[ll_i].procode) And (u_workprice_changemx.wpcode = :s_workprice_mx[ll_i].wpcode) And (u_workprice_changemx.billid <> :arg_billid) ; If sqlca.SQLCode <> 0 Then cnt = 0 If cnt = 0 Then li_ifchangebill = 0 Else li_ifchangebill = 1 End If If li_rsltflag = 0 Then If s_workprice_mx[ll_i].workqty > 0 Then Update u_sc_workprice Set proname = :s_workprice_mx[ll_i].proname, workqty = :s_workprice_mx[ll_i].workqty, workprice = :s_workprice_mx[ll_i].workprice, wrkgrpid = :s_workprice_mx[ll_i].wrkgrpid, ifstandard = :s_workprice_mx[ll_i].ifstandard, lsxtype = :s_workprice_mx[ll_i].lsxtype, lastflag = :s_workprice_mx[ll_i].lastflag, workhour = :s_workprice_mx[ll_i].workhour_minute / 60, workhour_minute = :s_workprice_mx[ll_i].workhour_minute, beforehour_minute = :s_workprice_mx[ll_i].beforehour_minute, afterhour_minute = :s_workprice_mx[ll_i].afterhour_minute, eqworkhour_minute = :s_workprice_mx[ll_i].eqworkhour_minute, beforehour = :s_workprice_mx[ll_i].beforehour_minute / 60, afterhour = :s_workprice_mx[ll_i].afterhour_minute / 60, eqworkhour = :s_workprice_mx[ll_i].eqworkhour_minute / 60, dscrp = :s_workprice_mx[ll_i].dscrp, worklevel = :s_workprice_mx[ll_i].worklevel, techlevel = :s_workprice_mx[ll_i].techlevel, ifjd = :s_workprice_mx[ll_i].ifjd, status = :s_workprice_mx[ll_i].status, auditflag = 1, auditrep = :arg_opemp, auditdate = getdate(), pricestr = :s_workprice_mx[ll_i].pricestr, workqtystr = :s_workprice_mx[ll_i].workqtystr, wrkid = :s_workprice_mx[ll_i].wrkid, u_workqty = :s_workprice_mx[ll_i].u_workqty, u_workprice = :s_workprice_mx[ll_i].u_workprice, u_workqtystr = :s_workprice_mx[ll_i].u_workqtystr, u_pricestr = :s_workprice_mx[ll_i].u_pricestr, arg1 = :s_workprice_mx[ll_i].arg1, arg2 = :s_workprice_mx[ll_i].arg2, arg3 = :s_workprice_mx[ll_i].arg3, arg4 = :s_workprice_mx[ll_i].arg4, arg5 = :s_workprice_mx[ll_i].arg5, arg6 = :s_workprice_mx[ll_i].arg6, arg7 = :s_workprice_mx[ll_i].arg7, arg8 = :s_workprice_mx[ll_i].arg8, arg9 = :s_workprice_mx[ll_i].arg9, ifgroup = :s_workprice_mx[ll_i].ifgroup, auditflag_gj = 1 , auditrep_gj = :arg_opemp , auditdate_gj = getdate() , oppflag = 0 , opprep = '' , oppdate = :ldt_nulldt, changeflag = 2, lastprice = :s_workprice_mx[ll_i].workprice, replacestr = :s_workprice_mx[ll_i].replacestr, relchangecode = :ls_billcode, worktype = :s_workprice_mx[ll_i].worktype, rpcode = :s_workprice_mx[ll_i].rpcode, ifdftpg = :s_workprice_mx[ll_i].ifdftpg, ifdftjj = :s_workprice_mx[ll_i].ifdftjj, ifchangebill = :li_ifchangebill Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then //Or sqlca.SQLNRows = 0 THEN rslt = 0 ARG_MSG = '更新工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If If uo_workprice.uof_update_workprice_zl(s_workprice_mx[ll_i].mtrlid,s_workprice_mx[ll_i].wpcode,s_workprice_mx[ll_i].procode,ARG_MSG,False) = 0 Then rslt = 0 Goto ext End If ElseIf s_workprice_mx[ll_i].workqty = 0 Then //数量为0,删除 Delete From u_sc_workprice Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then //Or sqlca.SQLNRows = 0 THEN rslt = 0 ARG_MSG = '删除工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If Else //20141013修改:反对的明细不取消工价审,否则会导致原工价无效 YS // auditflag_gj = 0 , // auditrep_gj = '' , // auditdate_gj = :ldt_nulldt , Update u_sc_workprice Set oppflag = 1 , opprep = :arg_opemp , oppdate = getdate(), oppreason = :s_workprice_mx[ll_i].reason, relchangecode = :ls_billcode, ifchangebill = :li_ifchangebill Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then //Or sqlca.SQLNRows = 0 THEN rslt = 0 ARG_MSG = '更新工价表反对标记失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If ElseIf s_workprice_mx[ll_i].editflag = 2 Then //删除 Delete From u_sc_workprice Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then //Or sqlca.SQLNRows = 0 THEN rslt = 0 ARG_MSG = '删除工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If Else // 新增 cnt = 0 Select count(*) Into :cnt From u_sc_workprice Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '查询工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If If cnt > 0 Then rslt = 0 ARG_MSG = '工价表已存在相同信息,不能插入重复内容,第 '+String(ll_i)+' 行' Goto ext End If Select count(*) Into :cnt From u_mtrl_workprice Where mtrlid = :s_workprice_mx[ll_i].mtrlid And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '查询车间工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If If cnt = 0 Then Insert Into u_mtrl_workprice (mtrlid, wrkid, flag, opemp, opdate, wpcode) Values (:s_workprice_mx[ll_i].mtrlid, :s_workprice_mx[ll_i].wrkid, 0, :arg_opemp, getdate(), :s_workprice_mx[ll_i].wpcode); If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '插入车间工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If Insert Into u_sc_workprice ( mtrlid, proorder, procode, proname, workqty, workprice, wrkgrpid, ifstandard , lsxtype , lastflag , workhour, dscrp , worklevel , techlevel, proid, auditflag, auditrep, auditdate, status, ifjd, wrkid, workhour_minute, beforehour_minute, afterhour_minute, eqworkhour_minute, beforehour, afterhour, eqworkhour, pricestr, workqtystr, wpcode, u_workqty, u_workprice, u_workqtystr, u_pricestr, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, ifgroup, lastprice, replacestr, worktype, rpcode, ifdftpg, ifdftjj) Values ( :s_workprice_mx[ll_i].mtrlid, :s_workprice_mx[ll_i].proorder, :s_workprice_mx[ll_i].procode, :s_workprice_mx[ll_i].proname, :s_workprice_mx[ll_i].workqty, :s_workprice_mx[ll_i].workprice, :s_workprice_mx[ll_i].wrkgrpid, :s_workprice_mx[ll_i].ifstandard, :s_workprice_mx[ll_i].lsxtype, :s_workprice_mx[ll_i].lastflag, :s_workprice_mx[ll_i].workhour_minute / 60 , :s_workprice_mx[ll_i].dscrp, :s_workprice_mx[ll_i].worklevel, :s_workprice_mx[ll_i].techlevel, 0, 1, :arg_opemp, getdate(), :s_workprice_mx[ll_i].status, :s_workprice_mx[ll_i].ifjd, :s_workprice_mx[ll_i].wrkid, :s_workprice_mx[ll_i].workhour_minute, :s_workprice_mx[ll_i].beforehour_minute, :s_workprice_mx[ll_i].afterhour_minute, :s_workprice_mx[ll_i].eqworkhour_minute, :s_workprice_mx[ll_i].beforehour_minute / 60, :s_workprice_mx[ll_i].afterhour_minute / 60, :s_workprice_mx[ll_i].eqworkhour_minute / 60, :s_workprice_mx[ll_i].pricestr, :s_workprice_mx[ll_i].workqtystr, :s_workprice_mx[ll_i].wpcode, :s_workprice_mx[ll_i].u_workqty, :s_workprice_mx[ll_i].u_workprice, :s_workprice_mx[ll_i].u_workqtystr, :s_workprice_mx[ll_i].u_pricestr, :s_workprice_mx[ll_i].arg1, :s_workprice_mx[ll_i].arg2, :s_workprice_mx[ll_i].arg3, :s_workprice_mx[ll_i].arg4, :s_workprice_mx[ll_i].arg5, :s_workprice_mx[ll_i].arg6, :s_workprice_mx[ll_i].arg7, :s_workprice_mx[ll_i].arg8, :s_workprice_mx[ll_i].arg9, :s_workprice_mx[ll_i].ifgroup, :s_workprice_mx[ll_i].workprice, :s_workprice_mx[ll_i].replacestr, :s_workprice_mx[ll_i].worktype, :s_workprice_mx[ll_i].rpcode, :s_workprice_mx[ll_i].ifdftpg, :s_workprice_mx[ll_i].ifdftjj ); If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '插入工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If // IF uo_workprice.update_auditflag(s_workprice_mx[ll_i].mtrlid,serdate,arg_opemp,ARG_MSG,FALSE) = 0 THEN // rslt = 0 // GOTO ext // END IF Next //更新审核标记 Update u_workprice_change Set auditingrep = :arg_opemp, auditingdate = getdate(), flag = 1 Where billid = :arg_billid And flag = 0; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = "因网络或其它原因导致单据审核操作失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = "单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText Goto ext End If ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Destroy uo_workprice Return rslt end function public function integer getinfo (long arg_billid, ref s_workprice_changemx arg_ref_mx[], ref long arg_arr_cnt, ref string arg_msg);Int rslt = 1 Long i = 1,no_mxcheck = 0 IF arg_billid <= 0 THEN rslt = 0 arg_msg = '错误单据唯一码' GOTO ext END IF //用游标读取明细 DECLARE cur_mx CURSOR FOR SELECT billid, printid, editflag, mtrlid, proorder, procode, proname, workqty, workprice_ori, workprice, wrkgrpid, ifstandard, lsxtype, lastflag, workhour, dscrp, worklevel, techlevel, status, ifjd, wrkid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, workhour_minute, beforehour_minute, afterhour_minute, eqworkhour_minute, pricestr, workqtystr, rsltflag, wpcode, u_workqty, u_workprice, u_workqtystr, u_pricestr, ifgroup, reason, replacestr, worktype, iffinishoa, rpcode, ifdftpg, ifdftjj FROM u_workprice_changemx WHERE u_workprice_changemx.billid = :arg_billid Order By u_workprice_changemx.printid; OPEN cur_mx; FETCH cur_mx INTO :arg_ref_mx[i].billid, :arg_ref_mx[i].printid, :arg_ref_mx[i].editflag, :arg_ref_mx[i].mtrlid, :arg_ref_mx[i].proorder, :arg_ref_mx[i].procode, :arg_ref_mx[i].proname, :arg_ref_mx[i].workqty, :arg_ref_mx[i].workprice_ori, :arg_ref_mx[i].workprice, :arg_ref_mx[i].wrkgrpid, :arg_ref_mx[i].ifstandard, :arg_ref_mx[i].lsxtype, :arg_ref_mx[i].lastflag, :arg_ref_mx[i].workhour, :arg_ref_mx[i].dscrp, :arg_ref_mx[i].worklevel, :arg_ref_mx[i].techlevel, :arg_ref_mx[i].status, :arg_ref_mx[i].ifjd, :arg_ref_mx[i].wrkid, :arg_ref_mx[i].arg1, :arg_ref_mx[i].arg2, :arg_ref_mx[i].arg3, :arg_ref_mx[i].arg4, :arg_ref_mx[i].arg5, :arg_ref_mx[i].arg6, :arg_ref_mx[i].arg7, :arg_ref_mx[i].arg8, :arg_ref_mx[i].arg9, :arg_ref_mx[i].workhour_minute, :arg_ref_mx[i].beforehour_minute, :arg_ref_mx[i].afterhour_minute, :arg_ref_mx[i].eqworkhour_minute, :arg_ref_mx[i].pricestr, :arg_ref_mx[i].workqtystr, :arg_ref_mx[i].rsltflag, :arg_ref_mx[i].wpcode, :arg_ref_mx[i].u_workqty, :arg_ref_mx[i].u_workprice, :arg_ref_mx[i].u_workqtystr, :arg_ref_mx[i].u_pricestr, :arg_ref_mx[i].ifgroup, :arg_ref_mx[i].reason, :arg_ref_mx[i].replacestr, :arg_ref_mx[i].worktype, :arg_ref_mx[i].iffinishoa, :arg_ref_mx[i].rpcode, :arg_ref_mx[i].ifdftpg, :arg_ref_mx[i].ifdftjj; DO WHILE sqlca.SQLCode = 0 i++ FETCH cur_mx INTO :arg_ref_mx[i].billid, :arg_ref_mx[i].printid, :arg_ref_mx[i].editflag, :arg_ref_mx[i].mtrlid, :arg_ref_mx[i].proorder, :arg_ref_mx[i].procode, :arg_ref_mx[i].proname, :arg_ref_mx[i].workqty, :arg_ref_mx[i].workprice_ori, :arg_ref_mx[i].workprice, :arg_ref_mx[i].wrkgrpid, :arg_ref_mx[i].ifstandard, :arg_ref_mx[i].lsxtype, :arg_ref_mx[i].lastflag, :arg_ref_mx[i].workhour, :arg_ref_mx[i].dscrp, :arg_ref_mx[i].worklevel, :arg_ref_mx[i].techlevel, :arg_ref_mx[i].status, :arg_ref_mx[i].ifjd, :arg_ref_mx[i].wrkid, :arg_ref_mx[i].arg1, :arg_ref_mx[i].arg2, :arg_ref_mx[i].arg3, :arg_ref_mx[i].arg4, :arg_ref_mx[i].arg5, :arg_ref_mx[i].arg6, :arg_ref_mx[i].arg7, :arg_ref_mx[i].arg8, :arg_ref_mx[i].arg9, :arg_ref_mx[i].workhour_minute, :arg_ref_mx[i].beforehour_minute, :arg_ref_mx[i].afterhour_minute, :arg_ref_mx[i].eqworkhour_minute, :arg_ref_mx[i].pricestr, :arg_ref_mx[i].workqtystr, :arg_ref_mx[i].rsltflag, :arg_ref_mx[i].wpcode, :arg_ref_mx[i].u_workqty, :arg_ref_mx[i].u_workprice, :arg_ref_mx[i].u_workqtystr, :arg_ref_mx[i].u_pricestr, :arg_ref_mx[i].ifgroup, :arg_ref_mx[i].reason, :arg_ref_mx[i].replacestr, :arg_ref_mx[i].worktype, :arg_ref_mx[i].iffinishoa, :arg_ref_mx[i].rpcode, :arg_ref_mx[i].ifdftpg, :arg_ref_mx[i].ifdftjj; LOOP CLOSE cur_mx; //检验明细是否读入完整 SELECT count(*) INTO :no_mxcheck FROM u_workprice_changemx Where billid = :arg_billid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = "查询操作失败,单据明细数量" GOTO ext END IF IF i <> (no_mxcheck + 1) THEN rslt = 0 arg_msg = "查询操作失败,单据明细" GOTO ext END IF arg_arr_cnt = i - 1 ext: RETURN rslt end function public function integer save (s_workprice_change arg_s_workprice, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1,cnt = 0 DateTime server_dt Long ll_billid,it_mxbt,i,ll_i String ls_sccode,ls_billcode If IsNull(arg_s_workprice.scid) Then arg_s_workprice.scid = 0 If IsNull(arg_s_workprice.billid) Then arg_s_workprice.billid = 0 If IsNull(arg_s_workprice.wrkid) Then arg_s_workprice.wrkid = 0 //备注性质 If IsNull(arg_s_workprice.procode) Then arg_s_workprice.procode = '' If IsNull(arg_s_workprice.proname) Then arg_s_workprice.proname = '' If IsNull(arg_s_workprice.rep) Then arg_s_workprice.rep = '' If IsNull(arg_s_workprice.dscrp) Then arg_s_workprice.dscrp = '' //IF arg_s_workprice.procode = '' THEN // arg_msg = '请选择工序' // rslt = 0 // GOTO ext //END IF If arg_s_workprice.rep = '' Then arg_msg = '请输入经手人' rslt = 0 Goto ext End If If arg_s_workprice.scid < 0 Then arg_msg = '请选择分部' rslt = 0 Goto ext End If Select Top 1 getdate() Into :server_dt From u_user; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "查询操作失败,日期 " Goto ext End If it_mxbt = UpperBound(arg_s_workprice.arg_s_mx) If it_mxbt <= 0 Then rslt = 0 arg_msg = "没有正确明细内容" Goto ext End If //新增类型,检查 工组 对应 车间 For i = 1 To it_mxbt If arg_s_workprice.arg_s_mx[i].wpcode = '' Then rslt = 0 arg_msg = "行"+String(i)+ ",没有工价表号" Goto ext End If //新增类型,检查 工组 对应 车间 //新增类型,检查 流水表打印类型 不能为 不参加打印[0] If arg_s_workprice.arg_s_mx[i].editflag = 1 Then If arg_s_workprice.arg_s_mx[i].lsxtype = 0 Then rslt = 0 arg_msg = "行"+String(i)+ ",新增工序的流水表打印类型不能为[不参加打印]" Goto ext End If Select count(*) Into :cnt From u_sc_workgroup Where u_sc_workgroup.wrkGrpid = :arg_s_workprice.arg_s_mx[i].wrkgrpid And u_sc_workgroup.storageid = :arg_s_workprice.arg_s_mx[i].wrkid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "行"+String(i)+ ",查询工组对应车间失败,"+sqlca.SQLErrText Goto ext End If If cnt = 0 Then rslt = 0 arg_msg = "行"+String(i)+ ",当前工组、车间与资料设置不一致" Goto ext End If End If //检查是否有未审核的相同物料,工序的单据 Select count(*) Into :cnt From u_workprice_change Inner JOIN u_workprice_changemx ON u_workprice_change.billid = u_workprice_changemx.billid Where (u_workprice_change.flag = 0) And (u_workprice_changemx.mtrlid = :arg_s_workprice.arg_s_mx[i].mtrlid) And(u_workprice_changemx.procode = :arg_s_workprice.arg_s_mx[i].procode) And (u_workprice_change.billid <> :arg_s_workprice.billid) And (u_workprice_changemx.rsltflag = 0); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "行"+String(i)+ ",查询是否有相关未审工价表变更单失败,"+sqlca.SQLErrText Goto ext End If If cnt > 0 Then rslt = 0 arg_msg = "行"+String(i)+ ",存在相同物料相同工序的工价表变更单未审核["+String(cnt)+"]" Goto ext End If Next If arg_s_workprice.billid = 0 Then ll_billid = f_sys_scidentity(0,"u_workprice_change","billid",arg_msg,True,id_sqlca) If ll_billid <= 0 Then rslt = 0 Goto ext End If If f_get_sccode(0,sqlca,ls_sccode,arg_msg) = 0 Then rslt = 0 Goto ext End If ls_billcode = getid(0,ls_sccode + 'WC',Date(server_dt),False,sqlca) If ls_billcode = "err" Then rslt = 0 arg_msg = "无法获取单据编号"+"~n"+sqlca.SQLErrText Goto ext End If Insert Into u_workprice_change (scid, billid, billcode, billdate, relcode, procode, proname, rep, dscrp, opdate, opemp, wrkid) Values (:arg_s_workprice.scid, :ll_billid, :ls_billcode, :arg_s_workprice.billdate, :arg_s_workprice.relcode, :arg_s_workprice.procode, :arg_s_workprice.proname, :arg_s_workprice.rep, :arg_s_workprice.dscrp, getdate(), :arg_opemp, :arg_s_workprice.wrkid); If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "因网络或其它原因导致建立单据操作失败"+"~n"+sqlca.SQLErrText Goto ext End If uo_billid = ll_billid uo_billcode = ls_billcode Else Update u_workprice_change Set billdate = :arg_s_workprice.billdate, procode = :arg_s_workprice.procode, proname = :arg_s_workprice.proname, rep = :arg_s_workprice.rep, dscrp = :arg_s_workprice.dscrp, relcode = :arg_s_workprice.relcode, moddate = getdate(), modemp = :arg_opemp, wrkid = :arg_s_workprice.wrkid Where billid = :arg_s_workprice.billid And flag = 0 ; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 Then rslt = 0 arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Delete From u_workprice_changemx Where billid = :arg_s_workprice.billid; If sqlca.SQLCode <> 0 Then rslt = 0 arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If uo_billid = arg_s_workprice.billid End If For i = 1 To it_mxbt If IsNull(arg_s_workprice.arg_s_mx[i].ifgroup) Then arg_s_workprice.arg_s_mx[i].ifgroup = 0 If arg_s_workprice.arg_s_mx[i].workqty = 0 then arg_s_workprice.arg_s_mx[i].editflag = 2 Insert Into u_workprice_changemx (billid, printid, editflag, mtrlid, proorder, procode, proname, workqty_ori, workqty, workprice_ori, workprice, wrkgrpid, ifstandard, lsxtype, lastflag, dscrp, workhour, techlevel, status, ifjd, wrkid, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, workhour_minute, beforehour_minute, afterhour_minute, eqworkhour_minute, pricestr, workqtystr, wpcode, u_workqty, u_workprice, u_workqtystr, u_pricestr, proname_ori, ifgroup, replacestr, worktype, rpcode, ifdftpg, ifdftjj) Values (:uo_billid, :arg_s_workprice.arg_s_mx[i].printid, :arg_s_workprice.arg_s_mx[i].editflag, :arg_s_workprice.arg_s_mx[i].mtrlid, :arg_s_workprice.arg_s_mx[i].proorder, :arg_s_workprice.arg_s_mx[i].procode, :arg_s_workprice.arg_s_mx[i].proname, :arg_s_workprice.arg_s_mx[i].workqty_ori, :arg_s_workprice.arg_s_mx[i].workqty, :arg_s_workprice.arg_s_mx[i].workprice_ori, :arg_s_workprice.arg_s_mx[i].workprice, :arg_s_workprice.arg_s_mx[i].wrkgrpid, :arg_s_workprice.arg_s_mx[i].ifstandard, :arg_s_workprice.arg_s_mx[i].lsxtype, :arg_s_workprice.arg_s_mx[i].lastflag, :arg_s_workprice.arg_s_mx[i].dscrp, :arg_s_workprice.arg_s_mx[i].workhour, :arg_s_workprice.arg_s_mx[i].techlevel, :arg_s_workprice.arg_s_mx[i].status, :arg_s_workprice.arg_s_mx[i].ifjd, :arg_s_workprice.arg_s_mx[i].wrkid, :arg_s_workprice.arg_s_mx[i].arg1, :arg_s_workprice.arg_s_mx[i].arg2, :arg_s_workprice.arg_s_mx[i].arg3, :arg_s_workprice.arg_s_mx[i].arg4, :arg_s_workprice.arg_s_mx[i].arg5, :arg_s_workprice.arg_s_mx[i].arg6, :arg_s_workprice.arg_s_mx[i].arg7, :arg_s_workprice.arg_s_mx[i].arg8, :arg_s_workprice.arg_s_mx[i].arg9, :arg_s_workprice.arg_s_mx[i].workhour_minute, :arg_s_workprice.arg_s_mx[i].beforehour_minute, :arg_s_workprice.arg_s_mx[i].afterhour_minute, :arg_s_workprice.arg_s_mx[i].eqworkhour_minute, :arg_s_workprice.arg_s_mx[i].pricestr, :arg_s_workprice.arg_s_mx[i].workqtystr, :arg_s_workprice.arg_s_mx[i].wpcode, :arg_s_workprice.arg_s_mx[i].u_workqty, :arg_s_workprice.arg_s_mx[i].u_workprice, :arg_s_workprice.arg_s_mx[i].u_workqtystr, :arg_s_workprice.arg_s_mx[i].u_pricestr, :arg_s_workprice.arg_s_mx[i].proname_ori, :arg_s_workprice.arg_s_mx[i].ifgroup, :arg_s_workprice.arg_s_mx[i].replacestr, :arg_s_workprice.arg_s_mx[i].worktype, :arg_s_workprice.arg_s_mx[i].rpcode, :arg_s_workprice.arg_s_mx[i].ifdftpg, :arg_s_workprice.arg_s_mx[i].ifdftjj); If sqlca.SQLCode <> 0 Then uo_billid = arg_s_workprice.billid rslt = 0 arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText Goto ext End If Next For ll_i = 1 To it_mxbt If arg_s_workprice.arg_s_mx[ll_i].editflag = 0 Then //变更 If arg_s_workprice.arg_s_mx[ll_i].workqty > 0 Then Update u_sc_workprice Set ifchangebill = 1 Where mtrlid = :arg_s_workprice.arg_s_mx[ll_i].mtrlid And procode = :arg_s_workprice.arg_s_mx[ll_i].procode And wpcode = :arg_s_workprice.arg_s_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = '更新工价表是否有相关变更单字段失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If End If Next ext: If rslt = 0 Then Rollback; ElseIf arg_ifcommit And rslt = 1 Then Commit; End If Return rslt end function public function integer uof_mod_rsltflag (long arg_billid, long arg_printid, integer arg_rsltflag, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag,li_priceflag IF arg_billid <= 0 THEN rslt = 0 ARG_MSG = '错误单据唯一码' GOTO ext END IF IF p_getflag(arg_billid,li_flag,li_priceflag,ARG_MSG) = 0 THEN rslt = 0 GOTO ext END IF IF li_flag <> 0 THEN rslt = 0 ARG_MSG = '单据不是在待审核状态,不可以修改结果' GOTO ext END IF UPDATE u_workprice_changemx SET rsltflag = :arg_rsltflag WHERE billid = :arg_billid and printid = :arg_printid ; IF sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 THEN rslt = 0 arg_msg = "更新工价表变更单明细结果操作失败"+"~n"+sqlca.SQLErrText GOTO ext END IF ext: IF rslt = 0 THEN ROLLBACK; ELSEIF arg_ifcommit THEN COMMIT; END IF RETURN rslt end function public function integer priceaudit (long arg_billid, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag, li_priceflag Long ll_scid String ls_billcode, ls_relcode, ls_dscrp DateTime null_dt SetNull(null_dt) If arg_billid <= 0 Then rslt = 0 ARG_MSG = '错误单据唯一码' Goto ext End If If p_getflag(arg_billid,li_flag,li_priceflag,ARG_MSG) = 0 Then rslt = 0 Goto ext End If If li_priceflag <> 0 Then rslt = 0 ARG_MSG = '单据不是在待确认状态,不可以确认' Goto ext End If Select scid, billcode, relcode, dscrp Into :ll_scid, :ls_billcode, :ls_relcode, :ls_dscrp From u_workprice_change Where billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '查询单据信息失败,'+sqlca.SQLErrText Goto ext End If //更新确认标记 Update u_workprice_change Set priceemp = :arg_opemp, pricedate = getdate(), priceflag = 1 Where billid = :arg_billid And priceflag = 0; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = "单据确认操作失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = "单据正在确认,请稍后查询。"+"~n"+sqlca.SQLErrText Goto ext End If If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 And audit_buildtype = 0 Then If f_oa(sqlca,False,ARG_MSG,1494,ll_scid,arg_billid,ls_billcode,ls_relcode,ls_dscrp) = 0 Then rslt = 0 Goto ext End If End If s_workprice_changemx s_workprice_mx[] Long ll_arr_cnt,ll_i If getinfo(arg_billid,s_workprice_mx,ll_arr_cnt,ARG_MSG) = 0 Then rslt = 0 Goto ext End If For ll_i = 1 To ll_arr_cnt If s_workprice_mx[ll_i].editflag = 0 Then //变更 If s_workprice_mx[ll_i].workqty > 0 Then Update u_sc_workprice Set changeflag_ori = changeflag, changeflag = 1, oppflag = 0 Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = '更新工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If End If Next ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Return rslt end function public function integer c_priceaudit (long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1 Int li_flag, li_priceflag Long ll_scid If arg_billid <= 0 Then rslt = 0 ARG_MSG = '错误单据唯一码' Goto ext End If If p_getflag(arg_billid,li_flag,li_priceflag,ARG_MSG) = 0 Then rslt = 0 Goto ext End If If li_priceflag <> 1 Then rslt = 0 ARG_MSG = '单据不是在已确认状态,不可以反确认' Goto ext End If If li_flag <> 0 Then rslt = 0 ARG_MSG = '单据不是在待审核状态,不可以反确认' Goto ext End If Select scid Into :ll_scid From u_workprice_change Where billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '查询单据信息失败,'+sqlca.SQLErrText Goto ext End If If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 And audit_buildtype = 0 Then If f_check_if_oaflow_caudit(ll_scid,arg_billid,1494,ARG_MSG ) = 0 Then rslt = 0 Goto ext End If End If s_workprice_changemx s_workprice_mx[] Long ll_arr_cnt,ll_i If getinfo(arg_billid,s_workprice_mx,ll_arr_cnt,ARG_MSG) = 0 Then rslt = 0 Goto ext End If For ll_i = 1 To ll_arr_cnt If s_workprice_mx[ll_i].editflag = 0 Then //变更 If audit_buildtype = 0 Then If s_workprice_mx[ll_i].workqty > 0 Then Update u_sc_workprice Set changeflag = changeflag_ori Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = '更新工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If Else Update u_sc_workprice Set changeflag = changeflag_ori, oppflag = 1, opprep = :publ_operator, oppdate = getdate(), oppreason = :oppreason Where mtrlid = :s_workprice_mx[ll_i].mtrlid And procode = :s_workprice_mx[ll_i].procode And wpcode = :s_workprice_mx[ll_i].wpcode; If sqlca.SQLCode <> 0 Or sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = '更新工价表失败,第 '+String(ll_i)+' 行'+'~n'+sqlca.SQLErrText Goto ext End If End If End If Next //更新确认标记 Update u_workprice_change Set priceemp = '', pricedate = Null, priceflag = 0 Where billid = :arg_billid And priceflag = 1 And flag = 0; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = "单据反确认操作失败"+"~n"+sqlca.SQLErrText Goto ext ElseIf sqlca.SQLNRows = 0 Then rslt = 0 ARG_MSG = "单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText Goto ext End If If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 And audit_buildtype = 0 Then Update oa_doc Set docflag = 12 Where powerid = 1494 And scid = :ll_scid And billid = :arg_billid; If sqlca.SQLCode <> 0 Then rslt = 0 ARG_MSG = '更新相关公文状态失败'+sqlca.SQLErrText Goto ext End If End If ext: If rslt = 0 Then Rollback; ElseIf rslt = 1 And arg_ifcommit Then Commit; End If Return rslt end function public function integer p_getflag (long arg_billid, ref integer arg_flag, ref integer arg_priceflag, ref string arg_msg);Int rslt = 1 SELECT flag,priceflag INTO :arg_flag,:arg_priceflag FROM u_workprice_change WHERE billid = :arg_billid; IF sqlca.SQLCode <> 0 THEN ARG_MSG = '查询单据审核标记失败,'+sqlca.SQLErrText rslt = 0 GOTO ext END IF ext: RETURN rslt end function on uo_workprice_change.create call super::create TriggerEvent( this, "constructor" ) end on on uo_workprice_change.destroy TriggerEvent( this, "destructor" ) call super::destroy end on