<!--#include file="Conn.asp"--><%Checklogin("")


Keys=Server.URLEnCode(Request.QueryString("Keys"))
Ord=Server.URLEnCode(Request.QueryString("Ord"))
Page=Request.QueryString("Page")
id=Request.QueryString("id")
cp=Request.QueryString("cp")
hrefstr="Keys="&Keys&"&Ord="&Ord&"&Page="&Page&"&id="&id&"&cp="&cp

If id="" Or Not IsNumeric(id) Then Response.Write "非法的操作":Response.End

%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理区域</title>
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script language="javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/js.js"></script>

</head>

<body>
<div id="man_zone">
<%
Act = Request.QueryString("act")
If act = "save" Then
isedit = False

daid = Request.Form("daid")
If daid<>"" And IsNumeric(daid) Then isedit = True


cid = Request.Form("cid")
If cid="" Or Not IsNumeric(cid) Then cid=0

damc = TextEnCode(Request.Form("damc"))
daurl = TextEnCode(Request.Form("daurl"))
daord = Request.Form("daord")


If isedit Then
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "Select * From da Where id="&daid,Conn,1,3
	If Not Rs.Bof And Not Rs.Eof Then

		Rs("damc") = damc
		Rs("cid")=cid
		Rs("cpid") = id
		If daord<>"" And IsNumeric(daord) Then Rs("daord") = daord
		Rs("daurl")=daurl

	Else
		Rs.AddNew

		Rs("damc") = damc:Rs("cid")=cid:Rs("cpid")=id
		If daord<>"" And IsNumeric(daord) Then Rs("daord") = daord Else Rs("daord") = 0
		Rs("dastate") = 1
		Rs("daurl")=daurl
	End If
	Rs.Update:Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing
	Response.Redirect "?"&hrefstr
Else
	If daord="" Or Not IsNumeric(daord) Then daord=0
	Conn.Execute("Insert into da(cid,cpid,damc,daurl,daord,dastate) values("&cid&",'"&id&"','"&damc&"','"&daurl&"',"&daord&",1)")
	Conn.Close:Set Conn=Nothing:Response.Redirect "?"&hrefstr
End If

Conn.Close:Set Conn=Nothing

Response.End
End If 'end save

If Act = "add" Or Act = "edit" Then
daid = Request.QueryString("daid")
isedit = False
If daid<>"" And IsNumeric(daid) Then isedit=True
If isedit Then
	Set Rs = Server.CreateObject("ADODB.RecordSet")
	Rs.Open "Select * From da Where id="&daid,Conn,1,1
	If Not Rs.Bof And Not Rs.Eof Then
		damc=Rs("damc"):daord=Rs("daord"):cid=Rs("cid"):daurl=Rs("daurl")
	Else
		isedit = False
	End If
	Rs.Close:Set Rs=Nothing
End If
%>
	<form name="form1" method="post" action="?<%=hrefstr%>&act=save">
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<tbody>
			<tr>
				<th width="8%">类型选择</th>
				<td><select name="cid">
					<option value="0">请选择类型</option>
					<option value="1"<%If cid=1 Then Response.Write " selected=""selected"""%>>产品操作说明书</option>
					<option value="2"<%If cid=2 Then Response.Write " selected=""selected"""%>>产品相关文献</option>
					<option value="3"<%If cid=3 Then Response.Write " selected=""selected"""%>>产品彩页彩册</option>
					</select><input type="hidden" name="daid" value="<%=daid%>" /></td>
			</tr>
			<tr>
				<th width="8%">档案名称</th>
				<td><input type="text" id="damc" name="damc" value="<%=damc%>" class="txt1" /></td>
			</tr>
			<tr>
				<th width="8%">上传资料</th>
				<td><input type="text" id="infoimgurl" name="daurl" value="<%=daurl%>" class="txt1" style="width:390px;float:left;" /><iframe src="uploadfile.asp" frameborder="0" scrolling="no" style="width:400px;height:22px;float:left;margin-left:10px;"></iframe></td>
			</tr>
			<tr>
				<th width="8%">排序</th>
				<td><input type="text" id="daord" name="daord" value="<%=daord%>" class="txt1" /></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="submit" name="save" id="save" value="确定" class="btn1" /> <input type="reset" name="save" id="save" value="重置" class="btn1" /> <input type="button" value="返回" class="btn1" onClick="location.href='?<%=hrefstr%>'" /></td>
			</tr>
		</tbody>
	</table>
	</form>
