ITPub博客

首页 > 数字化转型 > ERP > JSP(10) - 修改商品信息模块

JSP(10) - 修改商品信息模块

原创 ERP 作者:zhyuh 时间:2005-06-14 21:48:37 0 删除 编辑
该模块类似于 修改客户信息模块(http://blog.itpub.net/post/334/31813)[@more@]

upt_comm1.jsp:

<%@ page contentType="text/html; charset=GBK" %>



<br />请输入要修改的商品的编号


<!---->



请输入要修改的商品编号

          type="button" value="取消" name="cancel">




upt_comm2.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
java.util.Date d = new java.util.Date();
DateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINESE);
%>






修改商品信息




<%
String sCommID = request.getParameter("comm_id");
String sCommName = "";
String sCommCate = "";
String sCommUnit = null;
String sCommQutt = null;
String sCommUptDt = null;
String sCommColor = "";
String sCommSize = "";


Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl???????SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
ResultSet rs = null;
String sQuery = null;
Statement stmt = null;


try {
sQuery = "select COMM_ID, COMM_NAME, COMM_CATE, COMM_UNIT, COMM_QUTT,";
sQuery = sQuery + "to_char(COMM_UPT_DATE,'yyyy-mm-dd') COMM_UPT_DATE, COMM_COLOR, COMM_SIZE ";
sQuery = sQuery + "from commodity where comm_id = '"+sCommID+"'";

stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);

while(rs.next())
{
sCommID = rs.getString("COMM_ID");
sCommName = rs.getString("COMM_NAME");
sCommCate = rs.getString("COMM_CATE");
if (sCommCate==null) sCommCate="";
sCommUnit = rs.getString("COMM_UNIT");
sCommQutt = rs.getString("COMM_QUTT");
sCommUptDt = rs.getString("COMM_UPT_DATE");
sCommColor = rs.getString("COMM_COLOR");
if (sCommColor==null) sCommColor="";
sCommSize = rs.getString("COMM_SIZE");
if (sCommSize==null) sCommSize="";
}

rs.close();
stmt.close();
conn.close();
}

catch (Exception e){
System.out.println("检索商品信息失败!");
e.printStackTrace();
out.println("

检索商品信息失败!

");
out.println( e.getMessage() );
}

finally{
if(stmt != null) stmt.close();
conn.close();
}

%>


修改商品信息


商品编号: 

商品名称: 

类别:     

单价:     

颜色:     

尺寸:     

库存:     

修改日起:


           







upt_comm3.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>




修改商品信息




<%
String sCommID = request.getParameter("comm_id");
String sCommName = request.getParameter("comm_name");
String sCommCate = request.getParameter("comm_cate");
String sCommUnit = request.getParameter("comm_unit");
String sCommQutt = request.getParameter("comm_qutt");
String sCommUptDt = request.getParameter("comm_upt_date");
String sCommColor = request.getParameter("comm_color");
String sCommSize = request.getParameter("comm_size");

String sCommID2 = new String(sCommID.getBytes("iso-8859-1"),"GBK");
String sCommName2 = new String(sCommName.getBytes("iso-8859-1"),"GBK");
String sCommCate2 = new String(sCommCate.getBytes("iso-8859-1"),"GBK");
String sCommColor2 = new String(sCommColor.getBytes("iso-8859-1"),"GBK");
String sCommSize2 = new String(sCommSize.getBytes("iso-8859-1"),"GBK");

Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@TCSCH074.tcsgdccn.com:1521:orcl";
//orcl为你的数据库的SID
String user="store";
String password="store";
Connection conn= DriverManager.getConnection(url,user,password);
String sUpdate = null;
Statement stmt = null;

try{

sUpdate = "update commodity set comm_cate='"+sCommCate2+
"',comm_unit="+sCommUnit+
",comm_color='"+sCommColor2+
"',comm_size='"+sCommSize2+
"',comm_upt_date=to_date('"+sCommUptDt+
"','yyyy-mm-dd') where comm_id='"+sCommID2+"'";

//out.println(sUpdate+"
");
stmt = conn.createStatement();
stmt.execute(sUpdate);
conn.commit();
out.println("修改商品"+sCommName2+"信息完成");
}
catch(Exception e){
System.out.println("修改商品信息失败!");
e.printStackTrace();
out.println("

修改商品信息失败!

");
out.println( e.getMessage() );
out.println("

");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}

%>

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/207/viewspace-800203/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    233
  • 访问量
    2008662