<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="conn" scope="page" class="download.conn"/>
<%!
	ResultSet rs = null;
	ResultSet rstmp = null;
	boolean founderr = false;
	int currid = 0;
	String errmsg = "";
	String filename = "";
    String showname = "";
    String note = "";
    String tt = "";
    String size = "";
    String hot = "";
    String face = "";
    String sql = "";
%>
<%
if(session.getAttribute("login")==null || !session.getAttribute("login").equals("ok")) {
  response.sendRedirect("login.asp");
}
request.setCharacterEncoding("GBK");
rstmp = conn.executeQuery ( "select max(id) as maxid from download" );
rstmp.next();
currid = rstmp.getInt("maxid");
rstmp.close();
if(request.getParameter("txtfilename")==null || request.getParameter("txtfilename").equals("")) {
  founderr = true;
  errmsg="<li>下载的程序文件名不能为空</li>";
}
if(request.getParameter("txtshowname")==null || request.getParameter("txtshowname").equals("")) {
  founderr = true;
  errmsg = errmsg+"<li>显示名称不能为空</li>";
}
if(request.getParameter("size")==null || request.getParameter("size").equals("")) {
  founderr = true;
  errmsg = errmsg+"<li>软件大小不能为空</li>";
}
if(request.getParameter("hot")==null || request.getParameter("hot").equals("")) {
  founderr = true;
  errmsg = errmsg+"<li>星级评定不能为空</li>";
}
if(request.getParameter("face")==null || request.getParameter("face").equals("")) {
  founderr = true;
  errmsg = errmsg + "<li>运行环境不能为空</li>";
}
if(request.getParameter("txtnote")==null || request.getParameter("txtnote").equals("")) {
  founderr = true;
  errmsg = errmsg+"<li>程序简介不能为空</li>";
}
if(request.getParameter("typename")==null || request.getParameter("typename").equals("")) {
  founderr = true;
  errmsg=errmsg+"<li>程序类型不能为空</li>";
}
if(founderr==false) {
		filename = request.getParameter("txtfilename");
		showname = request.getParameter("txtshowname");
		note = request.getParameter("txtnote");
		tt = request.getParameter("typename");
		size = request.getParameter("size");
		hot = request.getParameter("hot");
		face = request.getParameter("face");
		sql =  "insert into download values (" + currid + ",date(),'" + filename + "',";
		sql +=  size + ",'" + showname + "','";
		sql +=  hot + "','";
		sql +=  face + "','";
		sql +=  tt + "','";
		sql +=  note + "',0)";
        conn.executeUpdate ( sql ); 
%>
		<html>
		<head>
			<title>软件添加成功</title>
		</head>
		<body bgcolor="#FFFFFF">
		<div align="center"><center>
		<table border="1" cellspacing="0" width="50%" bordercolorlight="#000000"
		bordercolordark="#FFFFFF" cellpadding="0">
		      <tr bgcolor="#000099"> 
		        <td width="100%" height="27"> 
		          <p align="center"><font color="#FFFFFF" size="3">软件仓库──添加成功</font>
		        </td>
		  </tr>
		  <tr>
		        <td width="100%"> 
		          <p align="center">&nbsp;</p>
		          <p align="center"><font color="#000000"><b>恭喜恭喜！<br>
		            </b></font><font color="#000000"><b> 软件仓库又添新软件！</b></font><br>
		            其文件名为：<%=filename%><br>
		            显示名称为：<%=showname%></p>
		          <p align="center">是否继续添加？<br>
		    <br>
		    <a href="add.jsp">是</a>&nbsp;&nbsp; <a href="xtwh.jsp">否</a><br>
		    <br>
		    </td>
		  </tr>
		</table>
		</center></div>
<%
} else {
	 out.println("由于以下的原因不能保存数据：");
     out.println(errmsg);
}
%>
</body>
</html>
