首页 > 代码库 > POS管理系统之新增设备入库
POS管理系统之新增设备入库
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>设备新增入库</title>
<style type="text/css">
table{
color: blue;
font-weight: bold;
border-color: #C1DCF9;
}
</style>
</head>
<body>
<form action="<%=request.getContextPath()%>/equipAdd.do" method="post">
<table border="1">
<tr>
<td>设备厂商</td>
<td colspan="6"><input type="text" name="equipname"></td>
</tr>
<tr>
<td>经办人</td>
<td colspan="2"><input type="text" name="username"></td>
<td>日期</td>
<td colspan="3"><input type="text" name="date"></td>
</tr>
<tr>
<td>设备编号</td>
<td>设备种类</td>
<td>出场编号</td>
<td>设备类型</td>
<td>设备型号</td>
<td>备注</td>
<td>操作</td>
</tr>
<tr>
<td><input type="text" name="equipno"/></td>
<td><select name="type">
<option value="http://www.mamicode.com/POS机">POS机</option>
<option value="http://www.mamicode.com/电器类">电器类</option>
<option value="http://www.mamicode.com/运输类">运输类</option>
<option value="http://www.mamicode.com/食品类">食品类</option>
</select>
</td>
<td><input type="text" name="outno"/></td>
<td><select name="type1">
<option value="http://www.mamicode.com/普通消费POS机">普通消费POS机</option>
<option value="http://www.mamicode.com/挖掘机">挖掘机</option>
<option value="http://www.mamicode.com/纺织机">纺织机</option>
<option value="http://www.mamicode.com/豆浆机">豆浆机</option>
</select></td>
<td><input type="text" name="xinghao"></td>
<td><input type="text" name="beizhu"></td>
<td><a href="http://www.mamicode.com/#">删除</a></td>
</tr>
<tr>
<td colspan="6"></td>
<td><a href="http://www.mamicode.com/#">添加</a></td>
</tr>
<tr>
<td colspan="7">
<input type="submit" value="http://www.mamicode.com/保存">
</td>
</tr>
</table>
</form>
</body>
</html>
定义实体类:
package entity;
public class EquipAdd {
private String gysid;
private String buypeople;
private String buydate;
private String equipno;
private String equiptype;
private String ccno;
private String equipleixing;
private String equipxinghao;
private String equipzt;
public String getGysid() {
return gysid;
}
public void setGysid(String gysid) {
this.gysid = gysid;
}
public String getBuypeople() {
return buypeople;
}
public void setBuypeople(String buypeople) {
this.buypeople = buypeople;
}
public String getBuydate() {
return buydate;
}
public void setBuydate(String buydate) {
this.buydate = buydate;
}
public String getEquipno() {
return equipno;
}
public void setEquipno(String equipno) {
this.equipno = equipno;
}
public String getEquiptype() {
return equiptype;
}
public void setEquiptype(String equiptype) {
this.equiptype = equiptype;
}
public String getCcno() {
return ccno;
}
public void setCcno(String ccno) {
this.ccno = ccno;
}
public String getEquipleixing() {
return equipleixing;
}
public void setEquipleixing(String equipleixing) {
this.equipleixing = equipleixing;
}
public String getEquipxinghao() {
return equipxinghao;
}
public void setEquipxinghao(String equipxinghao) {
this.equipxinghao = equipxinghao;
}
public String getEquipzt() {
return equipzt;
}
public void setEquipzt(String equipzt) {
this.equipzt = equipzt;
}
public EquipAdd(String gysid, String buypeople, String buydate, String equipno,
String equiptype, String ccno, String equipleixing,
String equipxinghao, String equipzt) {
super();
this.gysid = gysid;
this.buypeople = buypeople;
this.buydate = buydate;
this.equipno = equipno;
this.equiptype = equiptype;
this.ccno = ccno;
this.equipleixing = equipleixing;
this.equipxinghao = equipxinghao;
this.equipzt = equipzt;
}
public EquipAdd(String equipno,String gysid ) {
super();
this.equipno = equipno;
this.gysid = gysid;
}
public EquipAdd() {
super();
// TODO Auto-generated constructor stub
}
}
三层结构DAO类:
package dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import entity.EquipAdd;
public class EquipAddDao extends BaseDao{
public int insertEquip(EquipAdd e) {
String insert="insert into equip(gysid,buypeople,buydate,equipno,equiptype," +
"ccno,equipleixing,equipxinghao,equipzt)values(?,?,?,?,?,?,?,?,?)";
List<Object>params=new ArrayList<Object>();
params.add(e.getGysid());
params.add(e.getBuypeople());
params.add(e.getBuydate());
params.add(e.getEquipno());
params.add(e.getEquiptype());
params.add(e.getCcno());
params.add(e.getEquipleixing());
params.add(e.getEquipxinghao());
params.add(e.getEquipzt());
return this.executeUpdate(insert, params);
}
public List<EquipAdd> findEquip(){
List<EquipAdd> list=new ArrayList<EquipAdd>();
String select="select*from equip";
ResultSet rs=this.executeQuery(select, null);
try{
while(rs.next()){
EquipAdd e=new EquipAdd();
e.setGysid(rs.getString("gysid"));
e.setBuypeople(rs.getString("buypeople"));
e.setBuydate(rs.getString("buydate"));
e.setEquipno(rs.getString("equipno"));
e.setEquiptype(rs.getString("equiptype"));
e.setCcno(rs.getString("ccno"));
e.setEquipleixing(rs.getString("equipleixing"));
e.setEquipxinghao(rs.getString("equipxinghao"));
e.setEquipzt(rs.getString("equipzt"));
list.add(e);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
this.closeAll();
}
return list;
}
public ResultSet findEquipByEquipno(String no){
String select="select*from equip where equipno=?";
List<Object>params=new ArrayList<Object>();
params.add(no);
return this.executeQuery(select, params);
}
}
Service层:
package service;
import dao.EquipAddDao;
import entity.EquipAdd;
public class EquipAddService {
EquipAddDao ed=new EquipAddDao();
public int insertEquip(EquipAdd e) {
return ed.insertEquip(e);
}
}
Servlet层:
package servlet;
import java.io.IOException;
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 dao.EquipAddDao;
import entity.EquipAdd;
import service.EquipAddService;
@SuppressWarnings("serial")
public class EquipAddServlet extends HttpServlet {
@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");
EquipAddService eas=new EquipAddService();
String gysid=req.getParameter("equipname");
String buypeople=req.getParameter("username");
String buydate=req.getParameter("date");
String equipno=req.getParameter("equipno");
String equiptype=req.getParameter("type");
String ccno=req.getParameter("outno");
String equipleixing=req.getParameter("type1");
String equipxinghao=req.getParameter("xinghao");
String equipzt=req.getParameter("beizhu");
EquipAdd e=new EquipAdd(gysid, buypeople, buydate, equipno, equiptype, ccno, equipleixing, equipxinghao, equipzt);
int a=eas.insertEquip(e);
if(a>0){
//resp.sendRedirect("http://www.baidu.com");
List<EquipAdd> list=new ArrayList<EquipAdd>();
EquipAddDao ead=new EquipAddDao();
list=ead.findEquip();
req.setAttribute("uname",list);
RequestDispatcher rd = req.getRequestDispatcher("/tiaozhuan/equipAddEdit.jsp");
rd.forward(req, resp);
}else{
resp.sendRedirect("http://www.sohu.com");
}
}
}
跳转页面:
<%@page import="entity.EquipAdd"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>设备商列表</title>
</head>
<body>
<table border="1px">
<tr>
<td>设备编号</td>
<td>设备种类</td>
<td>出厂编号</td>
<td>设备类型</td>
<td>设备型号</td>
<td>供应商ID</td>
<td>购入日期</td>
<td>购入经办人</td>
<td>客户标识</td>
<td>设备状态</td>
<td>最近入库日期</td>
<td>最近出库日期</td>
<td>关联设备编号</td>
<td>操作员ID</td>
<td>操作时间</td>
<td>机构ID</td>
</tr>
<%
List<EquipAdd> list=(List<EquipAdd>)request.getAttribute("uname");
for(int i=0;i<list.size();i++){
%>
<tr>
<td><%=list.get(i).getEquipno() %></td>
<td><%=list.get(i).getEquiptype() %></td>
<td><%=list.get(i).getCcno() %></td>
<td><%=list.get(i).getEquipleixing() %></td>
<td><%=list.get(i).getEquipxinghao() %></td>
<td><%=list.get(i).getGysid() %></td>
<td><%=list.get(i).getBuydate() %></td>
<td><%=list.get(i).getBuypeople() %></td>
<td><%=list.get(i).getEquipzt() %></td>
</tr>
<%} %>
</table>
</body>
</html>