我做的个库存管理系统,在出库的时候判断所要出库的数量不大于库存量,我不知道具体格式是什么样,哪位高手帮我改改.其中rs.getString("shuliang")是库存量,'"+shuliang+"'是要取的数量
代码如下:
while (rs.next())
{
  
 
 if(rs.getString("shuliang"))<='"+shuliang+"')
 {
  sql="insert into rkb(shijian,fangshi,danwei,fenlei,mingcheng,xinghao,danjia,shuliang,jldw,heji,fl) values (to_date('"+shijian+"','yyyy-mm-dd'),'"+fangshi+"','"+danwei+"','"+department+"','"+division+"','"+speciality+"','"+danjia+"','"+shuliang+"','"+jldw+"','"+heji+"','0')";
  sql1="update wupinbiao set shuliang=shuliang-'"+shuliang+"',heji=heji-'"+heji+"' where  FENLEI='"+department+"' and LEIXING='"+division+"' and XINGHAO='"+speciality+"'  ";
  stmt.executeUpdate(sql);
  stmt.executeUpdate(sql1);
  response.sendRedirect("d.htm");
  }

解决方案 »

  1.   

    如果库存不足则提示
     else
      {
      %>
    <html>
    <body>
    <p><a href="Register.jsp">请返回</a></p>
    </body>
     </html>
      <%
       out.println("对不起,库存不够出库的数量");
      }
      %>
      

  2.   

    我不建议LZ这样写.
    while中嵌套sql的insert和update.执行效率慢而且错误率高.
    你可以先把所有想要的放一变量中
    然后进行变量的判断
      

  3.   

    if(rs.getString("shuliang")<='"+shuliang+"')
    这句话报unclosed character literal的错误
      

  4.   

    这样对吗?
    if(xx>=(int)request.getParameter("shuliang"))
    提示错误如下
    /usr/java/jakarta-tomcat-5.0.28/work/Catalina/localhost/_/org/apache/jsp/shouji/chukutj_jsp.java:127: inconvertible types
    found   : java.lang.String
    required: int
     if(xx>=(int)request.getParameter("shuliang"))
                                     ^