以前有个完整版的。我想修改下,加了点东西但是不能用了。
[code="java"]<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="java.sql.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.StringTokenizer"%>
<%
request.setCharacterEncoding("UTF-8");
//String tmp = new String(request.getParameter("tmp").getBytes("ISO-8859-1"),"utf-8") ;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String systime = sdf.format(new java.util.Date());
String tmp = request.getParameter("tmp");
StringTokenizer st = null;
StringTokenizer st2 = null;
if(tmp != null){
tmp = new String(tmp.getBytes("ISO-8859-1"),"UTF-8");
st = new StringTokenizer(tmp,"|");
st2 = new StringTokenizer(tmp,"|");
}
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:ORCL";
//orcl为你的数据库的SID
String user="boo";
String password="boo";
String leixing[] = {"nothing","矿粉石料室","焦炭室","焦煤室","喷吹煤室","合金室"};//更改部分
String pinzhong[] = {"nothing","国内矿粉(炼铁)","竖炉球(炼铁)","竖炉球(青龙自产)","锰矿","钛矿","石灰石粉","白云石粉","白灰面","石灰石","轻烧白云石","石灰","精炼萤石","白云石渣","硅灰石","外购焦炭","主焦煤","肥煤","1/3焦煤","瘦煤","洗精煤合计","喷吹白煤","喷吹烟煤","烧结煤","硅锰合金","高碳锰铁","硅铁","锌锭","其他合金","生铁"};//更改部分
String yuefen[] = {"nothing","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
if(st!= null){
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
// 删除
st2.nextToken();
st2.nextToken();
st2.nextToken();
String month = yuefen[Integer.parseInt(st2.nextToken())];
String year = st2.nextToken();
String sql2 = "delete from steelanalysis where nianfen='"+year+"' and yuefen='"+month+"'";
System.out.println(sql2);
stmt.execute(sql2);
// 添加
String sql="insert into steelanalysis(submittime,leixing,pinzhong,yuefen,nianfen,jihua,junjia,jine) values('"+st.nextToken()+"','"+leixing[Integer.parseInt(st.nextToken())]+"','"+pinzhong[Integer.parseInt(st.nextToken())]+"','"+yuefen[Integer.parseInt(st.nextToken())]+"','"+st.nextToken()+"','"+st.nextToken()+"','"+st.nextToken()+"','"+st.nextToken()+"')";//添加部分为junjia,jine
System.out.println(sql);
ResultSet rs=stmt.executeQuery(sql);
stmt.execute("commit");
rs.close();
stmt.close();
conn.close();
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
My JSP 'index.jsp' starting page
<script type="text/javascript">
function doSubmit(){
var liexing = getSelectValue('leixing');
var pinzhong = getSelectValue('pinzhong');
var yuefen = getSelectValue('yuefen');
var nianfen = getSelectValue('nianfen');
var jihua = document.getElementById("jihua").value;//添加部分
var junjia = document.getElementById("junjia").value;//添加部分
var jine = document.getElementById("jine").value;
var systime=document.getElementById("systime").value;
var tmp = systime+'|'+liexing+'|'+pinzhong+'|'+yuefen+'|'+nianfen+'|'+jihua+'|'+junjia+'|'+jine;//添加部分junjia,jine
document.submitform.action="steelanalysis.jsp?tmp="+tmp;
if(confirm("确认提交吗?")){
alert('提交完毕');
document.submitform.submit();
}
}
function getSelectValue(id){
var _selObj=document.getElementById(id);//取下拉框的元素
var _selVal=_selObj[_selObj.selectedIndex].value;//取下拉框被选中的值
return _selVal;
}
</script>
类型 |
矿粉石料室 焦炭室 焦煤室 喷吹煤室 合金室 |
品种 |
国内矿粉(炼铁) 竖炉球(炼铁) 竖炉球(青龙自产) 锰矿 钛矿 石灰石粉 白云石粉 白灰面 石灰石 轻烧白云石 石灰 精炼萤石 白云石渣 硅灰石 外购焦炭 主焦煤 肥煤 1/3焦煤 瘦煤 洗精煤合计 喷吹白煤 喷吹烟煤 烧结煤 硅锰合金 高碳锰铁 硅铁 锌锭 其他合金 生铁
|