这是我第一次接触Oracle数据库并且利用JavaSwing图形界面编写的一个简单的超市管理系统,其实整体代码后续看了一下,因为JDBC刚接触以及之前JavaSE没学清楚,弄得代码逻辑很繁杂,后面想改又懒,就先记着,有空的话再说==。

具体要求如下:
某超市需要开发购物管理系统进行收银管理,需要为:
(1)系统用户分为管理员和收银员,管理员有用户管理,会员管理和商品管理的功能,收银员通过系统进行收银;
(2)只有会员能在超市购买商品;
(3)系统有一些统计分析功能,如每个月销售最好的商品,不同年龄层(如10年分类一个年龄层)的购物类别,单月收银最高的收银员等。

要求:
(1)后台数据库使用的是Oracle;
(2)超市购物管理系统的所有操作均在可视化界面下进行,前台开发工具不限;
(3)最后提交材料包括代码和文档。

具体代码如下:
dao包
管理员操作

package supermaket.dao;//对货物信息表进行操作的数据访问类
import chaoshiguanli.entity.Good;
import supermaket.entity.GoodsInfo;
import supermaket.entity.Cashier;
import supermaket.entity.Member;
import supermaket.until.JDBCUtils;import java.sql.*;
import java.util.ArrayList;/*管理员操作类通过调用sql查询获取数据库信息,并更新前端表格*/
public class AdminDao {//仓库管理// 获取所有数据,不需要文本框,就一个按钮,点击会全部跳出结果public ArrayList<GoodsInfo> queryAllData() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象stmt = conn.createStatement();// 发送SQL语句,select * from scott.t_goodsString sql = "SELECT * FROM scott.t_goods order by g_num";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {GoodsInfo sgoods = new GoodsInfo();sgoods.setNum(rs.getString("g_num"));sgoods.setName(rs.getString("g_name"));sgoods.setPrice(rs.getString("g_price"));sgoods.setCount(rs.getString("g_count"));list.add(sgoods);}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}//需要修改,修改成一个单独查询按钮,点击跳出对应查询结果// 查询数据public GoodsInfo find(String cnumber) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句String sql = "select * from scott.t_goods where g_num='" + cnumber + "'";rs = stmt.executeQuery(sql);if (rs.next()) {System.out.println("查询数据成功!");GoodsInfo goodsInfo=new GoodsInfo();goodsInfo.setNum(rs.getString("g_num"));goodsInfo.setName(rs.getString("g_name"));goodsInfo.setPrice(rs.getString("g_price"));goodsInfo.setCount(rs.getString("g_count"));return goodsInfo;}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}// 添加数据//   ✔public void add(GoodsInfo mr) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,insert into scott.t_goods values(g_seq.nextval,name,price,count)//insert into scott.t_goods values(g_seq.nextval,'饼干',5,200)String sql = "INSERT INTO scott.t_goods VALUES(scott.g_seq.nextval,'" + mr.getName() + "'," + Integer.valueOf(mr.getPrice())+ "," + Integer.valueOf(mr.getCount()) + ")";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("插入数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//删除数据public void del(String delNumber) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 首先执行查询语句判断商品存在,select * from scott.t_goods where g_num=numrs = stmt.executeQuery("select * from scott.t_goods where g_num='" + delNumber + "'");System.out.println(delNumber);if (rs.next()) {//sql语句。delete from scott.t_goods where g_num=numString sql = "DELETE FROM scott.t_goods WHERE g_num='" + delNumber + "'";System.out.println(sql);int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("删除数据成功!");}}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//修改数据public void update(GoodsInfo mr) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,update scott.t_good set g_name = name,g_price=price,g_count=count where g_num=numString sql = "UPDATE scott.t_goods set g_name='" + mr.getName() + "',g_price=" + Integer.valueOf(mr.getPrice()) + ",g_count="+  Integer.valueOf(mr.getCount()) + " where g_num='" + mr.getNum() + "'";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("更新数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//会员管理/*** 添加会员* @param new_mem:会员账号,会员密码,会员名,会员年龄*/public void addMem(Member new_mem){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,INSERT INTO scott.t_member VALUES(m_seq.nextval,accout,psw,name,age)String sql = "INSERT INTO scott.t_member VALUES(scott.m_seq.nextval,'" + new_mem.getAccout() + "','" + new_mem.getPsw() +"','" + new_mem.getName()+"'," + new_mem.getAge() + ")";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("插入数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}/*** 删除会员* @param delAccout:会员账号*/public void delMem(String delAccout){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 首先执行查询语句判断会员是否存在,select * from scott.t_member where m_acc=acc;rs = stmt.executeQuery("select * from scott.t_member where m_acc='" + delAccout + "'");System.out.println(delAccout);if (rs.next()) {String sql = "DELETE FROM scott.t_member WHERE m_acc='" + delAccout + "'";System.out.println(sql);int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("删除数据成功!");}}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}/*** 更新会员细腻些* @param mem:会员账号,会员密码,会员姓名,会员年龄*/public void updateMem(Member mem){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句// update scott.t_member set m_acc=acc,m_pwd=pwd,m_name=name.m_age=age where m_acc=acc;String sql = "UPDATE scott.t_member set m_acc='" + mem.getAccout() + "',m_pwd='" + mem.getPsw()  +"',m_name='"+mem.getName() +"',m_age="+ mem.getAge()+" where m_acc='" +  mem.getAccout() + "'";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("更新数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}/*** 查询全部会员* @return 会员信息链表*/public ArrayList<Member> queryAllMem() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<Member> list = new ArrayList<Member>();try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象stmt = conn.createStatement();// 发送SQL语句// select* from scott.t_memberString sql = "SELECT * FROM scott.t_member";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {Member member = new Member();member.setAccout(rs.getString("m_acc"));member.setPsw(rs.getString("m_pwd"));member.setName(rs.getString("m_name"));member.setAge(rs.getInt("m_age"));list.add(member);}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}//查询单个会员信息public Member queMem(String acc){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句 select * from scott.t_member where m_acc=acc;String sql = "select * from scott.t_member where m_acc='" + acc + "'";rs = stmt.executeQuery(sql);if (rs.next() ) {System.out.println("查询数据成功!");Member member = new Member();member.setAccout(rs.getString("m_acc"));member.setPsw(rs.getString("m_pwd"));member.setName(rs.getString("m_name"));member.setAge(rs.getInt("m_age"));return member;}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}//收银员管理//增加会员,public void addCash(Cashier cashier){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,INSERT INTO scott.t_cashier VALUES(c_seq.nextval,accout,psw,name)String sql = "INSERT INTO scott.t_cashier VALUES(scott.c_seq.nextval,'" + cashier.getAccout() + "','" + cashier.getPsw() +"','"+cashier.getName()+"')";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("插入数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//删除会员public void delCash(String delAccout){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 首先执行查询语句判断会员是否存在,select * from scott.t_cashier where m_acc=acc;rs = stmt.executeQuery("select * from scott.t_cashier where c_acc='" + delAccout + "'");System.out.println(delAccout);if (rs.next()) {String sql = "DELETE FROM scott.t_cashier WHERE c_acc='" + delAccout + "'";System.out.println(sql);int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("删除数据成功!");}}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//修改会员public void updateCash(Cashier cashier){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句// update scott.t_cashier set c_acc=acc,c_pwd=pwd,c_name=name.c_age=age where c_acc=acc;String sql = "UPDATE scott.t_cashier set c_acc='" + cashier.getAccout() + "',c_pwd='" + cashier.getPsw() +"',c_name='"+cashier.getName() +"' where c_acc='" +  cashier.getAccout() + "'";int num = stmt.executeUpdate(sql);if (num > 0) {System.out.println("更新数据成功!");}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}}//查询全部会员信息public ArrayList<Cashier> queryAllCash() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<Cashier> list = new ArrayList<Cashier>();try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象stmt = conn.createStatement();// 发送SQL语句// select* from scott.t_cashierString sql = "SELECT * FROM scott.t_cashier";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {Cashier cashier = new Cashier();cashier.setAccout(rs.getString("c_acc"));cashier.setPsw(rs.getString("c_pwd"));cashier.setName(rs.getString("c_name"));list.add(cashier);}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}//查询单个会员信息//✔public Cashier queCash(String acc){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句 select * from scott.t_cashier where c_acc=acc;String sql = "select * from scott.t_cashier where c_acc='" + acc + "'";rs = stmt.executeQuery(sql);if (rs.next() ) {System.out.println("CASH查询数据成功!");Cashier cashier = new Cashier();cashier.setAccout(rs.getString("c_acc"));cashier.setPsw(rs.getString("c_pwd"));cashier.setName(rs.getString("c_name"));return cashier;}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}//统计服务/*** 查询历史销售额* @return*/public String[][] allsale(){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();//长度查询String leng_sql="select count(*)as num from  scott.t_goods_sal ";rs=stmt.executeQuery(leng_sql);int leng=0;if (rs.next())leng=rs.getInt("num");System.out.println("长度为"+leng);// 发送SQL语句 select g_num,g_price,sum(g_sales)as sale from scott.t_goods_sal group by g_num,g_name,g_priceString sql="select g_num,g_name,g_price,sum(g_sales)as sale from scott.t_goods_sal " +"group by g_num,g_name,g_price order by sale";rs=stmt.executeQuery(sql);String [][] list=new String[leng][4];int i=0;while (rs.next()&&leng!=0){list[i][0]=rs.getString("g_num");list[i][1]=rs.getString("g_name");list[i][2]=rs.getString("g_price");list[i][3]=rs.getString("Sale");i++;if (i==leng)break;;}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}/*** 返回最大销量或者最小销量* @param choice,0-->最大值,1-->最小值* @return 最大值||最小值*/public String[] maxorminsale(int choice){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();String sql;if (choice==0) {//最大// 发送SQL语句 select g_num,g_price,sum(g_sales)as sale from scott.t_goods_sal group by g_num,g_name,g_pricesql = "select g_num,g_name,g_price,sum(g_sales)as sale from scott.t_goods_sal" +" where g_num in (select g_num from (select g_num,sum(g_sales)as sales" +" from scott.t_goods_sal group by g_num) where sales=(Select max(sales) From(select g_num,sum(g_sales)as sales" +" from scott.t_goods_sal group by g_num)))group by g_num,g_name,g_price";}else{sql="select g_num,g_name,g_price,sum(g_sales)as sale from scott.t_goods_sal" +" where g_num in (select g_num from (select g_num,sum(g_sales)as sales" +" from scott.t_goods_sal group by g_num) where sales=(Select min(sales) From(select g_num,sum(g_sales)as sales" +" from scott.t_goods_sal group by g_num)))group by g_num,g_name,g_price";}rs=stmt.executeQuery(sql);if(rs.next()){String[] goodsdata=new String[4];goodsdata[0]=rs.getString("g_num");goodsdata[1]=rs.getString("g_name");goodsdata[2]=rs.getString("g_price");goodsdata[3]=rs.getString("sale");return goodsdata;}} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}/*** 返回总的收银账单* @return list, String[][]类型账单列表*/public String[][] allcash(){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();int leng=0;String leng_sql="select count(*)as num from  scott.t_cashier_cash";rs=stmt.executeQuery(leng_sql);if (rs.next())leng=rs.getInt("num");System.out.println("长度为"+leng);// 发送SQL语句 select g_num,sum(cash)as cash from scott.t_cashier_cash group by g_num;String sql="select c_acc,sum(cash)as cashs from scott.t_cashier_cash group by c_acc";rs=stmt.executeQuery(sql);String [][] list=new String[leng][2];int i=0;while (rs.next()&&leng!=0){list[i][0]=rs.getString("c_acc");list[i][1]=rs.getString("cashs");i++;if (i==leng)break;}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}public String[] turnover(){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句String sql="select c_acc,sum(cash)as Cashs from scott.t_cashier_cash" +" where c_acc in (select c_acc from (select c_acc,sum(cash)as cashs" +" from scott.t_cashier_cash group by c_acc) where cashs=(Select max(cashs) from" +" (select c_acc,sum(cash)as cashs from scott.t_cashier_cash group by c_acc))) group by c_acc";rs=stmt.executeQuery(sql);if (rs.next()){String[] cashdata=new String[2];cashdata[0]=rs.getString("c_acc");//收银员编号cashdata[1]=rs.getString("Cashs");//对应的收银额return cashdata;}elsereturn null;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}public String[] buy(){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句String sql="select m_acc,sum(buy)as Buy from scott.t_goods_mem" +" where m_acc in (select m_acc from (select m_acc,sum(buy)as buys" +" from scott.t_goods_mem group by m_acc) where buys=(Select max(buy) from" +" (select m_acc,sum(buy)as buys from scott.t_goods_mem group by m_acc))) group by m_acc";rs=stmt.executeQuery(sql);if (rs.next()){String [] data=new String[2];data[0]=rs.getString("m_acc");data[1]=rs.getString("Buy");return data;}elsereturn null;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}public String[][] ageforgoods(){Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();String[][]data=new String[6][3];int loc=0;for (int i=0;i<=60;i=i+10){String sql="select g_num,g_name from scott.t_goods_age where age between " +i+" and "+(i+10)+" group by g_num,g_name";rs=stmt.executeQuery(sql);if (rs.next()){data[loc][0]=i+"~"+(i+10);data[loc][1]=rs.getString("g_num");data[loc][2]=rs.getString("g_name");loc++;}}if (loc!=0)return data;elsereturn null;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return null;}/*** 查询全部会员* @return 会员信息链表*/public ArrayList<Member> querymemhis() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<Member> list = new ArrayList<Member>();try {conn = JDBCUtils.getConnection();stmt = conn.createStatement();// 发送SQL语句String sql = "select * from scott.t_member_his";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {Member member = new Member();member.setAccout(rs.getString("m_acc"));member.setPsw(rs.getString("m_pwd"));member.setName(rs.getString("m_name"));member.setAge(rs.getInt("m_age"));list.add(member);}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}public ArrayList<Good> querygoodhis() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<Good> list = new ArrayList<Good>();try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象stmt = conn.createStatement();String sql = "SELECT * FROM scott.t_goods_his";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {Good sgoods = new Good();sgoods.setNum(rs.getString("g_num"));sgoods.setName(rs.getString("g_name"));sgoods.setPrice(rs.getString("g_price"));list.add(sgoods);}return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}
}

