<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../conn.asp"-->
<!--#include file="../seeion.asp"-->
<!--#include file="../page.asp"-->
<!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=gb2312" />
<title><%=site_info("title")%>-后台管理系统</title>
<link href="../css.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function showUploadDialog(s_Type, s_Link, s_Thumbnail){
var arr = showModalDialog("../eWebEditor/dialog/i_upload.htm?style=pcfinal&type="+s_Type+"&link="+s_Link+"&thumbnail="+s_Thumbnail, window, "dialogWidth:0px;dialogHeight:0px;help:no;scroll:no;status:no");}
</script>
</head>
<body>
<br />
<%
Sub infoback(info)
    response.Write "<script language=javascript>alert('"&info&"');window.history.back();</script>"
    response.End
End Sub
Sub infohref(info, url)
    response.Write "<script language=javascript>alert('"&info&"');window.location.href='"&url&"'</script>"
    response.End
End Sub

If request.Form("submit") = "删除选中" Then
    If Request("id") = "" Then
        Call infoback("请选中要删除的新闻！")
    End If
    sql = "delete from news_image where id in ("&request("id")&")"
    conn.Execute(sql)
	Call close_conn
    Call infohref("成功删除选中的新闻！", "news_image.asp")
End If
Sub close_conn
    conn.Close
    Set conn = Nothing
End Sub
%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="52"><img src="../images/main_1.jpg" width="52" height="55" /></td>
              <td background="../images/main_2.jpg" class="title1">新闻图片管理</td>
              <td width="52"><img src="../images/main_3.jpg" width="52" height="55" /></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="15" background="../images/main_4.gif">&nbsp;</td>
              <td background="../images/main_9.gif"><table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
			  				  <%
Set rs = server.CreateObject("adodb.recordset")
exec = "select * from news_image order by order_id asc"
rs.Open exec, conn, 1, 1
If rs.EOF Then
    response.Write "&nbsp;暂无产品子分类！"
Else
    rs.PageSize = 10 '每页记录条数
    iCount = rs.RecordCount '记录总数
    iPageSize = rs.PageSize
    maxpage = rs.PageCount
    page = request("page")
    If Not IsNumeric(page) Or page = "" Then
        page = 1
    Else
        page = CInt(page)
    End If
    If page<1 Then
        page = 1
    ElseIf page>maxpage Then
        page = maxpage
    End If
    rs.AbsolutePage = Page
    If page = maxpage Then
        x = iCount - (maxpage -1) * iPageSize
    Else
        x = iPageSize
    End If
%>
<form  method="post">               
                  <tr>
				  	<th width="87" class="td2">选择</th>
                    <th width="280" class="td2">新闻标题</th>
                    <th width="411" class="td2">新闻浏览</th>
                    <th width="157" class="td2">排序</th>
                    <th width="116" class="td2">修改操作</th>
                  </tr>
				  

                  <%For i=1 To x%>
                  
                    <tr>
					  <td class="td" align="center" width="87"><input name="id" type="checkbox" value="<%=rs("id")%>" /></td>
                      <td class="td"><%=rs("title")%></td>
                      <td class="td"><img src="../../<%=rs("thumbnail")%>" width="70" height="20" title="<%=rs("title")%>" alt="<%=rs("title")%>" /></td>
                      <td class="td"><%=rs("order_id")%></td>
                      <td class="td"><input name="update" type="button" class="button" value="修改内容" onclick="window.location.href='news_image_upd.asp?id=<%=rs("id")%>'" /></td>
                    </tr>
                  
                  <%rs.movenext
Next
%>
                  <%
End If
%>
					<tr>
					<td class="td" align="center"><input name="ID" type="checkbox" onclick="check_all(this,'ID')"/>全选
					<script type="text/javascript"> 
						function check_all(obj,cName)
						{
						var checkboxs = document.getElementsByName(cName);
						for(var i=0;i<checkboxs.length;i++){checkboxs[i].checked = obj.checked;}
						}
						</script>
					</td>
					<td class="td" colspan="4" align="center"><input type="submit" name="submit" value="删除选中" onclick="return confirm('确定要删除选中的新闻吗？删除后将不可恢复！')" /></td>
				</tr>
</form>
                </table>
                <%'以下显示分页
Call PageControl(iCount, maxpage, page, "border=0 align=center", "<p align=center>")
rs.Close
Set rs = Nothing
%></td>
              <td width="15" background="../images/main_5.gif">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="52"><img src="../images/main_6.gif" width="52" height="16" /></td>
              <td background="../images/main_7.gif" width="100%"></td>
              <td width="52"><img src="../images/main_8.gif" width="52" height="16" /></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="52"><img src="../images/main_1.jpg" width="52" height="55" /></td>
              <td background="../images/main_2.jpg" class="title1">添加新闻图片</td>
              <td width="52"><img src="../images/main_3.jpg" width="52" height="55" /></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="15" background="../images/main_4.gif">&nbsp;</td>
              <td background="../images/main_9.gif"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="1">
                  <form action="news_image.asp?add=ok" method="post" id="news_image"  name="news_image">
                    <tr>
                      <td width="80" class="td">图片标题：</td>
                      <td class="td"><input name="title" type="text" class="input" size="20" /></td>
                    </tr>
                    <tr>
                      <td class="td">新闻图片：</td>
                      <td class="td"><input name="thumbnail" type="text" class="input" size="80"/>
                          <input name="button" type="button" class="button" onclick="showUploadDialog('image', 'news_image.thumbnail', '')" value="上传图片" /></td>
                    </tr>
                    <tr>
                      <td class="td">排序：</td>
                      <td class="td"><input name="order_id" type="text" class="input" size="5" /></td>
                    </tr>
                    <tr>
                      <td colspan="2" class="td"><p class="submit">
                          <input name="submit" type="submit" class="button" value="添加新闻图片" />
                      </p></td>
                    </tr>
                  </form>
              </table></td>
              <td width="15" background="../images/main_5.gif">&nbsp;</td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="52"><img src="../images/main_6.gif" width="52" height="16" /></td>
              <td background="../images/main_7.gif" width="100%"></td>
              <td width="52"><img src="../images/main_8.gif" width="52" height="16" /></td>
            </tr>
        </table></td>
      </tr>
    </table>
</body>
</html>
<%
If Request.QueryString("add") = "ok" Then
    Set rs = server.CreateObject("adodb.recordset")
    sql = "select * from news_image"
    rs.Open sql, conn, 1, 3
    title = request.Form("title")
	thumbnail = request.Form("thumbnail")
    order_id = request.Form("order_id")
    If title = "" Then
        response.Write("<script language=javascript>alert('子级分类名称不能为空!');history.go(-1)</script>")
        response.End
    End If
    If order_id = "" Then
        response.Write("<script language=javascript>alert('排序数字不能为空!');history.go(-1)</script>")
        response.End
    End If
    If Not IsNumeric(request("order_id")) Then
        response.Write("<script language=javascript>alert('排序字符必须为数字！'); history.go(-1);</script>")
        response.End
    End If
    rs.addnew
    rs("title") = title
	rs("thumbnail") = thumbnail
    rs("order_id") = order_id
    rs.update
    rs.Close
    Set rs = Nothing
    conn.Close
    Set rs = Nothing
    Response.Write "<script language=javascript>alert('添加成功！');window.location.href='news_image.asp';</script>"
End If
%>

<!--#include file="../close.asp"-->
