在新增一个业务时,在JSP页面上自动生成一个有序的序号
<tdwidth="135"><inputname="bgd"type="text"size="18"></td>比如在这里input里面自动生成一个有序的序号比如200...
<td width="135"><input name="bgd" type="text" size="18" ></td>
比如在这里input里面自动生成一个有序的序号
比如2009XZYW0001,下次在新增时就是2009XZYW0002以此类推。
帮忙写出来,谢谢! 展开
比如在这里input里面自动生成一个有序的序号
比如2009XZYW0001,下次在新增时就是2009XZYW0002以此类推。
帮忙写出来,谢谢! 展开
3个回答
展开全部
<%@ page import="java.text.*" %>
<%
String time = "";
SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
time = dformat.format(new java.util.Date());
time = time.replaceAll("-","");
time = time.replaceAll(" ","");
time = time.substring(0,4);
String ReportType=request.getParameter("ReportType");
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
SQLBean_JDBC so = new SQLBean_JDBC();
String stringSql="";
String serial4="";
stringSql = "select max(convert(int,substring(yewubaogaodanhao,9,4)))+1 as yewubaogaodanhao "
+" from tuoyun where substring(yewubaogaodanhao,1,4)='"+time+"'";
String serial= "";
try{
conn = so.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(stringSql);
}
catch (Exception ex) {
System.out.println("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
}
while (rs.next()){
try {
serial4 = rs.getString("yewubaogaodanhao");
%>
<%
} catch (Exception ex) {
System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ ex.getMessage());
%>
<%
}
}
rs.close();
stmt.close();
conn.close();
if(serial4==null){serial4="0001";}
if(serial4.length()==1){serial4="000"+serial4;}
if(serial4.length()==2){serial4="00"+serial4;}
if(serial4.length()==3){serial4="0"+serial4;}
serial = time+"RLMD"+serial4;
%>
<%
String time = "";
SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
time = dformat.format(new java.util.Date());
time = time.replaceAll("-","");
time = time.replaceAll(" ","");
time = time.substring(0,4);
String ReportType=request.getParameter("ReportType");
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
SQLBean_JDBC so = new SQLBean_JDBC();
String stringSql="";
String serial4="";
stringSql = "select max(convert(int,substring(yewubaogaodanhao,9,4)))+1 as yewubaogaodanhao "
+" from tuoyun where substring(yewubaogaodanhao,1,4)='"+time+"'";
String serial= "";
try{
conn = so.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery(stringSql);
}
catch (Exception ex) {
System.out.println("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
}
while (rs.next()){
try {
serial4 = rs.getString("yewubaogaodanhao");
%>
<%
} catch (Exception ex) {
System.out.println("qqqqqqqqqqqqqqqqqqqqqqqqqqq"
+ ex.getMessage());
%>
<%
}
}
rs.close();
stmt.close();
conn.close();
if(serial4==null){serial4="0001";}
if(serial4.length()==1){serial4="000"+serial4;}
if(serial4.length()==2){serial4="00"+serial4;}
if(serial4.length()==3){serial4="0"+serial4;}
serial = time+"RLMD"+serial4;
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询