收银员操作

package supermaket.dao;import supermaket.entity.GoodsInfo;
import supermaket.entity.Member;
import supermaket.until.JDBCUtils;import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;public class CashierDao {// 获取所有数据,不需要文本框,在会员界面只会在初始情况自动调用,还有购物车结算后自动调用public ArrayList<GoodsInfo> queryAllData() {Connection conn = null;Statement stmt = null;ResultSet rs = null;ArrayList<GoodsInfo> list = new ArrayList<GoodsInfo>();try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象stmt = conn.createStatement();// 发送SQL语句,select * from scott.t_goodsString sql = "SELECT * FROM scott.t_goods  order by g_num ";rs = stmt.executeQuery(sql);// 处理结果集while (rs.next()) {GoodsInfo goods = new GoodsInfo();goods.setNum(rs.getString("g_num"));goods.setName(rs.getString("g_name"));goods.setPrice(rs.getString("g_price"));goods.setCount(rs.getString("g_count"));list.add(goods);}System.out.println("cash->goods查询全部库存成功");return list;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);// 关闭数据库}return null;}/**更新数据输入:编号,剩余数量输出:更新成功布尔值*/public boolean update(String num,int last) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,update scott.t_goods set g_count=last where g_num=num;String sql = "UPDATE scott.t_goods set g_count=" +last +" where g_num='" + num+ "'";int res = stmt.executeUpdate(sql);if (res > 0) {System.out.println("cash->good更新数据成功!");return true;}elsereturn false;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return false;}public boolean updategoodsal(GoodsInfo goods, int sal, int age,Member member) {Connection conn = null;Statement stmt = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement对象stmt = conn.createStatement();// 发送SQL语句,insert scott.t_goods_sal values(num,name,price,sal),先更新sal表String sql_1 = "insert into scott.t_goods_sal values ('" +goods.getNum() + "','" +goods.getName()+"','" +goods.getPrice()+ "'," +sal+")";//t_goods_sal插入数据成功后,对t_goods_age插入数据//sql语句为 insert scott.t_goods_age values(num,name,age),再更新age表String sql_2 = "insert into scott.t_goods_age values ('" +goods.getNum() + "','" +goods.getName()+"'," +age+")";String sql_3="insert into scott.t_goods_mem values('"+member.getAccout()+"',"+sal+")";int res_1 = stmt.executeUpdate(sql_1);int res_2 = stmt.executeUpdate(sql_2);int res_3 = stmt.executeUpdate(sql_3);if (res_1 > 0 && res_2 > 0 && res_3 > 0) {return true;}elsereturn false;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs, stmt, conn);}return false;}
}

检查用户

