文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

JSP(12) - 商品处理模块

2023-06-03 08:46

关注
该模块基本上为 进货模块(http://blog.itpub.net/post/334/32287)的反过程。[@more@]

dispose_bef.jsp:

<%@ page contentType="text/html; charset=GBK" %>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.text.DateFormat" %>
<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader("Expires", 0); //prevents caching at the proxy server

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 sExchId = request.getParameter("exch_id");
String sExchName = "";
String sExchUnit = "";
String sExchQutt = "";

String sCommQutt = request.getParameter("exch_qutt");

boolean rsnull=true;

if(sExchId != null && !sExchId.equals("")){

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 sQuery = null;
Statement stmt = null;
ResultSet rs = null;

try{

sQuery = "select comm_name, comm_unit, comm_qutt from commodity ";
sQuery = sQuery + " where comm_id='"+sExchId+"'";

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

while(rs.next())
{
rsnull=false;
sExchName = rs.getString("comm_name");
sExchUnit = rs.getString("comm_unit");
sExchQutt = rs.getString("comm_qutt");
}

}
catch(Exception e){
System.out.println("检索商品信息时出错!");
e.printStackTrace();
out.println("

检索商品信息时出错!请联系技术支持人员。

");
out.println( e.getMessage() );
out.println("");
}
finally{
if(stmt != null) stmt.close();
conn.close();
}
}
%>





进货







<!--

-->



javascript:window.alert("商品编号不存在!")<%}%>>

<!---->

处理


商品编号: 

当日处理批次:  


         




商品名称: 

单价: 

库存: 






dispose_aft.jsp:

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






处理







<%
String sExchSeq = request.getParameter("exch_seq");
String sExchCommID = request.getParameter("exch_id");
String sExchCustID = "000001";
String sExchQutt = request.getParameter("exch_qutt");
String sExchDate = request.getParameter("exch_date");

String sCommName = null;
String sCommQutt = null;
String sCommUnit = null;
String sExchMon = null;

if (sExchSeq.equals("")){
throw new Exception("当日进货批次不准为空");
}
if (sExchCommID.equals("")){
throw new Exception("商品编号不准为空!");
}
if (sExchQutt.equals("")){
throw new Exception("进货数量不准为空!");
}

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 sInsert = null;
String sQuery = null;
String sUpdate = null;
Statement stmt = null;
ResultSet rs = null;

try {
sQuery = "select comm_name,comm_qutt,comm_unit from commodity where comm_id='"+sExchCommID+"'";

stmt = conn.createStatement();
rs = stmt.executeQuery(sQuery);
if (rs.next()) {
sCommName = rs.getString("comm_name");
sCommQutt = rs.getString("comm_qutt");
sCommUnit = rs.getString("comm_unit");
}

sExchMon = String.valueOf(Double.parseDouble(sCommUnit)*Double.parseDouble(sExchQutt));

sInsert = "insert into exchange(EXCH_SEQ, EXCH_CST_ID, EXCH_COMM_ID, EXCH_NB, EXCH_MON, EXCH_DATE, EXCH_TYPE) ";
sInsert = sInsert + "values("+sExchSeq+",'"+sExchCustID+"','"+sExchCommID+"',"+sExchQutt+","+sExchMon+",to_date('"+sExchDate+"','yyyy-mm-dd'),'F')";

sUpdate = "update commodity set COMM_QUTT=("+sCommQutt+"-"+sExchQutt+") where comm_id='"+sExchCommID+"'";

//out.println(sQuery+"
");
//out.println(sInsert+"
");
//out.println(sUpdate+"
");

stmt = conn.createStatement();
stmt.addBatch(sInsert);
stmt.addBatch(sUpdate);
stmt.executeBatch();

conn.commit();
out.println("商品处理完成
");
out.println("商品编号:"+sExchCommID+"
");
out.println("商品:"+sCommName+"
");
out.println("数量:"+sExchQutt+"
");
out.println("单价:"+sCommUnit+"
");
out.println("金额:"+sExchMon+"
");
}

catch (Exception e){
System.out.println("处理操作失败!");
e.printStackTrace();
out.println("处理操作失败!
");
out.println(e.getMessage());
out.println("");
}

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


阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-后端开发
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