⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsp1.jsp~56~

📁 JAVA实验图形 =各种 的 JAVA简单代码 出初学者必备!!!!!!!!!
💻 JSP~56~
字号:
<%@page contentType="text/html; charset=GBK"%><%@page import="java.sql.*"%>
<%request.setCharacterEncoding("gb2312");%>
<%!
int bjiage=1;
int balljiage=1;
int booknum=1;
int n1=1;

%>
<link href="2.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function mycheck(){
alert("恭喜,申请成功,请转入发票页!");
response.sendRedirect("jsp6.jsp");
}
</script>

<HTML><BODY><center>
<div id="container">

<center><font SIZE="30" color="red">申请教材
</font>
<marquee direction="left" scrollamount="2" scrolldelay="1" width="150" height="80">  <img border=1 src="images/1.png"><img border=1 src="images/2.png"><img border=1 src="images/3.png"><img border=1 src="images/4.png"><img border=1 src="images/5.png"><img border=1 src="images/6.png"><img border=1 src="images/7.png">
</marquee>
  <div id="Header"><div id="menu">
<ul>
    <li><a href="jsp3.jsp">查看可申请教材目录</a></li>
    <li class="menuDiv"></li>
    <li><a href="jsp2.jsp">返回主页</a><br></li>
    <li class="menuDiv"></li>
</ul>
</div></div> 
<html><body>
<%
  String getsno = request.getParameter("sno");
  String getbnum = request.getParameter("bnum");
  String getbooknum= request.getParameter("booknum");
%>
<A href=jsp6.jsp?sno=<%=getsno%>>
<center><font SIZE="30" color="red">领取发票</font></A>
<%
     Statement stmt=null;
        PreparedStatement pstmt=null;
String str = "select * from s where bnum='"+getbnum+"'";

        //加载JDBC-ODBC桥驱动
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            //定义JDBC URL
        }catch (Exception e) {
        out.println(e.getMessage());
        }
          try{ System.out.print("SQL:" + str);
            String url = "jdbc:odbc:s";
            //得到与数据库的连接
            Connection con = DriverManager.getConnection(url);
              stmt = con.createStatement();
            ResultSet g = stmt.executeQuery(str);
 while(g.next())
 {
          bjiage=g.getInt("bjiage");
          balljiage=Integer.parseInt(getbooknum)*bjiage;
          booknum=g.getInt("booknum");
         n1 = booknum- Integer.parseInt(getbooknum);

  if(n1>=0)
 { out.print(""+n1);
  str= "update s set booknum='"+n1 +"' where bnum like'"+getbnum+"'";
    ResultSet h = stmt.executeQuery(str);
 }
if(n1<0)
 {
   n1=-n1;
   out.print("<script>type='text/JavaScript'>alert('对不起 该教材已经没有库存!请等候通知');</script>");
    str= "insert into waitbuybook(sno,bnum,booknum) VALUES("+getsno+"," +getbnum + "," +n1+ ")";
      ResultSet h = stmt.executeQuery(str);out.print(""+str);
    }
 }
            } catch (Exception e) {}

            String sql = "insert into fapiao(sno,bnum,bjiage,booknum,balljiage) VALUES(" +getsno+
                  "," +getbnum + "," +bjiage + "," +getbooknum + "," +balljiage + ")";
        //加载JDBC-ODBC桥驱动
        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            //定义JDBC URL
        }catch (Exception e) {
        out.println(e.getMessage());
        }
          try{

        String url = "jdbc:odbc:s";
            //得到与数据库的连接
            Connection con = DriverManager.getConnection(url);
            //显示UPL和连接信息
            System.out.print("URL:" + url);
            System.out.print("Connection:" + con);
            //得到一个Statement对象
            stmt = con.createStatement();
            //执行SQL语句
            System.out.print("SQL:" + sql);
            ResultSet p = stmt.executeQuery(sql);
            } catch (Exception e) {}
%>
<FORM Action="jsp1.jsp" method="POST" name="myform">
请输入学号<input type="text" name="sno" style="height:18px;width:100px">&nbsp;&nbsp;
请输入要申请的教材号<input type="text" name="bnum" style="height:18px;width:100px">&nbsp;&nbsp;
请输入要申请的教材数量<input type="text" name="booknum" style="height:18px;width:100px">&nbsp;&nbsp;
<br><br><br><br><br><input type=submit name="submit" value="申请教材" onclick="mycheck()">
</FORM></center>
</HTML></BODY>

⌨️ 快捷键说明

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