<%@ page contentType="text/html;charset=gb2312" language="java"%>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<%@ 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.CalendarBean"/>
<html>
<title>商品入库信息</title>
<link href="../CSS/style.css" rel="stylesheet" type="text/css">
<body>
<%
String strSql="select * from tb_kucun";
String strKh="select * from tb_customer";
String maxCount="select max(id) from tb_sell";
ResultSet rs=rst.getResult(strSql);//在下拉列表中显示销售商品名称
ResultSet rsKh=rst.getResult(strKh);
String jc=""; String gg="";String bz="";String spid="";String spname="";
String dj="";String cd="";String dw="";String kcsl="";String theMax="";
String xsspname=(String)request.getParameter("xsspname");//获得用户所选商品的简称
String rkStr="select * from tb_kucun where jc='"+xsspname+"'";
ResultSet rs1=rst.getResult(rkStr);//根据简称查询出用户所选商品
if(rs1.next()){
jc=rs1.getString("jc");gg=rs1.getString("gg");bz=rs1.getString("bz");
cd=rs1.getString("cd");dw=rs1.getString("dw");kcsl=rs1.getString("kcsl");
spid=rs1.getString("ID");spname=rs1.getString("spname");
dj=rs1.getString("dj").substring(0,3);
}
ResultSet rs2=rst.getResult(maxCount);//获得tb_ruku表中字段"id"最大的记录
if(rs2.next()){
theMax=rs2.getString(1);
}
//将最大的字段加1
String xsph="XS"+calendar.getDateString()+(Integer.parseInt(theMax.substring(10))+1);
%>
<center><h3>商品销售单</h3>
<table width="420" height="112" border="0" align="center" cellpadding="1" cellspacing="1">
<tr><td >
<form name="form1" method="post" action="spxs.jsp" >
<tr><td><select name="xsspname" onchange="spchange()">
<option >请选择销售的商品名称</option>
<%while(rs.next()){%>
<option value=<%=rs.getString("jc")%>> <%=rs.getString("spname")%> </option>
<%}%>
</select></td><td> <font color="#585858">注:带*号为必填项 </font></td></tr>
<tr><td>销售票号:<font color="#585858"><%=xsph%></font></td></tr>
<tr><td>商品名称:<font color="#585858"><%=spname%></font></td>
<td>简 称:<font color="#585858"><%=jc%></font></td>
</tr>
<tr><td>规 格:<font color="#585858"><%=gg%></font></td>
<td>包 装:<font color="#585858"><%=bz%></font></td>
</tr>
<tr><td>产 地:<font color="#585858"><%=cd%></font></td>
<td>进 价:<font color="#585858"><%=dj%>元</font></td>
</tr>
</form>
<form name="form2" method="post" action="xsChange.jsp" >
<%
session.setAttribute("jc",jc); session.setAttribute("spname",spname);
session.setAttribute("gg",gg); session.setAttribute("bz",bz);
session.setAttribute("cd",cd); session.setAttribute("xsph",xsph);
session.setAttribute("dw",dw); session.setAttribute("spid",spid);
session.setAttribute("dj",dj);
%>
<tr><td>客户全称:<select name="xskhname">
<%while(rsKh.next()){%>
<option value="<%=rsKh.getString("khname")%>"> <%=rsKh.getString("khname")%></option>
<%}%>
</select></td>
<td>库存数量:<input type="text" name="kcsl" readonly value="<%=kcsl%>">
</td></tr>
<tr><td>单 价:<input type="text" name="dj" readonly value="<%=dj%>">
<font color="#585858">(元)</font></td>
<td>金 额:<input type="text" name="je" readonly></td>
</tr>
<tr><td>数 量:<input type="text" name="sl" >
<font color="#585858">(<%=dw.trim()%>)*</font></td>
<td>应 收:<input type="text" name="ys" readonly></td>
</tr>
<tr><td>实 收:<input type="text" name="ss" onblur="autoje()">
<font color="#585858">(元)*</font></td>
<td>未 收:<input type="text" name="ws" readonly></td>
</tr>
<tr><td>操 作 员:<input type="text" name="czy" readonly value="<%=session.getAttribute("username")%>">
<font color="#585858"></font></td>
<td>经 手 人:<input type="text" name="jsr">*</td>
</tr>
<tr><td>入库日期:<input type="text" name="xsdate" readonly value="<%=calendar.getDate()%>">
<font color="#585858"></font></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%>></form>
<tr><td><input name="submit" type="button" value="保存信息" onclick="check()"></td>
<td><input type="reset" class="btn_grey" value="清除重置"></td></tr>
</form>
</td></tr>
</table>
</body>
</html>
<script language='JavaScript'>
function spchange()
{
document.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.ss.value;
if(isNaN(str)){
form2.ss.value=0;
alert("输入错误,请输入数字");form2.ss.focus();retrun;}
form2.je.value=form2.dj.value*form2.sl.value;
form2.ys.value=form2.je.value;
form2.ws.value=form2.ys.value-form2.ss.value;
if(form2.ss.value>form2.ys.value){
form2.ss.value=0;
form2.ws.value=form2.ys.value;
alert("实收金额不应大于应收金额!");form2.ss.focus();return;
}
aa=form2.kcsl.value;
form2.kcsl.value=form2.kcsl.value-form2.sl.value;
}
function check()
{
if(form2.sl.value==0){
alert("请输入数量");form2.sl.focus();return;}
if(form2.dj.value==0){
alert("请输入单价");form2.dj.focus();return;}
if(form2.ss.value==0){
alert("请输入实收");form2.sf.focus();return;}
if(form2.jsr.value==""){
alert("请输入经手人姓名");form2.jsr.focus();return;}
if(form2.kcsl.value<0){
form2.sl.value=0;form2.kcsl.value=aa;
alert("库存数量不能为空");form2.sl.focus();return;}
form2.submit();
}
</script>