首页上一页 1 下一页尾页 1 条记录 1/1页
在进行商品入库操作时点击保存无法跳转页面(一直停在那个页面)也没有在tomcat显示错误,之后在数据库中也无法找到相应的数据,表单及代码如下
发表在JavaWeb图书答疑
2014-04-18
是否精华
是
否
版块置顶:
是
否
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ page import="java.sql.*,java.io.*"%>
<%@ page import="com.mingri.dbconn.DBResult"%>
<jsp:useBean id="rst" scope="page" class="com.mingri.dbconn.DBResult"/>
<jsp:useBean id="calendar" scope="page" class="com.mingri.showtime.CalendarBean"/>
<%
request.setCharacterEncoding("gb2312");//解决表单提交中的中文乱码问题
//获取表单数据
String jc=(String)session.getAttribute("jc"); String spname=(String)session.getAttribute("spname");
String gg=(String)session.getAttribute("gg"); String thid=(String)session.getAttribute("rkbh");
String bz=(String)session.getAttribute("bz"); String gysname=(String)session.getAttribute("gysname");
String cd=(String)session.getAttribute("cd"); String spid=(String)session.getAttribute("spid");
String dw=(String)session.getAttribute("dw");
String sl=(String)request.getParameter("sl"); String czy=(String)request.getParameter("czy");
String je=(String)request.getParameter("je"); String jsr=(String)request.getParameter("jsr");
String dj=(String)request.getParameter("dj"); String thdate=(String)request.getParameter("rkdate");
String yf=(String)request.getParameter("yf"); String jsfs=(String)request.getParameter("jsfs");
String sf=(String)request.getParameter("sf"); String wf=(String)request.getParameter("wf");
String whether="";
if(wf.equals("0")){//记录商品入库时是否有未付款
whether="是";
}else{
whether="否";
}
String theMax="";
//保存入库退货信息
String rukuthSql="insert into tb_rukuth values('"+thid+"','"+spid+"','"+spname+"',"+
"'"+jc+"','"+cd+"','"+gg+"','"+bz+"','"+dw+"',"+dj+",'"+sl+"',"+je+","+
"'"+gysname+"','"+thdate+"','"+czy+"','"+jsr+"','"+jsfs+"')";
//保存入库退货票号信息
String rkphSql="insert into tb_thph_rk values('"+thid+"','"+sl+"',"+yf+","+sf+","+
""+wf+",'"+gysname+"','"+thdate+"','"+czy+"','"+jsr+"','"+jsfs+"','"+whether+"')";
//保存或修改库存信息
String rkkcSelect="select * from tb_kucun where id='"+spid+"'";
ResultSet rkkc=rst.getResult(rkkcSelect);
String rkkcSql="";
//判断库存中是否有该商品,如果有则修改库存信息,否则提示出错信息
if(rkkc.next()){
rkkcSql="update tb_kucun set kcsl=kcsl-"+sl+",dj="+dj+","+
"kcje=(kcsl-"+sl+")*"+dj+" where id='"+spid+"'";
}else{
out.println("<script language='javascript'>alert('库存中没有该商品不能退货');"+
"window.location.href='sprkth.jsp';</script>");
}
rst.getResult(rkkcSql);rst.getResult(rukuthSql);rst.getResult(rkphSql);
out.println("<script language='javascript'>alert('商品入库退货成功');"+
"window.location.href='sprkth.jsp';</script>");
%>
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ page import="java.sql.*,java.io.*"%>
<jsp:useBean id="rst" scope="page" class="com.mingri.dbconn.DBResult"/>
<jsp:useBean id="calendar" scope="page" class="com.mingri.showtime.ShowTime"/>
<html>
<title>商品入库信息</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<link href="../CSS/style.css" rel="stylesheet" type="text/css">
<body>
<%
request.setCharacterEncoding("gb2312");//对字符串统一编码解决表单提交中的中文乱玛问题
String strSql="select * from tb_brand";
String maxCount="select max(id) from tb_ruku";//在入库表中查找出最大的id号
ResultSet rs=rst.getResult(strSql);//在下拉列表中显示商品名称
String jc=""; String gg="";String bz="";String spid="";String spname="";
String gysname="";String cd="";String dw="";String theMax="";
String rkspname=(String)request.getParameter("rkspname");//获得用户所选商品的简称
String rkStr="select * from tb_brand where spname='"+rkspname+"'";
ResultSet rs1=rst.getResult(rkStr);//根据商品名称查询出用户所选商品
if(rs1.next()){
jc=rs1.getString("jc");gg=rs1.getString("gg");bz=rs1.getString("bz");
gysname=rs1.getString("gysname"); cd=rs1.getString("cd");dw=rs1.getString("dw");
spid=rs1.getString("ID");spname=rs1.getString("spname");
}
ResultSet rs2=rst.getResult(maxCount);//获得tb_ruku表中字段"id"最大的记录
if(rs2.next()){
theMax=rs2.getString(1);
}
//将最大的字段加1
String rkbh="RK"+calendar.getDateString()+(Integer.parseInt(theMax.substring(10))+1);
%>
<table width="584" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="27" colspan="6" bgcolor="#EEEEEE" class="tableBorder_gray">
<span class="word_deepgrey"> 当前位置:库存管理 </span>商品入库 >>></td>
</tr>
<tr><td valign="top" height="83"><br>
<table width="98%" height="112" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#F2F2F2">
<tr><td width="274" >
<form name="form1" method="post" action="sprk.jsp" >
<tr><td height="27"> <select name="rkspname" onChange="spchange()">
<option selected="selected">请选择入库商品的商品名称</option>
<%while(rs.next()){%>
<option value=<%=rs.getString("spname")%>> <%=rs.getString("spname")%> </option>
<%}%>
</select></td><td width="276"> 注:带*号为必填项 </td></tr>
<tr><td height="27"> 入库编号:<font color="#585858"><%=rkbh%></font></td></tr>
<tr><td height="27"> 商品名称:<font color="#585858"><%=spname%></font></td>
<td> 简 称:<font color="#585858"><%=jc%></font></td>
</tr>
<tr><td height="27"> 规 格:<font color="#585858"><%=gg%></font></td>
<td> 包 装:<font color="#585858"><%=bz%></font></td>
</tr>
<tr><td height="27"> 供应商全称:<font color="#585858"><%=gysname%></font></td>
<td> 产 地:<font color="#585858"><%=cd%></font></td>
</tr>
<form name="form2" method="post" action="spChange.jsp" >
<%
session.setAttribute("jc",jc); session.setAttribute("spname",spname);
session.setAttribute("gg",gg); session.setAttribute("bz",bz);
session.setAttribute("cd",cd); session.setAttribute("rkbh",rkbh);
session.setAttribute("dw",dw); session.setAttribute("spid",spid);
session.setAttribute("gysname",gysname);
%>
<tr><td height="27"> 数 量:<input type="text" name="sl" onBlur="autoje()">
(<%=dw%>)*</td>
<td> 金 额:<input type="text" name="je" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 单 价:<input type="text" name="dj" onBlur="autoje()">
(元)*</td>
<td> 应 付:<input type="text" name="yf" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 实 付:<input type="text" name="sf" onBlur="autoje()">
(元)*</td>
<td> 未 付:<input type="text" name="wf" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 操作员:<input type="text" name="czy" readonly value="<%=session.getAttribute("username")%>">
</td>
<td> 经手人:<select name="jsr">
<option value="张静" >张静</option>
<option value="莫锦花" >莫锦花</option>
<option value="田达" >田达</option>
<option value="黄鑫" >黄鑫</option>
<option value="张三" >张三</option>
<option value="黄锡" >黄锡</option>
<option value="张四" >张四</option>
<option value="张春" >张春</option>
</select></td>
</tr>
<tr><td height="27"> 入库日期:<input type="text" name="rkdate" readonly value="<%=calendar.getDate()%>">
</td>
<td> 结算方式:<select name="jsfs">
<option value="现金" selected>现金</option>
<option value="yf" >预付</option>
<option value="zp" >支票</option>
<option value="gz" >挂账</option></select></td>
</tr>
<input type="hidden" name="hjc" value=<%=jc%>>
<tr><td height="40" colspan="2" align="center">
<input name="mySubmit" type="button" value="保存信息" onclick="check()" class="btn_grey">
<input name="myeset"type="reset" class="btn_grey" value="清除重置" onClick="myreset()"></td>
</tr>
</table> </td></tr>
</table>
</body>
</html>
<script language='JavaScript'>
function spchange()
{
form1.submit();
}
function autoje()
{
str=form2.sl.value;
if(isNaN(str)){//判断输入是否为数字
form2.sl.value=0;
alert("输入错误,请输入数字");form2.sl.focus();retrun;}
str=form2.dj.value;
if(isNaN(str)){
form2.dj.value=0;
alert("输入错误,请输入数字");form2.dj.focus();retrun;}
str=form2.sf.value;
if(isNaN(str)){
form2.sf.value=0;
alert("输入错误,请输入数字");form2.sf.focus();retrun;}
//自动计算金额、应收及未收款
form2.je.value=form2.dj.value*form2.sl.value;
form2.yf.value=form2.je.value;
form2.wf.value=form2.yf.value-form2.sf.value;
if(form2.sf.value-form2.yf.value>0){
form2.sf.value=0;
form2.wf.value=form2.yf.value;
alert("实付金额不应大于应付金额!");form2.sf.focus();return;
}
}
function check()
{
if(form2.sl.value==0){
alert("请输入数量");form2.sl.focus();return;}
if(form2.dj.value==0){
alert("请输入单价");form2.dj.focus();return;}
if(form2.sf.value==0){
alert("请输入实付");form2.sf.focus();return;}
if(form2.jsr.value==""){
alert("请输入经手人姓名");form2.jsr.focus();return;}
form2.submit();
}
function myreset()
{
form2.reset();
}
</script>
<%@ page import="java.sql.*,java.io.*"%>
<%@ page import="com.mingri.dbconn.DBResult"%>
<jsp:useBean id="rst" scope="page" class="com.mingri.dbconn.DBResult"/>
<jsp:useBean id="calendar" scope="page" class="com.mingri.showtime.CalendarBean"/>
<%
request.setCharacterEncoding("gb2312");//解决表单提交中的中文乱码问题
//获取表单数据
String jc=(String)session.getAttribute("jc"); String spname=(String)session.getAttribute("spname");
String gg=(String)session.getAttribute("gg"); String thid=(String)session.getAttribute("rkbh");
String bz=(String)session.getAttribute("bz"); String gysname=(String)session.getAttribute("gysname");
String cd=(String)session.getAttribute("cd"); String spid=(String)session.getAttribute("spid");
String dw=(String)session.getAttribute("dw");
String sl=(String)request.getParameter("sl"); String czy=(String)request.getParameter("czy");
String je=(String)request.getParameter("je"); String jsr=(String)request.getParameter("jsr");
String dj=(String)request.getParameter("dj"); String thdate=(String)request.getParameter("rkdate");
String yf=(String)request.getParameter("yf"); String jsfs=(String)request.getParameter("jsfs");
String sf=(String)request.getParameter("sf"); String wf=(String)request.getParameter("wf");
String whether="";
if(wf.equals("0")){//记录商品入库时是否有未付款
whether="是";
}else{
whether="否";
}
String theMax="";
//保存入库退货信息
String rukuthSql="insert into tb_rukuth values('"+thid+"','"+spid+"','"+spname+"',"+
"'"+jc+"','"+cd+"','"+gg+"','"+bz+"','"+dw+"',"+dj+",'"+sl+"',"+je+","+
"'"+gysname+"','"+thdate+"','"+czy+"','"+jsr+"','"+jsfs+"')";
//保存入库退货票号信息
String rkphSql="insert into tb_thph_rk values('"+thid+"','"+sl+"',"+yf+","+sf+","+
""+wf+",'"+gysname+"','"+thdate+"','"+czy+"','"+jsr+"','"+jsfs+"','"+whether+"')";
//保存或修改库存信息
String rkkcSelect="select * from tb_kucun where id='"+spid+"'";
ResultSet rkkc=rst.getResult(rkkcSelect);
String rkkcSql="";
//判断库存中是否有该商品,如果有则修改库存信息,否则提示出错信息
if(rkkc.next()){
rkkcSql="update tb_kucun set kcsl=kcsl-"+sl+",dj="+dj+","+
"kcje=(kcsl-"+sl+")*"+dj+" where id='"+spid+"'";
}else{
out.println("<script language='javascript'>alert('库存中没有该商品不能退货');"+
"window.location.href='sprkth.jsp';</script>");
}
rst.getResult(rkkcSql);rst.getResult(rukuthSql);rst.getResult(rkphSql);
out.println("<script language='javascript'>alert('商品入库退货成功');"+
"window.location.href='sprkth.jsp';</script>");
%>
<%@ page contentType="text/html;charset=gb2312" language="java"%>
<%@ page import="java.sql.*,java.io.*"%>
<jsp:useBean id="rst" scope="page" class="com.mingri.dbconn.DBResult"/>
<jsp:useBean id="calendar" scope="page" class="com.mingri.showtime.ShowTime"/>
<html>
<title>商品入库信息</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<link href="../CSS/style.css" rel="stylesheet" type="text/css">
<body>
<%
request.setCharacterEncoding("gb2312");//对字符串统一编码解决表单提交中的中文乱玛问题
String strSql="select * from tb_brand";
String maxCount="select max(id) from tb_ruku";//在入库表中查找出最大的id号
ResultSet rs=rst.getResult(strSql);//在下拉列表中显示商品名称
String jc=""; String gg="";String bz="";String spid="";String spname="";
String gysname="";String cd="";String dw="";String theMax="";
String rkspname=(String)request.getParameter("rkspname");//获得用户所选商品的简称
String rkStr="select * from tb_brand where spname='"+rkspname+"'";
ResultSet rs1=rst.getResult(rkStr);//根据商品名称查询出用户所选商品
if(rs1.next()){
jc=rs1.getString("jc");gg=rs1.getString("gg");bz=rs1.getString("bz");
gysname=rs1.getString("gysname"); cd=rs1.getString("cd");dw=rs1.getString("dw");
spid=rs1.getString("ID");spname=rs1.getString("spname");
}
ResultSet rs2=rst.getResult(maxCount);//获得tb_ruku表中字段"id"最大的记录
if(rs2.next()){
theMax=rs2.getString(1);
}
//将最大的字段加1
String rkbh="RK"+calendar.getDateString()+(Integer.parseInt(theMax.substring(10))+1);
%>
<table width="584" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="27" colspan="6" bgcolor="#EEEEEE" class="tableBorder_gray">
<span class="word_deepgrey"> 当前位置:库存管理 </span>商品入库 >>></td>
</tr>
<tr><td valign="top" height="83"><br>
<table width="98%" height="112" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#F2F2F2">
<tr><td width="274" >
<form name="form1" method="post" action="sprk.jsp" >
<tr><td height="27"> <select name="rkspname" onChange="spchange()">
<option selected="selected">请选择入库商品的商品名称</option>
<%while(rs.next()){%>
<option value=<%=rs.getString("spname")%>> <%=rs.getString("spname")%> </option>
<%}%>
</select></td><td width="276"> 注:带*号为必填项 </td></tr>
<tr><td height="27"> 入库编号:<font color="#585858"><%=rkbh%></font></td></tr>
<tr><td height="27"> 商品名称:<font color="#585858"><%=spname%></font></td>
<td> 简 称:<font color="#585858"><%=jc%></font></td>
</tr>
<tr><td height="27"> 规 格:<font color="#585858"><%=gg%></font></td>
<td> 包 装:<font color="#585858"><%=bz%></font></td>
</tr>
<tr><td height="27"> 供应商全称:<font color="#585858"><%=gysname%></font></td>
<td> 产 地:<font color="#585858"><%=cd%></font></td>
</tr>
<form name="form2" method="post" action="spChange.jsp" >
<%
session.setAttribute("jc",jc); session.setAttribute("spname",spname);
session.setAttribute("gg",gg); session.setAttribute("bz",bz);
session.setAttribute("cd",cd); session.setAttribute("rkbh",rkbh);
session.setAttribute("dw",dw); session.setAttribute("spid",spid);
session.setAttribute("gysname",gysname);
%>
<tr><td height="27"> 数 量:<input type="text" name="sl" onBlur="autoje()">
(<%=dw%>)*</td>
<td> 金 额:<input type="text" name="je" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 单 价:<input type="text" name="dj" onBlur="autoje()">
(元)*</td>
<td> 应 付:<input type="text" name="yf" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 实 付:<input type="text" name="sf" onBlur="autoje()">
(元)*</td>
<td> 未 付:<input type="text" name="wf" onBlur="autoje()"></td>
</tr>
<tr><td height="27"> 操作员:<input type="text" name="czy" readonly value="<%=session.getAttribute("username")%>">
</td>
<td> 经手人:<select name="jsr">
<option value="张静" >张静</option>
<option value="莫锦花" >莫锦花</option>
<option value="田达" >田达</option>
<option value="黄鑫" >黄鑫</option>
<option value="张三" >张三</option>
<option value="黄锡" >黄锡</option>
<option value="张四" >张四</option>
<option value="张春" >张春</option>
</select></td>
</tr>
<tr><td height="27"> 入库日期:<input type="text" name="rkdate" readonly value="<%=calendar.getDate()%>">
</td>
<td> 结算方式:<select name="jsfs">
<option value="现金" selected>现金</option>
<option value="yf" >预付</option>
<option value="zp" >支票</option>
<option value="gz" >挂账</option></select></td>
</tr>
<input type="hidden" name="hjc" value=<%=jc%>>
<tr><td height="40" colspan="2" align="center">
<input name="mySubmit" type="button" value="保存信息" onclick="check()" class="btn_grey">
<input name="myeset"type="reset" class="btn_grey" value="清除重置" onClick="myreset()"></td>
</tr>
</table> </td></tr>
</table>
</body>
</html>
<script language='JavaScript'>
function spchange()
{
form1.submit();
}
function autoje()
{
str=form2.sl.value;
if(isNaN(str)){//判断输入是否为数字
form2.sl.value=0;
alert("输入错误,请输入数字");form2.sl.focus();retrun;}
str=form2.dj.value;
if(isNaN(str)){
form2.dj.value=0;
alert("输入错误,请输入数字");form2.dj.focus();retrun;}
str=form2.sf.value;
if(isNaN(str)){
form2.sf.value=0;
alert("输入错误,请输入数字");form2.sf.focus();retrun;}
//自动计算金额、应收及未收款
form2.je.value=form2.dj.value*form2.sl.value;
form2.yf.value=form2.je.value;
form2.wf.value=form2.yf.value-form2.sf.value;
if(form2.sf.value-form2.yf.value>0){
form2.sf.value=0;
form2.wf.value=form2.yf.value;
alert("实付金额不应大于应付金额!");form2.sf.focus();return;
}
}
function check()
{
if(form2.sl.value==0){
alert("请输入数量");form2.sl.focus();return;}
if(form2.dj.value==0){
alert("请输入单价");form2.dj.focus();return;}
if(form2.sf.value==0){
alert("请输入实付");form2.sf.focus();return;}
if(form2.jsr.value==""){
alert("请输入经手人姓名");form2.jsr.focus();return;}
form2.submit();
}
function myreset()
{
form2.reset();
}
</script>