课程作业3-基于java设计的射频识别课程作业

1.系统需求分析
1.1 IC卡读写板
IC卡读写板可以把IC卡的信息读出来,也可以往里面写信息。
IC卡读写板实物图 读写板原理图

1.2 IC卡
IC卡
2. 系统总体设计
在这里插入图片描述
在这里插入图片描述
3.java开发系统界面

  1. 会员录入页面:
    在这里插入图片描述
  2. 会员消费记录查询页面:
    在这里插入图片描述
  3. 记录会员消费记录页面:
    在这里插入图片描述
  4. 会员卡查询余额和充值页面:

在这里插入图片描述

  1. 消费类型页面:
    在这里插入图片描述
    4.系统实现代码
  2. 显示会员消费记录方法
  public void showData() {
		
		String sql = "select * from record";
		// 数据库访问
		DBUtil1 db = new DBUtil1();
		try {
			db.getConnection("entering");
			ResultSet rs = db.executeQuery(sql, null);
			ResultSetMetaData rsmd = rs.getMetaData();
			// 获取列数
			int colCount = rsmd.getColumnCount();
			// 存放列名
			Vector<String> title = new Vector<String>();
			// 列名
			for (int i = 1; i <= colCount; i++) {
				title.add(rsmd.getColumnLabel(i));
			}
			// 表格数据
			Vector<Vector<String>> data = new Vector<Vector<String>>();
			int rowCount = 0;
			while (rs.next()) {
				rowCount++;
				// 行数据
				Vector<String> rowdata = new Vector<String>();
				for (int i = 1; i <= colCount; i++) {
					rowdata.add(rs.getString(i));
				}
				data.add(rowdata);
			}
			if (rowCount == 0) {
				model.setDataVector(null, title);
			} else {
				model.setDataVector(data, title);
			}
		} catch (Exception ee) {
			System.out.println(ee.toString());
			JOptionPane.showMessageDialog(this, "系统出现异常错误。请检查数据库。系统即将退出!!!",
					"错误", 0);
		} finally {
			db.closeAll();
		}
	}
  1. 删除消费记录方法
public void deleteData() {
	int index[] = table_1.getSelectedRows();
	if (index.length == 0) {
		JOptionPane.showMessageDialog(this, "请选择要删除的记录", "提示",
				JOptionPane.PLAIN_MESSAGE);
	} else {
		try {
			int k = JOptionPane.showConfirmDialog(this,
					"您确定要从数据库中删除所选的数据吗 ?", "删除", JOptionPane.YES_NO_OPTION,
					JOptionPane.QUESTION_MESSAGE);
			if (k == JOptionPane.YES_OPTION) {
				DBUtil1 db = new DBUtil1();
				try {
					db.getConnection("entering");
					String name = table_1.getValueAt(index[0], 1).toString();
					String sql = "delete from record where name=?";
					int count = db.executeUpdate(sql, new String[] {name});
					if (count == 1) {
						JOptionPane.showMessageDialog(this, "删除操作成功完成!",
								"成功", JOptionPane.PLAIN_MESSAGE);
						showData();
					} else {
						JOptionPane.showMessageDialog(this, "抱歉! 删除数据失败!",
								"失败:", 0);
					}
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					db.closeAll();
				}
			}
		} catch (Exception ee) {
			JOptionPane.showMessageDialog(this, "抱歉!删除数据失败!【系统异常!】", "失败:",
					0);
		}
	}
}
  1. 插入消费记录方法
public void insertData() {
	int i=model.getRowCount();
	model.addRow(new Vector());
}
  1. 保存消费记录方法
protected void saveData() {
	int i=model.getRowCount();
	DBUtil1 db = new DBUtil1();
				try {
					db.getConnection("entering");
					String rfidno = table_1.getValueAt(i-1, 0).toString();
					String name = table_1.getValueAt(i-1, 1).toString();
					String gender = table_1.getValueAt(i-1, 2).toString();
					String record = table_1.getValueAt(i-1, 3).toString();
					String money = table_1.getValueAt(i-1, 4).toString();
					String phoneno = table_1.getValueAt(i-1, 5).toString();
					String time = table_1.getValueAt(i-1, 6).toString();
					String sql = "insert into record values('"+rfidno+"','"+name+"','"+
							gender+"','"+record+"','"+money+"','"+phoneno+"','"+time+"')";
					int count = db.executeUpdate(sql, null);
					if (count == 1) {
						JOptionPane.showMessageDialog(this, "保存操作成功完成!",
								"成功", JOptionPane.PLAIN_MESSAGE);
						showData();
					} else {
						JOptionPane.showMessageDialog(this, "抱歉! 保存数据失败!",
								"失败:", 0);
					}
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					db.closeAll();
				}
}
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值