首页 > 其他 > 详细

POS管理系统之供应商查询

时间:2014-08-16 09:41:50      阅读:499      评论:0      收藏:0      [点我收藏+]

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
 
    <title>My JSP ‘LoginServlet.jsp‘ starting page</title>
   
  </head>
 
  <body>
        <form action="<%=request.getContextPath()%>/mfrEdit1.do" method="post">
     <table border="1">
      <tr>
       <td>厂商代码</td>
       <td><input type="text" name="cno">
       <input type="hidden" name="method" value="find"/>
       </td>
      </tr>
      <tr>
       <td>
       <input type="submit" value="查询"/>
       </td>
      </tr>
      </table>
    </form>
  </body>
</html>

package servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Cusinfo;

@SuppressWarnings("serial")
public class EditServlet1 extends HttpServlet{
 private final String URL="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
 private final String USER="gsuser";
 private final String PWD="160127";
 
 @Override
 protected void doGet(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
  
  doPost(req, resp);
 }

 @Override
 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
   throws ServletException, IOException {
  req.setCharacterEncoding("utf-8");
      String cno=req.getParameter("cno");
    int i = deletemfrEdit(cno);
    if (i > 0) {
     // 删除成功了
     resp.sendRedirect(req.getContextPath() + "/Success.jsp");
    } else {
     resp.sendRedirect("http://www.sohu.com");
    }

}
 private int deletemfrEdit(String cno) {
  String delete= "DELETE FROM MFREDIT A WHERE A.CNO=?";
  int i = 0;
  // 加载驱动
  try {
   Class.forName("oracle.jdbc.driver.OracleDriver");
  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  }
  Connection conn = null;
  PreparedStatement pstmt = null;
  try {
   conn = DriverManager.getConnection(URL, USER, PWD);
   pstmt = conn.prepareStatement(delete);
   // 设置参数
   pstmt.setString(1, cno);
   //pstmt.setString(2, cname);   // 执行
   i = pstmt.executeUpdate();
  } catch (SQLException e) {
   e.printStackTrace();
  }finally {
   try {
   if (pstmt != null) {
    pstmt.close();
   }
   if (conn != null) {
    conn.close();
   }
  } catch (SQLException e) {
   e.printStackTrace();
  }
 }
  return i;
 }

POS管理系统之供应商查询,布布扣,bubuko.com

POS管理系统之供应商查询

原文:http://www.cnblogs.com/fanweichao/p/3916006.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!