sub CancelCheckArticle(ID) '取消检验并在工资表中删除记录
set rs=server.createobject("adodb.recordset")
sql="select C_LSH, from WAGE where C_LSH=" & CLng(ID)
rsDel.open sqlDel,conn,1,3
if rsDel.bof and rsDel.eof then
response.write "找不到相关记录"
rs.Close
set rs=nothing
response.end
else
sqlDel="select C_LSH,C_YSM,C_YSSJM,C_GM,C_YQ from PRODUCTS where C_LSH=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
if rsDel.bof and rsDel.eof then
response.write "找不到相关记录"
elseif not isNull(rsDel("C_GM")) or not isNull(rsDel("C_YQ")) then
response.write ""&CLng(ID)&" 已经有刮磨或油漆的记录,不能取消!"
rsDel.close
set rsDel=nothing
call CloseConn()
response.end
elseif (Year(Date) &"/"& Month(Date))<>(year(rsDel("C_YSSJM"))&"/"&month(rsDel("C_YSSJM"))) then '只有当月才能取消审核
rsDel.close
set rsDel=nothing
call CloseConn()
response.end
else
rsDel("C_YSM")=null
rsDel("C_YSSJM")=null
end if
rsDel.update
'删除工资表中的记录
sql2="delete from WAGE where C_LSH="&CLng(ID)
conn.execute sql2
rsDel.close
set rsDel=nothing
end if
end sub
if submit<>"删除" and xuanze="Check" then
conn.begintrans '开启事务
if instr(C_LSH,",")>0 then
idArr=split(C_LSH)
for i = 0 to ubound(idArr)
call CheckArticle(idarr(i))
next
else
call CheckArticle(clng(C_LSH))
end if
if err <> 0 then '如果错误则数据库回滚
conn.rollbacktrans
err.clear
response.write "<center><font color=red>"
response.Write "添加失败!<br>"
response.write "</font></center>"
else
conn.committrans '正确则写入
Response.Write "添加记录成功!"
call CloseConn()
response.write " <script language=javascript>alert('流水号"&C_LSH&"检验成功');location.href='check.asp'; </script>"
end if
如果在循环中有一步是错误的,那么就无法执行conn.rollbacktrans和conn.committrans 这样的话,那些在数据库中临时写入和删掉除的数据怎么办?没有回滚也没有确认写入。这样会不会对后来的调用产生音响?
请赐教!
谢谢
set rs=server.createobject("adodb.recordset")
sql="select C_LSH, from WAGE where C_LSH=" & CLng(ID)
rsDel.open sqlDel,conn,1,3
if rsDel.bof and rsDel.eof then
response.write "找不到相关记录"
rs.Close
set rs=nothing
response.end
else
sqlDel="select C_LSH,C_YSM,C_YSSJM,C_GM,C_YQ from PRODUCTS where C_LSH=" & CLng(ID)
Set rsDel= Server.CreateObject("ADODB.Recordset")
rsDel.open sqlDel,conn,1,3
if rsDel.bof and rsDel.eof then
response.write "找不到相关记录"
elseif not isNull(rsDel("C_GM")) or not isNull(rsDel("C_YQ")) then
response.write ""&CLng(ID)&" 已经有刮磨或油漆的记录,不能取消!"
rsDel.close
set rsDel=nothing
call CloseConn()
response.end
elseif (Year(Date) &"/"& Month(Date))<>(year(rsDel("C_YSSJM"))&"/"&month(rsDel("C_YSSJM"))) then '只有当月才能取消审核
rsDel.close
set rsDel=nothing
call CloseConn()
response.end
else
rsDel("C_YSM")=null
rsDel("C_YSSJM")=null
end if
rsDel.update
'删除工资表中的记录
sql2="delete from WAGE where C_LSH="&CLng(ID)
conn.execute sql2
rsDel.close
set rsDel=nothing
end if
end sub
if submit<>"删除" and xuanze="Check" then
conn.begintrans '开启事务
if instr(C_LSH,",")>0 then
idArr=split(C_LSH)
for i = 0 to ubound(idArr)
call CheckArticle(idarr(i))
next
else
call CheckArticle(clng(C_LSH))
end if
if err <> 0 then '如果错误则数据库回滚
conn.rollbacktrans
err.clear
response.write "<center><font color=red>"
response.Write "添加失败!<br>"
response.write "</font></center>"
else
conn.committrans '正确则写入
Response.Write "添加记录成功!"
call CloseConn()
response.write " <script language=javascript>alert('流水号"&C_LSH&"检验成功');location.href='check.asp'; </script>"
end if
如果在循环中有一步是错误的,那么就无法执行conn.rollbacktrans和conn.committrans 这样的话,那些在数据库中临时写入和删掉除的数据怎么办?没有回滚也没有确认写入。这样会不会对后来的调用产生音响?
请赐教!
谢谢