spinfo.jsp

来自「用于商品进销存管理的BS系统」· JSP 代码 · 共 57 行

JSP
57
字号
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%
	request.setCharacterEncoding("gb2312");
%>
<%@ page import="java.sql.*,java.io.*"%>

<jsp:useBean id="conn" scope="page" class="com.mingri.dbconn.DBResult" />
<%
	//regist.setSpinfo(spinfo);
	//regist.regist();
	String sql = null;
	String newmax = null;//最大ID
	String Spname = null;
	String Jc = null;
	String Cd = null;
	String Dw = null;
	String Gg = null;
	String Bz = null;
	String Ph = null;
	String Pzwh = null;
	String Gysname = null;
	String Memo = null;
	String str = "select max(id) as maxint from tb_brand";
	ResultSet rs = conn.getResult(str);

	while (rs.next()) {
		String max = rs.getString("maxint"); //获得最大的字段
		String maxi = max.substring(2, max.length()); //截取子字符串
		newmax = "SP" + String.valueOf(Integer.parseInt(maxi) + 1);
	}
	Spname = request.getParameter("spname");
	Jc = request.getParameter("jc");
	Cd = request.getParameter("cd");
	Dw = request.getParameter("dw");
	Gg = request.getParameter("gg");
	Bz = request.getParameter("bz");
	Ph = request.getParameter("ph");
	Pzwh = request.getParameter("pzwh");
	Gysname = request.getParameter("gysname");
	Memo = request.getParameter("memo");
	sql = "insert into tb_brand values('" + newmax + "','" + Spname
			+ "','" + Jc + "','" + Cd + "','" + Dw + "','" + Gg + "','"
			+ Bz + "','" + Ph + "','" + Pzwh + "','" + Gysname + "','"
			+ Memo + "')";
	
	int resu = conn.executeUpdate(sql);
	if (resu == 0) {
		out.println("<script language='javascript'>alert('登记失败');"
				+ "window.location.href='khinfo.html';</script>");
	}

	else {
		out.println("<script language='javascript'>alert('登记成功');"
				+ "window.location.href='khinfo.html';</script>");
	}
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?