库存物资管理系统-测试

实验要求: 1.、有一个存放商品的仓库,每天都有商品出库和入库。 2、每种商品都有名称、生产厂家、型号、规格等。 3、出入库时必须填写出入库单据,单据包括商品名称、生产厂家、型号、规格、数量、日期、时间、入库单位(或出库单位)名称、送货(或提货)人姓名。

建两张数据表,一张用来商品的增删改查,一张记录商品的出库与入库信息

所用及代码:

public class GoodsBean
{
    private String name;
    private String type;
    private String PM;
    private String specification;
    private int number;
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    public String getType()
    {
        return type;
    }
    public void setType(String type)
    {
        this.type = type;
    }
    public String getPM()
    {
        return PM;
    }
    public void setPM(String pM)
    {
        PM = pM;
    }
    public String getSpecification()
    {
        return specification;
    }
    public void setSpecification(String specification)
    {
        this.specification = specification;
    }
    public int getNumber()
    {
        return number;
    }
    public void setNumber(int number)
    {
        this.number = number;
    }

}
public class GoodsBean
{
    private String name;
    private String type;
    private String PM;
    private String specification;
    private int number;
    public String getName()
    {
        return name;
    }
    public void setName(String name)
    {
        this.name = name;
    }
    public String getType()
    {
        return type;
    }
    public void setType(String type)
    {
        this.type = type;
    }
    public String getPM()
    {
        return PM;
    }
    public void setPM(String pM)
    {
        PM = pM;
    }
    public String getSpecification()
    {
        return specification;
    }
    public void setSpecification(String specification)
    {
        this.specification = specification;
    }
    public int getNumber()
    {
        return number;
    }
    public void setNumber(int number)
    {
        this.number = number;
    }

}
import java.sql.*;

import com.ccr.jsp.bean.GoodsBean;
import com.ccr.jsp.util.DB;

public class GoodsDao
{
    public boolean insert(GoodsBean g)
    {
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        stm.execute("insert into goods(name,PM,type,specification,number) values (‘"+g.getName()+"‘,‘"+g.getPM()+"‘,‘"+g.getType()+"‘,‘"+g.getSpecification()+"‘,"+g.getNumber()+")");
        }
        catch (Exception e)
        {
        e.printStackTrace();
        return false;
        }
        return true;
    }
    public boolean update(int number,int i)
    {
        int num=0;
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        ResultSet rs =stm.executeQuery("select number from goods where id="+i);
        System.out.println("update"+i+"num "+number);
        rs.next();
        num=rs.getInt("number");
        System.out.print(num+"+"+number);
        num=num+number;
        System.out.println("="+num);
        stm.execute("update goods set number="+num+" where id="+i);
        }
        catch (Exception e)
        {
        e.printStackTrace();
        return false;
        }
        return true;
    }
    public int chick(GoodsBean g)
    {
        int i=-1;//i>0查询有结果
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        ResultSet rs =stm.executeQuery("select id from goods where name=‘"+g.getName()+"‘ and PM=‘"+g.getPM()+"‘ and type=‘"+g.getType()+"‘ and specification=‘"+g.getSpecification()+"‘");
        if(rs.next())
        {
            i=rs.getInt("id");
        }
        }
        catch (Exception e)
        {
        e.printStackTrace();
        }
        return i;
    }
}
import java.sql.*;

import com.ccr.jsp.bean.GoodsBean;
import com.ccr.jsp.util.DB;

public class GoodsDao
{
    public boolean insert(GoodsBean g)
    {
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        stm.execute("insert into goods(name,PM,type,specification,number) values (‘"+g.getName()+"‘,‘"+g.getPM()+"‘,‘"+g.getType()+"‘,‘"+g.getSpecification()+"‘,"+g.getNumber()+")");
        }
        catch (Exception e)
        {
        e.printStackTrace();
        return false;
        }
        return true;
    }
    public boolean update(int number,int i)
    {
        int num=0;
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        ResultSet rs =stm.executeQuery("select number from goods where id="+i);
        System.out.println("update"+i+"num "+number);
        rs.next();
        num=rs.getInt("number");
        System.out.print(num+"+"+number);
        num=num+number;
        System.out.println("="+num);
        stm.execute("update goods set number="+num+" where id="+i);
        }
        catch (Exception e)
        {
        e.printStackTrace();
        return false;
        }
        return true;
    }
    public int chick(GoodsBean g)
    {
        int i=-1;//i>0查询有结果
        DB db=new DB();
        Connection con = db.getCon();
        try
        {
        Statement stm = con.createStatement();
        ResultSet rs =stm.executeQuery("select id from goods where name=‘"+g.getName()+"‘ and PM=‘"+g.getPM()+"‘ and type=‘"+g.getType()+"‘ and specification=‘"+g.getSpecification()+"‘");
        if(rs.next())
        {
            i=rs.getInt("id");
        }
        }
        catch (Exception e)
        {
        e.printStackTrace();
        }
        return i;
    }
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ccr.jsp.bean.GoodsBean;
import com.ccr.jsp.bean.ListBean;
import com.ccr.jsp.dao.GoodsDao;
import com.ccr.jsp.dao.ListDao;