package supermaket.dao;import supermaket.entity.Administrator;
import supermaket.entity.Cashier;
import supermaket.entity.Member;
import supermaket.until.JDBCUtils;import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;public class Checkusers {//判断管理员账号是否存在在数据库中public static boolean checkAdm(Administrator adm){Connection conn = null;Statement sta = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象sta = conn.createStatement();// 发送SQL语句String sql = "SELECT * FROM scott.tb_admin where a_acc='"+adm.getAccout()+"'";//重新命名,应该是管理员表,System.out.println(sql);rs = sta.executeQuery(sql);// 找到该账号,判断密码是否正确if (rs.next()){if (rs.getString("a_pwd").equals(adm.getPsw()))return true;elsereturn false;}elsereturn false;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release(rs,sta, conn);// 关闭数据库}return false;}//判断收银员账号是否存在在数据库中public static boolean checkCash(Cashier cashier){Connection conn = null;Statement sta = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象sta = conn.createStatement();// 发送SQL语句String sql = "SELECT * FROM scott.t_cashier where c_acc='"+cashier.getAccout()+"'";//重新命名,应该是管理员表,rs = sta.executeQuery(sql);// 找到该账号,判断密码是否正确if (rs.next()){if (rs.getString("c_pwd").equals(cashier.getPsw()))return true;elsereturn false;}elsereturn false;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release( rs,sta, conn);// 关闭数据库}return false;}public static Member checkMem(String acc,String psw){Connection conn = null;Statement sta = null;ResultSet rs = null;try {// 获得数据的连接conn = JDBCUtils.getConnection();// 获得Statement 对象sta = conn.createStatement();// 发送SQL语句String sql = "SELECT * FROM scott.t_member where m_acc='"+acc+"'";//重新命名,应该是管理员表,rs = sta.executeQuery(sql);// 找到该账号,判断密码是否正确if (rs.next()){if (rs.getString("m_pwd").equals(psw)){Member member1=new Member(rs.getString("m_acc"),rs.getString("m_pwd"),rs.getString("m_name"),rs.getInt("m_age"));return member1;}elsereturn null;}elsereturn null;} catch (Exception e) {e.printStackTrace();} finally {JDBCUtils.release( rs,sta, conn);// 关闭数据库}return null;}}

daoimpl包

package supermaket.daoimpl;//定义管理窗口类AbstractAdminDialog
import supermaket.login.CashManaDialogController;
import supermaket.login.MemManaDialogController;
import supermaket.login.StaticsDialogController;import java.awt.Font;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import javax.swing.*;//管理窗口类
@SuppressWarnings("serial")
public abstract class AbstractAdminDialog extends JDialog  implements WindowListener {// 定义界面使用到的组件// 成员变量private JLabel tableLabel = new JLabel("货物列表");// 标题private JScrollPane tablePane = new JScrollPane();// 滚动视口protected JTable table = new JTable();// 货物列表private JLabel numLabel = new JLabel("货物编号");private JLabel promptLabel = new JLabel("仅用于查询,无法修改");private JLabel nameLabel = new JLabel("货物名称");private JLabel priceLabel = new JLabel("货物单价");private JLabel countLabel = new JLabel("货物数量");private JLabel numLabel_1 = new JLabel("货物编号");private JLabel numLabel_2 = new JLabel("货物编号");//添加功能组件protected JTextField addnameText = new JTextField();// 添加名称文本框protected JTextField addpriceText = new JTextField();// 添加单价文本框protected JTextField addcountText = new JTextField();// 添加货物数量文本框private JButton addBtn = new JButton("添加");//修改功能组件protected JTextField updatenumText = new JTextField();// 修改编号文本框protected JTextField updatenameText = new JTextField();// 修改名称文本框protected JTextField updatepriceText = new JTextField();// 修改单价文本框protected JTextField updatecountText = new JTextField();// 修改货物数量文本框private JButton updateBtn = new JButton("修改");//删除功能组件protected JTextField delnumText = new JTextField();// 删除编号文本框private JButton delBtn = new JButton("删除");//查询功能组件protected JTextField searchnumText = new JTextField();// 查询编号文本框private JButton findBtn = new JButton("查询");//添加会员组件private JButton CashBtn = new JButton("收银员管理");private JButton MemBtn = new JButton("会员管理");private JButton DataBtn = new JButton("统计数据");//构造方法public AbstractAdminDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();this.addWindowListener((WindowListener) this);}public AbstractAdminDialog() {this(null, true);}//初始化private void init() {this.setTitle("超市管理系统:管理员界面");this.setSize(700, 600);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}//添加组件private void addComponent() {this.setLayout(null);// 表格标题tableLabel.setBounds(320, 5, 100, 20);// 设置位置大小tableLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(tableLabel);// 表格table.getTableHeader().setReorderingAllowed(false);// 列不可移动table.getTableHeader().setResizingAllowed(false);// 不可拉动表格table.setEnabled(false);// 不可更改数据tablePane.setBounds(30, 40, 630, 270);tablePane.setViewportView(table);this.add(tablePane);// 字段标题numLabel.setBounds(30, 360, 100, 30);// 放置四个标签numLabel.setFont(new Font("宋体", Font.PLAIN, 16));promptLabel.setBounds(30, 390, 120, 10);// 放置四个标签promptLabel.setFont(new Font("宋体", Font.PLAIN, 8));nameLabel.setBounds(150, 320, 100, 30);     //150nameLabel.setFont(new Font("宋体", Font.PLAIN, 16));priceLabel.setBounds(280, 320, 100, 30);    //280priceLabel.setFont(new Font("宋体", Font.PLAIN, 16));countLabel.setBounds(410, 320, 100, 30);countLabel.setFont(new Font("宋体", Font.PLAIN, 16));this.add(numLabel);this.add(promptLabel);this.add(nameLabel);this.add(priceLabel);this.add(countLabel);// 增加addnameText.setBounds(150, 350, 80, 30);addpriceText.setBounds(280, 350, 80, 30);addcountText.setBounds(410, 350, 80, 30);this.add(addnameText);this.add(addpriceText);this.add(addcountText);addBtn.setBounds(540, 350, 80, 30);addBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(addBtn);// 修改updatenumText.setBounds(30, 400, 80, 30);updatenameText.setBounds(150, 400, 80, 30);updatepriceText.setBounds(280, 400, 80, 30);updatecountText.setBounds(410, 400, 80, 30);this.add(updatenumText);this.add(updatenameText);this.add(updatepriceText);this.add(updatecountText);updateBtn.setBounds(540, 400, 80, 36);updateBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(updateBtn);numLabel_1.setBounds(35, 430, 100, 30);// 放置四个标签numLabel_1.setFont(new Font("宋体", Font.PLAIN, 16));numLabel_2.setBounds(415, 430, 100, 30);// 放置四个标签numLabel_2.setFont(new Font("宋体", Font.PLAIN, 16));this.add(numLabel_1);this.add(numLabel_2);// 查询searchnumText.setBounds(30, 460, 80, 36);// 460this.add(searchnumText);findBtn.setBounds(150, 460, 80, 36);// 460findBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(findBtn);// 删除delnumText.setBounds(410, 460, 80, 36);// 510this.add(delnumText);delBtn.setBounds(540, 460, 80, 36);// 510delBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(delBtn);//会员管理MemBtn.setBounds(50,515,160,36);MemBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(MemBtn);//收银员管理CashBtn.setBounds(250,515,160,36);CashBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(CashBtn);//数据统计界面DataBtn.setBounds(450,515,160,36);DataBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(DataBtn);}//添加监听器private void addListener() {// 添加按钮监听addBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法addGoodsItem();}});// 修改按钮监听updateBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法updateGoodsItem();}});// 删除按钮监听delBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法delGoodsItem();}});// 查询按钮监听findBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法findGoodsItem();}});//会员按钮监听MemBtn.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {//开启添加会员窗口new MemManaDialogController().setVisible(true);}});//收银员按钮监听CashBtn.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {//开启添加收银窗口new CashManaDialogController().setVisible(true);}});DataBtn.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {//开启添加收银窗口new StaticsDialogController().setVisible(true);System.out.println("正在完善");}});}//添加public abstract void addGoodsItem();//修改public abstract void updateGoodsItem();//删除public abstract void delGoodsItem();//输出全部表内容public abstract void queryGoodsItem();//查询public abstract void findGoodsItem();
}
package supermaket.daoimpl;import supermaket.entity.GoodsInfo;
import supermaket.login.CheckMemDialogController;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import java.util.ArrayList;public abstract class AbstractCashDialog extends JDialog  implements WindowListener {// 定义界面使用到的组件// 成员变量private JLabel tableLabel = new JLabel("货物列表");// 标题private JScrollPane tablePane = new JScrollPane();// 滚动视口protected JTable table = new JTable();// 货物列表private JLabel numLabel = new JLabel("货物编号");private JLabel nameLabel = new JLabel("货物名称");private JLabel priceLabel = new JLabel("货物单价");private JLabel countLabel = new JLabel("货物数量");private JLabel promptLabel = new JLabel("编号,数量必填,其他可不填");//添加物品至购物车protected JTextField addnumText = new JTextField();// 添加编号文本框protected JTextField addnameText = new JTextField();// 添加名称文本框protected JTextField addpriceText = new JTextField();// 添加单价文本框protected JTextField addcountText = new JTextField();// 添加货物数量文本框private JButton addBtn = new JButton("添加");//购物车结算private JButton browseBtn = new JButton("结算");private JLabel cartLabel = new JLabel("购物车列表");// 标题private JScrollPane cartPane = new JScrollPane();// 滚动视口protected JTable carttable = new JTable();// 货物列表ArrayList<GoodsInfo> cart;//存储用户的购物车//构造方法public AbstractCashDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();this.addWindowListener((WindowListener) this);}public AbstractCashDialog() {this(null, true);}//初始化private void init() {this.setTitle("超市管理系统:会员界面");this.setSize(700, 650);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}//添加组件private void addComponent() {this.setLayout(null);// 表格标题tableLabel.setBounds(320, 15, 100, 20);// 设置位置大小tableLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(tableLabel);// 表格table.getTableHeader().setReorderingAllowed(false);// 列不可移动table.getTableHeader().setResizingAllowed(false);// 不可拉动表格table.setEnabled(false);// 不可更改数据tablePane.setBounds(30, 50, 630, 220);tablePane.setViewportView(table);this.add(tablePane);// 字段标题numLabel.setBounds(50, 270, 100, 30);// 放置四个标签numLabel.setFont(new Font("宋体", Font.PLAIN, 16));nameLabel.setBounds(170, 270, 100, 30);nameLabel.setFont(new Font("宋体", Font.PLAIN, 16));priceLabel.setBounds(300, 270, 100, 30);priceLabel.setFont(new Font("宋体", Font.PLAIN, 16));countLabel.setBounds(430, 270, 100, 30);countLabel.setFont(new Font("宋体", Font.PLAIN, 16));promptLabel.setBounds(530, 270, 160, 30);promptLabel.setFont(new Font("宋体", Font.PLAIN, 12));this.add(numLabel);this.add(nameLabel);this.add(priceLabel);this.add(countLabel);this.add(promptLabel);// 增加addnumText.setBounds(50, 300, 80, 30);addnameText.setBounds(170, 300, 80, 30);addpriceText.setBounds(300, 300, 80, 30);addcountText.setBounds(430, 300, 80, 30);this.add(addnumText);this.add(addnameText);this.add(addpriceText);this.add(addcountText);addBtn.setBounds(560, 300, 80, 30);addBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(addBtn);// 表格标题cartLabel.setBounds(320, 340, 100, 20);// 设置位置大小cartLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(cartLabel);// 表格carttable.getTableHeader().setReorderingAllowed(false);// 列不可移动carttable.getTableHeader().setResizingAllowed(false);// 不可拉动表格carttable.setEnabled(false);// 不可更改数据cartPane.setBounds(30, 365, 630, 200);cartPane.setViewportView(carttable);this.add(cartPane);browseBtn.setBounds(320, 575, 80, 30);browseBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(browseBtn);}//添加监听器private void addListener() {// 添加按钮监听addBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {addShopCart();//添加进购物车列表showCart(); //展示购物车}});// 修改按钮监听browseBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {updateGoodsItem();}});}//修改public abstract void updateGoodsItem();//展示购物车列表public abstract void showCart();public abstract void addShopCart();//输出全部表内容public abstract void queryGoodsItem();//查询public abstract GoodsInfo findGoodsItem();
}
package supermaket.daoimpl;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;public abstract class   AbstractCashManaDialog  extends JDialog {// 定义界面使用到的组件// 成员变量private JLabel tableLabel = new JLabel("收银员列表");// 标题private JScrollPane tablePane = new JScrollPane();// 滚动视口protected JTable table = new JTable();// 货物列表private JLabel accLabel = new JLabel("收银员账号(不可重复)");private JLabel pwdLabel = new JLabel("密码");private JLabel nameLabel = new JLabel("姓名");private JLabel numLabel_1 = new JLabel("收银员账号");private JLabel numLabel_2 = new JLabel("收银员账号");//添加功能组件protected JTextField addaccText = new JTextField();// 添加编号文本框protected JTextField addpwdText = new JTextField();// 添加名称文本框protected JTextField addnameText = new JTextField();// 添加编号文本框private JButton addBtn = new JButton("添加");//修改功能组件protected JTextField updateaccText = new JTextField();// 修改编号文本框protected JTextField updatepwdText = new JTextField();// 修改名称文本框protected JTextField updatenameText = new JTextField();// 修改单价文本框private JButton updateBtn = new JButton("修改");//删除功能组件protected JTextField delaccText = new JTextField();// 删除编号文本框private JButton delBtn = new JButton("删除");//查询功能组件protected JTextField searchnumText = new JTextField();// 查询编号文本框private JButton findBtn = new JButton("查询");//构造方法public AbstractCashManaDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();}public AbstractCashManaDialog() {this(null, true);}//初始化private void init() {this.setTitle("超市管理系统:收银员管理");this.setSize(550, 550);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}//添加组件private void addComponent() {this.setLayout(null);// 表格标题tableLabel.setBounds(220, 15, 100, 20);// 设置位置大小tableLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(tableLabel);// 表格table.getTableHeader().setReorderingAllowed(false);// 列不可移动table.getTableHeader().setResizingAllowed(false);// 不可拉动表格table.setEnabled(false);// 不可更改数据tablePane.setBounds(30, 50, 480, 270);tablePane.setViewportView(table);this.add(tablePane);// 字段标题accLabel.setBounds(35, 320, 130, 30);// 放置4个标签,账号,密码,姓名,年龄accLabel.setFont(new Font("宋体", Font.PLAIN, 12));pwdLabel.setBounds(175, 320, 100, 30);pwdLabel.setFont(new Font("宋体", Font.PLAIN, 16));nameLabel.setBounds(315, 320, 100, 30);nameLabel.setFont(new Font("宋体", Font.PLAIN, 16));this.add(accLabel);this.add(pwdLabel);this.add(nameLabel);// 增加addaccText.setBounds(30, 350, 80, 30);addpwdText.setBounds(150, 350, 80, 30);addnameText.setBounds(280, 350, 80, 30);this.add(addaccText);this.add(addpwdText);this.add(addnameText);addBtn.setBounds(380, 350, 80, 30);addBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(addBtn);// 修改updateaccText.setBounds(30, 400, 80, 30);updatepwdText.setBounds(150, 400, 80, 30);updatenameText.setBounds(280, 400, 80, 30);this.add(updateaccText);this.add(updatepwdText);this.add(updatenameText);updateBtn.setBounds(380, 400, 80, 36);updateBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(updateBtn);numLabel_1.setBounds(35, 430, 100, 30);// 放置四个标签numLabel_1.setFont(new Font("宋体", Font.PLAIN, 16));numLabel_2.setBounds(285, 430, 100, 30);// 放置四个标签numLabel_2.setFont(new Font("宋体", Font.PLAIN, 16));this.add(numLabel_1);this.add(numLabel_2);// 查询searchnumText.setBounds(30, 460, 80, 36);// 460this.add(searchnumText);findBtn.setBounds(150, 460, 80, 36);// 460findBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(findBtn);// 删除delaccText.setBounds(280, 460, 80, 36);// 510this.add(delaccText);delBtn.setBounds(380, 460, 80, 36);// 510delBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(delBtn);}//添加监听器private void addListener() {// 添加按钮监听addBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {addCash();}});// 修改按钮监听updateBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {updateCash();}});// 删除按钮监听delBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {deleteCash();}});// 查询按钮监听findBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {querryCash();}});}//添加会员public abstract void addCash();//删除会员public abstract void deleteCash();//修改会员信息public abstract void updateCash();//查询全部会员信息public abstract void querryAllCash();//查询单个会员信息public abstract void querryCash();
}
package supermaket.daoimpl;import supermaket.entity.Member;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;public abstract class AbstractCheckMemDialog  extends JDialog {// 定义界面使用到的组件// 成员变量private JLabel accLabel_1 = new JLabel("会员账号");private JLabel pwdLabel_1 = new JLabel("会员密码");//添加功能组件protected JTextField addaccText = new JTextField();// 添加编号文本框protected JTextField addpwdText = new JTextField();// 添加名称文本框private JButton addBtn = new JButton("检查");//构造方法public AbstractCheckMemDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();}private void init() {this.setTitle("超市管理系统:会员账号输入");this.setSize(350, 150);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}public AbstractCheckMemDialog() {this(null, true);}//添加组件private void addComponent() {this.setLayout(null);// 字段标题accLabel_1.setBounds(15, 15, 100, 30);// 放置俩个标签accLabel_1.setFont(new Font("宋体", Font.PLAIN, 16));pwdLabel_1.setBounds(125, 15, 100, 30);pwdLabel_1.setFont(new Font("宋体", Font.PLAIN, 16));this.add(accLabel_1);this.add(pwdLabel_1);// 增加addaccText.setBounds(10, 45, 80, 30);addpwdText.setBounds(120, 45, 80, 30);this.add(addaccText);this.add(addpwdText);addBtn.setBounds(220, 45, 80, 30);addBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(addBtn);}//添加监听器private void addListener() {// 添加按钮监听addBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法checkMem();}});}public abstract void checkMem();
}
package supermaket.daoimpl;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;public abstract class AbstractMemManaDialog extends JDialog {// 定义界面使用到的组件// 成员变量private JLabel tableLabel = new JLabel("统计数据表");// 标题private JScrollPane tablePane = new JScrollPane();// 滚动视口protected JTable table = new JTable();// 显示数据private JLabel accLabel = new JLabel("会员账号(不可重复)");private JLabel pwdLabel = new JLabel("密码");private JLabel nameLabel = new JLabel("姓名");private JLabel ageLabel = new JLabel("年龄");private JLabel numLabel_1 = new JLabel("会员账号");private JLabel numLabel_2 = new JLabel("会员账号");protected JTextField addaccText = new JTextField();// 添加编号文本框protected JTextField addpwdText = new JTextField();// 添加名称文本框protected JTextField addnameText = new JTextField();// 添加单价文本框protected JTextField addageText = new JTextField();// 添加货物数量文本框private JButton addBtn = new JButton("添加");protected JTextField updateaccText = new JTextField();// 添加编号文本框protected JTextField updatepwdText = new JTextField();// 添加名称文本框protected JTextField updatenameText = new JTextField();// 添加单价文本框protected JTextField updateageText = new JTextField();// 添加货物数量文本框private JButton updateBtn = new JButton("修改");//删除功能组件protected JTextField delaccText = new JTextField();// 删除编号文本框private JButton delBtn = new JButton("删除");//查询功能组件protected JTextField searchnumText = new JTextField();// 删除编号文本框private JButton findBtn = new JButton("查询");//构造方法public AbstractMemManaDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();}public AbstractMemManaDialog() {this(null, true);}//初始化private void init() {this.setTitle("超市管理系统:会员管理面");this.setSize(700, 550);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}//添加组件private void addComponent() {this.setLayout(null);// 表格标题tableLabel.setBounds(320, 15, 100, 20);// 设置位置大小tableLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(tableLabel);// 表格table.getTableHeader().setReorderingAllowed(false);// 列不可移动table.getTableHeader().setResizingAllowed(false);// 不可拉动表格table.setEnabled(false);// 不可更改数据tablePane.setBounds(30, 50, 630, 270);tablePane.setViewportView(table);this.add(tablePane);// 字段标题accLabel.setBounds(30, 320, 130, 30);// 放置4个标签,账号,密码,姓名,年龄accLabel.setFont(new Font("宋体", Font.PLAIN, 12));pwdLabel.setBounds(170, 320, 100, 30);pwdLabel.setFont(new Font("宋体", Font.PLAIN, 16));nameLabel.setBounds(300, 320, 100, 30);nameLabel.setFont(new Font("宋体", Font.PLAIN, 16));ageLabel.setBounds(430, 320, 100, 30);ageLabel.setFont(new Font("宋体", Font.PLAIN, 16));this.add(accLabel);this.add(pwdLabel);this.add(nameLabel);this.add(ageLabel);// 增加addaccText.setBounds(30, 350, 80, 30);addpwdText.setBounds(150, 350, 80, 30);addnameText.setBounds(280, 350, 80, 30);addageText.setBounds(410, 350, 80, 30);this.add(addaccText);this.add(addpwdText);this.add(addnameText);this.add(addageText);addBtn.setBounds(540, 350, 80, 30);addBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(addBtn);// 修改updateaccText.setBounds(30, 400, 80, 30);updatepwdText.setBounds(150, 400, 80, 30);updatenameText.setBounds(280, 400, 80, 30);updateageText.setBounds(410, 400, 80, 30);this.add(updateaccText);this.add(updatepwdText);this.add(updatenameText);this.add(updateageText);updateBtn.setBounds(540, 400, 80, 36);updateBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(updateBtn);numLabel_1.setBounds(35, 430, 100, 30);// 放置四个标签numLabel_1.setFont(new Font("宋体", Font.PLAIN, 16));numLabel_2.setBounds(415, 430, 100, 30);// 放置四个标签numLabel_2.setFont(new Font("宋体", Font.PLAIN, 16));this.add(numLabel_1);this.add(numLabel_2);// 查询searchnumText.setBounds(30, 460, 80, 36);// 460this.add(searchnumText);findBtn.setBounds(150, 460, 80, 36);// 460findBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(findBtn);// 删除delaccText.setBounds(410, 460, 80, 36);// 510this.add(delaccText);delBtn.setBounds(540, 460, 80, 36);// 510delBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(delBtn);}//添加监听器private void addListener() {// 添加按钮监听addBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法addMem();}});// 修改按钮监听updateBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法updateMem();}});// 删除按钮监听delBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法deleteMem();}});// 查询按钮监听findBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// 调用修改方法querryMem();}});}//添加会员public abstract void addMem();//删除会员public abstract void deleteMem();//修改会员信息public abstract void updateMem();//查询全部会员信息public abstract void querryAllMem();//查询单个会员信息public abstract void querryMem();
}
package supermaket.daoimpl;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;public abstract class AbstractStatisticsDialog extends JDialog {// 成员变量private JLabel tableLabel = new JLabel("统计数据表");// 标题private JScrollPane tablePane = new JScrollPane();// 滚动视口protected JTable table = new JTable();// 显示数据private JButton allSaleBtn = new JButton("货物对应营业额");private JButton maxSalBtn = new JButton("销量最好");private JButton minSalBtn = new JButton("销量最差");private JButton cashBtn = new JButton("收银账表");private JButton turnoverBtn = new JButton("业绩最好员工");private JButton buyBtn = new JButton("购买最多会员");private JButton ageForGoodsBtn = new JButton("不同年龄层购物最爱");private JButton goodhisBtn = new JButton("货物历史");private JButton memberhisBtn = new JButton("会员历史");//构造方法public AbstractStatisticsDialog(Frame owner, boolean modal) {super(owner, modal);this.init();this.addComponent();this.addListener();}public AbstractStatisticsDialog() {this(null, true);}//初始化private void init() {this.setTitle("超市管理系统:会员管理面");this.setSize(700, 550);this.setLocation(150, 30);this.setLocationRelativeTo(null);this.setResizable(false);}//添加组件private void addComponent() {this.setLayout(null);// 表格标题tableLabel.setBounds(320, 15, 100, 20);// 设置位置大小tableLabel.setFont(new Font("宋体", Font.PLAIN, 16));// 字体this.add(tableLabel);// 表格table.getTableHeader().setReorderingAllowed(false);// 列不可移动table.getTableHeader().setResizingAllowed(false);// 不可拉动表格table.setEnabled(false);// 不可更改数据tablePane.setBounds(30, 50, 630, 270);tablePane.setViewportView(table);this.add(tablePane);//7个功能按钮组件//货物对应营业额组件allSaleBtn.setBounds(30, 340, 160, 30);allSaleBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(allSaleBtn);maxSalBtn.setBounds(265, 340, 120, 36);maxSalBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(maxSalBtn);minSalBtn.setBounds(455, 340, 120, 36);minSalBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(minSalBtn);//收银员及会员统计数据cashBtn.setBounds(45, 400, 120, 36);// 510cashBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(cashBtn);turnoverBtn.setBounds(250, 400, 150, 36);// 510turnoverBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(turnoverBtn);buyBtn.setBounds(440, 400, 150, 36);// 510buyBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(buyBtn);ageForGoodsBtn.setBounds(45, 450, 180, 36);// 460ageForGoodsBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(ageForGoodsBtn);goodhisBtn.setBounds(250, 450, 100, 36);// 460goodhisBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(goodhisBtn);memberhisBtn.setBounds(380, 450, 100, 36);// 460memberhisBtn.setFont(new Font("宋体", Font.PLAIN, 16));this.add(memberhisBtn);}//添加监听器private void addListener() {allSaleBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {AllSale();}});maxSalBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {MaxSale();}});minSalBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {MinSale();}});cashBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {AllCash();}});turnoverBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {Turnover();}});buyBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {Buy();}});ageForGoodsBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {AgeForGoods();}});goodhisBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {GoodHis();}});memberhisBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {MemberHis();}});}//显示不同货物对应营业额public abstract void AllSale();//显示售出最多的货物的营业额,用一个弹出按钮显示public abstract void MaxSale();//显示售出最少的货物的营业额,用一个弹出按钮显示public abstract void MinSale();//显示所有收银账单public abstract void AllCash();//显示收银最多的收银员,用弹出按钮显示public abstract void Turnover();//显示购买最多的会员public abstract void Buy();//不同年龄段对应的货物public abstract void AgeForGoods();//货物历史表格public abstract void GoodHis();//会员历史public abstract void MemberHis();
}

entity包

package supermaket.entity;//管理员实体类
public class Administrator {private String accout;private String psw;public Administrator(String accout, String psw) {this.accout = accout;this.psw = psw;}public String getAccout() {return accout;}public String getPsw() {return psw;}public void setAccout(String accout) {this.accout = accout;}public void setPsw(String psw) {this.psw = psw;}
}
package supermaket.entity;//会员实体类
public class Cashier {private String accout;private String psw;private String name;public Cashier(String accout, String psw) {this.accout = accout;this.psw = psw;}public Cashier(String accout, String psw,String name) {this.accout = accout;this.psw = psw;this.name=name;}public Cashier() {}public String getAccout() {return accout;}public String getPsw() {return psw;}public String getName() {return name;}public void setName(String name) {this.name = name;}public void setAccout(String accout) {this.accout = accout;}public void setPsw(String psw) {this.psw = psw;}
}
package supermaket.entity;//创建超市货物数据模型GoodsInfo//超市货物数据模型
public class GoodsInfo {// 超市货物的私有属性private String num;// 货物编号private String name;// 货物名称private String price;// 货物单价private String count;// 货物数量// 构造方法public GoodsInfo() { }public GoodsInfo(String num, String name, String price, String count) {// 有参构造方法this.num = num;this.name = name;this.price = price;this.count = count;}public String getNum() {return num;}public void setNum(String num) {this.num = num;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getPrice() {return price;}public void setPrice(String price) {this.price = price;}public String getCount() {return count;}public void setCount(String count) {this.count = count;}
}
package supermaket.entity;public class Member {private String accout;private String psw;private String name;private int age;public Member(){ }public Member(String accout, String psw){this.accout=accout;this.psw=psw;}public Member(String accout, String psw, String name, int age){this.accout=accout;this.psw=psw;this.name=name;this.age=age;}public String getAccout() {return accout;}public String getPsw() {return psw;}public String getName() {return name;}public int getAge() {return age;}public void setAccout(String accout) {this.accout = accout;}public void setPsw(String psw) {this.psw = psw;}public void setName(String name) {this.name = name;}public void setAge(int age) {this.age = age;}
}

login包

package supermaket.login;
//定义管理员界面操作类AdminDialogControllerimport supermaket.entity.Administrator;
import supermaket.service.AdminService;
import supermaket.entity.GoodsInfo;
import supermaket.daoimpl.AbstractAdminDialog;import java.awt.Frame;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;//管理员界面操作
@SuppressWarnings("serial")
public class AdminDialogController extends AbstractAdminDialog   implements WindowListener {private AdminService adminService = new AdminService();Administrator administrator;public AdminDialogController(Administrator administrator) {super();queryGoodsItem();this.administrator=administrator;}public AdminDialogController(Frame owner, boolean modal) {super(owner, modal);// 创建对象时展示数据queryGoodsItem();}// 查询全部数据,用于初始化显示货物数量public void queryGoodsItem() {// 定义表格头String[] thead = { "货物编号", "货物名称", "货物单价", "货物数量" };// 调用adminService 的查询业务ArrayList<GoodsInfo> dataList = new AdminService().queryAllGoodsItem();String[][] tbody = list2Array(dataList);TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}// 集合数据转为二维数组public String[][] list2Array(ArrayList<GoodsInfo> list) {String[][] tbody = new String[list.size()][4];for (int i = 0; i < list.size(); i++) {GoodsInfo goodsItem = list.get(i);tbody[i][0] = goodsItem.getNum();tbody[i][1] = goodsItem.getName();tbody[i][2] = goodsItem.getPrice();tbody[i][3] = goodsItem.getCount();}return tbody;}// 查询方法public void findGoodsItem() {String findnum = searchnumText.getText();GoodsInfo findSuccess = adminService.findGoodsItem(findnum);if (findSuccess!=null) {String mes="货物编号:"+findSuccess.getNum()+",名称:"+findSuccess.getName()+",单价:"+findSuccess.getPrice()+",数量"+findSuccess.getCount();JOptionPane.showMessageDialog(this, mes);clear();} else {JOptionPane.showMessageDialog(this, "请输入正确编号");clear();}}//添加方法public void addGoodsItem() {String addcap = addnameText.getText();String addtype = addpriceText.getText();String addcount = addcountText.getText();// 调用adminService 的添加服务boolean addSuccess = adminService.addGoodsItem("", addcap, addtype, addcount);if (addSuccess) {// 添加成功后刷新queryGoodsItem();clear();} else {// 未添加成功提示JOptionPane.showMessageDialog(this, "货物编号不能重复,请检查数据!");clear();}}//修改方法public void updateGoodsItem() {String updatenum = updatenumText.getText();String updatecap = updatenameText.getText();String updatetype = updatepriceText.getText();String updatecount = updatecountText.getText();// 调用adminService 的添加服务boolean updateSuccess = adminService.updateGoodsItem(updatenum, updatecap, updatetype, updatecount);if (updateSuccess) {// 修改成功后刷新queryGoodsItem();clear();} else {// 未修改成功提示JOptionPane.showMessageDialog(this, "超市库存中无此货物编号,请检查数据!");clear();}}//删除方法public void delGoodsItem() {String delnum = delnumText.getText();boolean delSuccess = adminService.delGoodsItem(delnum);if (delSuccess) {queryGoodsItem();clear();} else {JOptionPane.showMessageDialog(this, "超市库存中无此货物编号,请检查数据!");clear();}}//清除数据public void clear() {addnameText.setText("");addpriceText.setText("");addcountText.setText("");updatenameText.setText("");updatenumText.setText("");updatepriceText.setText("");updatecountText.setText("");delnumText.setText("");searchnumText.setText("");}@Overridepublic void windowClosing(WindowEvent e) {System.exit(0);}@Overridepublic void windowOpened(WindowEvent e) {}@Overridepublic void windowClosed(WindowEvent e) {System.exit(0);}@Overridepublic void windowIconified(WindowEvent e) {}@Overridepublic void windowDeiconified(WindowEvent e) {}@Overridepublic void windowActivated(WindowEvent e) {}@Overridepublic void windowDeactivated(WindowEvent e) {}
}
package supermaket.login;import supermaket.entity.Cashier;
import supermaket.entity.Member;
import supermaket.service.CashierService;
import supermaket.entity.GoodsInfo;
import supermaket.daoimpl.AbstractCashDialog;import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;public class CashierDialogController extends AbstractCashDialog implements WindowListener {private CashierService cashierService;  //收银员服务ArrayList<GoodsInfo> cart = new ArrayList<GoodsInfo>();//存储用户的购物车Cashier cashier;    //收银员账号public CashierDialogController(Cashier cashier) {super();queryGoodsItem();this.cashier=cashier;cashierService = new CashierService();}//会员关于数据库的操作// 查询方法public void queryGoodsItem() {// 定义表格头String[] thead = { "货物编号", "货物名称", "货物单价", "货物数量" };// 调用adminService 的查询业务ArrayList<GoodsInfo> dataList = new CashierService().queryAllGoodsItem();String[][] tbody = list2Array(dataList);TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}// 集合数据转为二维数组public String[][] list2Array(ArrayList<GoodsInfo> list) {String[][] tbody = new String[list.size()][4];for (int i = 0; i < list.size(); i++) {GoodsInfo goodsItem = list.get(i);tbody[i][0] = goodsItem.getNum();tbody[i][1] = goodsItem.getName();tbody[i][2] = goodsItem.getPrice();tbody[i][3] = goodsItem.getCount();}return tbody;}//通过购物车数据一次性更新数据public void updateGoodsItem() {CheckMemDialogController cm=new CheckMemDialogController();cm.setVisible(true);Member member=cm.member;CashierService cashierservice=new CashierService(this.cashier,member);//新建一个服务,用于更新goods_sal表和goods_age表int updateSuccess = cashierservice.updateGoodsItem(cart);if (updateSuccess==0) { //为0时则全部更新成功,否则剩余几个结算失败// 修改成功后刷新queryGoodsItem();cart.clear();JOptionPane.showMessageDialog(this, "结算成功!!!");showCart(null);} else {String mes="";for (;updateSuccess< cart.size();){mes=mes.concat(cart.get(updateSuccess).getNum());mes=mes.concat(" ");}mes=mes.concat("未结算成功!请找管理员咨询原因");// 未修改成功提示JOptionPane.showMessageDialog(this, mes);clear();}}// 判断输入的量是否超出库存public GoodsInfo findGoodsItem() {String findnum = addnumText.getText();//搜索列表是否存在String count=addcountText.getText();if (findnum.trim().isEmpty() || count.trim().isEmpty()) {//JOptionPane.showMessageDialog(this, "错误输入!请检查后重新输入!");return null;}else {int checkcount = Integer.parseInt(count);//判断数量是否符合GoodsInfo findSuccess = cashierService.findGoodsItem(findnum);if (findSuccess != null) {int last = Integer.valueOf(findSuccess.getCount());if (last >= checkcount)return findSuccess;} else {JOptionPane.showMessageDialog(this, "输入错误,请检查后确认输入!");clear();}}return null;}//添加一次就保存到购物车public void addShopCart(){GoodsInfo goods =this.findGoodsItem();goods.setCount(addcountText.getText());if (goods!=null) {cart.add(goods);clear();JOptionPane.showMessageDialog(this, "已添加至购物车");}else {JOptionPane.showMessageDialog(this, "添加失败");}}public void showCart() {// 定义表格头String[] thead = { "货物编号", "货物名称", "货物单价", "货物数量" };String[][] tbody = list2Array(cart);TableModel dataModal = new DefaultTableModel(tbody, thead);carttable.setModel(dataModal);}public void showCart(String [][] infor) {// 定义表格头String[] thead = { "货物编号", "货物名称", "货物单价", "货物数量" };TableModel dataModal = new DefaultTableModel(infor, thead);carttable.setModel(dataModal);}//清除数据public void clear() {addnumText.setText("");addnameText.setText("");addpriceText.setText("");addcountText.setText("");}@Overridepublic void windowOpened(WindowEvent e) {}@Overridepublic void windowClosing(WindowEvent e) {}@Overridepublic void windowClosed(WindowEvent e) {System.exit(0);}@Overridepublic void windowIconified(WindowEvent e) {}@Overridepublic void windowDeiconified(WindowEvent e) {}@Overridepublic void windowActivated(WindowEvent e) {}@Overridepublic void windowDeactivated(WindowEvent e) {}
}
package supermaket.login;import supermaket.daoimpl.AbstractCashDialog;
import supermaket.daoimpl.AbstractCashManaDialog;
import supermaket.entity.Cashier;
import supermaket.entity.Member;
import supermaket.service.AdminService;import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.util.ArrayList;public class CashManaDialogController extends AbstractCashManaDialog {private AdminService adminService = new AdminService();public CashManaDialogController(){super();querryAllCash();}@Overridepublic void addCash() {String acc = addaccText.getText();String pwd = addpwdText.getText();String name=addnameText.getText();Cashier cashier=new Cashier(acc,pwd,name);boolean addSuccess = adminService.addCash(cashier);if (addSuccess) {// 添加成功后刷新querryAllCash();JOptionPane.showMessageDialog(this, "添加成功");} else {// 未添加成功提示JOptionPane.showMessageDialog(this, "账号不能重复,请检查数据!");}clear();}@Overridepublic void deleteCash() {String acc = delaccText.getText();boolean delSuccess = adminService.delCash(acc);if (delSuccess) {JOptionPane.showMessageDialog(this, "已成功删除!!!");querryAllCash();} else {JOptionPane.showMessageDialog(this, "列表中无此账号,请检查数据!");}clear();}@Overridepublic void updateCash() {String acc = updateaccText.getText();String pwd = updatepwdText.getText();String name=addnameText.getText();Cashier cashier=new Cashier(acc,pwd,name);// 调用adminService 的添加服务boolean updateSuccess = adminService.updateCash(cashier);if (updateSuccess) {// 修改成功后刷新querryAllCash();JOptionPane.showMessageDialog(this, "更新信息成功!");} else {// 未修改成功提示JOptionPane.showMessageDialog(this, "列表中无此账号,请检查数据!");}clear();}@Overridepublic void querryAllCash() {// 定义表格头String[] thead = { "收银员账号", "密码","姓名"};// 调用adminService 的查询业务ArrayList<Cashier> list = new AdminService().queryAllCash();String[][] tbody = list2Array(list);TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}@Overridepublic void querryCash() {String findnum = searchnumText.getText();Cashier cashier = adminService.findCash(findnum);if (cashier!=null) {String mes="该会员账号为:"+cashier.getAccout()+",密码为:"+cashier.getPsw()+",姓名为:"+cashier.getName()+".";JOptionPane.showMessageDialog(this, mes);} else {JOptionPane.showMessageDialog(this, "列表中无此账号,请检查输入!");}clear();}// 集合数据转为二维数组public String[][] list2Array(ArrayList<Cashier> list) {String[][] tbody = new String[list.size()][3];for (int i = 0; i < list.size(); i++) {Cashier cashier_temp = list.get(i);tbody[i][0] = cashier_temp.getAccout();tbody[i][1] = cashier_temp.getPsw();tbody[i][2] = cashier_temp.getName();}return tbody;}//清除数据public void clear() {addaccText.setText("");addpwdText.setText("");addnameText.setText("");updateaccText.setText("");updatepwdText.setText("");updatenameText.setText("");delaccText.setText("");searchnumText.setText("");}
}
package supermaket.login;import supermaket.dao.Checkusers;
import supermaket.daoimpl.AbstractCashDialog;
import supermaket.daoimpl.AbstractCheckMemDialog;
import supermaket.entity.Member;import javax.swing.*;public class CheckMemDialogController extends AbstractCheckMemDialog {Member member;@Overridepublic void checkMem() {String acc = addaccText.getText();//搜索列表是否存在String pwd=addpwdText.getText();Member member= Checkusers.checkMem(acc,pwd);if (member!=null)this.member=member;elsethis.member=null;JOptionPane.showMessageDialog(this, "会员账号密码无误!");this.setVisible(false);}
}
package supermaket.login;import supermaket.entity.Administrator;
import supermaket.entity.Cashier;import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
//超市管理系统界面
@SuppressWarnings("serial")
public class Enter extends JPanel  implements ActionListener {Administrator administrator;    //用于存储此时的管理员账号Cashier cashier;                //用于存储此时的收银员账号private JLabel welcome_lab = new  JLabel("超市管理系统欢迎您!");private JButton enter_bt=new JButton("进入系统");JPanel panel;int type;   // 0 表示进入管理员界面,1 表示进入会员界面public Enter(int type,Administrator administrator){//设置属性this.type=type;this.administrator=administrator;this.setSize(700,600);this.setLayout(null);welcome_lab.setBounds(220,40,500,300);welcome_lab.setFont(new Font("宋体",Font.PLAIN,25));this.add(welcome_lab);enter_bt.setBounds(295,465,100,35);enter_bt.setFont(new Font("宋体",Font.PLAIN,16));enter_bt.setBackground(Color.white);enter_bt.setFocusPainted(false); //去掉按钮中文体的边框enter_bt.setBorderPainted(false); //去掉边框enter_bt.addActionListener(this);this.add(enter_bt);this.setVisible(true);}public Enter(int type,Cashier cashier){//设置属性this.type=type;this.cashier=cashier;this.setSize(700,600);this.setLayout(null);welcome_lab.setBounds(220,40,500,300);welcome_lab.setFont(new Font("宋体",Font.PLAIN,25));this.add(welcome_lab);//this.setVisible(true);enter_bt.setBounds(295,465,100,35);enter_bt.setFont(new Font("宋体",Font.PLAIN,16));enter_bt.setBackground(Color.white);//enter_bt.setContentAreaFilled(false); //透明度enter_bt.setFocusPainted(false); //去掉按钮中文体的边框enter_bt.setBorderPainted(false); //去掉边框enter_bt.addActionListener(this);this.add(enter_bt);this.setVisible(true);}@Overridepublic void actionPerformed(ActionEvent e) {if(panel!=null){this.remove(panel);}if(e.getActionCommand()=="进入系统"&&this.type==0){this.removeAll();//showAdminDialog();new AdminDialogController(this.administrator).setVisible(true);this.setSize(700,600);this.setVisible(false);this.repaint();// this.setVisible(true);}if (e.getActionCommand()=="进入系统"&&this.type==1){this.removeAll();new CashierDialogController(this.cashier).setVisible(true);this.setSize(700,600);this.setVisible(false);this.repaint();}}//管理员界面public JPanel showAdminDialog(){new AdminDialogController(this.administrator).setVisible(true);return panel;}//会员界面public  JPanel showMemDialog(){return null;}
}
package supermaket.login;//定义一个登录界面Loginimport supermaket.dao.Checkusers;
import supermaket.entity.Administrator;
import supermaket.entity.Cashier;import java.awt.event.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;@SuppressWarnings("serial")
//主窗口
public class Login extends JFrame implements ActionListener{//标签private JLabel username_label;//定义用户名标签private JLabel pwd_label;//定义密码标签private JLabel permit_label;//定义权限标签//文本对象private JTextField accoutext;private JPasswordField passwordtext;//定义文本框对象//定义权限按钮private JRadioButton adm_rbt;private JRadioButton cash_rbt;//登录,退出,注册按钮private JButton logbt;private JButton resetbt;private JButton exitbt;private ButtonGroup bg;final String username="admin";final String pwd="aaaaaa";JPanel panel;Administrator administrator;Cashier cashier;public Login(){this.setSize(700, 600);//设置窗体的大小this.setTitle("超市管理系统");//设置窗体标题this.setLayout(null);//将窗体的默认布局方式设置为无布局方式username_label = new JLabel("用户名");pwd_label = new JLabel("密  码");permit_label = new JLabel("权 限");//按钮初始化logbt = new JButton("登录");//"登录"resetbt = new JButton("重置");//"重置"exitbt = new JButton("退出");//"退出"adm_rbt =new JRadioButton("管理员");bg=new ButtonGroup();bg.add(adm_rbt);adm_rbt.setSize(100,20);adm_rbt.setLocation(263,290);adm_rbt.setSelected(true); //初始页面默认选择权限为管理员cash_rbt = new JRadioButton("收银员");bg.add(cash_rbt);cash_rbt.setSize(100,20);cash_rbt.setLocation(363,290);cash_rbt.setSelected(true); //初始页面默认选择权限为管理员//设置标签的参数username_label.setSize(70, 37);username_label.setLocation(190,150);username_label.setFont(new Font("宋体", Font.BOLD, 20));pwd_label.setSize(70, 37);pwd_label.setLocation(190,215);pwd_label.setFont(new Font("宋体", Font.BOLD, 20));permit_label.setSize(130, 40);permit_label.setLocation(190,280);//设置文本框参数accoutext=new JTextField();accoutext.setSize(180,30);accoutext.setLocation(270, 155);accoutext.setFont(new Font("宋体",Font.PLAIN,20));passwordtext=new JPasswordField();passwordtext.setSize(180,30);passwordtext.setLocation(270, 220);passwordtext.setFont(new Font("宋体",Font.PLAIN,20));logbt.setSize(70,30);logbt.setLocation(230,350);resetbt.setSize(70,30);resetbt.setLocation(310,350);exitbt.setSize(70,30);exitbt.setLocation(390,350);logbt.addActionListener(this);resetbt.addActionListener(this);exitbt.addActionListener(this);this.add(username_label);this.add(pwd_label);this.add(permit_label);this.add(accoutext);this.add(passwordtext);this.add(adm_rbt);this.add(cash_rbt);this.add(logbt);this.add(resetbt);this.add(exitbt);this.setLocationRelativeTo(null);this.setVisible(true);//设置窗体可见this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}@Overridepublic void actionPerformed(ActionEvent e) {if(e.getActionCommand()=="登录"){if (adm_rbt.isSelected()) {adminlogin();        //连接到管理员界面方法}else if (cash_rbt.isSelected()){cashierlogin();}}else if(e.getActionCommand()=="重置") {clear();}else if(e.getActionCommand()=="退出") {System.exit(0);}else if(e.getID() == WindowEvent.WINDOW_CLOSING) {System.exit(0);}}@SuppressWarnings("deprecation")public void adminlogin(){//管理员对象this.administrator = new Administrator(accoutext.getText(), passwordtext.getText());if(Checkusers.checkAdm(administrator)){JOptionPane.showMessageDialog(null,"登录成功!","提示消息",JOptionPane.WARNING_MESSAGE);clear();dispose();this.remove(username_label);this.remove(pwd_label);this.remove(permit_label);this.remove(accoutext);this.remove(passwordtext);this.remove(adm_rbt);this.remove(cash_rbt);this.remove(logbt);this.remove(resetbt);this.remove(exitbt);JPanel panel = new Enter(0,this.administrator);//创建欢迎面板panel.setLocation(0,0);this.add(panel);this.repaint();this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置当关闭窗口时,保证JVM也退出}else if(accoutext.getText().isEmpty()&&passwordtext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入用户名和密码!","提示消息",JOptionPane.WARNING_MESSAGE);}else if(accoutext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入用户名!","提示消息",JOptionPane.WARNING_MESSAGE);}else if(passwordtext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入密码!","提示消息",JOptionPane.WARNING_MESSAGE);}else{JOptionPane.showMessageDialog(null,"用户名或者密码错误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);clear(); //清空输入框}}public void cashierlogin(){//会员对象this.cashier = new Cashier(accoutext.getText(),passwordtext.getText());if(Checkusers.checkCash(cashier)){JOptionPane.showMessageDialog(null,"登录成功!","提示消息",JOptionPane.INFORMATION_MESSAGE);clear();dispose();this.remove(username_label);this.remove(pwd_label);this.remove(permit_label);this.remove(accoutext);this.remove(passwordtext);this.remove(adm_rbt);this.remove(cash_rbt);this.remove(logbt);this.remove(resetbt);this.remove(exitbt);JPanel panel = new Enter(1,this.cashier);//创建欢迎面板panel.setLocation(0,0);this.add(panel);this.repaint();this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置当关闭窗口时,保证JVM也退出}else if(accoutext.getText().isEmpty()&&passwordtext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入用户名和密码!","提示消息",JOptionPane.WARNING_MESSAGE);}else if(accoutext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入用户名!","提示消息",JOptionPane.WARNING_MESSAGE);}else if(passwordtext.getText().isEmpty()){JOptionPane.showMessageDialog(null,"请输入密码!","提示消息",JOptionPane.WARNING_MESSAGE);}else{JOptionPane.showMessageDialog(null,"用户名或者密码错误!\n请重新输入","提示消息",JOptionPane.ERROR_MESSAGE);clear(); //清空输入框}}//清空文本框和密码框public void clear(){accoutext.setText("");passwordtext.setText("");}}
package supermaket.login;import supermaket.daoimpl.AbstractMemManaDialog;
import supermaket.entity.Member;
import supermaket.service.AdminService;import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.util.ArrayList;//购物车结算窗口
public class MemManaDialogController extends AbstractMemManaDialog {private AdminService adminService = new AdminService();public MemManaDialogController(){super();querryAllMem();}@Overridepublic void addMem() {String acc = addaccText.getText();String pwd = addpwdText.getText();String name=addnameText.getText();System.out.println(addageText.getText());int age=Integer.valueOf(addageText.getText());// 调用adminService 的添加服务Member member=new Member(acc,pwd,name,age);boolean addSuccess = adminService.addMem(member);if (addSuccess) {// 添加成功后刷新querryAllMem();JOptionPane.showMessageDialog(this, "添加成功");} else {// 未添加成功提示JOptionPane.showMessageDialog(this, "会员账号不能重复,请检查数据!");}clear();}@Overridepublic void deleteMem() {String acc = delaccText.getText();boolean delSuccess = adminService.delMem(acc);if (delSuccess) {JOptionPane.showMessageDialog(this, "已成功删除!!!");querryAllMem();} else {JOptionPane.showMessageDialog(this, "会员列表中无此账号,请检查数据!");}clear();}@Overridepublic void updateMem() {String acc = updateaccText.getText();String pwd = updatepwdText.getText();String name=updatenameText.getText();int age=Integer.valueOf(updateageText.getText());Member member=new Member(acc,pwd,name,age);// 调用adminService 的添加服务boolean updateSuccess = adminService.updateMem(member);if (updateSuccess) {// 修改成功后刷新querryAllMem();JOptionPane.showMessageDialog(this, "更新会员信息成功!");} else {// 未修改成功提示JOptionPane.showMessageDialog(this, "列表中无此会员账号,请检查数据!");}clear();}@Overridepublic void querryAllMem() {// 定义表格头String[] thead = { "会员账号", "会员密码","会员姓名","年龄" };// 调用adminService 的查询业务ArrayList<Member> list = new AdminService().queryAllMem();String[][] tbody = list2Array(list);TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}@Overridepublic void querryMem() {String findnum = searchnumText.getText();Member mem = adminService.findMem(findnum);if (mem!=null) {String mes="该会员账号为:"+mem.getAccout()+",密码为:"+mem.getPsw()+",姓名为:"+mem.getName()+",年龄为:"+mem.getAge()+".";JOptionPane.showMessageDialog(this, mes);} else {JOptionPane.showMessageDialog(this, "列表中无此会员,请检查输入!");}clear();}// 集合数据转为二维数组public String[][] list2Array(ArrayList<Member> list) {String[][] tbody = new String[list.size()][4];for (int i = 0; i < list.size(); i++) {Member mem_temp = list.get(i);tbody[i][0] = mem_temp.getAccout();tbody[i][1] = mem_temp.getPsw();tbody[i][2] = mem_temp.getName();tbody[i][3] = String.valueOf(mem_temp.getAge());}return tbody;}//清除数据public void clear() {addaccText.setText("");addpwdText.setText("");addnameText.setText("");addageText.setText("");updateaccText.setText("");updatepwdText.setText("");updatenameText.setText("");updateageText.setText("");delaccText.setText("");searchnumText.setText("");}
}
package supermaket.login;import chaoshiguanli.entity.Good;
import supermaket.daoimpl.AbstractStatisticsDialog;
import supermaket.entity.Member;
import supermaket.service.AdminService;import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.util.ArrayList;public class StaticsDialogController extends AbstractStatisticsDialog {private AdminService adminService = new AdminService();@Overridepublic void AllSale() {String[] thead = {"编号", "名称", "单价", "销售额"};// 调用adminService 的查询业务TableModel dataModal = new DefaultTableModel(adminService.allSale(), thead);table.setModel(dataModal);}@Overridepublic void MaxSale() {String[] data = adminService.maxOrMin(0);String mess = "货物编号为:" + data[0] + ",名称:" + data[1] + ",单价:" + data[2] + ",总销售额为:" + data[3] + ".";JOptionPane.showMessageDialog(this, mess);}@Overridepublic void MinSale() {String[] data = adminService.maxOrMin(1);String mess = "货物编号为:" + data[0] + ",名称:" + data[1] + ",单价:" + data[2] + ",总销售额为:" + data[3] + ".";JOptionPane.showMessageDialog(this, mess);}@Overridepublic void AllCash() {String[] thead = {"收银员", "收银额"};// 调用adminService 的查询业务TableModel dataModal = new DefaultTableModel(adminService.allCash(), thead);table.setModel(dataModal);}@Overridepublic void Turnover() {String[] data = adminService.tur();String mess = "账号为:" + data[0] + ",收银为:" + data[1];JOptionPane.showMessageDialog(this, mess);}@Overridepublic void Buy() {String[] data = adminService.buy();String mess = "账号为:" + data[0] + ",购买额为:" + data[1];JOptionPane.showMessageDialog(this, mess);}@Overridepublic void AgeForGoods() {String[] thead = {"年龄段", "货物编号", "货物名"};// 调用adminService 的查询业务TableModel dataModal = new DefaultTableModel(adminService.afg(), thead);table.setModel(dataModal);}@Overridepublic void GoodHis() {// 定义表格头String[] thead = { "货物编号", "货物名称", "货物单价"};// 调用adminService 的查询业务ArrayList<Good> dataList = adminService.queryGoodsHis();String[][] tbody = new String[dataList.size()][4];for (int i = 0; i < dataList.size(); i++) {Good goodsItem = dataList.get(i);tbody[i][0] = goodsItem.getNum();tbody[i][1] = goodsItem.getName();tbody[i][2] = goodsItem.getPrice();}TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}@Overridepublic void MemberHis() {String[] thead = {"会员账号", "会员密码", "会员姓名", "年龄"};// 调用adminService 的查询业务ArrayList<Member> list=adminService.queryMemhis();String[][] tbody = new String[list.size()][4];for (int i = 0; i < list.size(); i++) {Member mem_temp = list.get(i);tbody[i][0] = mem_temp.getAccout();tbody[i][1] = mem_temp.getPsw();tbody[i][2] = mem_temp.getName();tbody[i][3] = String.valueOf(mem_temp.getAge());}TableModel dataModal = new DefaultTableModel(tbody, thead);table.setModel(dataModal);}}

service包

package supermaket.service;//定义管理业务类AdminService
import chaoshiguanli.entity.Good;
import supermaket.dao.AdminDao;
import supermaket.entity.GoodsInfo;
import supermaket.entity.Cashier;
import supermaket.entity.Member;import java.util.*;
//管理员业务类
public class AdminService {private AdminDao adminDao = new AdminDao();public GoodsInfo findGoodsItem(String num) {ArrayList<GoodsInfo> data = queryAllGoodsItem();// 使用输入编号与所有数据对比for (int i = 0; i < data.size(); i++) {GoodsInfo goodsItem = data.get(i);if (num.equals(goodsItem.getNum())) {return goodsItem;}}return null;}//查询所有货物(应该在刚开始就自动调用显示)public ArrayList<GoodsInfo> queryAllGoodsItem() {// 调用Dao层的获取所有数据方法获取所有数据ArrayList<GoodsInfo> data = adminDao.queryAllData();return data;}//添加业务public boolean addGoodsItem(String num, String name, String price, String count) {ArrayList<GoodsInfo> data = queryAllGoodsItem();// 使用输入编号与所有数据对比for (int i = 0; i < data.size(); i++) {GoodsInfo goodsItem = data.get(i);// 若存在重复编号则添加不成功if (num.equals(goodsItem.getNum())) {return false;}}// 若没有重复编号,将数据封装为GoodsItem对象GoodsInfo thisGoodsItem = new GoodsInfo(num, name, price, count);adminDao.add(thisGoodsItem);return true;}//修改业务public boolean updateGoodsItem(String num, String name, String price, String count) {ArrayList<GoodsInfo> data = queryAllGoodsItem();// 使用输入编号与所有数据对比for (int i = 0; i < data.size(); i++) {GoodsInfo goodsItem = data.get(i);// 若存在相同编号的数据,则可以修改if (num.equals(goodsItem.getNum())) {// 若没有重复编号,将数据封装为GoodsItem对象GoodsInfo thisGoodsItem = new GoodsInfo(num, name, price, count);adminDao.update(thisGoodsItem);return true;}}return false;}//删除业务public boolean delGoodsItem(String delNum) {ArrayList<GoodsInfo> data = queryAllGoodsItem();// 使用输入编号与所有数据对比for (int i = 0; i < data.size(); i++) {GoodsInfo goodsItem = data.get(i);// 若存在相同编号的数据,则可以删除if (delNum.equals(goodsItem.getNum())) {// 调用Dao层的删除指定编号数据方法adminDao.del(delNum);return true;}}return false;}//会员操作//添加业务public boolean addMem(Member member) {ArrayList<Member> list = queryAllMem();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Member member_1 = list.get(i);// 若存在重复编号则添加不成功if (member.getAccout().equals(member_1.getAccout())) {return false;}}// 无重复编号,写入数据库adminDao.addMem(member);return true;}//删除业务public boolean delMem(String acc) {ArrayList<Member> list = queryAllMem();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Member member = list.get(i);// 若存在相同编号的数据,则可以删除if (acc.equals(member.getAccout())) {// 调用Dao层的删除指定编号数据方法adminDao.delMem(acc);return true;}}return false;}//修改业务public boolean updateMem(Member member) {ArrayList<Member> list = queryAllMem();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Member member_data = list.get(i);// 若存在相同编号的数据,则可以修改if (member.getAccout().equals(member_data.getAccout())) {// 调用Dao层的删除指定编号数据方法adminDao.updateMem(member);return true;}}return false;}public Member findMem(String acc) {Member member = adminDao.queMem(acc);// 使用输入编号与所有数据对比if(member !=null)return member;elsereturn null;}//查询所有货物(应该在刚开始就自动调用显示)public ArrayList<Member> queryAllMem() {// 调用Dao层的获取所有数据方法获取所有数据ArrayList<Member> data = adminDao.queryAllMem();return data;}//管理员服务//添加业务public boolean addCash(Cashier cashier) {ArrayList<Cashier> list = queryAllCash();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Cashier cash_temp = list.get(i);// 若存在重复编号则添加不成功if (cashier.getAccout().equals(cash_temp.getAccout())) {return false;}}// 无重复编号,写入数据库adminDao.addCash(cashier);return true;}//删除业务public boolean delCash(String acc) {ArrayList<Cashier> list = queryAllCash();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Cashier cashier = list.get(i);// 若存在相同编号的数据,则可以删除if (acc.equals(cashier.getAccout())) {// 调用Dao层的删除指定编号数据方法adminDao.delCash(acc);return true;}}return false;}//修改业务public boolean updateCash(Cashier cashier) {ArrayList<Cashier> list = queryAllCash();// 使用输入编号与所有数据对比for (int i = 0; i < list.size(); i++) {Cashier cashier_data = list.get(i);// 若存在相同编号的数据,则可以修改if (cashier.getAccout().equals(cashier_data.getAccout())) {// 调用Dao层的删除指定编号数据方法adminDao.updateCash(cashier);return true;}}return false;}public Cashier findCash(String acc) {Cashier cashier = adminDao.queCash(acc);// 使用输入编号与所有数据对比if(cashier !=null)return cashier;elsereturn null;}//查询所有货物(应该在刚开始就自动调用显示)public ArrayList<Cashier> queryAllCash() {// 调用Dao层的获取所有数据方法获取所有数据ArrayList<Cashier> data = adminDao.queryAllCash();return data;}//统计服务//全部销售额public String[][]allSale(){String [][]data=adminDao.allsale();return data;}//最大或者最小值public String[]maxOrMin(int choice){return adminDao.maxorminsale(choice);}//全部收银员的营业额public String[][] allCash(){return adminDao.allcash();}//最高收银额对应的收银员public String[] tur(){return adminDao.turnover();}//购买最多的会员public String[] buy(){return adminDao.buy();}//不同年龄段的最爱public String[][] afg(){return adminDao.ageforgoods();}//货物历史数据public ArrayList<Good> queryGoodsHis() {ArrayList<Good> data = adminDao.querygoodhis();return data;}//会员历史public ArrayList<Member> queryMemhis() {ArrayList<Member> data = adminDao.querymemhis();return data;}
}
package supermaket.service;import supermaket.dao.CashierDao;
import supermaket.entity.Cashier;
import supermaket.entity.GoodsInfo;
import supermaket.entity.Member;import java.util.ArrayList;public class CashierService {private CashierDao cashierDao = new CashierDao();//数据库操作语句Cashier cashier;    //收银员Member member;      //会员public CashierService(){}public CashierService(Cashier cashier,Member member){this.cashier=cashier;this.member=member;}public GoodsInfo findGoodsItem(String num) {ArrayList<GoodsInfo> data = queryAllGoodsItem();// 使用输入编号与所有数据对比for (int i = 0; i < data.size(); i++) {GoodsInfo goodsItem = data.get(i);// 若存在编号,则查询成功if (num.equals(goodsItem.getNum())) {return goodsItem;}}return null;}//查询所有货物(应该在刚开始就自动调用显示)public ArrayList<GoodsInfo> queryAllGoodsItem() {// 调用Dao层的获取所有数据方法获取所有数据ArrayList<GoodsInfo> data = cashierDao.queryAllData();return data;}//修改业务public int updateGoodsItem(ArrayList<GoodsInfo> shopCart) {ArrayList<GoodsInfo> data = queryAllGoodsItem();//原数量// 使用输入编号与所有数据对比boolean flag_1=true;boolean flag_2=true;boolean flag_3=true;int j=0;int i = 0;for (; i < data.size()&&j<shopCart.size(); i++) {GoodsInfo goodsItem = data.get(i);GoodsInfo cartGoods = shopCart.get(j);//名称相同时,计算剩余库存if (goodsItem.getNum().equals(cartGoods.getNum())) {int last = Integer.valueOf(goodsItem.getCount()) - Integer.valueOf(cartGoods.getCount());flag_1= cashierDao.update(goodsItem.getNum(), last);//库存表更新int price = Integer.valueOf(goodsItem.getPrice());int sal = price*Integer.valueOf(cartGoods.getCount());//goods_age表,goods_sale表更新flag_2= cashierDao.updategoodsal(cartGoods,sal,Integer.valueOf(member.getAge()),this.member);j++;//购物车物品判断向后移动if (flag_1 &&j<shopCart.size() &&flag_2 && flag_3)continue;elsebreak;}}if (flag_1)return 0;elsereturn j;}
}

until包

package supermaket.until;import java.sql.*;//加载数据库驱动,并建立数据库连接
public class JDBCUtils {public static Connection getConnection() throws SQLException, ClassNotFoundException {Class.forName("oracle.jdbc.driver.OracleDriver");// 加载jdbc连接oracle的驱动String url = "jdbc:oracle:thin:@localhost:1521:orcl";//数据库管理员账号,具有其他权限可以创建其他会员账号和管理员账号String username = "lwb";String password = "123456";Connection conn = DriverManager.getConnection(url, username, password);conn.createStatement();// 用上面定义好的连接字符串,用户名和密码来创建数据库连接对象System.out.println("数据库连接成功");return conn;}//关闭数据库连接,释放资源public static void release(Statement stmt, Connection conn) {if (stmt != null) {try {stmt.close();} catch (SQLException e) {e.printStackTrace();}stmt = null;}if (conn != null) {try {conn.close();} catch (SQLException e) {e.printStackTrace();}conn = null;}}public static void release(ResultSet rs, Statement stmt, Connection conn) {if (rs != null) {try {rs.close();} catch (SQLException e) {e.printStackTrace();}rs = null;}release(stmt, conn);}}

整个java界面的代码如上了,数据库的代码放下一篇了

超市管理系统-1(JavaSwing和Oracle数据库)相关推荐

  1. 计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档

    计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档 计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目架构:B/S架构 开发语言 ...

  2. java汽车4S店管理系统myeclipse定制开发oracle数据库网页模式java编程jdbc

    一.源码特点  java汽车4S店管理系统 是一套完善的web设计系统,对理解JSP java编程开发语言有帮助 oracle数据库,系统具有完整的源代码和数据库,系统主要采用B/S模式开发. jav ...

  3. Oracle 数据库、实例、表空间、用户、数据库对象

    Oracle是一种数据库管理系统,是一种关系型的数据库管理系统.通常情况了我们称的"数据库",包含了物理数据.数据库管理系统.内存.操作系统进程的组合体,就是指这里所说的数据库管理 ...

  4. 基于SSH的便利店、超市管理系统

    [A-035]基于SSH的便利店.超市管理系统 基本思想是使用数据库存储便利店的大量数据以及使用前台后台来管理便利店.主要实现以下功能模块: ) 大前提:进价和卖家都不会变. 商品类型:食品类.杂货类 ...

  5. django+mysql超市管理系统-计算机毕业设计源码26073

    摘要 随着小超市规模的发展不断扩大,商品数量急剧增加,有关商品的各种信息量也成倍增长.超市时时刻刻都需要对商品各种信息进行统计分析.而大型的超市管理系统功能过于强大而造成操作繁琐降低了小超市的工作效率 ...

  6. MySQL实验超市管理系统_超市会员管理系统(数据库)实验报告.doc

    PAGE PAGE 2 学号: 成绩:________ 数据库综合实验报告 院 系 计算机与电子信息学院 专 业 计算机科学与技术 班 级 xxxxxxxxxxx 设计题目 超市会员管理系统 姓 名 ...

  7. 把超市系统连接到java数据库_Java项目 超市管理系统(二)数据库的分析与建立...

    项目是在网上找的,后面我会附上项目的链接. 需求:建立一个简易的超市管理系统数据库 分析:超市数据库中肯定有一个商品表,有一个管理员表,还有一个销售表.这样一个基本的超市数据库雏形就有了.下面开始构建 ...

  8. Java项目 超市管理系统(二)数据库的分析与建立

    项目是在网上找的,后面我会附上项目的链接. 需求:建立一个简易的超市管理系统数据库 分析:超市数据库中肯定有一个商品表,有一个管理员表,还有一个销售表.这样一个基本的超市数据库雏形就有了.下面开始构建 ...

  9. java中showconfirmdialog_Java实现超市管理系统(含数据库)

    序言: 这次写的超市管理系统,实现的功能有账户的注册.登录,超市商品类别的添加.修改和删除以及商品的添加.修改和删除的功能.用户注册之后把注册信息导入数据库:用户登录时候查询用户表,方可登录进去:商品 ...

最新文章

  1. 十大排序算法 导图总结
  2. 在Python中获取文件大小? [重复]
  3. 关于HTML5的十条霸气侧漏预测
  4. JavaScript深入理解对象方法——Object.assign()
  5. jQuery 判断是否为数字的方法 及 转换数字函数
  6. 《企业的边界》的书摘
  7. 【白话机器学习】算法理论+实战之朴素贝叶斯
  8. Linux 串口调试工具汇总
  9. PEP8 Python 编码规范
  10. miscrosoft visio 2003记
  11. Linux【操作系统】
  12. excel怎么设置自动计算_机械设计工程师辅助计算Excel表格,自动进行选型计算...
  13. 网页设计中文标题h1~h4应用技巧
  14. linux系统下的微信安装(ubuntu20.04)
  15. 错误代码0x800F081F怎么解决,安装NET Framework
  16. MPEG-2压缩编码的视频基本流
  17. SAR/GMTI-概述及常用抑制杂波方法DPCA
  18. 全局热键给截图自动加水印并win10系统通知
  19. MS-DOS系统下的autoexec.bat
  20. GE凝胶成像 AI600

热门文章

  1. VR头戴显示器对健康有害吗?会引发晕动症、视觉辐辏调节冲突
  2. 在线正则表达式解析器和可视化工具
  3. Ubuntu 16.04系统安装VS Code流程详解
  4. win10右键菜单没有新建Excel选项的解决方法
  5. Android基于腾讯云的视频聊天研究
  6. 禁止触摸屏触控板手指缩放,需要这样处理
  7. python设计一个学生类姓名年龄成绩_C# 编写学生类Student,包含学生姓名,成绩,设计一个友员函数sortDegree(),将学生成绩按大到小排序。...
  8. 用ESP32与Python实现物联网(IoT)火焰检测报警系统
  9. 远程视频监控必备专业知识
  10. ARM920T内核工作模式