<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="conn" scope="page" class="download.conn"/>
<%!
	ResultSet rs = null;
	boolean founderr = false;
	String errmsg = "";
	String filename = "";
    String showname = "";
    String note = "";
    String tt = "";
    String size = "";
    String hot = "";
    String face = "";
    String sql = "";
%>
<%
request.setCharacterEncoding("GBK");
if(session.getAttribute("login")==null || !session.getAttribute("login").equals("ok")) {
  response.sendRedirect("login.asp");
}
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 =  "update download set filename='" + filename + "',";
		sql += "showname='" + showname + "',";
		sql += "softnote='" + note + "',";
		sql += "face='" + face + "',";
		sql += "size=" + size + ",";
		sql += "hot='" + hot + "',";
		sql += "typename='" + tt + "' ";
		sql += "where id=" + request.getParameter("id") ;
        conn.executeUpdate ( sql ); 
%>
		<jsp:forward page="xtwh.jsp">
		    <jsp:param name="Page" value="1"/>
        </jsp:forward>
<%
}
else {
		out.println("由于以下的原因不能保存数据：");
		out.println(errmsg);
}
%>
