peisong2.asp<%@ Language=VBScript %>
<%option explicit%>
<%Response.Expires=0%>
<!--#include file="AdoAccess.asp"-->
<script language=vbscript>
<!--
'输入值非空以及text3是否为数据值的判断
function form1_onsubmit()
if form1.text1.value=""then
MsgBox"请输入值,不能为空"
form1.text1.focus()
form1_onsubmit=false
exit function
elseif form1.text2.value=""then
MsgBox"请输入值,不能为空"
form1.text2.focus()
form1_onsubmit=false
exit function
elseif form1.text3.value=""then
MsgBox"请输入值,不能为空"
form1.text3.focus()
form1_onsubmit=false
exit function
elseif form1.text4.value=""then
MsgBox"请输入值,不能为空"
form1.text4.focus()
form1_onsubmit=false
exit function
end if
if not IsNumeric(form1.text3.value)then
MsgBox"请输入数值!"
form1_onsubmit=false
form1.text3.focus()
exit function
end if
form1_onsubmit=true
'在sDISTRIBUTIONACCESSORIES表中插入数据
strsql2="INSERT INTO sDISTRIBUTIONACCESSORIES (DISTRIBUTIONID,DRAWINGID,NAME,REMARK,ACCOUNT) VALUES ('"&session("id")&"','"&drawingid&"','"&name&"','"&remark&"','"&account&"')"
'strsql2="UPDATE sDISTRIBUTIONACCESSORIES SET DRAWINGID='"&drawingid&"',NAME='"&name&"',ACCOUNT='"&account&"',REMARK='"&remark&"' WHERE DISTRIBUTIONID='"&session("id")&"'"
'改写sDISTRIBUTION表中DISTRIBUTIONSTATE的值为在借
strsql3="UPDATE sDISTRIBUTION SET DISTRIBUTIONSTATE='在借' WHERE DISTRIBUTIONID='"&session("id")&"'"
cn.Execute strsql2
cn.Execute strsql3
'刀具配送完毕,显示该id的sDISTRIBUTIONACCESSORIES表记录
strsql="SELECT * FROM sDISTRIBUTIONACCESSORIES where (DISTRIBUTIONID='"&session("id")&"'and DRAWINGID='"&drawingid&"'and NAME='"&name&"'and ACCOUNT='"&account&"'and REMARK='"&remark&"')"
set rstest=server.CreateObject ("ADODB.recordset")
rstest.Open strsql,cn,3,3,1%>
<table border="3" align="center">
<tr>
<td>
<%Response.Write"令单ID"%>
</td>
<td>
<%Response.Write "物料图号"%>
</td>
<td>
<%Response.Write"物料名称"%>
</td>
<td>
<%Response.Write"附件数量"%>
</td>
<td>
<%Response.Write"备注"%>
</td>
</tr>
<%
for i=0 to rstest.Fields.Count-1
Response.Write"<td>"&rstest(i).value&"</td>"
next
Response.Write"</tr>"
Response.Write "</table>"
rstest.Close
cn.Close
set rstest=nothing
set cn=nothing
end if
const MaxPerPage=10
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
'数据库连接
dim cn,rs,strsql,strsql2,strsql3,rstest2
set cn=server.CreateObject ("ADODB.Connection")
cn.Open strcn
'查询sDISTRIBUTION中DISTRIBUTIONSTATE='申请'的记录
strsql="SELECT DISTRIBUTIONID,PAIGONGHAO,PLANMODAL,PARTDRAWINGID,PROCROUTING,ASSESSCLASS FROM sDISTRIBUTION WHERE DISTRIBUTIONSTATE='申请'"
'每次刷新时显示新出现的申请记录其中SHUAXINSTATE='1'
strsql2="SELECT DISTRIBUTIONID FROM sDISTRIBUTION WHERE (SHUAXINSTATE='1'and DISTRIBUTIONSTATE='申请')"
'显示新出现的申请记录后将其中SHUAXINSTATE改为0
strsql3="UPDATE sDISTRIBUTION SET SHUAXINSTATE='0' WHERE DISTRIBUTIONSTATE='申请'"
set rs=server.CreateObject ("ADODB.recordset")
set rstest2=server.CreateObject ("ADODB.recordset")
rstest2.Open strsql2,cn,3,3,1
'有新的令单出现时,提示信息
if rstest2.RecordCount>0 then
do while not rstest2.eof
%>
<%rstest2.MoveNext
loop
end if
rstest2.Close
set rstest2=nothing
rs.Open strsql,cn,3,3,1
'分页
'数据指针移到第一条
if not rs.EOF <>0 then
rs.MoveFirst
end if
rs.pagesize=MaxPerPage
dim howmanyfields
howmanyfields=rs.Fields.Count-1
If trim(Request("Page"))<>"" then
CurrentPage= CLng(request("Page"))
If CurrentPage> rs.PageCount then
CurrentPage = rs.PageCount
End If
Else
CurrentPage= 1
End If
if rs.eof then
response.write "<p align='center'> 没有新的配送令单!</p>"
else
totalPut=rs.recordcount
if CurrentPage<>1 then
if (currentPage-1)*MaxPerPage<totalPut then
rs.move(currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
end if
end if
dim n,k
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if%>
<p align="center">PAGE <%=currentpage%> OF <%=n%> 共<%=rs.recordcount%> 纪录
<% k=currentPage
if k<>1 then
response.write "[<b>"+"<a href='PEISONG.asp?page=1'>首页</a></b>] "
response.write "[<b>"+"<a href='PEISONG.asp?page="+cstr(k-1)+"'>上一页</a></b>] "
else
Response.Write "[首页] [上一页]"
end if
if k<>n then
response.write "[<b>"+"<a href='PEISONG.asp?page="+cstr(k+1)+"'>下一页</a></b>] "
response.write "[<b>"+"<a href='PEISONG.asp?page="+cstr(n)+"'>尾页</a></b>] "
else
Response.Write "[下一页] [尾页]"
end if
'记录显示
%>
i=0
do while not rs.eof and i<maxperpage%>
<tr align="middle">
<td>
<a HREF="peisong2.asp?id=<%=rs("DISTRIBUTIONID")%>">编辑</a>
</td>
<%for j=0 to howmanyfields%>
<td>
<%=rs(j)%>
</td>
<%next%>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</table>
<%cn.Execute strsql3
rs.close
cn.Close
set rs=nothing
end if