<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->
<!--#include file="../sub.asp"-->
<%
function encodestr(str)
	dim i
	str=trim(str)
	str=replace(str,"'","""")
	str=replace(str,vbCrLf&vbCrlf,"<p></p>")
	str=replace(str,vbCrLf,"<br>")
	encodestr=replace(str,"  ","　")
end function

ID=clng(request("ID"))
Num=clng(request.QueryString("Num"))
Action=trim(request.form("Action"))
page=cint(request.QueryString("page"))
if Action="" then
	titleID=clng(request.querystring("titleID"))
	set rs=conn.execute("select a.ClassID,a.titleName,a.Photoer,a.Recomm,b.ImageInfo from title as a,imgbook as b where a.titleID="&titleID&" and b.ID="&ID&" and b.titleID=a.titleID")
	ClassID=rs(0)
	titleName=rs(1)
	Photoer=rs(2)
	Recomm=rs(3)
	ImageInfo=split(rs(4),",")
	RsClose
	width=ImageInfo(0)
	height=ImageInfo(1)
	size=ImageInfo(2)	
else
	OldID=clng(request.querystring("OldID"))
	content=encodestr(request.Form(("content")))
	ClassID=clng(request.Form("ClassID"))
	titleName=request.Form("titleName")
	Photoer=request.Form("Photoer")
	ImageInfo=request.form("width")&","&request.Form("height")&","&request.Form("size")
	if Action="Image" then
		set rs=server.createobject("adodb.recordset")
		rs.open "select * from title where titleName='"&titleName&"' and ClassID="&ClassID&" and Photoer='"&Photoer&"'",conn,1,3
		if rs.eof or rs.bof then
			rs.addnew
			rs("ClassID")=ClassID
			rs("titleCount")=1
			set Num=server.CreateObject("adodb.recordset")
			Num.open "select max(titleNum) from Title",conn,1,1
			if Num.eof or Num.bof or isNull(Num(0)) then
				titleNum=10000001
			else
				titleNum=Num(0)+1
			end if
			Num.Close
			set Num=nothing
			rs("titleNum")=titleNum
			rs("titleName")=titleName
			rs("Photoer")=Photoer
			if content<>"" then
				rs("desc")=content
			end if
			rs("updatetime")=now
		else
			if rs("titleID")<>OldID then
				rs("titleCount")=rs("titleCount")+1
				conn.execute("update title set titleCount=titleCount-1 where titleID="&OldID)
			end if
		end if
		rs.update
		rs.close
		
		set rs=conn.execute("select titleID from title where titleName='"&titleName&"' and ClassID="&ClassID&" and Photoer='"&Photoer&"'")
		titleID=rs(0)
		rs.close
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select titleID,content,ImageInfo from Imgbook where ID="&ID,conn,1,3
		if content<>"" then
			rs("content")=content
		end if
		if ImageInfo<>",," then
			rs("ImageInfo")=ImageInfo
		end if
		rs("titleID")=titleID
		rs.update
		RsClose
		response.write("<script>alert('修改成功！ ');this.location.href='manage.asp?page="&page&"';</script>")
	elseif Action="title" then
		set rs=server.CreateObject("adodb.recordset")
		rs.open "select * from title where titleID="&OldID,conn,1,3
		rs("ClassID")=ClassID
		rs("titleName")=titleName
		rs("Photoer")=Photoer
		if content<>"" then
			rs("desc")=content
		end if
		rs.update
		RsClose
		response.write("<script>alert('修改成功！ ');this.location.href='manage.asp?page="&page&"';</script>")
	end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图片上传</title>
<link href="images/bbs.css" rel="stylesheet" type="text/css">
</head>

<body topmargin="0">

<div align="center">
  <center>
    <table width="563" border="0" cellpadding="0" cellspacing="0" id="AutoNumber1">
      <form method="post" name="frmadd" action="?ID=<%=ID%>&OldID=<%=titleID%>">
        <tr> 
          <td height="36" colspan="3"><div align="center"><strong>图 片 修 改 </strong></div></td>
        </tr>
        <tr> 
          <td height="22" colspan="3">　图片编号 ： <%=Num%></td>
        </tr>
        <tr>
          <td colspan="3">　所属分类：
          <%ShowClass(ClassID)%></td>
        </tr>
        <tr> 
          <td colspan="3">　组图名称：
          <input name="titleName" type="text" id="titleName" style="width: 94px" value="<%=titleName%>"></td>
        </tr>
        <tr> 
          <td colspan="3">　摄 影 师：
          <input name="Photoer" type="text" id="Photoer" style="width: 94px" value="<%=Photoer%>">
          </td>
        </tr>
        <tr> 
          <td colspan="3">　　</td>
        </tr>
        <tr> 
          <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="76" valign="top">　图片说明：<br>
                  <br>
                  <font color="#FF0000">**</font>
                如果不要修改请留空！                  <br></td>
                <td width="477"><textarea name="content" cols="48" rows="6" id="textarea" onclick="this.value=''"></textarea></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td width="77"><div align="center">图片数据：</div></td>
          <td colspan="2">宽
            <input name="width" type="text" id="width" onmouseover="this.select();" value="<%=width%>" size="4">
            高
            <input name="height" type="text" id="height" onmouseover="this.select();" value="<%=height%>" size="4">
            大小
            <input name="size" type="text" id="size" onmouseover="this.select();" value="<%=size%>" size="4">
          KB</td></tr>
        <tr>
          <td height="13" valign="top"><div align="center">修改属性：</div></td>
          <td colspan="2"><input type="radio" name="Action" value="Image" checked>
            只修改此编号的图片
              （您可以修改单张图片的信息）<br>
              <input name="Action" type="radio" value="title">
修改组（您可以修改组图总说明）</td>
        </tr>
        <tr> 
          <td>&nbsp;</td>
          <td width="253">&nbsp;</td>
          <td width="233"> <p> 
          </td>
        </tr>
        <tr> 
          <td colspan="3"><div align="center"> 
              <input type="submit" name="Submit" value="修改">
              <input type="reset" name="Submit2" value="取消">
            </div></td>
        </tr>
      </form>
    </table>
  </center>
</div>
</body>
</html>