基于javaweb+mysql的jsp+servlet大学实验室设备管理系统(java+jsp+easyui+mysql)

基于javaweb+mysql的jsp+servlet大学实验室设备管理系统(java+jsp+easyui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet大学实验室设备管理系统(java+jsp+easyui+mysql)

项目介绍

本项目为后台管理系统,主要功能如下: 管理员登录,管理数据字典,设备信息管理,进购管理,报损管理,查看库存,账号管理等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

HTML+CSS+JavaScript+JSP+jquery+easyui+mysql

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dbpool.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/jsp_dxsys_sys/ 登录 管理员账号密码:admin/admin
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, pstm, rs);
		}
		return num;
	}
	
	/**
	 * 添加商品记录
	 * @param goods
	 * @return
	 */
	public int goodsAdd(Goods goods) {
		int num = 0;
		Connection conn = dbUtil.getConnection();
		String sql = "INSERT INTO t_goods (goodsname, cost, sell, supplierId, supplier, typeId, type) VALUES (?, ?, ?, ?, ?, ?, ?)";
		PreparedStatement pstm = null;
		try {
			pstm = conn.prepareStatement(sql);
			pstm.setString(1, goods.getGoodsname());
			pstm.setFloat(2, goods.getCost());
			pstm.setFloat(3, goods.getSell());
			pstm.setInt(4, goods.getSupplierId());
			pstm.setString(5, goods.getSupplier());
			pstm.setInt(6, goods.getTypeId());
			pstm.setString(7, goods.getType());
			num = pstm.executeUpdate();
			} catch (Exception e) {
				e.printStackTrace();
		} finally {
			dbUtil.close(conn, pstm, rs);
		}
		return num;
	}
	
	/**
	 * 修改商品记录
	 * @param goods
	 * @return
	 */
	public int goodsModify (Goods goods) {
		int num = 0;
		Connection conn = dbUtil.getConnection();
		String sql = "UPDATE t_goods SET goodsname = ? , cost = ? , sell = ? , supplierId = ? , supplier = ? , typeId = ? , type = ? WHERE goodsid = ?";
		PreparedStatement pstm = null;
		try {
			pstm = conn.prepareStatement(sql);
			pstm.setString(1, goods.getGoodsname());
			pstm.setFloat(2, goods.getCost());
			pstm.setFloat(3, goods.getSell());
	ResultSet rs = null;
	KucunService kucunService = new KucunService();
	
	public String execute() throws SQLException{
		Connection conn = dbUtil.getConnection();
		PageBean pageBean = new PageBean (Integer.parseInt(page), Integer.parseInt(rows));
		try {
			if(kucun == null) {
				kucun = new Kucun();
			}
			JSONObject result = new JSONObject();
			JSONArray jsonArray = JsonUtil.formatRsToJsonArray(kucunService.kucunList(conn, pageBean, kucun));
			int total = kucunService.kucunListTotal(conn, kucun);
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	/*******************GETTER/SETTER*********************/

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public String getRows() {
		return rows;
	}

	public void setRows(String rows) {
		this.rows = rows;
	}

		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
}

/**
 * 库存信息实体类
 * @email 840446169@qq.com
 */
public class Kucun {

	private int id; // 库存编号
	
	private int goodsid; // 商品ID
	
	private int inventory; // 库存量
	
	private Date endDate; // 日期
	
	private String goodsname; // 商品名称

	
	
	/**
	 * 
	 */
	public Kucun() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param goodsid
	 * @param inventory
	 * @param date
	 */
	<table id="dg" class="easyui-datagrid" title="Row Editing DataGrid" style="width:700px;height:auto"
			data-options="
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				url: '../datagrid/datagrid_data1.json',
				onClickRow: onClickRow
			">
		<thead>
			<tr>
				<th data-options="field:'itemid',width:80">Item ID</th>
				<th data-options="field:'productid',width:100,
						formatter:function(value,row){
							return row.productname;
						},
						editor:{
							type:'combobox',
							options:{
								valueField:'productid',
								textField:'productname',
								url:'../datagrid/products.json',
								required:true
							}
						}">Product</th>
				<th data-options="field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}">List Price</th>
				<th data-options="field:'unitcost',width:80,align:'right',editor:'numberbox'">Unit Cost</th>
				<th data-options="field:'attr1',width:250,editor:'text'">Attribute</th>
				<th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
			</tr>
		</thead>
	</table>

	<div id="tb" style="height:auto">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append()">Append</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="remove()">Remove</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">Accept</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">Reject</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="getChanges()">GetChanges</a>
	</div>
	
	<script type="text/javascript">
		var editIndex = undefined;
		function endEditing(){
			if (editIndex == undefined){return true}
			if ($('#dg').datagrid('validateRow', editIndex)){
				var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'});
				var productname = $(ed.target).combobox('getText');
				$('#dg').datagrid('getRows')[editIndex]['productname'] = productname;
				$('#dg').datagrid('endEdit', editIndex);
				editIndex = undefined;
				return true;
			} else {
				return false;

	public int getGoodsid() {
		return goodsid;
	}

	public void setGoodsid(int goodsid) {
		this.goodsid = goodsid;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public Date getOuttime() {
		return outtime;
	}

	public void setOuttime(Date outtime) {
		this.outtime = outtime;
	}

	public String getGoodsname() {
		return goodsname;
	}

	public void setGoodsname(String goodsname) {
		this.goodsname = goodsname;
	}
}
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>大学设备管理系统</title>
<style type="text/css">
<!-- 
body {
	margin-left: 0px;
	margin-top: 0px;
				this.pool.release(connection);
		} catch (SQLException e) {
			e.printStackTrace();
			logger.error("关闭数据库连接时出现异常!");
		}
	}
	
}

public class Jinhuo {

	private int id; // 编号
	
	private int goodsid = -1; // 商品实体对象ID
	
	private int quantity; // 进货数量
	
	private Date intodate; // 进货时间
	
	private String goodsname; // 商品名称
	
	/**********************GETTER/SETTER***********************/

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getGoodsid() {
		return goodsid;
	}

	public void setGoodsid(int goodsid) {
		this.goodsid = goodsid;
	}

	public int getQuantity() {
		return quantity;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	public Date getIntodate() {
				<th data-options="field:'end',width:80,editor:'datebox'">End Date</th>
				<th data-options="field:'progress',width:120,formatter:formatProgress,editor:'numberbox'">Progress</th>
			</tr>
		</thead>
	</table>
	<script type="text/javascript">
		function formatProgress(value){
	    	if (value){
		    	var s = '<div style="width:100%;border:1px solid #ccc">' +
		    			'<div style="width:' + value + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
		    			'</div>';
		    	return s;
	    	} else {
		    	return '';
	    	}
		}
		var editingId;
		function edit(){
			if (editingId != undefined){
				$('#tg').treegrid('select', editingId);
				return;
			}
			var row = $('#tg').treegrid('getSelected');
			if (row){
				editingId = row.id
				$('#tg').treegrid('beginEdit', editingId);
			}
		}
		function save(){
			if (editingId != undefined){
				var t = $('#tg');
				t.treegrid('endEdit', editingId);
				editingId = undefined;
				var persons = 0;
				var rows = t.treegrid('getChildren');
				for(var i=0; i<rows.length; i++){
					var p = parseInt(rows[i].persons);
					if (!isNaN(p)){
						persons += p;
					}
				}
				var frow = t.treegrid('getFooterRows')[0];
				frow.persons = persons;
				t.treegrid('reloadFooter');
			}
		}
		function cancel(){
			if (editingId != undefined){

public class KucunAction {

	private String page; // 第几页
	private String rows; // 每页记录数
	private Kucun kucun; // 库存实体
	private String id; // 库存ID
	private String delIds; // 批量删除ID
	
	DBUtil dbUtil = new DBUtil();
	ResultSet rs = null;
	KucunService kucunService = new KucunService();
	
	public String execute() throws SQLException{
		Connection conn = dbUtil.getConnection();
		PageBean pageBean = new PageBean (Integer.parseInt(page), Integer.parseInt(rows));
		try {
			if(kucun == null) {
				kucun = new Kucun();
			}
			JSONObject result = new JSONObject();
			JSONArray jsonArray = JsonUtil.formatRsToJsonArray(kucunService.kucunList(conn, pageBean, kucun));
			int total = kucunService.kucunListTotal(conn, kucun);
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	/*******************GETTER/SETTER*********************/

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public String getRows() {
		return rows;
	}
//		try {
//			pstm = conn.prepareStatement(sql);
//			pstm.setInt(1, user.getId());
//			pstm.executeUpdate();
//		} catch (SQLException e) {
//			e.printStackTrace();
//		} finally {
//			dbUtil.close(conn, pstm, rs);
//		}
//	}
	
	/**
	 * 获取管理员记录
	 * 
	 * @param user
	 * @return
	 */
	public ResultSet queryForAll(User currentuser, PageBean pageBean, String s_username) {
		Connection conn = dbUtil.getConnection();
		StringBuffer sb = new StringBuffer("SELECT * FROM t_user");
		if(currentuser != null && StringUtil.isNotEmpty(s_username)) {
			sb.append(" AND username LIKE '%"+ s_username +"%'");
		}
		sb.append(" AND id != "+ currentuser.getId());
		if(pageBean != null) {
			sb.append(" LIMIT "+ pageBean.getStart() +","+ pageBean.getRows());
		}
		String sql = sb.toString().replaceFirst("AND", "WHERE");
		PreparedStatement pstm = null;
		ResultSet rs = null;
		try {
			pstm = conn.prepareStatement(sql);
			rs = pstm.executeQuery();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return rs;
	}
	
	/**
	 * 检测用户是否存在
	 * 
	 * @param username
	 * @return
	 */
	public boolean checkUser (String username) {
		boolean flag = false;
		Connection conn = dbUtil.getConnection();
		String sql = "select * from t_user where username = ?";
		PreparedStatement pstm = null;
		try {
			pstm = conn.prepareStatement(sql);
			pstm.setString(1, username);
			rs = pstm.executeQuery();
	public int getInventory() {
		return inventory;
	}

	public void setInventory(int inventory) {
		this.inventory = inventory;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getGoodsname() {
		return goodsname;
	}

	public void setGoodsname(String goodsname) {
		this.goodsname = goodsname;
	}
}

public class DBUtil {

	protected final Logger logger = Logger.getLogger(getClass());
	
	ConnectionPool pool = ConnectionPool.getInstance(); // 连接池
	Connection conn = null; // 数据库连接
	PreparedStatement pstmt = null; // 用于执行一条静态的 SQL 语句并获取它产生的结果
	
	/** 获取连接对象 */
	public Connection getConnection() {
		conn = pool.getConnection();
		return conn;
								</tr>
								<tr>
									<td>&nbsp;</td>
									<td height="30"><table width="100%" border="0"
											cellspacing="0" cellpadding="0">
											<tr>
												<td width="44%" height="20">&nbsp;</td>
											</tr>
										</table>
									</td>
									<td>&nbsp;</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td bgcolor="#a2d962">&nbsp;</td>
		</tr>
	</table>
</body>
</html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
a:link {text-decoration:none; color:black;}		/* 未被访问的链接 */
a:visited {text-decoration:none; color:black;}	/* 已被访问的链接 */
a:hover {text-decoration:none; color:red;}	/* 鼠标指针移动到链接上 */
a:active {text-decoration:none; color:red;}	/* 正在被点击的链接 */
</style> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>大学固定资产管理系统</title>

		this.rows = rows;
	}

	public Chuhuo getChuhuo() {
		return chuhuo;
	}

	public void setChuhuo(Chuhuo chuhuo) {
		this.chuhuo = chuhuo;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getS_goodsid() {
		return s_goodsid;
	}

	public void setS_goodsid(String s_goodsid) {
		this.s_goodsid = s_goodsid;
	}

	public String getS_outtime() {
		return s_outtime;
	}

	public void setS_outtime(String s_outtime) {
		this.s_outtime = s_outtime;
	}
	
}

		PreparedStatement pstm = null;
		try {
			pstm = conn.prepareStatement(sb.toString().replaceFirst("AND", "WHERE"));
			rs = pstm.executeQuery();
			if(rs.next()) {
				return rs.getInt("total");
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, pstm, rs);
		}
		return 0;
	}
	
	/**
	 * 批量删除记录
	 * @param delIds
	 * @return
	 */
	public int goodsDelete (String delIds) {
		int num = 0;
		Connection conn = dbUtil.getConnection();
		String sql = "DELETE FROM t_goods WHERE goodsid IN ("+ delIds +")";
		PreparedStatement pstm = null;
		try {
			pstm = conn.prepareStatement(sql);
			num = pstm.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, pstm, rs);
		}
		return num;
	}
	
	/**
	 * 添加商品记录
	 * @param goods
	 * @return
	 */
	public int goodsAdd(Goods goods) {
		int num = 0;
		Connection conn = dbUtil.getConnection();
		String sql = "INSERT INTO t_goods (goodsname, cost, sell, supplierId, supplier, typeId, type) VALUES (?, ?, ?, ?, ?, ?, ?)";

public class KucunAction {

	private String page; // 第几页
	private String rows; // 每页记录数
	private Kucun kucun; // 库存实体
	private String id; // 库存ID
	private String delIds; // 批量删除ID
	
	DBUtil dbUtil = new DBUtil();
	ResultSet rs = null;
	KucunService kucunService = new KucunService();
	
	public String execute() throws SQLException{
		Connection conn = dbUtil.getConnection();
		PageBean pageBean = new PageBean (Integer.parseInt(page), Integer.parseInt(rows));
		try {
			if(kucun == null) {
				kucun = new Kucun();
			}
			JSONObject result = new JSONObject();
			JSONArray jsonArray = JsonUtil.formatRsToJsonArray(kucunService.kucunList(conn, pageBean, kucun));
			int total = kucunService.kucunListTotal(conn, kucun);
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	/*******************GETTER/SETTER*********************/

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
				}
			},{
				text:"库存查看",
				attributes:{
					url:"<%=path %>/dynamic/server/kucun/page.jsp"
				}
			},{
				text:"账号管理",
				attributes:{
					url:"<%=path %>/dynamic/server/user/page.jsp"
				}
			}]
		}];
		
		// 实例化树菜单
		$("#tree").tree({
			data:treeData,
			lines:true,
			onClick:function(node){
				if(node.attributes){
					openTab(node.text,node.attributes.url);
				}
			}
		});
		
		// 新增Tab
		function openTab(text,url){
			if($("#tabs").tabs('exists',text)){
				$("#tabs").tabs('select',text);
			}else{
				var content="<iframe frameborder='0' scrolling='auto' style='width:100%;height:100%' src="+url+"></iframe>";
				$("#tabs").tabs('add',{
					title:text,
					closable:true,
					content:content
				});
			}
		}
	});
	
	function logout(){
		var f = confirm('确定要注销登录?');
		if(!f)
			return false;
		top.location.href = '<%=path %>/server/logout.action';
	}
</script>
	}

	public Kucun getKucun() {
		return kucun;
	}

	public void setKucun(Kucun kucun) {
		this.kucun = kucun;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDelIds() {
		return delIds;
	}

	public void setDelIds(String delIds) {
		this.delIds = delIds;
	}

	public DBUtil getDbUtil() {
		return dbUtil;
	}

	public void setDbUtil(DBUtil dbUtil) {
		this.dbUtil = dbUtil;
	}
	
}

public class Goods {
	
	private int goodsid; // 编号
	
	private String goodsname; // 商品名
	
	private float cost; // 成本
	
	private float sell; // 售价
	
	private int supplierId; // 供应商ID
	
	private String supplier; // 供应商名
	
	private int typeId; // 商品类型ID
	
	private String type; // 商品类型名
		}
	}
	
	/**
	 * 在连接池中创建初始设置的数据库连接
	 */
	private void addConnection() {
		Connection conn = null;
		for (int i = 0; i < poolSize; i++) {
			try {
				Class.forName(driverClassName);
				conn = java.sql.DriverManager.getConnection(url, username, password);
				pool.add(conn);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
	}
	
	private void readConfig() {
		try {
			//String path = System.getProperty("user.dir") + "\\src\\dbpool.properties";  // 路径
			
			/**
			 *  加载配置文件
			 */
		//	FileInputStream is = new FileInputStream(path); 
			Properties props = new Properties();
			props.load(getClass().getResourceAsStream("/dbpool.properties"));
			
			/**
			 * 读取属性值
			 */
			this.driverClassName = props.getProperty("driverClassName"); // 读取数据库类型
			this.username = props.getProperty("username"); // 读取账户
			this.url = props.getProperty("url"); // 读取路径
			this.password = props.getProperty("password"); // 读取密码
			this.poolSize = Integer.parseInt(props.getProperty("poolSize")); // 读取数据库连接个数
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("读取属性文件出错。");
		}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值