码迷,mamicode.com
首页 > 其他好文 > 详细

POS管理系统之供应商新增

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

标签:style   http   color   java   os   io   for   ar   

<%@ 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>
    <style type="text/css">
       table{
         color: blue;
         font-weight: bold;
         text-align: center;
         border-color: #C1DCF9;
       }
    </style>
   
  </head>
 
  <body>
        <form action="<%=request.getContextPath()%>/mfrEdit1.do" method="post">
     <table border="1">
      <tr>
       <td>厂商代码</td>
       <td colspan="3"><input type="text" name="cno">
       <input type="hidden" name="method" value="add"/>
       </td>
      </tr>
      <tr>
       <td>厂商名称</td>
       <td><input type="text" name="cname"></td>
       <td>代理商</td>
       <td><input type="text" name="dname"></td>
      </tr>
      
      <tr>
          <td>厂商地址</td>
       <td><input type="text" name="caddress"/></td>
       <td>代理商地址</td>
       <td><input type="text" name="daddress"/></td>
      </tr>
      <tr>
           <td>厂商邮编</td>
                 <td><input type="text" name="cemail"/></td>
                 <td>代理商邮编</td>
                 <td><input type="text" name="dnumber"/></td>
      </tr>
      <tr>
           <td>厂商联系电话</td>
                 <td><input type="text" name="cphone"/></td>
                 <td>代理商联系电话</td>
                 <td><input type="text" name="dphone"/></td>
      </tr>
      <tr>
           <td>厂商联系人</td>
                 <td><input type="text" name="cpeople"/></td>
                 <td>代理商联系人</td>
                 <td><input type="text" name="dpeople"/></td>
      </tr>
      <tr>
           <td>可供应产品</td>
                 <td colspan="3"><textarea cols="70" rows="5" name="product"></textarea></td>
      </tr>
      <tr>
           <td>售后服务商</td>
                 <td><input type="text" name="shouhou"/></td>
                 <td>服务商邮编</td>
                 <td><input type="text" name="fnumber"/></td>
      </tr>
      <tr>
           <td>服务商地址</td>
                 <td><input type="text" name="faddress"/></td>
                 <td>售后服务电话</td>
                 <td><input type="text" name="shphone"/></td>
      </tr>
      <tr>
           <td>备注</td>
                 <td colspan="3"><textarea cols="70" rows="5" name="beizhu"></textarea></td>
      </tr>
      <tr>
           <td rowspan="2"><input type="submit" value="保存"/></td>
                 <td rowspan="2"><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");
      String cname = req.getParameter("cname");
      String caddress=req.getParameter("caddress");
      String cemail=req.getParameter("cemail");
      String cphone=req.getParameter("cphone");
      String cpeople=req.getParameter("cpeople");
      int i = savemfrEdit(cno, cname,caddress,cemail,cphone,cpeople);
      if (i > 0) {
   // 新增成功了
   resp.sendRedirect(req.getContextPath() + "/Success.jsp");
  } else {
   resp.sendRedirect("http://www.sohu.com");
  }
  }

 private int savemfrEdit(String cno, String cname,String caddress,String cemail,String cphone, String cpeople) {
  String insert= "INSERT INTO MFREDIT(CNO,CNAME,CADDRESS,CEMAIL,CPHONE,CPEOPLE)VALUES(?,?,?,?,?,?)";
  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(insert);
   // 设置参数
   pstmt.setString(1, cno);
   pstmt.setString(2, cname);
   pstmt.setString(3, caddress);
   pstmt.setString(4, cemail);
   pstmt.setString(5, cphone);
   pstmt.setString(6, cpeople);
   // 执行
   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管理系统之供应商新增

标签:style   http   color   java   os   io   for   ar   

原文地址:http://www.cnblogs.com/fanweichao/p/3915996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!