</div>
</body>
</html>
<%
Response.End
End If 'End add


If Act="postchk" Then

Keys = Server.UrlEnCode(Request.QueryString("Keys"))
Ord = Server.UrlEnCode(Request.QueryString("Ord"))
Page = Request.QueryString("Page")

id=Request.QueryString("id")
cp=Request.QueryString("cp")

chkact = Request.Form("chkact")
SqlStr = ""
For i = 1 To Request.Form("chkbox").Count
	If SqlStr<>"" Then
		SqlStr = SqlStr & " Or id="&Request.Form("chkbox")(i)
	Else
		SqlStr = " Where id="&Request.Form("chkbox")(i)
	End If
Next

Select Case chkact
Case "0":SqlStr = "Update da Set dastate="&chkact&SqlStr
Case "1":SqlStr = "Update da Set dastate="&chkact&SqlStr
Case Else:SqlStr = "Delete From da"&SqlStr
End Select

Conn.Execute(SqlStr):Conn.Close:Set Conn=Nothing
Response.Redirect "?Keys="&Keys&"&Ord="&Ord&"&Page="&Page&"&id="&id&"&cp="&cp
Response.End
End If	'End postchk


Set Rs=Server.CreateObject("ADODB.RecordSet")
Rs.Open "Select * From da Where cpid="&id&" Order By daord Desc,id Desc",Conn,1,1
%>	
	<form id="form1" method="post" action="?act=postchk&<%=hrefstr%>" onSubmit="return false" />
	<table width="100%" border="0" cellpadding="3" cellspacing="1" class="table1">
		<thead>
			<tr>
				<th width="4%"><input type="checkbox" name="chkall" id="chkall" onClick="chkboxall(this,'chkbox')" /></th>
				<th width="6%">序号</th>
				<th width="16%">所属类型</th>
				<th width="50%">档案名称</th>
				<th width="8%">排序</th>
				<th width="8%">状态</th>
				<th width="8%">操作</th>
			</tr>
		</thead>
		<tbody>
<%
If Not Rs.Bof And Not Rs.Eof Then
	Do While Not Rs.Bof And Not Rs.Eof
%>

			<tr onMouseOver="this.style.background='#F7FCFF'" onMouseOut="this.style.background='#FFFFFF'">
				<td align="center"><input type="checkbox" name="chkbox" value="<%=Rs(0)%>" /></td>
				<td align="center"><%=TempNum%></td>
				<td align="center"><%
Select Case Rs("cid")
Case 1:Response.Write "产品操作说明书"
Case 2:Response.Write "产品相关文献"
Case 3:Response.Write "产品彩页彩册"
Case Else:Response.Write "未选择"
End Select
%></td>
				<td align="center"><%=Rs("damc")%></td>
				<td align="center"><%=Rs("daord")%></td>
				<td align="center"><%If Rs("dastate")=1 Then Response.Write "显示" Else Response.Write "隐藏" End If%></td>
				<td align="center"><a href="?<%=hrefstr%>&act=edit&daid=<%=Rs(0)%>" class="ico_edit">修改</a></td>
			</tr>
<%
	Rs.MoveNext
	Loop
Else
%>
			<tr>
				<td align="center" colspan="8">Sorry，当前暂无产品档案</td>
			</tr>
<%
End If
%>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="8">
					<div class="postchkbox">
						<select id="chkact" name="chkact">
							<option value="1">显示</option>
							<option value="0">隐藏</option>
							<option value="-1">删除</option>
						</select>
						<input type="button" value="执行" onClick="postchk(1)" class="btn1" />
						<input type="button" value="新增" onClick="location.href='?act=add&<%=hrefstr%>'" class="btn1" />
						<input type="button" value="返回" onClick="location.href='cp<%=cp%>.asp?<%=hrefstr%>'" class="btn1" />
					</div>
				</td>
			</tr>
		</tfoor>
	</table>
	</form>
<%Rs.Close:Set Rs=Nothing:Conn.Close:Set Conn=Nothing%>
</div>
</body>
</html>