/**
 * Servlet implementation class GoodsServlet
 */
@WebServlet("/GoodsServlet")
public class GoodsServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public GoodsServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        response.setHeader("content-type", "text/html;charset=UTF-8");
        String action=request.getParameter("action");
        if(action.equals("select"))
        {
            select(request,response);
        }
        if(action.equals("in"))
        {
            in(request,response);
        }
        if(action.equals("out"))
        {
            out(request,response);
        }
    }
    protected void select(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        String name=request.getParameter("name");
        String date=request.getParameter("date");
        ListDao d=new ListDao();
        List<ListBean>l=d.select(name,date);
        request.getSession().setAttribute("l", l);
        request.getRequestDispatcher("select.jsp").forward(request,response);
    }
    protected void in(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        int id=-2;
        ListBean b=new ListBean();
        GoodsBean g=new GoodsBean();
        GoodsDao gd=new GoodsDao();
        ListDao ld=new ListDao();
        b.setName(request.getParameter("name"));
        b.setPM(request.getParameter("PM"));
        b.setType(request.getParameter("type"));
        b.setSpecification(request.getParameter("specification"));
        b.setNumber(Integer.parseInt(request.getParameter("number")));
        b.setUnits(request.getParameter("units"));
        b.setPName(request.getParameter("PName"));
        b.setIo("in");
        b.setDate();
        ld.insert(b);

        g.setName(request.getParameter("name"));
        g.setPM(request.getParameter("PM"));
        g.setType(request.getParameter("type"));
        g.setSpecification(request.getParameter("specification"));
        g.setNumber(Integer.parseInt(request.getParameter("number")));
        id=gd.chick(g);
        System.out.println(id);
        if(id>0)
        {
            gd.update(b.getNumber(), id);
        }
        else
        {
            gd.insert(g);
        }
        request.getRequestDispatcher("in.jsp").forward(request,response);
    }
    protected void out(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
        int id=-2;
        ListBean b=new ListBean();
        GoodsBean g=new GoodsBean();
        GoodsDao gd=new GoodsDao();
        ListDao ld=new ListDao();
        b.setName(request.getParameter("name"));
        b.setPM(request.getParameter("PM"));
        b.setType(request.getParameter("type"));
        System.out.println(b.getType());
        b.setSpecification(request.getParameter("specification"));
        int number=Integer.parseInt(request.getParameter("number"));
        number=-1*number;
        System.out.println("SN"+number);
        b.setNumber(number);
        b.setUnits(request.getParameter("units"));
        b.setPName(request.getParameter("PName"));
        b.setIo("out");
        b.setDate();
        ld.insert(b);

        g.setName(request.getParameter("name"));
        g.setPM(request.getParameter("PM"));
        g.setType(request.getParameter("type"));
        g.setSpecification(request.getParameter("specification"));
        g.setNumber(number);
        id=gd.chick(g);
        if(id>0)
        {
            gd.update(b.getNumber(), id);
        }
        else
        {
            System.out.println("错误");
        }
        request.getRequestDispatcher("out.jsp").forward(request,response);
    }

}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DB
{
    private Connection con;
    private Statement stm;
    private ResultSet rs;
    private String classname="com.mysql.jdbc.Driver";
    private String url="jdbc:mysql://127.0.0.1:3306/warehouse?useSSL=false&characterEncoding=utf-8";
    public Connection getCon(){
        try{
            Class.forName(classname);
            System.out.println("驱动加载成功");
        }
        catch(ClassNotFoundException e){
            e.printStackTrace();
        }
        try{
            con=DriverManager.getConnection(url,"root","root");
            System.out.println("数据库连接成功");
        }
        catch(Exception e){
            e.printStackTrace(System.err);
            con=null;
        }
        return con;
    }
    public static void close(Statement stm, Connection conn) {
        if(stm!=null) {
            try {
                stm.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(conn!=null) {
            try {
                conn.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    public static void close(ResultSet rs, Statement stm, Connection con) {
        if(rs!=null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(stm!=null) {
            try {
                stm.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        if(con!=null) {
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>in</title>
</head>
<body>
<h1>入库</h1>
<form method="post" action="GoodsServlet?action=in">
<div>
    <div>
        <div style="display:inline"><label for="name">&nbsp;&nbsp;名&nbsp;&nbsp;&nbsp;&nbsp;称&nbsp;&nbsp;</label></div>
        <div style="display:inline"><input type="text" name="name" id="name"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">&nbsp;&nbsp;型&nbsp;&nbsp;&nbsp;&nbsp;号&nbsp;&nbsp;</label></div>
        <div style="display:inline"><input type="text" name="type" id="type"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">出产厂家</label></div>
        <div style="display:inline"><input type="text" name="PM" id="PM"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">&nbsp;&nbsp;规&nbsp;&nbsp;&nbsp;&nbsp;格&nbsp;&nbsp;</label></div>
        <div style="display:inline"><input type="text" name="specification" id="specification"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">入库单位</label></div>
        <div style="display:inline"><input type="text" name="units" id="units"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">送货人名</label></div>
        <div style="display:inline"><input type="text" name="PName" id="PName"></div>
    </div><br/>
    <div>
        <div style="display:inline"><label for="name">&nbsp;&nbsp;数&nbsp;&nbsp;&nbsp;&nbsp;量&nbsp;&nbsp;</label></div>
        <div style="display:inline"><input type="text" name="number" id="number"></div>
    </div><br/>
    <div>
        <div><input type="submit" value="提交"></div>
    </div>
</div>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>left</title>
</head>
<body>
<div>
<div><a style="color:blue" target="right" href="select.jsp">查询</a></div><br/>
<div><a style="color:blue" target="right" href="out.jsp">出库</a></div><br/>
<div><a style="color:blue" target="right" href="in.jsp">入库</a></div><br/>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>main</title>
<style>
        html,body{width: 100%;height: 100%;padding: 0;margin: 0}
         #left{width:20%;height: 100%;padding: 0;margin: 0;border: none;}
         #right{width: 80%;height: 100%;padding: 0;margin: 0;border: none;}
</style>
</head>
<body>
<iframe name="left" id="left" align="left" height="500px" width="200" scrolling="no" src="left.jsp"></iframe>
<iframe name="right" id="right" align="right" height="500px" width="800" scrolling="no" src="select.jsp"></iframe>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>main</title>
<style>
        html,body{width: 100%;height: 100%;padding: 0;margin: 0}
         #left{width:20%;height: 100%;padding: 0;margin: 0;border: none;}
         #right{width: 80%;height: 100%;padding: 0;margin: 0;border: none;}
</style>
</head>
<body>
<iframe name="left" id="left" align="left" height="500px" width="200" scrolling="no" src="left.jsp"></iframe>
<iframe name="right" id="right" align="right" height="500px" width="800" scrolling="no" src="select.jsp"></iframe>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.ccr.jsp.bean.ListBean" %>
<%@ page import="java.util.List" %>
<%@ page import="javax.servlet.http.HttpServletRequest" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>select</title>
</head>
<body>
<h1>信息查询</h1>
<form method="post" action="GoodsServlet?action=select">
    <div>
        <div>
            <div><label>产品名称</label></div>
            <div><input type="text" name="name" id="name"></div>
        </div>
        <div>
            <div><label>日期</label></div>
            <div><input type="text" name="date" id="date"></div>
        </div>
        <div>
            <input type="submit" value="查询">
        </div>
    </div>
</form>
<c:set var="list" value="${sessionScope.l}"></c:set>
<c:if test="${l!=null }">
<c:forEach var="i" begin="0" end="${l.size()-1}">
&nbsp;名称&nbsp;${l[i].getName()}
&nbsp;型号&nbsp;${l[i].getType()}
&nbsp;出产厂家&nbsp;${l[i].getPM()}
&nbsp;规格&nbsp;${l[i].getSpecification()}
&nbsp;数量&nbsp;${l[i].getNumber()}
&nbsp;单位&nbsp;${l[i].getUnits()}
&nbsp;姓名&nbsp;${l[i].getPName()}
&nbsp;操作&nbsp;${l[i].getIo()}
&nbsp;日期&nbsp;${l[i].getDate()}
<br/>
</c:forEach>
</c:if>
</body>
</html>

原文地址:https://www.cnblogs.com/zjm15511858030/p/10117015.html

时间: 2024-08-26 23:27:04

库存物资管理系统-测试的相关文章

库存物资管理系统代码,详细过程和总结

库存物资管理系统实验要求如下: 1.背景资料 1.有一个存放商品的仓库,每天都有商品出库和入库.2.每种商品都有名称.生产厂家.型号.规格等.3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号.规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人姓名.2.系统要求与功能设计2.1页面要求(1)能够在Tomcat服务器中正确部署,并通过浏览器查看:(1分)(2)网站页面整体风格统一:2.2设计要求1.设计出入库单据的录入.2.实现按商品名称.出入库日期的查询. 3.评

库存物资管理系统(过关测试)

实验要求: 1..有一个存放商品的仓库,每天都有商品出库和入库. 2.每种商品都有名称.生产厂家.型号.规格等. 3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号.规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人姓名. 通过这次实验,我发现数据库的增删改查实验可以经由一个基本模板去演变,这样不但减少了工作量,同时使错误减少. 下面是此次测试的截图和代码 1 <%@ page language="java" import="java.u

库存物资管理系统

package com.hjf.util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * 数据库连接工具 * @author Hu * */ public class DBUti

【javaweb】库存物资管理系统思路与总结

题目: 1.有一个存放商品的仓库,每天都有商品出库和入库. 2.每种商品都有名称.生产厂家.型号.规格等. 3.出入库时必须填写出入库单据,单据包括商品名称.生产厂家.型号. 规格.数量.日期.时间.入库单位(或出库单位)名称.送货(或提货)人 姓名. 首先建立数据库goodsmanager table:goods记录商品信息 table:list记录出入库信息 Java部分: 先把页面写好 首页面用<iframe>分为左侧导航栏,和右侧页面 点击左侧超链接即可实现右侧页面的跳转,在left.

疫情防控公益免费开源项目推荐-出入人员登记系统-学生健康报备管理系统-员工疫情筛查工具-物资管理系统-消毒检查登记系统

具体项目清单 项目1.出入人员登记系统 项目描述:疫情期间严格执行出入登记.支持出入人员自助扫码填表,支持管理员查看.统计.搜索和导出excel.还可根据车次.航班自动识别是否乘坐过确诊人员乘坐的交通工具.登记人员初次填写后,第二次填表将无需重复填写基本信息. 项目负责人:DCloud_UNI_GSQ(QQ群昵称) 项目体验地址:wlry.m3w.cn 源码地址:https://gitee.com/dcloud/xinguan2020-alien-registration 截图: 案例: 已经在

学习python两个月后,用了一个月用django写的物资管理系统

2017年5月,因为工作需要,单位急需一套物资管理系统来实现无纸化办公,当时也找外部门懂计算机编程的写过一套,用c(#)写的,因为是外单位做的,有很多细节无法满足工作需要,如果再进行改动,可能要重新做.求人不如靠自己,当时自己就有了一个想法,我要自己编写,或许只是一时的冲动,但如果做成了,确实能提升我在单位的自我价值.在此之前,我完全没有编程基础,只是在上中专的时候简单的学习过c语言,但那个时候已经是将近20年的事情了,编程在我脑子里完全没有概念.抱着试试看的态度,我决定开始学习.       

物资管理系统

一:首先连接数据库 package util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class JDBUtil { public static String url="jdbc:mysql://localhost:3306/test?u

图书管理系统——测试与调试

1 调试方法 该系统在本地服务器上进行运行和调试,鉴于对系统的内部结构和处理算法的完全了解以及对系统功能的全面掌握对系统进行白盒测试和黑盒测试. 在开发软件系统的过程中,需要面对错综复杂的问题,因此,在软件生存周期的每个阶段都不可避免地会产生错误.测试目的在于:发现错误而执行一个程序的过程,测试的最重要目的是发现其中尚未发现的错误. 为了设计出有效的测试方案按照下面准则进行测试:所有测试都应追溯到用户需求:在完成了需求模型就要着手制定测试计划,在编码之前对所有测试工作进行计划和设计:御用Pare

对于业务中库存超卖测试

多并发时,用相应的锁方案保证库存不发生超卖.实现这个方案后,要有相应的场景测试方案. 很多时候,验证方案非常重要. java可以利用CountDownLatch测试多并发.CountDownlatch通常用于某个业务线程需要等待其它多个线程完成某个条件后才进行相应操作. CountDownLatch有countDown及await方法,分别对应减少计数器及当计数器大于0时阻塞当前线程.当计数量等于0时所有调用await方法且被阻塞的线程都被唤醒,然后进行相应操作. 此处用于模拟10个并发用户进行