Compare commits

...

7 Commits

Author SHA1 Message Date
cwfeng 723fa85afd Merge remote-tracking branch 'remotes/origin/main' into developer
9 months ago
HouXinyu 979b0b099e Merge branch 'developer'
9 months ago
HouXinyu b319190310 t3
9 months ago
HouXinyu 286a3d9786 t2
9 months ago
HouXinyu 57f8f74053 t1
9 months ago
HouXinyu 070f2a5274 new
9 months ago
p4vsywzlp f7fe585506 Merge pull request 'update' (#49) from developer into main
9 months ago

@ -3,5 +3,5 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK" />
</project>

@ -6,6 +6,6 @@
<classpathentry kind="src" path="config"/>
<classpathentry kind="lib" path="Supermarket/lib/activation.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mail.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mysql-connector-java-8.0.20.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mysql-connector-java-5.1.32.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -2,7 +2,7 @@
<project version="4">
<component name="dataSourceStorageLocal" created-in="IU-231.8109.175">
<data-source name="@localhost" uuid="5b23e521-053a-47c0-ae28-a98b513bc6ec">
<database-info product="MySQL" version="8.4.0" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.4.0" exact-driver-version="8.2">
<database-info product="MySQL" version="5.7.44-log" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="5.7.44" exact-driver-version="8.2">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/activation.jar" />
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/mail.jar" />
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/mysql-connector-java-5.1.32.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/activation.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/mail.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/mysql-connector-java-5.1.32.jar" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$" expected_position="1" />
@ -47,6 +47,5 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="mysql.connector.java" level="project" />
</component>
</module>

@ -6,6 +6,6 @@
<classpathentry kind="src" path="config"/>
<classpathentry kind="lib" path="Supermarket/lib/activation.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mail.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mysql-connector-java-8.0.20.jar"/>
<classpathentry kind="lib" path="Supermarket/lib/mysql-connector-java-5.1.32.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

@ -2,7 +2,7 @@
<project version="4">
<component name="dataSourceStorageLocal" created-in="IU-231.8109.175">
<data-source name="@localhost" uuid="5b23e521-053a-47c0-ae28-a98b513bc6ec">
<database-info product="MySQL" version="8.4.0" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="8.4.0" exact-driver-version="8.2">
<database-info product="MySQL" version="5.7.44-log" jdbc-version="4.2" driver-name="MySQL Connector/J" driver-version="mysql-connector-j-8.2.0 (Revision: 06a1f724497fd81c6a659131fda822c9e5085b6c)" dbms="MYSQL" exact-version="5.7.44" exact-driver-version="8.2">
<extra-name-characters>#@</extra-name-characters>
<identifier-quote-string>`</identifier-quote-string>
</database-info>

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/activation.jar" />
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/mail.jar" />
<libelement value="file://$MODULE_DIR$/../../../大二下学期实训超市管理系统/Supermarket/lib/mysql-connector-java-5.1.32.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/activation.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/mail.jar" />
<libelement value="file://D:/大二下学期实训超市管理系统/Supermarket/lib/mysql-connector-java-5.1.32.jar" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$" expected_position="1" />
@ -47,6 +47,5 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="mysql.connector.java" level="project" />
</component>
</module>

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket
user=root
password=123456

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket
user=root
password=123456

@ -1,4 +1,4 @@
driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket?serverTimezone=UTC
driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/supermarket
user=root
password=123456

@ -8,16 +8,16 @@ public class BGPanel extends JPanel{
private Image image;
public BGPanel(Image image) {
// 定义构造方法
// 定义一个构造方法接收一个Image类型的参数image用于创建BGPanel对象时传入要显示的图像
this.image = image;
// 将传入的参数image赋值给类的成员变量image
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
// 通过默认工具包Toolkit获取屏幕的宽度
// 通过默认工具包Toolkit获取屏幕的宽度存储在局部变量width中
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
// 通过默认工具包Toolkit获取屏幕的高度
// 通过默认工具包Toolkit获取屏幕的高度存储在局部变量height中
this.setSize(width, height);
// 设置该面板的大小为整个屏幕的大小
// 设置该面板BGPanel的大小为整个屏幕的大小,即宽度和高度分别为获取到的屏幕宽高
}
public BGPanel(Image image, int width, int height) {
@ -37,6 +37,7 @@ public class BGPanel extends JPanel{
// 调用父类JPanel的paintComponent方法以确保完成一些默认的绘制操作比如背景清除等
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
// 使用传入的Graphics对象g在面板上绘制图像参数含义如下
// image要绘制的图像对象就是之前保存的成员变量image
// 0, 0表示在面板上绘制图像的起始坐标x坐标和y坐标这里从面板的左上角0, 0位置开始绘制
// getWidth(), getHeight():获取当前面板的宽度和高度,用于指定绘制图像时按照面板的实际大小进行拉伸或缩放,确保图像填满整个面板

@ -7,10 +7,10 @@ import com.lingnan.supermarket.dto.Production;
public interface BufferService {
/*主要用于更新操作*/
/*根据商品id判断delmark是0还是1,即是否是新添加的商品返回2还是已经添加的商品返回1还是不存在的商品返回0*/
public Vector<Buffer> allOutBuffer();
public Buffer findOutBufferbyId(String id) ;
public Buffer findOutBufferbyId(String id) ;
public boolean addOutBufferNewProd(String id,int sum);
public boolean addOutBufferExeistProd(String id,int sum,Buffer buffer);
/*public Buffer findOutBufferSumAndOutPrice(String id);*/
@ -20,11 +20,11 @@ public interface BufferService {
public boolean DelAllOutBuffer();
public boolean DelOutBufferById(String id);
public boolean UpdateOutBufferById(String id,int sum);
/*进货模块*/
public Vector<Production> allInBuffer();
public Buffer findInBufferbyId(String id) ;
public Buffer findInBufferbyId(String id) ;
public boolean addInBufferNewProd(String id,int sum);
public boolean addInBufferExeistProd(String id,int sum,Buffer buffer);
/*public Buffer findInBufferSumAndInPrice(String id);*/

@ -8,25 +8,25 @@ import com.lingnan.supermarket.dto.User;
public interface SupplierInfService {
//查询操作 加where default==1
Vector<SupplierInf> findAllSupplierInf();
Vector<SupplierInf> findByNameSupplierInf(SupplierInf supplierInf);
Vector<SupplierInf> findAllSupplierInf();
Vector<SupplierInf> findByNameSupplierInf(SupplierInf supplierInf);
// SupplierInf findByNameSupplierInf(String name);
//根据id增加
int addSupplierInf(SupplierInf s);
//根据id删除
//int deleteSupplierInf(String id);
//根据id更新
int updateSupplierInf(SupplierInf supplierInf);
int deleteSupplierInf(int id);
//输出所有供应商名字
ArrayList<String> findNameSupplier();
//通过供应商名查找并输出id
int findIdSupplierByName(String name);
}
}

@ -515,13 +515,13 @@ public class BufferImpl implements BufferService {
/*如果delmark是1即是已经添加的商品*/
// 更新已存在商品的进货缓冲区记录
// 方法名称addInBufferExeistProd
// 参数:
// id - 商品的唯一标识符
// sum - 要添加的商品数量
// buffer - 包含商品信息的缓冲区对象
// 返回值:布尔值,表示更新操作是否成功
// 更新已存在商品的进货缓冲区记录
// 方法名称addInBufferExeistProd
// 参数:
// id - 商品的唯一标识符
// sum - 要添加的商品数量
// buffer - 包含商品信息的缓冲区对象
// 返回值:布尔值,表示更新操作是否成功
public boolean addInBufferExeistProd(String id,int sum,Buffer buffer){
boolean flag = false; // 初始化标志为false
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
@ -666,16 +666,16 @@ public class BufferImpl implements BufferService {
/*更改记录通过id*/
// 更新进货缓冲区记录
/**
* ID
*
* @param id ID
* @param sum
* @return
*/
public boolean UpdateInBufferById(String id,int sum) {
/*更改记录通过id*/
// 更新进货缓冲区记录
/**
* ID
*
* @param id ID
* @param sum
* @return
*/
public boolean UpdateInBufferById(String id,int sum) {
boolean flag = false; // 初始化标志为false
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement pstmt = null; // 初始化预编译语句对象

@ -52,12 +52,12 @@ public class inRecordServiceImpl implements inRecordService{
/**
*
*
* @param iNumber
* @return
*/
@Override
*
*
* @param iNumber
* @return
*/
@Override
public Vector<InRecord> findByIdinRecord(String iNumber) {
InRecord inRecord; // 声明一个进货记录对象
Vector<InRecord> v = new Vector<InRecord>(); // 创建一个向量用于存储进货记录
@ -91,7 +91,7 @@ public class inRecordServiceImpl implements inRecordService{
// 该方法用于将进货记录添加到数据库中。
// 参数 ir 是一个包含进货信息的对象。
// 返回值 flag 表示插入的结果1表示成功-1表示失败。
public int addinRecord(InRecord ir) {
public int addinRecord(InRecord ir) {
int flag = 0; // 初始化标志为0
String iNumber = ir.getiNumber(); // 获取进货单号
@ -121,7 +121,7 @@ public int addinRecord(InRecord ir) {
// 删除进货记录方法,根据进货单号进行删除操作
@Override
@Override
public int deleteinRecord(String iNumber) {
int flag = 0; // 初始化标志为0
@ -143,14 +143,14 @@ public int addinRecord(InRecord ir) {
return flag; // 返回删除结果标志
}
/**
*
*
* @param iNumber
* @param p
* @return truefalse
*/
public boolean insertInRecord(String iNumber,Production p) {
/**
*
*
* @param iNumber
* @param p
* @return truefalse
*/
public boolean insertInRecord(String iNumber,Production p) {
boolean flag = false; // 初始化标志为false
Connection conn = JDBCUtil.getConn(); // 获取数据库连接
PreparedStatement preparedStatement = null; // 初始化预编译语句对象

@ -13,29 +13,21 @@ import com.lingnan.supermarket.dto.InOrder;
import com.lingnan.supermarket.dto.OutOrder;
import com.lingnan.supermarket.utils.JDBCUtil;
// 实现outOrderService接口--用于处理与出库订单相关的数据访问操作
public class outOrderServiceImpl implements outOrderService {
public class outOrderServiceImpl implements outOrderService{
// 查询所有出库订单信息,并按照日期降序排列返回
@Override
public Vector<OutOrder> findAllOutOrder() {
// 存储查询到的所有出库订单信息的向量集合
Vector<OutOrder> outOrders = new Vector<OutOrder>();
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
// 从OutOrder表中查询所有记录并按oDate字段降序排序
String SQL = "select * from OutOrder order by oDate desc";
try {
// 根据SQL语句创建预编译的Statement对象
preparedStatement = conn.prepareStatement(SQL);
// 执行查询操作
resultSet = preparedStatement.executeQuery();
// 遍历结果集将每条记录封装成OutOrder对象并添加到outOrders集合中
while (resultSet.next()) {
while(resultSet.next()) {
OutOrder outOrder = new OutOrder();
outOrder.setoNumber(resultSet.getString("oNumber"));
outOrder.setAllOutPrice(resultSet.getFloat("allOutPrice"));
@ -47,143 +39,113 @@ public class outOrderServiceImpl implements outOrderService {
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭结果集、预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(resultSet, preparedStatement, conn);
}
return outOrders;
}
// 根据订单编号查询对应的出库订单信息
@Override
public OutOrder findByIdOutOrder(String oNumber) {
// 用于存储查询到的出库订单信息的对象
OutOrder outOrder = new OutOrder();
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
// 根据订单编号查询对应的出库订单记录
preparedStatement = conn.prepareStatement("select * from outOrder where oNumber =?");
// 设置查询的订单编号
preparedStatement = conn.prepareStatement("select * from outOrder where oNumber = ?");
preparedStatement.setString(1, oNumber);
// 执行查询操作
resultSet = preparedStatement.executeQuery();
// 如果结果集中有记录说明找到了对应的订单则将记录中的各字段值封装到outOrder对象中
if (resultSet.next()) {
outOrder.setoNumber(resultSet.getString("oNumber"));
outOrder.setAllOutPrice(resultSet.getFloat("allOutPrice"));
outOrder.setoDate(resultSet.getDate("oDate"));
outOrder.setPrincipal(resultSet.getString("principal"));
} else {
// 如果结果集中没有记录说明没有找到该订单或订单不存在返回null
return null;
return null; // 没有找到该订单或订单不存在返回null
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭结果集、预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(resultSet, preparedStatement, conn);
}
return outOrder;
}
// 向数据库中添加一条出库订单记录
@Override
public int addOutOrder(String oNumber, float allOutPrice) {
int flag = 0;
// 获取当前系统时间戳用于作为出库订单的日期oDate字段值表示订单创建时间
Timestamp oDate = new Timestamp(System.currentTimeMillis());
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
try {
// 创建预编译的SQL插入语句向outOrder表中插入一条记录
preparedStatement = conn.prepareStatement("insert into outOrder values (?,?,?,?)");
// 设置预编译语句中的参数,依次为订单编号、总出库价格、订单日期、负责人(此处写死为"a1",可能后续需要改进)
preparedStatement = conn.prepareStatement
("insert into outOrder values (?,?,?,?)");
preparedStatement.setString(1, oNumber);
preparedStatement.setFloat(2, allOutPrice);
preparedStatement.setTimestamp(3, oDate);
preparedStatement.setString(4, "a1");
// 执行插入操作
preparedStatement.executeUpdate();
// 如果插入成功将标志位flag设置为1表示操作成功
flag = 1;
} catch (SQLException e) {
// 如果插入出现异常将标志位flag设置为 -1表示操作失败
flag = -1;
e.printStackTrace();
} finally {
// 关闭预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null,preparedStatement, conn);
}
return flag;
}
// 根据订单编号从数据库中删除对应的出库订单记录
@Override
public int deleteOutOrder(String oNumber) {
int flag = 0;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
try {
// 创建预编译的SQL删除语句根据订单编号oNumber删除对应的出库订单记录
preparedStatement = conn.prepareStatement("delete from outOrder where oNumber =?");
// 设置预编译语句中的参数,即要删除的订单编号
preparedStatement = conn.prepareStatement
("delete from outOrder where oNumber = ?");
preparedStatement.setString(1, oNumber);
// 执行删除操作
preparedStatement.executeUpdate();
// 如果删除成功将标志位flag设置为1表示操作成功
flag = 1;
} catch (SQLException e) {
// 如果删除出现异常将标志位flag设置为 -1表示操作失败
flag = -1;
e.printStackTrace();
} finally {
// 关闭预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null,preparedStatement, conn);
}
return flag;
}
// 获取指定日期的今日出库金额总和(此处方法名可能有点混淆,从代码逻辑看是获取指定日期的出库金额总和)
//获取今日进货金额
public Float TodayOutPrice(String date) {
// 创建一个InOrder对象
InOrder inOrder = new InOrder();
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
// 用于存储查询到的今日出库金额总和初始为0
Float allInPrice = (float) 0;
Float allInPrice=(float) 0;
try {
// 通过求和函数查询指定日期范围内的总出库价格
preparedStatement = conn.prepareStatement("select sum(allOutPrice) from outOrder where oDate>=? and oDate<=date_add(?,interval 1 day)");
// 设置两个参数均为传入的日期值,用于限定查询的日期范围
preparedStatement.setString(1, date);
preparedStatement.setString(2, date);
// 执行查询操作
resultSet = preparedStatement.executeQuery();
// 如果结果集中有记录说明查询到了对应的金额数据则将其取出赋值给allInPrice变量
if (resultSet.next()) {
allInPrice = resultSet.getFloat("sum(allOutPrice)");
allInPrice=resultSet.getFloat("sum(allOutPrice)");
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭结果集、预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(resultSet, preparedStatement, conn);
}
return allInPrice;
}
}
}

@ -12,29 +12,21 @@ import com.lingnan.supermarket.dto.InRecord;
import com.lingnan.supermarket.dto.OutRecord;
import com.lingnan.supermarket.utils.JDBCUtil;
// 实现了outRecordService接口--用于处理出库记录相关的数据操作逻辑
public class outRecordServiceImpl implements outRecordService {
public class outRecordServiceImpl implements outRecordService{
// 查询所有出库记录信息
@Override
public Vector<OutRecord> findAllOutRecord() {
// 用于存储查询到的所有出库记录信息的向量集合
Vector<OutRecord> outRecords = new Vector<OutRecord>();
// 通过JDBCUtil工具类的静态方法来获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
// 从outRecord表中获取所有记录
String SQL = "select * from outRecord";
try {
// 根据SQL语句创建预编译的Statement对象
preparedStatement = conn.prepareStatement(SQL);
// 执行查询操作
resultSet = preparedStatement.executeQuery();
// 遍历结果集将每条记录封装成OutRecord对象并添加到outRecords集合中
while (resultSet.next()) {
while(resultSet.next()) {
OutRecord outRecord = new OutRecord();
outRecord.setoNumber(resultSet.getString("oNumber"));
outRecord.setSum(resultSet.getInt("sum"));
@ -45,33 +37,24 @@ public class outRecordServiceImpl implements outRecordService {
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭结果集、预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(resultSet, preparedStatement, conn);
}
return outRecords;
}
// 根据订单编号查询对应的出库记录信息,返回符合条件的多条记录
@Override
public Vector<OutRecord> findByIdOutRecordr(String oNumber) {
// 用于临时存储单个出库记录信息的对象
OutRecord outRecord;
// 获取数据库连接
OutRecord outRecord ;
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
// 存储查询到的符合条件的所有出库记录信息的向量集合
Vector<OutRecord> v = new Vector<OutRecord>();
try {
//根据给定的订单编号查询outRecord表中对应的记录
preparedStatement = conn.prepareStatement("select * from outRecord where oNumber =?");
// 设置要查询的订单编号
preparedStatement = conn.prepareStatement("select * from outRecord where oNumber = ?");
preparedStatement.setString(1, oNumber);
// 执行查询操作,获取结果集
resultSet = preparedStatement.executeQuery();
// 遍历结果集将每条符合条件的记录封装成OutRecord对象并添加到向量集合v中
while (resultSet.next()) {
outRecord = new OutRecord();
outRecord.setoNumber(resultSet.getString("oNumber"));
@ -84,78 +67,63 @@ public class outRecordServiceImpl implements outRecordService {
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭结果集、预编译语句以及数据库连接,释放相关资源
JDBCUtil.close(resultSet, preparedStatement, conn);
}
return v;
}
// 向数据库中添加一条出库记录信息
@Override
public int addoutRecord(OutRecord or) {
int flag = 0;
// 获取要添加的出库记录对象中的订单编号
String oNumber = or.getoNumber();
// 获取要添加的出库记录对象中的数量
int sum = or.getSum();
// 获取要添加的出库记录对象中的出库价格
Float outPrice = or.getOutPrice();
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
try {
// 创建预编译的SQL插入语句向outRecord表中插入一条记录包含订单编号、数量、出库价格三个字段的值
preparedStatement = conn.prepareStatement("insert into outRecord values (?,?,?)");
// 设置预编译语句中的参数,依次为订单编号、数量、出库价格
preparedStatement = conn.prepareStatement
("insert into outRecord values (?,?,?)");
preparedStatement.setString(1, oNumber);
preparedStatement.setInt(2, sum);
preparedStatement.setFloat(3, outPrice);
// 执行插入操作
preparedStatement.executeUpdate();
// 如果插入成功将标志位flag设置为1表示操作成功
flag = 1;
} catch (SQLException e) {
// 如果插入出现异常将标志位flag设置为 -1表示操作失败
flag = -1;
e.printStackTrace();
} finally {
// 关闭预编译语句以及数据库连接释放相关资源此处结果集为null
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null,preparedStatement, conn);
}
return flag;
}
// 根据订单编号从数据库中删除对应的出库记录信息
@Override
public int deleteOutOrder(String oNumber) {
int flag = 0;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
PreparedStatement preparedStatement = null;
try {
// 创建预编译的SQL删除语句根据给定的订单编号删除outRecord表中对应的记录
preparedStatement = conn.prepareStatement("delete from outRecord where oNumber =?");
// 设置要删除的订单编号
preparedStatement = conn.prepareStatement
("delete from outRecord where oNumber = ?");
preparedStatement.setString(1, oNumber);
// 执行删除操作
preparedStatement.executeUpdate();
// 如果删除成功将标志位flag设置为1表示操作成功
flag = 1;
} catch (SQLException e) {
// 如果删除出现异常将标志位flag设置为 -1表示操作失败
flag = -1;
e.printStackTrace();
} finally {
// 关闭预编译语句以及数据库连接释放相关资源此处结果集为null
JDBCUtil.close(null, preparedStatement, conn);
JDBCUtil.close(null,preparedStatement, conn);
}
return flag;
}
}
}

@ -12,241 +12,214 @@ import com.lingnan.supermarket.dao.prodCatalogService;
import com.lingnan.supermarket.dto.ProdCatalog;
import com.lingnan.supermarket.utils.JDBCUtil;
// 实现prodCatalogService接口--用于处理商品目录相关的数据持久化操作
public class prodCatalogImpl implements prodCatalogService {
public class prodCatalogImpl implements prodCatalogService{
// 将商品目录表和商品表联合查询,获取商品目录及相关商品信息
/*将商品目录表和商品表联合查询*/
@Override
public Vector<ProdCatalog> findProdCatalogAndProd() {
// 通过JDBCUtil工具类来获取已经配置好的连接对象
Connection conn = JDBCUtil.getConn();
// 创建一个Vector容器存放查询到的ProdCatalog对象
Connection conn=JDBCUtil.getConn();
Vector<ProdCatalog> v = new Vector<ProdCatalog>();
ProdCatalog prodCatalog;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
try {
// 通过预编译语句准备调用存储过程allProdCatalog
pstmt = conn.prepareStatement("call allProdCatalog()");
// 执行查询操作
resultSet = pstmt.executeQuery();
// 遍历结果集将每一条记录封装成ProdCatalog对象并添加到Vector容器中
while (resultSet.next()) {
while(resultSet.next()){
prodCatalog = new ProdCatalog();
// 设置ProdCatalog对象的id属性
prodCatalog.setId(resultSet.getString("id"));
// 设置ProdCatalog对象的name属性
prodCatalog.setName(resultSet.getString("name"));
v.add(prodCatalog);
}
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// 通过JDBCUtil工具类提供的方法进行关闭操作
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return v;
}
// 根据给定的id1查找商品目录名称
@Override
public String findProdCatalog(String id1) {
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
public String findProdCatalog(String id1 ) {
Connection conn=JDBCUtil.getConn();
PreparedStatement pstmt = null;
ResultSet resultSet = null;
String catalog = null;
ResultSet resultSet=null;
String catalog=null;
try {
// 预编译SQL语句用于根据给定的id2查询prodCatalog表中的记录
pstmt = conn.prepareStatement("select *from prodCatalog where id2 =?");
// 设置SQL语句中的参数将传入的id1赋值给查询语句中的占位符
pstmt.setString(1, id1);
pstmt.setString(1,id1);
// 执行查询操作
resultSet = pstmt.executeQuery();
// 如果结果集中有下一条记录则获取对应记录中的name1字段值作为商品目录名称
if (resultSet.next()) {
catalog = resultSet.getString("name1");
if(resultSet.next()){
catalog=resultSet.getString("name1");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// 关闭相关资源
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return catalog;
}
// 向商品目录表prodCatalog中添加一条记录
@Override
public int addProdCatalog(String id1, String id2) {
int flag = 0;
String name1 = null;
// 根据传入的id1判断商品类别名称01对应食品02对应电器03对应生活用品04对应其他
if (id1.equals("01"))
name1 = "食品";
else if (id1.equals("02"))
name1 = "电器";
else if (id1.equals("03"))
name1 = "生活用品";
int flag=0;
String name1=null;
//01 食品 02 电器 03 生活用品 04 其他
if(id1.equals("01"))
name1="食品";
else if(id1.equals("02"))
name1="电器";
else if(id1.equals("03"))
name1="生活用品";
else
name1 = "其他";
name1="其他";
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
//连接jdbc
Connection conn=JDBCUtil.getConn();
PreparedStatement pstmt = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
try {
// 预编译插入数据的SQL语句向prodCatalog表中插入三条数据
pstmt = conn.prepareStatement("insert into prodCatalog values(?,?,?)");
// 设置SQL语句中的第一个参数
pstmt.setString(1, id1);
// 设置SQL语句中的第二个参数
pstmt.setString(2, name1);
// 设置SQL语句中的第三个参数
pstmt.setString(3, id2);
// 执行插入操作若插入成功将flag置为1表示添加成功
pstmt.setString(1,id1);
pstmt.setString(2,name1);
pstmt.setString(3,id2);
pstmt.executeUpdate();
flag = 1;
flag=1;
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭相关资源
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return flag;
}
// 根据给定的id2删除商品目录表prodCatalog中的一条记录
@Override
public int deleteProdCatalog(String id2) {
int flag = 0;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
int flag=0;
//连接jdbc
Connection conn=JDBCUtil.getConn();
PreparedStatement pstmt = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
try {
// 预编译删除数据的SQL语句根据传入的id2作为条件从prodCatalog表中删除对应的记录
pstmt = conn.prepareStatement("delete from prodCatalog where id2=?");
// 设置SQL语句中的参数将传入的id2赋值给查询语句中的占位符?
pstmt.setString(1, id2);
// 执行删除操作若删除成功将flag置为1表示删除成功
pstmt.setString(1,id2);
pstmt.executeUpdate();
flag = 1;
flag=1;
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// 关闭相关资源
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return flag;
}
// 根据商品类production的name查询并输出类别id如果传入的name为"全部"则直接返回默认的catalogid "0"
@Override
//根据商品类production的name查询并输出类别id
public String findProdCatalogByname(String name) {
Connection conn = JDBCUtil.getConn();
Connection conn=JDBCUtil.getConn();
PreparedStatement pstmt = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
String catalogid = "0";
String catalogid="0";
try {
// 如果传入的商品名称为"全部"则直接返回默认的catalogid
if (name.equals("全部")) {
if(name.equals("全部")){
return catalogid;
}
// 预编译SQL语句用于根据给定的商品名称查询prodCatalog表中的记录获取对应的类别id
pstmt = conn.prepareStatement("select * from prodCatalog where name =?");
// 设置SQL语句中的参数将传入的name赋值给查询语句中的占位符
pstmt.setString(1, name);
pstmt.setString(1,name);
// 执行查询操作,获取结果集
resultSet = pstmt.executeQuery();
// 如果结果集中有下一条记录则获取对应记录中的id字段值作为类别id
if (resultSet.next()) {
catalogid = resultSet.getString("id");
if(resultSet.next()){
catalogid=resultSet.getString("id");
}
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// 关闭相关资源
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return catalogid;
}
/*
public static void main(String[] args) {
ProdCatalog p = new ProdCatalog();
prodCatalogImpl pi = new prodCatalogImpl();
p.setName("全部");
System.out.println(pi.findProdCatalogByname(p.getName()));
}
*/
// 查询商品目录表prodCatalog中的所有商品类别名称并添加"全部"作为第一个元素后返回
/* public static void main(String[] args) {
ProdCatalog p=new ProdCatalog();
prodCatalogImpl pi=new prodCatalogImpl();
p.setName("全部");
System.out.println(pi.findProdCatalogByname(p.getName()));
}*/
@Override
public ArrayList<String> findNameProdCatalog() {
Connection conn = JDBCUtil.getConn();
Connection conn=JDBCUtil.getConn();
ArrayList<String> v = new ArrayList<String>();
// 先添加"全部"作为默认的第一个类别名称
v.add("全部");
ProdCatalog prodCatalog;
PreparedStatement pstmt = null;
ResultSet resultSet = null;
ResultSet resultSet=null;
try {
// 预编译查询所有记录的SQL语句用于获取prodCatalog表中的所有商品类别名称
pstmt = conn.prepareStatement("select * from prodCatalog");
// 执行查询操作
resultSet = pstmt.executeQuery();
// 遍历结果集将每条记录中的商品类别名称添加到ArrayList容器中
while (resultSet.next()) {
while(resultSet.next()){
v.add(resultSet.getString("name"));
}
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
// 关闭相关资源
}finally{
JDBCUtil.close(resultSet, pstmt, conn);
}
return v;
}
/*
public static void main(String[] args) {
prodCatalogImpl pi = new prodCatalogImpl();
ArrayList<String> log = null;
log = pi.findNameProdCatalog();
String[] s = new String[log.size()];
for (int i = 0; i < log.size(); i++) {
s[i] = log.get(i);
System.out.println(log.get(i));
}
for (int i = 0; i < s.length; i++) {
System.out.println(s[i]);
}
}
*/
}
/*public static void main(String[] args) {
prodCatalogImpl pi=new prodCatalogImpl();
ArrayList<String>log=null;
log=pi.findNameProdCatalog();
String []s=new String[log.size()];
for(int i=0;i<log.size();i++)
{s[i]=log.get(i);
System.out.println(log.get(i));
}
for(int i=0;i<s.length;i++)
{
System.out.println(s[i]);
}
}*/
}

@ -273,8 +273,8 @@ public class productionImpl implements productionService {
if(id.equals("0"))
preparedStatement = conn.prepareStatement("select * from production where delmark = 1");
else
{preparedStatement = conn.prepareStatement("select * from production where id2= ? and delmark = 1");
preparedStatement.setString(1, id);}
{preparedStatement = conn.prepareStatement("select * from production where id2= ? and delmark = 1");
preparedStatement.setString(1, id);}
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
@ -316,7 +316,7 @@ public class productionImpl implements productionService {
preparedStatement.setString(3, prodId);
if(preparedStatement.executeUpdate()==1);
flag = true;
flag = true;
} catch (SQLException e) {
e.printStackTrace();

@ -6,15 +6,95 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
<<<<<<< HEAD
// 导入相关的业务逻辑接口、数据传输对象以及工具类,用于数据库操作和日期处理等功能
=======
<<<<<<< HEAD
=======
// 导入相关的业务逻辑接口、数据传输对象以及工具类,用于数据库操作和日期处理等功能
>>>>>>> developer
>>>>>>> remotes/origin/main
import com.lingnan.supermarket.dao.storageRecordService;
import com.lingnan.supermarket.dto.StorageRecord;
import com.lingnan.supermarket.utils.DateUtil;
import com.lingnan.supermarket.utils.JDBCUtil;
// 实现storageRecordService接口--用于处理库存记录相关的数据持久化操作
public class storageRecordImpl implements storageRecordService {
<<<<<<< HEAD
// 查询所有库存记录信息并以Vector容器存储返回
@Override
public Vector<StorageRecord> findAllStorageRecord() {
// 创建一个Vector容器用于存放查询到的StorageRecord对象
Vector<StorageRecord> v = new Vector<StorageRecord>();
// 获取数据库连接通过JDBCUtil工具类来获取已经配置好的连接对象
Connection conn = JDBCUtil.getConn();
PreparedStatement pstmt = null;
ResultSet resultSet = null;
try {
// 编写SQL查询语句从storageRecord表中查询所有记录并按照cDate字段降序排序
String sql = "select * from storageRecord order by cDate desc";
// 使用获取到的数据库连接对象预编译SQL语句
pstmt = conn.prepareStatement(sql);
// 执行查询操作
resultSet = pstmt.executeQuery();
// 遍历结果集将每一条记录封装成StorageRecord对象并添加到Vector容器中
while (resultSet.next()) {
StorageRecord sr = new StorageRecord();
// 设置StorageRecord对象的id属性
sr.setId(resultSet.getString("id"));
// 设置StorageRecord对象的库存编号属性
sr.setTheNumber(resultSet.getString("theNumber"));
// 设置StorageRecord对象的数量属性
sr.setNum(resultSet.getInt("num"));
// 设置StorageRecord对象的执行情况属性
sr.setExecute(resultSet.getString("execute"));
// 通过DateUtil工具类的dateToString方法将数据库中获取的时间戳类型的日期数据转换为字符串类型方便后续使用第二个参数为null可能表示使用默认的日期格式转换具体看DateUtil实现
=======
<<<<<<< HEAD
/**
*
*
* @return Vector<StorageRecord>
*/
@Override
public Vector<StorageRecord> findAllStorageRecord() {
// 创建一个空的Vector对象用于存储所有查询到的StorageRecord
Vector<StorageRecord> v = new Vector<StorageRecord>();
// 通过JDBC获取数据库连接
Connection conn = JDBCUtil.getConn();
// 声明PreparedStatement和ResultSet对象
PreparedStatement pstmt = null;
ResultSet resultSet = null;
try {
// 编写SQL查询语句按存储日期降序排列
String sql = "select * from storageRecord order by cDate desc";
// 准备SQL语句
pstmt = conn.prepareStatement(sql);
// 执行查询,获取结果集
resultSet = pstmt.executeQuery();
// 迭代结果集将每条记录封装成StorageRecord对象
while (resultSet.next()) {
StorageRecord sr = new StorageRecord();
// 设置StorageRecord对象的各个属性
sr.setId(resultSet.getString("id")); // 设置id字段
sr.setTheNumber(resultSet.getString("theNumber")); // 设置存储记录编号
sr.setNum(resultSet.getInt("num")); // 设置数量字段
sr.setExecute(resultSet.getString("execute")); // 设置执行状态字段
// 设置创建日期字段并通过DateUtil工具类格式化日期
=======
// 查询所有库存记录信息并以Vector容器存储返回
@Override
public Vector<StorageRecord> findAllStorageRecord() {
@ -46,11 +126,46 @@ public class storageRecordImpl implements storageRecordService {
sr.setExecute(resultSet.getString("execute"));
// 通过DateUtil工具类的dateToString方法将数据库中获取的时间戳类型的日期数据转换为字符串类型方便后续使用第二个参数为null可能表示使用默认的日期格式转换具体看DateUtil实现
>>>>>>> developer
>>>>>>> remotes/origin/main
sr.setcDate(DateUtil.dateToString(resultSet.getTimestamp("cDate"), null));
// 将StorageRecord对象添加到Vector中
v.add(sr);
}
<<<<<<< HEAD
=======
<<<<<<< HEAD
} catch (SQLException e) {
// 如果出现SQL异常打印错误信息
e.printStackTrace();
} finally {
// 确保资源被关闭,避免内存泄漏
JDBCUtil.close(resultSet, pstmt, conn);
}
// 返回所有存储记录的Vector
return v;
}
/**
*
*
* @param theNumber
* @return StorageRecord null
*/
@Override
public StorageRecord findByIdStorageRecord(String theNumber) {
// 创建一个空的StorageRecord对象用于存储查询结果
StorageRecord sr = null;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
// 声明PreparedStatement和ResultSet对象
=======
>>>>>>> remotes/origin/main
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
@ -71,10 +186,35 @@ public class storageRecordImpl implements storageRecordService {
StorageRecord sr = null;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
PreparedStatement pstmt = null;
ResultSet resultSet = null;
try {
<<<<<<< HEAD
=======
<<<<<<< HEAD
// 初始化StorageRecord对象
sr = new StorageRecord();
// 编写SQL查询语句通过存储记录编号查询特定记录
pstmt = conn.prepareStatement("select * from storageRecord where theNumber=?");
// 设置查询条件,即存储记录编号
pstmt.setString(1, theNumber);
// 执行查询操作并将结果存放在resultSet中
resultSet = pstmt.executeQuery();
// 如果查询到数据填充StorageRecord对象
if (resultSet.next()) {
sr.setTheNumber(resultSet.getString("theNumber"));
sr.setId(resultSet.getString("id"));
=======
>>>>>>> remotes/origin/main
// 创建一个新的StorageRecord对象用于后续封装查询到的数据
sr = new StorageRecord();
// 预编译SQL语句用于根据给定的库存编号theNumber查询storageRecord表中的记录
@ -87,11 +227,16 @@ public class storageRecordImpl implements storageRecordService {
if (resultSet.next()) {
sr.setTheNumber((resultSet.getString("theNumber")));
sr.setId((resultSet.getString("id")));
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
sr.setNum(resultSet.getInt("num"));
sr.setExecute(resultSet.getString("execute"));
// 设置存储记录的创建日期,并进行格式化
sr.setcDate(DateUtil.dateToString(resultSet.getTimestamp("cDate"), null));
}
<<<<<<< HEAD
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
@ -127,6 +272,119 @@ public class storageRecordImpl implements storageRecordService {
// 设置SQL语句中的第五个参数
pstmt.setInt(5, sum);
// 执行插入操作若受影响的行数为1则将flag置为true表示插入成功
if (pstmt.executeUpdate() == 1) {
flag = true;
}
=======
<<<<<<< HEAD
} catch (SQLException e) {
// 如果发生SQLException打印堆栈信息
e.printStackTrace();
} finally {
// 确保资源关闭,防止资源泄露
JDBCUtil.close(resultSet, pstmt, conn);
}
// 返回找到的存储记录对象如果没有找到则返回null
return sr;
}
/**
*
*
* @param iNumber
* @param time
* @param prodId
* @param execute
* @param sum
* @return boolean truefalse
*/
public boolean insertStorageRecord(String iNumber, String time, String prodId, String execute, int sum) {
// 默认插入操作失败
boolean flag = false;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
// 声明PreparedStatement和ResultSet对象
=======
>>>>>>> remotes/origin/main
} catch (SQLException e) {
// 若出现SQL异常打印异常栈信息
e.printStackTrace();
} finally {
// 关闭相关资源
JDBCUtil.close(resultSet, pstmt, conn);
}
<<<<<<< HEAD
=======
return sr;
}
// 向库存记录表storageRecord中插入一条新的库存记录信息
public boolean insertStorageRecord(String iNumber, String time, String prodId, String execute, int sum) {
// 定义一个布尔变量用于标记插入操作是否成功初始化为false
boolean flag = false;
// 获取数据库连接
Connection conn = JDBCUtil.getConn();
>>>>>>> developer
PreparedStatement pstmt = null;
ResultSet resultSet = null;
try {
<<<<<<< HEAD
// 编写SQL插入语句将数据插入到storageRecord表中
pstmt = conn.prepareStatement("insert into storageRecord values(?,?,?,?,?)");
// 设置插入的字段值
pstmt.setString(1, iNumber); // 存储记录编号
pstmt.setString(2, time); // 存储记录时间
pstmt.setString(3, prodId); // 商品编号
pstmt.setString(4, execute); // 执行状态
pstmt.setInt(5, sum); // 数量
// 执行插入操作如果插入成功则返回1
if (pstmt.executeUpdate() == 1) {
// 如果插入成功设置标志位为true
flag = true;
}
} catch (SQLException e) {
// 如果发生SQLException打印堆栈信息
e.printStackTrace();
} finally {
// 确保数据库连接和资源被关闭
JDBCUtil.close(resultSet, pstmt, conn);
}
// 返回插入操作的结果成功返回true失败返回false
=======
// 预编译插入数据的SQL语句向storageRecord表中插入五条数据
pstmt = conn.prepareStatement("insert into storageRecord values(?,?,?,?,?) ");
// 设置SQL语句中的第一个参数
pstmt.setString(1, iNumber);
// 设置SQL语句中的第二个参数
pstmt.setString(2, time);
// 设置SQL语句中的第三个参数
pstmt.setString(3, prodId);
// 设置SQL语句中的第四个参数
pstmt.setString(4, execute);
// 设置SQL语句中的第五个参数
pstmt.setInt(5, sum);
// 执行插入操作若受影响的行数为1则将flag置为true表示插入成功
if (pstmt.executeUpdate() == 1) {
flag = true;
@ -139,6 +397,8 @@ public class storageRecordImpl implements storageRecordService {
// 关闭相关资源
JDBCUtil.close(resultSet, pstmt, conn);
}
>>>>>>> developer
>>>>>>> remotes/origin/main
return flag;
}
}
}

@ -9,7 +9,7 @@ public interface inOrderService {
Vector<InOrder> findAllInOrder ();
//查询某个进货订单
InOrder findByIdinOrder (String iNumber);
//默认princial为a1. 创建时new一个时间插入,总价随机模拟
int addInOrder(String iNumber,float allInPrice );
int deleteInOrder(String iNumber);

@ -10,7 +10,7 @@ public interface inRecordService {
Vector<InRecord> findAllinRecord();
//查询某个进货详细订单
public Vector<InRecord> findByIdinRecord(String iNumber);
//默认princial为a1. 创建时new一个时间插入,总价随机模拟
int addinRecord(InRecord ir );
int deleteinRecord(String iNumber);

@ -10,7 +10,7 @@ public interface outOrderService {
Vector<OutOrder> findAllOutOrder ();
//查询某个进货订单
OutOrder findByIdOutOrder (String oNumber );
//默认princial为a1. 创建时new一个时间插入,总价随机模拟
int addOutOrder(String oNumber ,float allOutPrice );
int deleteOutOrder(String oNumber );

@ -9,8 +9,8 @@ public interface outRecordService {
Vector<OutRecord> findAllOutRecord ();
//查询某个进货订单
Vector<OutRecord> findByIdOutRecordr (String oNumber );
int addoutRecord(OutRecord or);
int deleteOutOrder(String oNumber);
int deleteOutOrder(String oNumber);
}

@ -11,12 +11,12 @@ public interface prodCatalogService {
String findProdCatalog(String id1 );
int addProdCatalog(String id1,String id2);
int deleteProdCatalog(String id2);
//根据商品类production的name查询并输出类别id
String findProdCatalogByname(String name );
//查找所有商品类的类名并以数组输出
ArrayList<String> findNameProdCatalog();
}

@ -9,23 +9,23 @@ public interface productionService {
//查找并输出全部商品
Vector<Production> findAllproduction ();
//由一个商品名查找并输出全部商品
Vector<Production> findproduction (String name);
Vector<Production> findproduction (String name);
Production findByNameProduction(String name);
//由一个商品类别id2查找并输出全部商品
Vector<Production> findProductionById2 (String id);
Vector<Production> findProductionById2 (String id);
/*通过id查找商品*/
public Production findByIdProduction(String id);
//根据id增加
int addProduction(Production p);
//根据id删除
public int deleteProduction(String id) ;
//根据id更新
int updateProduction(Production p) ;
boolean updateProductionSum(String prodId,int sum);
int updateProduction(Production p) ;
boolean updateProductionSum(String prodId,int sum);
}

@ -170,7 +170,7 @@ public class ChangeStatusDialog extends JDialog implements ActionListener{
} else if (catalog1.equals("取消订单")) {
catalog = 3;
}
}
}

@ -210,9 +210,9 @@ public class UserInfDialog extends JDialog implements ActionListener {
else if (sSuper1.equals("收银员"))
sSuper = 2; // 收银员权限
else if (sSuper1.equals("管理员")) // 新增权限角色
sSuper = 1;
else if (sSuper1.equals("进货员")) // 新增权限角色
sSuper = 3;
sSuper = 1;
else if (sSuper1.equals("进货员")) // 新增权限角色
sSuper = 3;
else
sSuper = 0; // 超级管理员
}

@ -3,11 +3,11 @@ package com.lingnan.supermarket.dto;
import java.util.Date;
public class OutOrder {
private String oNumber;
private Float allOutPrice;
private Date oDate;
private String principal;
private int delmark;
private String oNumber;
private Float allOutPrice;
private Date oDate;
private String principal;
private int delmark;
public String getoNumber() {
return oNumber;
}

@ -3,9 +3,9 @@ package com.lingnan.supermarket.dto;
import com.lingnan.supermarket.dto.base.BsDomain;
public class OutRecord extends BsDomain{
private String oNumber;
private int sum;
private Float outPrice;
private String oNumber;
private int sum;
private Float outPrice;
public String getoNumber() {
return oNumber;
}

@ -4,5 +4,5 @@ import com.lingnan.supermarket.dto.base.BaseProduction;
import com.lingnan.supermarket.dto.base.BsDomain;
public class Production extends BaseProduction{
}

@ -5,9 +5,25 @@ import java.util.Vector;
import com.lingnan.supermarket.dto.Buffer;
import com.lingnan.supermarket.dto.Production;
// 用于创建订单相关文本内容
public class CreateOrder {
<<<<<<< HEAD
=======
<<<<<<< HEAD
// 方法:生成订单小票文本
public String CreateOrder(Vector<Production> v, String oNumber, String time, Float allPrice, String username) {
// 初始化分隔符
String xx = "----------------------------------------------------------------------------\r\n";
// 订单生成时间
String InRequireText = time + "\r\n" + xx;
// 添加订单标题
InRequireText += "#名称 #单价 #数量 #金额\r\n";
// 遍历商品列表,生成订单项信息
=======
>>>>>>> remotes/origin/main
// 用于生成一个完整的订单文本信息,接收商品信息向量、订单编号、时间、总价以及负责人用户名等参数
public String CreateOrder(Vector<Production> v, String oNumber, String time, Float allPrice, String username) {
// 分割线
@ -18,10 +34,88 @@ public class CreateOrder {
// 添加订单小票中商品信息展示的表头部分
InRequireText += "#名称 #单价 #数量 #金额\r\n";
//循环遍历传入的商品信息向量,将每个商品的具体信息按照设定的格式拼接添加到订单文本中
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
for (Production p : v) {
InRequireText += p.getName() + " " + p.getInPrice() + " " + p.getSum() + " " + p.getPrice() + "\r\n";
}
<<<<<<< HEAD
=======
<<<<<<< HEAD
// 订单总金额
InRequireText += "\r\n" + xx;
InRequireText += "#总进货金额:" + allPrice + "元";
// 订单负责人和编号
InRequireText += "\r\n#负责人:" + username;
InRequireText += "\r\n#订单编号:" + oNumber;
// 商店信息
InRequireText += "\r\n#地址:新民超市";
InRequireText += "\r\n#联系电话:xxx";
// 加入订单备注
InRequireText += "\r\n#备注:谢谢光临,欢迎下次购买!";
// 空行分隔
InRequireText += "\r\n";
// 添加当前时间的时间戳
InRequireText += "#生成时间:" + System.currentTimeMillis() + "\r\n";
// 订单结束标记
InRequireText += "----------------------------------------------------------------------------\r\n";
// 返回生成的订单小票文本
return InRequireText;
}
// 日志记录方法(模拟)
private void logOrderCreation(String oNumber) {
// 这里模拟记录订单生成日志
System.out.println("订单创建成功,订单编号:" + oNumber);
}
// 模拟打印订单内容的方法
public void printOrder(String orderContent) {
// 打印订单内容(实际应用中可能是发送到打印机)
System.out.println(orderContent);
}
// 订单处理(模拟)方法
public void processOrder(Vector<Production> v, String oNumber, String time, Float allPrice, String username) {
// 创建订单内容
String orderContent = CreateOrder(v, oNumber, time, allPrice, username);
// 打印订单
printOrder(orderContent);
// 记录订单创建日志
logOrderCreation(oNumber);
}
// 添加订单清单格式方法
private String getOrderListFormat(Vector<Production> v) {
StringBuilder orderList = new StringBuilder();
for (Production p : v) {
orderList.append(p.getName())
.append(" - 单价: ")
.append(p.getInPrice())
.append(",数量: ")
.append(p.getSum())
.append(",金额: ")
.append(p.getPrice())
.append("\r\n");
}
return orderList.toString();
}
=======
>>>>>>> remotes/origin/main
// 添加一条分割线
InRequireText += "\r\n" + xx;
@ -39,4 +133,8 @@ public class CreateOrder {
// 返回最终生成的完整订单文本内容
return InRequireText;
}
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
}

@ -3,23 +3,20 @@ package com.lingnan.supermarket.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
// DateUtil类从名称可以推测是用于处理日期相关操作的工具类
public class DateUtil {
/**
* dateToStringDate
*
* @param date Date
* @param pattern "yyyy-MM-dd HH:mm:ss"-- ::
* patternnull使"yyyy-MM-dd HH:mm:ss"
* @return 便使
*
* @param date
* @param pattern
* @return
*/
public static String dateToString(Date date, String pattern) {
// 创建SimpleDateFormat对象它是Java中用于格式化日期的类通过指定的模式将日期转换为相应格式的字符串。
public static String dateToString(Date date,String pattern) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
// 使用applyPattern方法设置日期格式化的模式。如果传入的pattern为null就使用默认的"yyyy-MM-dd HH:mm:ss"格式。
simpleDateFormat.applyPattern(pattern == null? "yyyy-MM-dd HH:mm:ss" : pattern);
// 调用format方法将传入的Date对象按照设置好的模式进行格式化最终返回格式化后的日期字符串。
simpleDateFormat.applyPattern(pattern==null?"yyyy-MM-dd HH:mm:ss":pattern);
return simpleDateFormat.format(date);
}
}
}

@ -3,12 +3,12 @@ package com.lingnan.supermarket.utils;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;
// EmailTest类
public class EmailTest {
//Java程序的入口点
// 这里声明抛出AddressException和MessagingException异常意味着在方法执行过程中如果出现邮件地址相关或邮件发送相关的异常将直接向上抛出由调用者处理
public static void main(String[] args) throws AddressException, MessagingException {
// TODO Auto-generated method stub
}
}
}

@ -9,18 +9,28 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
<<<<<<< HEAD
=======
<<<<<<< HEAD
public class JDBCUtil {
// Properties对象用于加载配置文件
=======
>>>>>>> remotes/origin/main
// JDBCUtil工具类用于管理数据库连接相关的操作如加载数据库配置、获取数据库连接以及释放相关资源等
public class JDBCUtil {
// 用于存储数据库连接相关的配置信息,通过读取配置文件将配置项加载到该对象中
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
private static Properties properties;
// 数据库连接的URL地址
private static String url;
// 数据库连接的用户名
private static String user;
// 数据库连接的密码
private static String password;
<<<<<<< HEAD
// 静态代码块,在类加载时执行,主要用于加载数据库配置文件并注册数据库驱动,同时获取配置文件中的连接相关信息
static {
// 通过类加载器获取配置文件的输入流,该文件应位于类路径下,以便能够正确读取
@ -30,6 +40,36 @@ public class JDBCUtil {
properties = new Properties();
try {
=======
<<<<<<< HEAD
// 静态代码块用于加载配置文件和数据库驱动
static {
// 获取配置文件输入流
InputStream inputStream = JDBCUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
// 初始化Properties对象
properties = new Properties();
try {
// 加载配置文件
properties.load(inputStream);
} catch (IOException e) {
// 如果加载配置文件失败,打印错误信息
e.printStackTrace();
} finally {
// 关闭输入流
if (inputStream != null) {
=======
// 静态代码块,在类加载时执行,主要用于加载数据库配置文件并注册数据库驱动,同时获取配置文件中的连接相关信息
static {
// 通过类加载器获取配置文件的输入流,该文件应位于类路径下,以便能够正确读取
InputStream inputStream = JDBCUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
// 创建一个Properties对象用于存储键值对形式的配置信息
properties = new Properties();
try {
>>>>>>> remotes/origin/main
// 将从输入流中读取配置文件的内容加载到Properties对象中
properties.load(inputStream);
} catch (IOException e) {
@ -38,6 +78,10 @@ public class JDBCUtil {
} finally {
// 在完成配置文件读取后释放资源
if (inputStream!= null) {
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
try {
inputStream.close();
} catch (IOException e) {
@ -47,6 +91,23 @@ public class JDBCUtil {
}
}
<<<<<<< HEAD
=======
<<<<<<< HEAD
// 注册JDBC驱动
try {
// 加载JDBC驱动类
Class.forName(properties.getProperty("driver"));
// 获取数据库连接信息
url = properties.getProperty("url");
user = properties.getProperty("user");
password = properties.getProperty("password");
} catch (ClassNotFoundException e) {
// 如果驱动类加载失败,打印错误信息
=======
>>>>>>> remotes/origin/main
// 注册数据库驱动
try {
// 从配置文件中获取驱动类名属性,并加载该驱动类,类加载过程会执行驱动类中相关的静态代码,完成驱动在系统中的注册
@ -60,15 +121,31 @@ public class JDBCUtil {
password = properties.getProperty("password");
} catch (ClassNotFoundException e) {
// 若找不到指定的驱动类,打印异常栈信息
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
e.printStackTrace();
}
}
/**
<<<<<<< HEAD
=======
<<<<<<< HEAD
*
*
* @return
=======
>>>>>>> remotes/origin/main
* DriverManagerURL
* SQLnull
*
* @return null
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
*/
public static Connection getConn() {
try {
@ -82,6 +159,34 @@ public class JDBCUtil {
}
/**
<<<<<<< HEAD
=======
<<<<<<< HEAD
*
*
* @param resultSet
* @param statement SQL
* @param connection
*/
public static void close(ResultSet resultSet, Statement statement, Connection connection) {
try {
// 释放结果集资源
if (resultSet != null) {
resultSet.close();
}
// 释放Statement资源
if (statement != null) {
statement.close();
}
// 释放Connection资源
if (connection != null) {
connection.close();
}
=======
>>>>>>> remotes/origin/main
* ResultSetStatementConnection
* nullnullcloseSQL
*
@ -103,9 +208,78 @@ public class JDBCUtil {
if (connection!= null) {
connection.close();
}
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
} catch (SQLException e) {
// 如果关闭资源时发生错误,打印错误信息
e.printStackTrace();
}
}
<<<<<<< HEAD
=======
<<<<<<< HEAD
/**
*
*/
private static void printDbConfig() {
System.out.println("数据库连接信息:");
System.out.println("JDBC驱动" + properties.getProperty("driver"));
System.out.println("数据库URL" + properties.getProperty("url"));
System.out.println("数据库用户名:" + properties.getProperty("user"));
System.out.println("数据库密码:" + properties.getProperty("password"));
}
/**
*
*
* @return
*/
private static String getDbConnectionString() {
return "jdbc connection info: " + url + " as user " + user;
}
/**
*
*
* @return true if connection is successful, otherwise false
*/
public static boolean testConnection() {
Connection connection = null;
try {
connection = getConn();
if (connection != null) {
System.out.println("数据库连接成功!");
return true;
} else {
System.out.println("数据库连接失败!");
return false;
}
} catch (Exception e) {
System.out.println("测试数据库连接时发生异常:" + e.getMessage());
return false;
} finally {
// 关闭连接
close(null, null, connection);
}
}
/**
*
*/
private static void logConnectionStatus() {
System.out.println("正在尝试连接数据库...");
}
/**
*
*/
private static void logCloseConnection() {
System.out.println("数据库连接已关闭。");
}
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
}

@ -12,23 +12,23 @@ import javax.mail.internet.MimeMessage;
import com.lingnan.supermarket.dto.*;
public class SendQQMailUtil {
private String FromEamil;
private String Stmt;
private String ToEmail;
private String Title;
private String txtFile;
public SendQQMailUtil (String setFromEamil,String Stmt,String ToEmail,String Title,String txtFile) throws AddressException, MessagingException{
this.FromEamil=setFromEamil;
this.Stmt=Stmt;
this.ToEmail=ToEmail;
this.Title=Title;
this.txtFile=txtFile;
System.out.println("Stmt="+Stmt);
this.FromEamil=setFromEamil;
this.Stmt=Stmt;
this.ToEmail=ToEmail;
this.Title=Title;
this.txtFile=txtFile;
System.out.println("Stmt="+Stmt);
Properties properties = new Properties();
properties.put("mail.transport.protocol", "smtp");// 连接协议

@ -1,9 +1,9 @@
package com.lingnan.supermarket.utils;
//测试类,用于演示静态代码块的使用
public class Test {
static {
System.out.println("tasdasd."); // 打印一条测试信息
System.out.println("tasdasd.");
}
}
}

@ -4,10 +4,47 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;
//具类,用于生成订单号和时间戳
public class TimeAndOrder {
/**
<<<<<<< HEAD
=======
<<<<<<< HEAD
*
* @param username
* @return
*/
public static String[] TimeAndOrder(String username) {
// 创建一个长度为2的字符串数组用于存储订单号和当前时间
String[] s = new String[2];
// 创建两个SimpleDateFormat对象分别用于不同格式的日期输出
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 当前时间的格式
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyyMMddHHmmss"); // 订单号日期格式(年月日时分秒)
// 获取当前时间
Calendar cal = Calendar.getInstance();
String date1 = sdf1.format(cal.getTime()); // 当前日期时间
String date2 = sdf2.format(cal.getTime()); // 订单号使用的时间
// 生成随机数,以增加订单号的随机性
Random random = new Random();
int result1 = random.nextInt(10); // 随机生成一个0到9之间的数字
int result2 = random.nextInt(10); // 随机生成另一个0到9之间的数字
// 生成订单号,将用户名、时间和随机数拼接在一起
s[0] = username + result1 + date2 + result2;
// 生成当前时间字符串
s[1] = date1;
// 打印生成的订单号和时间(调试用)
System.out.println(s[0]);
System.out.println(s[1]);
// 返回包含订单号和时间的字符串数组
=======
>>>>>>> remotes/origin/main
*
*
* "yyyy-MM-dd HH:mm:ss"
@ -49,10 +86,51 @@ public class TimeAndOrder {
// 返回包含订单号和时间戳的字符串数组
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
return s;
}
/**
<<<<<<< HEAD
=======
<<<<<<< HEAD
*
* @return yyyy-MM-dd
*/
public static String yMdTime() {
// 创建一个SimpleDateFormat对象用于格式化当前日期
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
// 获取当前时间
Calendar cal = Calendar.getInstance();
String date = sdf1.format(cal.getTime()); // 获取当前日期的字符串
// 返回当前日期字符串
return date;
}
/**
*
*/
public static void testMethod() {
// 输出当前时间和生成的订单号
System.out.println("Current time: " + yMdTime());
String[] orderDetails = TimeAndOrder("testUser");
System.out.println("Generated order number: " + orderDetails[0]);
System.out.println("Generated time: " + orderDetails[1]);
}
/**
*
*/
private static void logMethodCall(String methodName) {
// 模拟打印方法调用日志
System.out.println("Method " + methodName + " was called.");
=======
>>>>>>> remotes/origin/main
* "yyyy-MM-dd"
*
* @return
@ -69,5 +147,10 @@ public class TimeAndOrder {
// 返回当前日期的字符串表示
return date;
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
}
}
}

@ -1,26 +1,23 @@
package com.lingnan.supermarket.utils;
import java.awt.*;
import java.awt. *;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import javax.swing.*;
import javax.swing. *;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
import java.awt.event.*;
public class tplbTest extends JFrame implements ActionListener
{
static tplbTest tplb=new tplbTest();
static JLabel pan=new JLabel();
//用于展示图片轮播效果
public class tplbTest extends JFrame implements ActionListener {
// 创建一个tplbTest实例
static tplbTest tplb = new tplbTest();
// 创建一个JLabel用于显示图片
static JLabel pan = new JLabel();
// 定义图片数组,包含多个图片路径
static ImageIcon[] imgs = {
new ImageIcon("static\\bg\\bg1.jpg"),
new ImageIcon("static\\bg\\bg2.jpg"),
@ -32,48 +29,54 @@ public class tplbTest extends JFrame implements ActionListener {
new ImageIcon("static\\bg\\bg8.jpg"),
};
//设置窗口的基本属性
public static void settplb() {
tplb.setTitle("图片轮播测试"); // 设置窗口标题
tplb.setLayout(null); // 设置布局为空布局
tplb.setSize(700, 800); // 设置窗口大小
tplb.setResizable(false); // 设置窗口不可调整大小
tplb.setLocationRelativeTo(null); // 设置窗口居中显示
tplb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设置关闭窗口时退出程序
tplb.setVisible(true); // 设置窗口可见
public static void settplb()/*<2A>ܿ<EFBFBD><DCBF>*/
{
tplb.setTitle("ͼƬ<EFBFBD>ֲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
tplb.setLayout(null);
tplb.setSize(700,800);
tplb.setResizable(false);
tplb.setLocationRelativeTo(null);/*<2A><><EFBFBD>þ<EFBFBD><C3BE><EFBFBD>*/
tplb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/*<2A>رճ<D8B1><D5B3><EFBFBD>*/
tplb.setVisible(true);
}
//设置图片显示区域,并启动定时器实现图片轮播
public static void setpan() {
pan.setBounds(50, 50, 500, 500); // 设置图片显示区域的坐标和大小
tplb.add(pan); // 将图片显示区域添加到窗口中
// 创建一个定时器每隔1000毫秒1秒触发一次
Timer timer = new Timer(1000, L);
timer.start(); // 启动定时器
public static void setpan()
{
pan.setBounds(50, 50, 500, 500);
tplb.add(pan);
Timer timer = new Timer(1000,L);
timer.start();
}
//定义一个ActionListener用于定时切换图片
static ActionListener L = new ActionListener() {
int index; // 图片索引
static ActionListener L=new ActionListener()
{
int index;
@Override
public void actionPerformed(ActionEvent e) {
pan.setIcon(imgs[index]); // 设置当前显示的图片
index++; // 图片索引加1
if (index == 7) // 如果索引超出图片数组范围
index = 0; // 重置索引为0
public void actionPerformed(ActionEvent e)
{
pan.setIcon(imgs[index]);
index++;
if(index==7)
index=0;
}
};
public static void main(String[] args) {
settplb(); // 设置窗口属性
setpan(); // 设置图片显示区域并启动定时器
settplb();
setpan();
}
//实现ActionListener接口的方法用于处理事件
@Override
public void actionPerformed(ActionEvent e) {
// 未实现
// TODO <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ɵķ<C9B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
}

@ -20,6 +20,7 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.text.html.HTMLDocument.Iterator;
import com.lingnan.supermarket.componet.BGPanel;
import com.lingnan.supermarket.dao.impl.BufferImpl;
@ -42,6 +43,17 @@ import com.lingnan.supermarket.utils.SendQQMailUtil;
import com.lingnan.supermarket.utils.TimeAndOrder;
import com.lingnan.supermarket.view.ProdCatalogView.MyItemListener;
<<<<<<< HEAD
=======
<<<<<<< HEAD
public class InView extends JPanel implements ActionListener{
//上面
private JPanel toolBarPanel;
=======
>>>>>>> remotes/origin/main
/**
*
*
@ -52,9 +64,36 @@ public class InView extends JPanel implements ActionListener {
private JPanel toolBarPanel;
// 搜索面板
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
private JPanel searchPanel;
private JLabel nameLabel, locationLabel;
private JLabel nameLabel,locationLabel;
private JTextField nameSearchTF;
<<<<<<< HEAD
=======
<<<<<<< HEAD
private JButton searchBtn,StockBtn,exitBtn;
private JPanel opePanel;
private JButton addBtn,updateBtn,deleteBtn,historyBtn,backBtn,detailBtn;
//中间
private JScrollPane tableScrollPane;
private JTable inTable;
//下面
private JPanel bottomPanel,bottomPanelLeft,bottomPanelRight;
private JLabel countInfoLabel,countInfoLabel2;
private Buffer Buffer;
private BufferImpl BufferImpl;
private static Vector<Production> v = new Vector<Production>();
=======
>>>>>>> remotes/origin/main
private JButton searchBtn, StockBtn, exitBtn;
// 操作面板
@ -77,10 +116,30 @@ public class InView extends JPanel implements ActionListener {
private static Vector<Production> v = new Vector<Production>();
// 状态下拉框
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
private JComboBox<String> combo;
private String[] status = {"全部", "已入库", "待入库", "已取消"};
private String[] status ={"全部","已入库","待入库","已取消"};
private int catalog;
<<<<<<< HEAD
=======
<<<<<<< HEAD
private JFrame jFrame;
private User user;
private InTableModel inTableModel ;
private BufferImpl bufferImpl = new BufferImpl();
private int mark;/*标记从提醒那里来1是进货表0是提醒过来的表*/
private inOrderServiceImpl inOrderImpl;
=======
>>>>>>> remotes/origin/main
// 主窗口和用户信息
private JFrame jFrame;
private User user;
@ -98,10 +157,266 @@ public class InView extends JPanel implements ActionListener {
private inOrderServiceImpl inOrderImpl;
// 总价和行数
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
private Float allPrice;
private int row;
private String uname;
<<<<<<< HEAD
//构造函数
public InView(JFrame jFrame, User user, Vector<Production> v, int mark) {
this.setLayout(new BorderLayout()); // 设置布局为BorderLayout
this.jFrame = jFrame; // 设置主窗口
this.user = user; // 设置用户信息
// 获得进货缓冲区的保存的货物并删除缓冲区
this.v = bufferImpl.allInBuffer(); // 从缓冲区获取商品数据
bufferImpl.DelAllInBuffer(); // 清空缓冲区
this.mark = mark; // 设置标记
System.out.println("mark=" + mark); // 打印标记值
uname = user.getUsername(); // 获取用户名
initView(); // 初始化界面
}
// 初始化界面组件。
private void initView() {
toolBarPanel = new JPanel(new BorderLayout()); // 创建顶部工具栏面板
searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建搜索面板
nameLabel = new JLabel("订单号"); // 创建订单号标签
nameSearchTF = new JTextField(20); // 创建订单号搜索文本框
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png")); // 创建搜索按钮
searchBtn.addActionListener(this); // 为搜索按钮添加事件监听器
locationLabel = new JLabel("当前位置>进货系统"); // 创建位置标签
locationLabel.setFont(new FontUtil().userFont); // 设置字体
locationLabel.setForeground(new Color(18, 150, 219)); // 设置颜色
combo = new JComboBox<String>(status); // 创建状态下拉框
combo.addItemListener(new MyItemListener()); // 为下拉框添加事件监听器
opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建操作面板
addBtn = new JButton(new ImageIcon("static\\icon\\add.png")); // 创建添加按钮
updateBtn = new JButton(new ImageIcon("static\\icon\\change.png")); // 创建更新按钮
deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png")); // 创建删除按钮
historyBtn = new JButton(new ImageIcon("static\\icon\\history.png")); // 创建历史记录按钮
backBtn = new JButton(new ImageIcon("static\\icon\\back.png")); // 创建返回按钮
detailBtn = new JButton(new ImageIcon("static\\icon\\detail.png")); // 创建详情按钮
addBtn.addActionListener(this); // 为添加按钮添加事件监听器
updateBtn.addActionListener(this); // 为更新按钮添加事件监听器
deleteBtn.addActionListener(this); // 为删除按钮添加事件监听器
historyBtn.addActionListener(this); // 为历史记录按钮添加事件监听器
backBtn.addActionListener(this); // 为返回按钮添加事件监听器
detailBtn.addActionListener(this); // 为详情按钮添加事件监听器
backBtn.setVisible(false); // 隐藏返回按钮
detailBtn.setVisible(false); // 隐藏详情按钮
opePanel.add(addBtn); // 添加添加按钮到操作面板
opePanel.add(backBtn); // 添加返回按钮到操作面板
opePanel.add(detailBtn); // 添加详情按钮到操作面板
opePanel.add(updateBtn); // 添加更新按钮到操作面板
opePanel.add(deleteBtn); // 添加删除按钮到操作面板
opePanel.add(historyBtn); // 添加历史记录按钮到操作面板
searchPanel.add(locationLabel); // 添加位置标签到搜索面板
searchPanel.add(nameLabel); // 添加订单号标签到搜索面板
searchPanel.add(nameSearchTF); // 添加订单号搜索文本框到搜索面板
searchPanel.add(searchBtn); // 添加搜索按钮到搜索面板
searchPanel.add(combo); // 添加状态下拉框到搜索面板
toolBarPanel.add(searchPanel, "West"); // 将搜索面板添加到工具栏面板的西侧
toolBarPanel.add(opePanel, "East"); // 将操作面板添加到工具栏面板的东侧
// 中间表
inTableModel = new InTableModel(v); // 创建表格模型
inTable = new JTable(inTableModel); // 创建表格
inTable.setFont(FontUtil.tableFont); // 设置表格字体
inTable.setRowHeight(50); // 设置表格行高
tableScrollPane = new JScrollPane(inTable); // 创建表格滚动面板
allPrice = inTableModel.getAllPrice(); // 获取总价
row = inTableModel.getRowCount(); // 获取行数
// 下面
bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT)); // 创建底部左侧面板
countInfoLabel = new JLabel("商品种类:" + row + ",总价:" + allPrice); // 创建商品种类和总价标签
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 创建底部右侧面板
StockBtn = new JButton(new ImageIcon("static\\icon\\stock.png")); // 创建结账按钮
exitBtn = new JButton(new ImageIcon("static\\icon\\exit.png")); // 创建退出按钮
StockBtn.addActionListener(this); // 为结账按钮添加事件监听器
exitBtn.addActionListener(this); // 为退出按钮添加事件监听器
bottomPanelRight.add(StockBtn); // 将结账按钮添加到底部右侧面板
bottomPanelRight.add(exitBtn); // 将退出按钮添加到底部右侧面板
bottomPanel = new JPanel(new BorderLayout()); // 创建底部面板
bottomPanel.add(bottomPanelRight, "East"); // 将底部右侧面板添加到底部面板的东侧
bottomPanel.add(bottomPanelLeft, "West"); // 将底部左侧面板添加到底部面板的西侧
this.add(toolBarPanel, "North"); // 将工具栏面板添加到顶部
this.add(tableScrollPane, "Center"); // 将表格滚动面板添加到中间
this.add(bottomPanel, "South"); // 将底部面板添加到底部
if (mark == 1) { // 判断是否从提醒那里过来的
refreshBuffer(v); // 刷新缓冲区
} else if (mark == 0) {
InOrderRecord(); // 调出进货订单表
}
setVisible(true); // 设置可见
}
//获取商品数量
public static Vector<Production> getVector() {
return v;
}
//处理状态下拉框的选项变化
=======
<<<<<<< HEAD
public InView(JFrame jFrame,User user,Vector<Production> v,int mark) {
this.setLayout(new BorderLayout());
this.jFrame = jFrame;
this.user = user;
//获得进货缓冲区的保存的货物并删除缓冲区
this.v =bufferImpl.allInBuffer();
bufferImpl.DelAllInBuffer();
this.mark=mark;
System.out.println("mark="+mark);
uname = user.getUsername();
initView();
}
private void initView() {
toolBarPanel = new JPanel(new BorderLayout());
searchPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
nameLabel = new JLabel("订单号");
nameSearchTF = new JTextField(20);
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png"));
searchBtn.addActionListener(this);
locationLabel=new JLabel("当前位置>进货系统");
locationLabel.setFont(new FontUtil().userFont);
locationLabel.setForeground(new Color(18, 150, 219));
combo = new JComboBox<String>(status);
combo.addItemListener(new MyItemListener());
opePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
addBtn =new JButton(new ImageIcon("static\\icon\\add.png"));
updateBtn =new JButton(new ImageIcon("static\\icon\\change.png"));
deleteBtn =new JButton(new ImageIcon("static\\icon\\delete.png"));
historyBtn =new JButton(new ImageIcon("static\\icon\\history.png"));
backBtn =new JButton(new ImageIcon("static\\icon\\back.png"));
detailBtn = new JButton(new ImageIcon("static\\icon\\detail.png"));
addBtn.addActionListener(this);
updateBtn.addActionListener(this);
deleteBtn.addActionListener(this);
historyBtn.addActionListener(this);
backBtn.addActionListener(this);
detailBtn.addActionListener(this);
backBtn.setVisible(false);/*在记录页面显示出来*/
detailBtn.setVisible(false);/*在订单详情页显示出来*/
opePanel.add(addBtn);
opePanel.add(backBtn);
opePanel.add(detailBtn);
opePanel.add(updateBtn);
opePanel.add(deleteBtn);
opePanel.add(historyBtn);
searchPanel.add(locationLabel);
searchPanel.add(nameLabel);
searchPanel.add(nameSearchTF);
searchPanel.add(searchBtn);
searchPanel.add(combo);
toolBarPanel.add(searchPanel,"West");
toolBarPanel.add(opePanel,"East");
//中间表
inTableModel = new InTableModel(v);
inTable = new JTable(inTableModel);
inTable.setFont(FontUtil.tableFont);
inTable.setRowHeight(50);
tableScrollPane = new JScrollPane(inTable);
allPrice = inTableModel.getAllPrice();
row = inTableModel.getRowCount();
//下面
bottomPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT));
countInfoLabel = new JLabel("商品种类:"+row+",总价:"+allPrice);
bottomPanelLeft.add(countInfoLabel,"Left");
bottomPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT));
StockBtn =new JButton(new ImageIcon("static\\icon\\stock.png"));/*结账按钮*/
exitBtn =new JButton(new ImageIcon("static\\icon\\exit.png"));/*退出按钮*/
StockBtn.addActionListener(this);
exitBtn.addActionListener(this);
bottomPanelRight.add(StockBtn);
bottomPanelRight.add(exitBtn);
bottomPanel = new JPanel(new BorderLayout());
bottomPanel.add(bottomPanelRight,"East");
bottomPanel.add(bottomPanelLeft,"West");
this.add(toolBarPanel,"North");
this.add(tableScrollPane,"Center");/*将表格放到中间*/
this.add(bottomPanel,"South");
if(mark==1) /*判断是不是从提醒那里过来的*/{
refreshBuffer(v);
}
else if(mark==0) {
InOrderRecord();
}
setVisible(true);
}
public static Vector<Production> getVector(){
return v;
}
=======
//构造函数
public InView(JFrame jFrame, User user, Vector<Production> v, int mark) {
@ -215,10 +530,29 @@ public class InView extends JPanel implements ActionListener {
//处理状态下拉框的选项变化
>>>>>>> developer
>>>>>>> remotes/origin/main
public class MyItemListener implements ItemListener {
@Override
public void itemStateChanged(ItemEvent e) {
<<<<<<< HEAD
=======
<<<<<<< HEAD
JComboBox cb = (JComboBox) e.getSource();
String catalog1 = (String) cb.getSelectedItem();
if(catalog1.equals("全部"))
catalog=0;
else if(catalog1.equals("已入库"))
catalog=1;
else if(catalog1.equals("待入库"))
catalog=2;
else if(catalog1.equals("已取消"))
catalog=3;
resultOfFindStatus(catalog);
=======
>>>>>>> remotes/origin/main
JComboBox cb = (JComboBox) e.getSource(); // 获取事件源
String catalog1 = (String) cb.getSelectedItem(); // 获取选中的状态
if (catalog1.equals("全部"))
@ -229,21 +563,53 @@ public class InView extends JPanel implements ActionListener {
catalog = 2;
else if (catalog1.equals("已取消"))
catalog = 3;
<<<<<<< HEAD
=======
>>>>>>> developer
>>>>>>> remotes/origin/main
resultOfFindStatus(catalog); // 根据状态查询结果
}
<<<<<<< HEAD
//按钮组件隐藏。
=======
<<<<<<< HEAD
}
//按钮组件隐藏
=======
//按钮组件隐藏。
>>>>>>> developer
>>>>>>> remotes/origin/main
public void OrderView() {
backBtn.setVisible(true); // 显示返回按钮
detailBtn.setVisible(true); // 显示详情按钮
updateBtn.setVisible(true); // 显示更新按钮
deleteBtn.setVisible(true); // 显示删除按钮
addBtn.setVisible(false); // 隐藏添加按钮
historyBtn.setVisible(false); // 隐藏历史记录按钮
backBtn.setVisible(true);
detailBtn.setVisible(true);
updateBtn.setVisible(true);
deleteBtn.setVisible(true);
addBtn.setVisible(false);
historyBtn.setVisible(false);
}
<<<<<<< HEAD
=======
<<<<<<< HEAD
public void resultOfNumber(String iNumber) {
this.mark=0;
InOrderTM inOrderTM = new InOrderTM();
inOrderTM.resultOfNumber(iNumber);
inTable.setModel(inOrderTM);
bottomPanelLeft.removeAll();
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
bottomPanelLeft.add(countInfoLabel);
OrderView();
}
=======
>>>>>>> remotes/origin/main
//根据订单号查询结果
public void resultOfNumber(String iNumber) {
this.mark = 0; // 设置标记为0
@ -257,6 +623,7 @@ public class InView extends JPanel implements ActionListener {
}
//根据状态查询结果
<<<<<<< HEAD
public void resultOfFindStatus(int catalog) {
this.mark = 0; // 设置标记为0
InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型
@ -300,27 +667,420 @@ public class InView extends JPanel implements ActionListener {
OrderView(); // 调用OrderView方法
}
=======
>>>>>>> developer
public void resultOfFindStatus(int catalog) {
this.mark=0;
InOrderTM inOrderTM = new InOrderTM();
inOrderTM.resultOfFind(catalog);
inTable.setModel(inOrderTM);
bottomPanelLeft.removeAll();
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
bottomPanelLeft.add(countInfoLabel);
OrderView();
}
<<<<<<< HEAD
// 调出进货订单表
/*刷新*/
public void refreshBuffer(Vector<Production> v) {
this.mark=1;
InTableModel inTableModel = new InTableModel(v);
inTable.setModel(inTableModel);
bottomPanelLeft.removeAll();
countInfoLabel = new JLabel("商品种类:"+inTableModel.getRowCount()+",总价:"+inTableModel.getAllPrice());
bottomPanelLeft.add(countInfoLabel);
backBtn.setVisible(false);
detailBtn.setVisible(false);
historyBtn.setVisible(true);
updateBtn.setVisible(true);
addBtn.setVisible(true);
deleteBtn.setVisible(true);
allPrice = inTableModel.getAllPrice();
row = inTableModel.getRowCount();
}
/*调出进货订单表*/
public void InOrderRecord() {
this.mark=0;
InOrderTM inOrderTM = new InOrderTM();
inOrderTM.allInOrderRecord();
inTable.setModel(inOrderTM);
bottomPanelLeft.removeAll();
countInfoLabel = new JLabel("共"+inOrderTM.getRowCount()+"条记录");
bottomPanelLeft.add(countInfoLabel);
OrderView();
}
/*调出进货订单表*/
public void InRecord(String iNumber) {
this.mark = 2; // 设置标记为2
InRecordTM inRecordTM = new InRecordTM(iNumber); // 创建进货记录表格模型
inRecordTM.findInRecordByINumber(); // 根据订单号查询进货记录
inTable.setModel(inRecordTM); // 设置表格模型
this.mark=2;
InRecordTM inRecordTM = new InRecordTM(iNumber);
inRecordTM.findInRecordByINumber();
inTable.setModel(inRecordTM);
bottomPanelLeft.removeAll();
countInfoLabel = new JLabel("订单号@"+iNumber+"共有"+inRecordTM.getRowCount()+"条记录");
bottomPanelLeft.add(countInfoLabel);
backBtn.setVisible(true);
detailBtn.setVisible(false);
updateBtn.setVisible(false);
addBtn.setVisible(false);
historyBtn.setVisible(false);
deleteBtn.setVisible(false);
}
=======
//刷新缓冲区
public void refreshBuffer(Vector<Production> v) {
this.mark = 1; // 设置标记为1
>>>>>>> remotes/origin/main
InTableModel inTableModel = new InTableModel(v); // 创建表格模型
inTable.setModel(inTableModel); // 设置表格模型
bottomPanelLeft.removeAll(); // 清空底部左侧面板
countInfoLabel = new JLabel("订单号@" + iNumber + "共有" + inRecordTM.getRowCount() + "条记录"); // 创建记录数标签
countInfoLabel = new JLabel("商品种类:" + inTableModel.getRowCount() + ",总价:" + inTableModel.getAllPrice()); // 创建商品种类和总价标签
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
backBtn.setVisible(true); // 显示返回按钮
backBtn.setVisible(false); // 隐藏返回按钮
detailBtn.setVisible(false); // 隐藏详情按钮
updateBtn.setVisible(false); // 隐藏更新按钮
addBtn.setVisible(false); // 隐藏添加按钮
historyBtn.setVisible(false); // 隐藏历史记录按钮
deleteBtn.setVisible(false); // 隐藏删除按钮
historyBtn.setVisible(true); // 显示历史记录按钮
updateBtn.setVisible(true); // 显示更新按钮
addBtn.setVisible(true); // 显示添加按钮
deleteBtn.setVisible(true); // 显示删除按钮
allPrice = inTableModel.getAllPrice(); // 获取总价
row = inTableModel.getRowCount(); // 获取行数
}
//调出进货订单表。
public void InOrderRecord() {
this.mark = 0; // 设置标记为0
InOrderTM inOrderTM = new InOrderTM(); // 创建进货订单表格模型
inOrderTM.allInOrderRecord(); // 查询所有进货订单记录
inTable.setModel(inOrderTM); // 设置表格模型
bottomPanelLeft.removeAll(); // 清空底部左侧面板
countInfoLabel = new JLabel("共" + inOrderTM.getRowCount() + "条记录"); // 创建记录数标签
bottomPanelLeft.add(countInfoLabel); // 将标签添加到底部左侧面板
OrderView(); // 调用OrderView方法
}
//按钮监听事件
>>>>>>> developer
/*按钮监听时间*/
@Override
public void actionPerformed(ActionEvent e) {
<<<<<<< HEAD
BufferImpl = new BufferImpl(); // 获取购物车
Object source = e.getSource(); // 获取事件源
if (searchBtn == source) { // 如果是搜索按钮
String number = nameSearchTF.getText(); // 获取搜索的订单号
System.out.println("搜索后的订单:" + number); // 打印订单号
resultOfNumber(number); // 根据订单号查询结果
} else if (addBtn == source) { // 如果是添加按钮
InDialog outDialog = new InDialog(jFrame, v, user); // 创建添加对话框
outDialog.setVisible(true); // 显示对话框
v = outDialog.getVector(); // 获取更新后的商品向量
refreshBuffer(v); // 刷新缓冲区
} else if (updateBtn == source) { // 如果是更新按钮
System.out.println("mark=" + mark); // 打印标记值
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
if (rowIndex == -1) { // 如果没有选中行
JOptionPane.showMessageDialog(this, "请选中一条进行更改数量"); // 提示用户选中行
return;
}
// 进货表修改
if (mark == 1) {
String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID
ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame, id, "In", v); // 创建更改数量对话框
changesumDialog.setVisible(true); // 显示对话框
v = changesumDialog.getVector(); // 获取更新后的商品向量
System.out.println("更改状态后v.size=" + v.size()); // 打印商品向量大小
refreshBuffer(v); // 刷新缓冲区
}
// inOrder修改,修改状态
else if (mark == 0) {
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
String status = (String) inTable.getValueAt(rowIndex, 4); // 获取选中行的状态
if (status.equals("已入库")) { // 如果状态是已入库
JOptionPane.showMessageDialog(this, "订单上的货物已入库无法修改状态", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户无法修改状态
return;
}
ChangeStatusDialog changeStatusDialog = new ChangeStatusDialog(jFrame, iNumber, status); // 创建更改状态对话框
changeStatusDialog.setVisible(true); // 显示对话框
MainView.refreshRemind(); // 刷新提醒
HomeView.refreshHome(); // 刷新主页
InOrderRecord(); // 调出进货订单表
}
} else if (deleteBtn == source) { // 如果是删除按钮
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
if (rowIndex == -1) { // 如果没有选中行
JOptionPane.showMessageDialog(this, "请选中一条"); // 提示用户选中行
return;
}
/* 删除进货表的 */
if (mark == 1) {
System.out.println("删除进货表"); // 打印日志
String id = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的ID
int select = JOptionPane.showConfirmDialog(this, "是否删除id为" + id + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除
if (select == JOptionPane.YES_OPTION) { // 如果用户选择是
for (int i = 0; i < v.size(); i++) { // 遍历商品向量
System.out.println("开始删除"); // 打印日志
if (v.elementAt(i).getId().equals(id)) { // 如果找到对应的商品
v.remove(i); // 删除商品
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功
break;
}
}
refreshBuffer(v); // 刷新缓冲区
}
}
// 删除进货订单
else if (mark == 0) {
System.out.println("删除订单表"); // 打印日志
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
int select = JOptionPane.showConfirmDialog(this, "是否删除订单为" + iNumber + "的记录", "提示", JOptionPane.YES_NO_OPTION); // 提示用户确认删除
if (select == JOptionPane.YES_OPTION) { // 如果用户选择是
System.out.println("iNumber=" + iNumber); // 打印订单号
inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类
inOrderImpl.deleteInOrder(iNumber); // 删除订单
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE); // 提示用户删除成功
InOrderRecord(); // 调出进货订单表
}
}
} else if (historyBtn == source) { // 如果是历史记录按钮
InOrderRecord(); // 调出进货订单表
} else if (backBtn == source) { // 如果是返回按钮
if (mark == 0)
refreshBuffer(v); // 刷新缓冲区
else if (mark == 2)
InOrderRecord(); // 调出进货订单表
} else if (detailBtn == source) { // 如果是详情按钮
int rowIndex = inTable.getSelectedRow(); // 获取选中的行
if (rowIndex == -1) { // 如果没有选中行
JOptionPane.showMessageDialog(this, "请选中一条查看订单详细信息"); // 提示用户选中行
return;
}
String iNumber = (String) inTable.getValueAt(rowIndex, 0); // 获取选中行的订单号
System.out.println("详情订单号为=" + iNumber); // 打印订单号
InRecord(iNumber); // 调出进货记录表
} else if (StockBtn == source) { // 如果是结账按钮
refreshBuffer(v); // 刷新缓冲区
if (v.size() == 0) { // 如果购物车为空
JOptionPane.showMessageDialog(null, "您的进货页面为空", "提示", JOptionPane.YES_OPTION); // 提示用户购物车为空
} else { // 如果购物车不为空
int res = JOptionPane.showConfirmDialog(null, "进价总金额:" + allPrice + "元\r\n负责人:" + uname + "\r\n发送邮件至 re@qq.com", "提交订单", JOptionPane.YES_NO_OPTION); // 提示用户确认提交订单
if (res == JOptionPane.YES_OPTION) { // 如果用户选择是
/* 获得时间和订单号,s[0]为订单号,s[1]为时间 */
String[] s = TimeAndOrder.TimeAndOrder(uname); // 获取时间和订单号
/* 往订单表插入一条记录 */
inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 创建进货订单服务实现类
inOrderImpl.InsertInOrder(s[0], allPrice, s[1], uname, 2); // 插入订单记录
/* 往inRecord表添加数据 */
inRecordServiceImpl inRecordImpl = new inRecordServiceImpl(); // 创建进货记录服务实现类
for (Production p : v) { // 遍历商品向量
inRecordImpl.insertInRecord(s[0], p); // 插入进货记录
}
/* 生成订单文本 */
CreateOrder createOrder = new CreateOrder(); // 创建订单生成工具类
String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice, uname); // 生成订单文本
try { // 发送邮件
SendQQMailUtil QQEmail = new SendQQMailUtil("cwfeng5@qq.com", "wlcinslohrgpdiac", "1912638153@qq.com", "@新民超市进货需求申请", OrderText); // 创建邮件发送工具类
} catch (MessagingException e1) { // 捕获异常
e1.printStackTrace(); // 打印异常信息
}
v = new Vector<Production>(); // 清空商品向量
refreshBuffer(v); // 刷新缓冲区
MainView.refreshRemind(); // 刷新提醒
JOptionPane.showConfirmDialog(null, "发送邮件成功\r\n订单号:" + s[0] + "\r\n负责人:" + uname, "提示", JOptionPane.YES_OPTION); // 提示用户发送邮件成功
}
=======
<<<<<<< HEAD
BufferImpl = new BufferImpl();/*获得购物车*/
Object source = e.getSource();
if(searchBtn==source) {
String number = nameSearchTF.getText();
System.out.println("搜索后的订单:"+number);
resultOfNumber(number);
}
else if(addBtn==source) {/*添加*/
InDialog outDialog = new InDialog(jFrame,v,user);
outDialog.setVisible(true);
v=outDialog.getVector();
refreshBuffer(v);
}
else if(updateBtn==source) {/*更新*/
System.out.println("mark="+mark);
int rowIndex = inTable.getSelectedRow();
if(rowIndex==-1) {
JOptionPane.showMessageDialog(this,"请选中一条进行更改数量");
return;
}
//进货表修改
if(mark==1) {
String id =(String) inTable.getValueAt(rowIndex,0);
ChangeSumDialog changesumDialog = new ChangeSumDialog(jFrame,id,"In",v);
changesumDialog.setVisible(true);
v = changesumDialog.getVector();
System.out.println("更改状态后v.size="+v.size());
refreshBuffer(v);
}
//inOrder修改,修改状态
else if(mark==0) {
String iNumber =(String) inTable.getValueAt(rowIndex,0);
String status =(String) inTable.getValueAt(rowIndex,4);
if(status.equals("已入库")) {
JOptionPane.showMessageDialog(this,"订单上的货物已入库无法修改状态","提示",JOptionPane.INFORMATION_MESSAGE);
return;
}
ChangeStatusDialog changeStatusDialog = new ChangeStatusDialog(jFrame,iNumber,status);
changeStatusDialog.setVisible(true);
MainView.refreshRemind();
HomeView.refreshHome();
InOrderRecord();
}
}
else if(deleteBtn==source) {
int rowIndex = inTable.getSelectedRow();
if(rowIndex==-1) {
JOptionPane.showMessageDialog(this,"请选中一条");
return;
}
/*删除进货表的*/
if(mark==1) {
System.out.println("删除进货表");
String id =(String) inTable.getValueAt(rowIndex,0);
int select = JOptionPane.showConfirmDialog(this,"是否删除id为"+id+"的记录","提示",JOptionPane.YES_NO_OPTION);
if(select==JOptionPane.YES_OPTION) {/*选择是*/
for(int i =0;i<v.size();i++) {
System.out.println("开始删除");
if(v.elementAt(i).getId().equals(id))
{
v.remove(i);
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.INFORMATION_MESSAGE);
break;
}
}
refreshBuffer(v);
}
}
//删除进货订单*/
else if(mark==0) {
System.out.println("删除订单表");
String iNumber =(String) inTable.getValueAt(rowIndex,0);
int select = JOptionPane.showConfirmDialog(this,"是否删除订单为"+iNumber+"的记录","提示",JOptionPane.YES_NO_OPTION);
if(select==JOptionPane.YES_OPTION) {/*选择是*/
System.out.println("iNumber="+iNumber);
inOrderImpl=new inOrderServiceImpl();
inOrderImpl.deleteInOrder(iNumber);
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.INFORMATION_MESSAGE);
InOrderRecord();
}
}
}else if(historyBtn==source) {/*查看历史全部记录*/
InOrderRecord();
}else if(backBtn==source) {/*历史记录中的返回按钮*/
if(mark==0)
refreshBuffer(v);
else if(mark==2)
InOrderRecord();
}else if(detailBtn==source) {/*查看订单详细*/
int rowIndex = inTable.getSelectedRow();
if(rowIndex==-1) {
JOptionPane.showMessageDialog(this,"请选中一条查看订单详细信息");
return;
}
String iNumber =(String) inTable.getValueAt(rowIndex,0);
System.out.println("详情订单号为="+iNumber);
InRecord(iNumber);
}
else if(StockBtn==source) {/*结账*/
refreshBuffer(v);
if(v.size()==0)/*购物车为空*/{
JOptionPane.showMessageDialog(null,"您的进货页面为空", "提示", JOptionPane.YES_OPTION);
}
else {/*购物车不为空*/
int res = JOptionPane.showConfirmDialog(null,"进价总金额:"+allPrice+"元\r\n负责人:"+uname+"\r\n发送邮件至 re@qq.com", "提交订单", JOptionPane.YES_NO_OPTION);
if(res==JOptionPane.YES_OPTION)/*如果已经结账*/{
/*获得时间和订单号,s[0]为订单号,s[1]为时间*/
String[] s =TimeAndOrder.TimeAndOrder(uname);
/*往订单表插入一条记录*/
inOrderServiceImpl inOrderImpl = new inOrderServiceImpl();
inOrderImpl.InsertInOrder(s[0], allPrice, s[1],uname ,2);
/*往inRecord表添加数据*/
inRecordServiceImpl inRecordImpl = new inRecordServiceImpl();
for(Production p:v) {/*往inRecord表添加数据*/
inRecordImpl.insertInRecord(s[0], p);
}
/*生成订单文本*/
CreateOrder createOrder = new CreateOrder();
String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice,uname);
try {/*发送邮件*/
SendQQMailUtil QQEmail = new SendQQMailUtil("sender@qq.com","自行获取 SMTP 授权码","receiver@qq.com","@新民超市进货需求申请",OrderText);
} catch (MessagingException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
v=new Vector<Production>();
refreshBuffer(v);
MainView.refreshRemind();
JOptionPane.showConfirmDialog(null,"发送邮件成功\r\n订单号:"+s[0]+"\r\n负责人:"+uname, "提示", JOptionPane.YES_OPTION);
}
}
}else if(exitBtn==source) {
int res = JOptionPane.showConfirmDialog(null,"确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION);
if(res==JOptionPane.YES_OPTION)/*如果退出*/{
v=new Vector<Production>();/*将数组置空*/
refreshBuffer(v);
JOptionPane.showConfirmDialog(null,"退出成功", "提示", JOptionPane.PLAIN_MESSAGE);
}
}
}
}
=======
BufferImpl = new BufferImpl(); // 获取购物车
Object source = e.getSource(); // 获取事件源
@ -452,6 +1212,7 @@ public class InView extends JPanel implements ActionListener {
JOptionPane.showConfirmDialog(null, "发送邮件成功\r\n订单号:" + s[0] + "\r\n负责人:" + uname, "提示", JOptionPane.YES_OPTION); // 提示用户发送邮件成功
}
>>>>>>> remotes/origin/main
}
} else if (exitBtn == source) { // 如果是退出按钮
int res = JOptionPane.showConfirmDialog(null, "确定退出并清空购物车吗", "结账", JOptionPane.YES_NO_OPTION); // 提示用户确认退出
@ -462,4 +1223,9 @@ public class InView extends JPanel implements ActionListener {
}
}
}
}
<<<<<<< HEAD
}
=======
}
>>>>>>> developer
>>>>>>> remotes/origin/main

@ -40,282 +40,337 @@ import com.lingnan.supermarket.view.base.BaseView;
import java.awt.*;
//主界面类继承自BaseView实现了ActionListener、MouseListener和WindowListener接口。
public class MainView extends BaseView implements ActionListener, MouseListener, WindowListener {
JMenuBar menuBar; // 菜单栏
JMenu settingMenu, helpMenu; // 设置菜单和帮助菜单
JMenuItem skinMenuItem, configMenuItem; // 皮肤菜单项和配置菜单项
JSplitPane containerPanel; // 主界面容器,分为左右两部分
CardLayout rightPanelLayout; // 右侧面板的布局管理器
JPanel leftPanel, rightPanel; // 左侧和右侧的面板
/* 菜单栏 */
JLabel logoLabel, userMenuLabel1, homeMenuLabel, userMenuLabel, inMenuLabel,
outMenuLabel, storageMenuLabel, supplierMenuLabel, catalogMenuLabel;
static JLabel remindMenuLabel; // 全局调用刷新的提醒标签
JPanel bottomPanel; // 底部面板
JLabel timeLabel; // 显示时间的标签
JPanel purposePanel, timePanel; // 显示当前位置和时间的面板
JLabel purposeLabel; // 显示当前位置的标签
JButton saveBtn, unSaveBtn, cancleBtn; // 退出时的按钮
Timer timer; // 定时器,用于更新时间
private User user; // 从登录界面传过来的用户信息
private BufferImpl bufferImpl; // 缓存实现类
private Image bgImage; // 背景图片
private String iconSkin; // 图标皮肤
private int skin; // 当前皮肤编号
private Vector<Production> vP = new Vector<Production>(); // 用于进货缓存
private int location; // 当前界面的位置
private int sSuper = -1; // 界面权限
private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl(); // 进货订单服务实现类
private static int unConfirmmark; // 未确认订单数量
//构造函数,初始化主界面并设置用户信息和皮肤
public MainView(User user, int skin, String iconSkin) {
super(1300, 850, "新民超市管理系统欢迎您", user, skin);
timer = new Timer(1000, this); // 创建定时器,每秒触发一次
timer.start(); // 启动定时器
this.user = user; // 设置用户信息
this.sSuper = user.getUsuper(); // 获取用户权限
System.out.println("userid=" + user.getId()); // 打印用户ID
this.addWindowListener(this); // 添加窗口监听器
this.skin = skin; // 设置皮肤编号
this.iconSkin = iconSkin; // 设置图标皮肤路径
ImageIcon icon = new ImageIcon(iconSkin); // 创建图标
this.setIconImage(icon.getImage()); // 设置窗口图标
// 获取未进货的信息
public class MainView extends BaseView implements ActionListener, MouseListener,WindowListener{
JMenuBar menuBar;
JMenu settingMenu,helpMenu;
JMenuItem skinMenuItem,configMenuItem;
JSplitPane containerPanel;
CardLayout rightPanelLayout;
JPanel leftPanel,rightPanel;
/*菜单栏*/
JLabel logoLabel,userMenuLabel1,homeMenuLabel,userMenuLabel,inMenuLabel,
outMenuLabel,storageMenuLabel,supplierMenuLabel,catalogMenuLabel;
static JLabel remindMenuLabel;/*全局调用刷新*/
JPanel bottomPanel;
JLabel timeLabel;
JPanel purposePanel,timePanel;
JLabel purposeLabel;
JButton saveBtn,unSaveBtn,cancleBtn;/*退出时按钮*/
//
Timer timer;
private User user ;/*从登录界面传过来的用户信息*/
private BufferImpl bufferImpl;
private Image bgImage ;
private String iconSkin;
private int skin;
private Vector<Production> vP=new Vector<Production>() ;/*用于进货缓存*/
private int location;
private int sSuper=-1;//界面权限
private static inOrderServiceImpl inOrderImpl = new inOrderServiceImpl();
private static int unConfirmmark;/*未确认订单*/
public MainView(User user,int skin,String iconSkin) {
super(1300,850,"新民超市管理系统欢迎您",user,skin);
timer = new Timer(1000,this);
timer.start();
this.user = user;
this.sSuper=user.getUsuper();//界面权限
System.out.println("userid="+user.getId());
this.addWindowListener(this);
this.skin = skin;
this.iconSkin = iconSkin;
ImageIcon icon=new ImageIcon(iconSkin); //xxx代表图片存放路径2.png图片名称及格式
this.setIconImage(icon.getImage());
//获得未进货的信息
Vector<InOrder> vInOrder;
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
unConfirmmark = vInOrder.size(); // 设置未确认订单数量
vInOrder = inOrderImpl.findUnconfirmInOrder();
unConfirmmark=vInOrder.size();
initView(user, skin); // 初始化界面
initView(user,skin);
}
//构造函数,初始化主界面并设置用户信息
public MainView(User user) {
super(1300, 850, "新民超市管理系统欢迎您");
timer = new Timer(1000, this); // 创建定时器,每秒触发一次
timer.start(); // 启动定时器
this.user = user; // 设置用户信息
this.sSuper = user.getUsuper(); // 获取用户权限
System.out.println("userid=" + user.getId()); // 打印用户ID
this.addWindowListener(this); // 添加窗口监听器
// 获取未进货的信息
super(1300,850,"新民超市管理系统欢迎您");
timer = new Timer(1000,this);
timer.start();
this.user = user;
this.sSuper=user.getUsuper();//界面权限
System.out.println("userid="+user.getId());
this.addWindowListener(this);
//获得未进货的信息
Vector<InOrder> vInOrder;
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
unConfirmmark = vInOrder.size(); // 设置未确认订单数量
vInOrder = inOrderImpl.findUnconfirmInOrder();
unConfirmmark=vInOrder.size();
initView(user, skin); // 初始化界面
initView(user,skin);
}
//刷新提醒标签,更新未确认订单数量
public static void refreshRemind() {
Vector<InOrder> vInOrder;
vInOrder = inOrderImpl.findUnconfirmInOrder(); // 查找未确认的进货订单
unConfirmmark = vInOrder.size(); // 更新未确认订单数量
remindMenuLabel.setText("待确认进货:" + unConfirmmark); // 更新提醒标签的文本
vInOrder = inOrderImpl.findUnconfirmInOrder();
unConfirmmark=vInOrder.size();
remindMenuLabel.setText("待确认进货:"+unConfirmmark);
}
//初始化界面,设置菜单栏、左侧菜单栏、右侧内容面板等
/* public static User getUserInf() {
return user;
}*/
@Override
protected void initView(User user, int skin) {
/* 菜单栏 */
menuBar = new JMenuBar(); // 创建菜单栏
settingMenu = new JMenu("设置"); // 创建设置菜单
helpMenu = new JMenu("帮助"); // 创建帮助菜单
skinMenuItem = new JMenuItem("随机切换皮肤", new ImageIcon("static\\icon\\skin.png")); // 创建皮肤菜单项
configMenuItem = new JMenuItem("参数设置", new ImageIcon("static\\icon\\setting.png")); // 创建配置菜单项
skinMenuItem.addActionListener(this); // 为皮肤菜单项添加事件监听器
settingMenu.add(configMenuItem); // 将配置菜单项添加到设置菜单
settingMenu.add(skinMenuItem); // 将皮肤菜单项添加到设置菜单
menuBar.add(settingMenu); // 将设置菜单添加到菜单栏
menuBar.add(helpMenu); // 将帮助菜单添加到菜单栏
setJMenuBar(menuBar); // 设置窗口的菜单栏
//左边菜单栏设置
protected void initView(User user,int skin) {
/*菜单栏*/
menuBar = new JMenuBar();
settingMenu = new JMenu("设置");
helpMenu = new JMenu("帮助");
skinMenuItem = new JMenuItem("随机切换皮肤",new ImageIcon("static\\icon\\skin.png"));
/* for(int i = 3;i<9;i++) {
}*/
configMenuItem = new JMenuItem("参数设置",new ImageIcon("static\\icon\\setting.png"));
skinMenuItem.addActionListener(this);
settingMenu.add(configMenuItem);
settingMenu.add(skinMenuItem);
menuBar.add(settingMenu);
menuBar.add(helpMenu);
setJMenuBar(menuBar);
/*左边菜单栏设置*/
try {
bgImage = ImageIO.read(new File("static\\bg\\bg" + skin + ".jpg")); // 读取背景图片
bgImage = ImageIO.read(new File("static\\bg\\bg"+skin+".jpg"));
} catch (IOException e) {
e.printStackTrace(); // 捕获并打印异常
// TODO Auto-generated catch block
e.printStackTrace();
}
leftPanel = new BGPanel(bgImage); // 创建带有背景图片的面板
leftPanel.setLayout(null); // 设置布局为空,自定义布局
//菜单栏:用户登录信息
System.out.println("用户头像地址==" + user.getImg()); // 打印用户头像地址
JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()), JLabel.LEFT); // 创建用户头像标签
System.out.println(user.getImg()); // 打印用户头像地址
leftPanel.add(logoLabel); // 将用户头像标签添加到左侧面板
logoLabel.setBounds(25, 30, 150, 150); // 设置用户头像标签的位置和大小
//账号名字
String x = UsuperIcon(user.getUsuper()); // 根据用户权限返回对应的图标地址
System.out.println("身份地址:" + x); // 打印身份图标地址
userMenuLabel1 = new JLabel("|" + user.getUsername() + "|" + user.getRname(), new ImageIcon(x), JLabel.LEFT); // 创建用户信息标签
userMenuLabel1.setFont(FontUtil.userFont); // 设置字体
userMenuLabel1.addMouseListener(this); // 添加鼠标监听器
userMenuLabel1.setBounds(20, 170, 180, 32); // 设置位置和大小
userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(userMenuLabel1); // 将用户信息标签添加到左侧面板
// 菜单栏:首页
homeMenuLabel = new JLabel("新民首页", new ImageIcon("static\\icon\\home1.png"), JLabel.LEFT); // 创建首页标签
homeMenuLabel.setFont(FontUtil.menuFont); // 设置字体
homeMenuLabel.addMouseListener(this); // 添加鼠标监听器
homeMenuLabel.setBounds(20, 250, 150, 32); // 设置位置和大小
homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(homeMenuLabel); // 将首页标签添加到左侧面板
// 菜单栏:人员管理
userMenuLabel = new JLabel("人员管理", new ImageIcon("static\\icon\\user1.png"), JLabel.LEFT); // 创建人员管理标签
userMenuLabel.setFont(FontUtil.menuFont); // 设置字体
userMenuLabel.addMouseListener(this); // 添加鼠标监听器
userMenuLabel.setBounds(20, 300, 150, 32); // 设置位置和大小
userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(userMenuLabel); // 将人员管理标签添加到左侧面板
// 菜单栏:进货系统
inMenuLabel = new JLabel("进货系统", new ImageIcon("static\\icon\\in1.png"), JLabel.LEFT); // 创建进货系统标签
inMenuLabel.setFont(FontUtil.menuFont); // 设置字体
inMenuLabel.addMouseListener(this); // 添加鼠标监听器
inMenuLabel.setBounds(20, 350, 150, 32); // 设置位置和大小
inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(inMenuLabel); // 将进货系统标签添加到左侧面板
// 菜单栏:收银系统
outMenuLabel = new JLabel("收银系统", new ImageIcon("static\\icon\\out1.png"), JLabel.LEFT); // 创建收银系统标签
outMenuLabel.setFont(FontUtil.menuFont); // 设置字体
outMenuLabel.addMouseListener(this); // 添加鼠标监听器
outMenuLabel.setBounds(20, 400, 150, 32); // 设置位置和大小
outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(outMenuLabel); // 将收银系统标签添加到左侧面板
// 菜单栏:库存
storageMenuLabel = new JLabel("商品库存", new ImageIcon("static\\icon\\storage1.png"), JLabel.LEFT); // 创建库存标签
storageMenuLabel.setFont(FontUtil.menuFont); // 设置字体
storageMenuLabel.addMouseListener(this); // 添加鼠标监听器
storageMenuLabel.setBounds(20, 450, 150, 32); // 设置位置和大小
storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(storageMenuLabel); // 将库存标签添加到左侧面板
// 菜单栏:供应商
supplierMenuLabel = new JLabel("供应商", new ImageIcon("static\\icon\\supplier1.png"), JLabel.LEFT); // 创建供应商标签
supplierMenuLabel.setFont(FontUtil.menuFont); // 设置字体
supplierMenuLabel.addMouseListener(this); // 添加鼠标监听器
supplierMenuLabel.setBounds(20, 500, 150, 32); // 设置位置和大小
supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(supplierMenuLabel); // 将供应商标签添加到左侧面板
// 菜单栏:商品目录
catalogMenuLabel = new JLabel("商品目录", new ImageIcon("static\\icon\\catalog1.png"), JLabel.LEFT); // 创建商品目录标签
catalogMenuLabel.setFont(FontUtil.menuFont); // 设置字体
catalogMenuLabel.addMouseListener(this); // 添加鼠标监听器
catalogMenuLabel.setBounds(20, 550, 150, 32); // 设置位置和大小
catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(catalogMenuLabel); // 将商品目录标签添加到左侧面板
// 提醒进货确认模块
remindMenuLabel = new JLabel("待确认进货:" + unConfirmmark, new ImageIcon("static\\icon\\remind1.png"), JLabel.LEFT); // 创建提醒标签
remindMenuLabel.setFont(FontUtil.remindFont); // 设置字体
remindMenuLabel.addMouseListener(this); // 添加鼠标监听器
remindMenuLabel.setBounds(0, 650, 200, 32); // 设置位置和大小
remindMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
leftPanel.add(remindMenuLabel); // 将提醒标签添加到左侧面板
rightPanelLayout = new CardLayout(); // 创建卡片布局管理器
// 0.超市首页展示
JPanel homePanel = new HomeView(this); // 创建首页面板
// 1.用户管理界面:用户的列表
JPanel userPanel = new UserView(this); // 创建用户管理面板
// 2.进货系统界面
JPanel inPanel = new InView(this, user, vP, 1); // 创建进货系统面板
// 3收银系统界面
JPanel outPanel = new OutView(this, user); // 创建收银系统面板
// 4.库存系统界面
JPanel storagePanel = new StorageView(this); // 创建库存系统面板
// 5.供应商界面
JPanel supplierPanel = new SupplierView(this); // 创建供应商面板
// 6商品目录界面
JPanel ProdCatalogPanel = new ProdCatalogView(this); // 创建商品目录面板
// 7商品目录界面
JPanel superPanel = new SuperView(this); // 创建普通用户界面
// 8进货信息提示
JPanel inPanel2 = new InView(this, user, vP, 0); // 创建进货信息提示面板
/* 添加界面并给索引 */
rightPanel = new JPanel(rightPanelLayout); // 创建右侧内容面板
rightPanel.add(homePanel, "0"); // 添加首页面板并设置索引
rightPanel.add(userPanel, "1"); // 添加用户管理面板并设置索引
rightPanel.add(inPanel, "2"); // 添加进货系统面板并设置索引
rightPanel.add(outPanel, "3"); // 添加收银系统面板并设置索引
rightPanel.add(storagePanel, "4"); // 添加库存系统面板并设置索引
rightPanel.add(supplierPanel, "5"); // 添加供应商面板并设置索引
rightPanel.add(ProdCatalogPanel, "6"); // 添加商品目录面板并设置索引
rightPanel.add(superPanel, "7"); // 添加普通用户面板并设置索引
rightPanel.add(inPanel2, "8"); // 添加进货信息提示面板并设置索引
containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); // 创建左右分割面板
containerPanel.setDividerLocation(180); // 设置分割位置
containerPanel.setDividerSize(0); // 设置分割线宽度为0
bottomPanel = new JPanel(); // 创建底部面板
bottomPanel.setBackground(Color.WHITE); // 设置背景颜色为白色
bottomPanel.setLayout(new BorderLayout()); // 设置布局为边界布局
purposePanel = new JPanel(); // 创建当前位置面板
purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); // 设置布局为流式布局(左对齐)
purposePanel.setBackground(Color.WHITE); // 设置背景颜色为白色
purposeLabel = new JLabel("当前位置是:超市首页"); // 创建当前位置标签
purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板
timePanel = new JPanel(); // 创建时间面板
timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // 设置布局为流式布局(右对齐)
timePanel.setBackground(Color.WHITE); // 设置背景颜色为白色
timeLabel = new JLabel(DateUtil.dateToString(new Date(), null)); // 创建时间标签
timePanel.add(timeLabel); // 将时间标签添加到时间面板
bottomPanel.add(purposePanel, "West"); // 将当前位置面板添加到底部面板的左侧
bottomPanel.add(timePanel, "East"); // 将时间面板添加到底部面板的右侧
Container container = getContentPane(); // 获取内容面板
container.add(containerPanel, "Center"); // 将主界面容器添加到内容面板的中间
container.add(bottomPanel, "South"); // 将底部面板添加到内容面板的底部
leftPanel = new BGPanel(bgImage);/*皮肤*/
leftPanel.setLayout(null);
/*菜单栏:用户登录信息*/
System.out.println("用户头像地址=="+user.getImg());
JLabel logoLabel = new JLabel(new ImageIcon(user.getImg()),JLabel.LEFT);
System.out.println(user.getImg());
leftPanel.add(logoLabel);
logoLabel.setBounds(25, 30,150,150);
/*账号名字*/
String x = UsuperIcon(user.getUsuper());/*判断权限返回icon地址*/
System.out.println("身份地址:"+x);
userMenuLabel1 = new JLabel("|"+user.getUsername()+"|"+user.getRname(),new ImageIcon(x),JLabel.LEFT);
userMenuLabel1.setFont(FontUtil.userFont);
userMenuLabel1.addMouseListener(this);
userMenuLabel1.setBounds(20, 170,180,32);
userMenuLabel1.setForeground(Color.white);
leftPanel.add(userMenuLabel1);/*添加用户选项到菜单栏*/
/*菜单栏:首页*/
homeMenuLabel = new JLabel("新民首页",new ImageIcon("static\\icon\\home1.png"),JLabel.LEFT);
homeMenuLabel.setFont(FontUtil.menuFont);
homeMenuLabel.addMouseListener(this);
homeMenuLabel.setBounds(20, 250,150,32);
homeMenuLabel.setForeground(Color.white);
leftPanel.add(homeMenuLabel);/*添加用户选项到菜单栏*/
/*菜单栏:人员管理*/
userMenuLabel = new JLabel("人员管理",new ImageIcon("static\\icon\\user1.png"),JLabel.LEFT);
userMenuLabel.setFont(FontUtil.menuFont);
userMenuLabel.addMouseListener(this);
userMenuLabel.setBounds(20, 300,150,32);
userMenuLabel.setForeground(Color.white);
leftPanel.add(userMenuLabel);/*添加用户选项到菜单栏*/
/*菜单栏:进货系统*/
inMenuLabel = new JLabel("进货系统",new ImageIcon("static\\icon\\in1.png") ,JLabel.LEFT);
inMenuLabel.setFont(FontUtil.menuFont);
inMenuLabel.addMouseListener(this);
inMenuLabel.setBounds(20, 350,150,32);
inMenuLabel.setForeground(Color.white);
leftPanel.add(inMenuLabel);
/*菜单栏:收银系统*/
outMenuLabel = new JLabel("收银系统",new ImageIcon("static\\icon\\out1.png") ,JLabel.LEFT);
outMenuLabel.setFont(FontUtil.menuFont);
outMenuLabel.addMouseListener(this);
outMenuLabel.setBounds(20, 400,150,32);
outMenuLabel.setForeground(Color.white);
leftPanel.add(outMenuLabel);
/*菜单栏:库存*/
storageMenuLabel = new JLabel("商品库存",new ImageIcon("static\\icon\\storage1.png") ,JLabel.LEFT);
storageMenuLabel.setFont(FontUtil.menuFont);
storageMenuLabel.addMouseListener(this);
storageMenuLabel.setBounds(20, 450,150,32);
storageMenuLabel.setForeground(Color.white);
leftPanel.add(storageMenuLabel);
/*菜单栏:供应商*/
supplierMenuLabel = new JLabel("供应商",new ImageIcon("static\\icon\\supplier1.png") ,JLabel.LEFT);
supplierMenuLabel.setFont(FontUtil.menuFont);
supplierMenuLabel.addMouseListener(this);
supplierMenuLabel.setBounds(20, 500,150,32);
supplierMenuLabel.setForeground(Color.white);
leftPanel.add(supplierMenuLabel);
/*菜单栏:商品目录*/
catalogMenuLabel = new JLabel("商品目录",new ImageIcon("static\\icon\\catalog1.png") ,JLabel.LEFT);
catalogMenuLabel.setFont(FontUtil.menuFont);
catalogMenuLabel.addMouseListener(this);
catalogMenuLabel.setBounds(20,550,150,32);
catalogMenuLabel.setForeground(Color.white);
leftPanel.add(catalogMenuLabel);
/*提醒进货确认模块*/
remindMenuLabel = new JLabel("待确认进货:"+unConfirmmark,new ImageIcon("static\\icon\\remind1.png") ,JLabel.LEFT);
remindMenuLabel.setFont(FontUtil.remindFont);
remindMenuLabel.addMouseListener(this);
remindMenuLabel.setBounds(0,650,200,32);
remindMenuLabel.setForeground(Color.white);
leftPanel.add(remindMenuLabel);
rightPanelLayout = new CardLayout();
//0.超市首页展示
JPanel homePanel = new HomeView(this);
//1.用户管理界面:用户的列表
JPanel userPanel = new UserView(this);
//2.进货系统界面
JPanel inPanel = new InView(this,user,vP,1);
//3收银系统界面
JPanel outPanel = new OutView(this,user);
//4.库存系统界面
JPanel storagePanel = new StorageView(this);
//5.供应商界面
JPanel supplierPanel = new SupplierView(this);
//6商品目录界面
JPanel ProdCatalogPanel = new ProdCatalogView(this);
//7商品目录界面
JPanel superPanel = new SuperView(this);
//8进货信息提示
JPanel inPanel2 = new InView(this,user,vP,0);
/*添加界面并给索引*/
rightPanel = new JPanel(rightPanelLayout);
rightPanel.add(homePanel, "0");
rightPanel.add(userPanel, "1");
rightPanel.add(inPanel, "2");
rightPanel.add(outPanel, "3");
rightPanel.add(storagePanel, "4");
rightPanel.add(supplierPanel, "5");
rightPanel.add(ProdCatalogPanel, "6");
rightPanel.add(superPanel, "7");
rightPanel.add(inPanel2, "8");
containerPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPanel,rightPanel);
containerPanel.setDividerLocation(180);
containerPanel.setDividerSize(0);
bottomPanel = new JPanel();//默认的布局是流式布局
bottomPanel.setBackground(Color.WHITE);
bottomPanel.setLayout(new BorderLayout());
purposePanel = new JPanel();
purposePanel.setLayout(new FlowLayout(FlowLayout.LEFT));
purposePanel.setBackground(Color.WHITE);
purposeLabel = new JLabel("当前位置是:超市首页");
purposePanel.add(purposeLabel);
timePanel=new JPanel();
timePanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
timePanel.setBackground(Color.WHITE);
timeLabel = new JLabel(DateUtil.dateToString(new Date(),null));
timePanel.add(timeLabel);
bottomPanel.add(purposePanel,"West");
bottomPanel.add(timePanel,"East");
Container container = getContentPane();
container.add(containerPanel,"Center");
container.add(bottomPanel,"South");
}
@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource(); // 获取事件来源
timeLabel.setText(DateUtil.dateToString(new Date(), null)); // 更新时间标签
if (source == skinMenuItem) /* 换肤 */ {
System.out.println("切换皮肤"); // 打印日志
Random random = new Random(); // 创建随机数生成器
skin = random.nextInt(10); // 随机生成皮肤编号
this.dispose(); // 关闭当前窗口
new MainView(user, skin, iconSkin); // 重新创建主界面
Object source = e.getSource();
timeLabel.setText(DateUtil.dateToString(new Date(),null));
if(source==skinMenuItem)/*换肤*/{
System.out.println("切换皮肤");
Random random=new Random();
skin=random.nextInt(10);
this.dispose();
new MainView(user,skin,iconSkin);
}
}
//左侧菜单栏点击事件处理方法。
/**
* cwf 2024/12/11
*
*/
@Override
/* 左侧菜单栏点击事件 */
public void mouseClicked(MouseEvent e) {
Object source = e.getSource(); // 获取点击事件的来源
@ -422,146 +477,175 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
refreshRemove(); // 刷新当前界面的位置信息
}
//刷新当前界面的位置信息。
public void refreshRemove() {
purposePanel.removeAll(); // 移除当前位置面板的所有组件
if (location == 0) {
purposeLabel = new JLabel("当前位置是:" + homeMenuLabel.getText()); // 设置当前位置为首页
} else if (location == 1) {
purposeLabel = new JLabel("当前位置是:" + userMenuLabel.getText()); // 设置当前位置为人员管理
} else if (location == 2) {
purposeLabel = new JLabel("当前位置是:" + inMenuLabel.getText()); // 设置当前位置为进货系统
} else if (location == 3) {
purposeLabel = new JLabel("当前位置是:" + outMenuLabel.getText()); // 设置当前位置为收银系统
} else if (location == 4) {
purposeLabel = new JLabel("当前位置是:" + storageMenuLabel.getText()); // 设置当前位置为库存系统
} else if (location == 5) {
purposeLabel = new JLabel("当前位置是:" + supplierMenuLabel.getText()); // 设置当前位置为供应商
} else {
purposeLabel = new JLabel("当前位置是:" + catalogMenuLabel.getText()); // 设置当前位置为商品目录
//获取当前位置
public void refreshRemove(){
purposePanel.removeAll();
if(location==0){
purposeLabel = new JLabel("当前位置是:"+homeMenuLabel.getText());
}else if(location==1){
purposeLabel = new JLabel("当前位置是:"+userMenuLabel.getText());
}else if(location==2){
purposeLabel = new JLabel("当前位置是:"+inMenuLabel.getText());
}else if(location==3){
purposeLabel = new JLabel("当前位置是:"+outMenuLabel.getText());
}else if(location==4){
purposeLabel = new JLabel("当前位置是:"+storageMenuLabel.getText());
}else if(location==5){
purposeLabel = new JLabel("当前位置是:"+supplierMenuLabel.getText());
}else{
purposeLabel = new JLabel("当前位置是:"+catalogMenuLabel.getText());
}
purposePanel.add(purposeLabel); // 将当前位置标签添加到当前位置面板
purposePanel.add(purposeLabel);
}
@Override
public void mousePressed(MouseEvent e) {
// 鼠标按下事件,暂未实现
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// 鼠标释放事件,暂未实现
// TODO Auto-generated method stub
}
@Override
// 鼠标焦点时
@Override/*鼠标焦点时*/
public void mouseEntered(MouseEvent e) {
Object source = e.getSource(); // 获取事件来源
if (source == homeMenuLabel) {
homeMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png")); // 设置图标
Object source = e.getSource();
if(source==homeMenuLabel) {
homeMenuLabel.setForeground(new Color(18, 150, 219));
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home2.png"));
}
if (source == userMenuLabel) {
userMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png")); // 设置图标
} else if (source == inMenuLabel) {
inMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png")); // 设置图标
} else if (source == outMenuLabel) {
outMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png")); // 设置图标
} else if (source == storageMenuLabel) {
storageMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png")); // 设置图标
} else if (source == supplierMenuLabel) {
supplierMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png")); // 设置图标
} else if (source == catalogMenuLabel) {
catalogMenuLabel.setForeground(new Color(18, 150, 219)); // 设置字体颜色
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png")); // 设置图标
} else if (source == userMenuLabel1) {
userMenuLabel1.setForeground(new Color(18, 150, 219)); // 设置字体颜色
if(source==userMenuLabel) {
userMenuLabel.setForeground(new Color(18, 150, 219));
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user2.png"));
}else if(source==inMenuLabel) {
inMenuLabel.setForeground(new Color(18, 150, 219));
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in2.png"));
}else if(source==outMenuLabel) {
outMenuLabel.setForeground(new Color(18, 150, 219));
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out2.png"));
}else if(source==storageMenuLabel) {
storageMenuLabel.setForeground(new Color(18, 150, 219));
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage2.png"));
}else if(source==supplierMenuLabel) {
supplierMenuLabel.setForeground(new Color(18, 150, 219));
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier2.png"));
}else if(source==catalogMenuLabel) {
catalogMenuLabel.setForeground(new Color(18, 150, 219));
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png"));
} else if(source==userMenuLabel1) {
userMenuLabel1.setForeground(new Color(18, 150, 219));
}
}
@Override
public void mouseExited(MouseEvent e) {
Object source = e.getSource(); // 获取事件来源
if (source == homeMenuLabel) {
homeMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png")); // 设置图标
} else if (source == userMenuLabel) {
userMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png")); // 设置图标
} else if (source == inMenuLabel) {
inMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png")); // 设置图标
} else if (source == outMenuLabel) {
outMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png")); // 设置图标
} else if (source == storageMenuLabel) {
storageMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png")); // 设置图标
} else if (source == supplierMenuLabel) {
supplierMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png")); // 设置图标
} else if (source == catalogMenuLabel) {
catalogMenuLabel.setForeground(Color.white); // 设置字体颜色为白色
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png")); // 设置图标
} else {
userMenuLabel1.setForeground(Color.white); // 设置字体颜色为白色
Object source = e.getSource();
if(source==homeMenuLabel) {
homeMenuLabel.setForeground(Color.white);
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png"));
} else if(source==userMenuLabel) {
userMenuLabel.setForeground(Color.white);
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png"));
}else if(source==inMenuLabel) {
inMenuLabel.setForeground(Color.white);
inMenuLabel.setIcon(new ImageIcon("static\\icon\\in1.png"));
}else if(source==outMenuLabel) {
outMenuLabel.setForeground(Color.white);
outMenuLabel.setIcon(new ImageIcon("static\\icon\\out1.png"));
}else if(source==storageMenuLabel) {
storageMenuLabel.setForeground(Color.white);
storageMenuLabel.setIcon(new ImageIcon("static\\icon\\storage1.png"));
}else if(source==supplierMenuLabel) {
supplierMenuLabel.setForeground(Color.white);
supplierMenuLabel.setIcon(new ImageIcon("static\\icon\\supplier1.png"));
}else if(source==catalogMenuLabel) {
catalogMenuLabel.setForeground(Color.white);
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png"));
} else {
userMenuLabel1.setForeground(Color.white);
}
}
@Override
protected void initView() {
// 初始化界面,未实现
// TODO Auto-generated method stub
}
@Override
public void windowOpened(WindowEvent e) {
// 窗口打开事件,未实现
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
Object source = e.getSource(); // 获取事件来源
if (source == this) { // 关闭窗口时检查进货系统和出货系统是否还有记录
this.vP = InView.getVector(); // 获取进货缓存
System.out.println("v的size=" + vP.size()); // 打印进货缓存大小
bufferImpl = new BufferImpl(); // 创建缓存实现类
if (vP.size() != 0 || bufferImpl.allOutBuffer().size() != 0) { // 如果购物车还有记录
CloseDialog closeDialog = new CloseDialog(this, vP); // 创建关闭对话框
closeDialog.setVisible(true); // 显示关闭对话框
} else {
System.exit(0); // 退出程序
}
// TODO Auto-generated method stub
Object source = e.getSource();
if(source==this) {/*关闭窗口时检查进货系统和出货系统是否还有记录*/
this.vP =InView.getVector();
System.out.println("v的size="+vP.size());
bufferImpl = new BufferImpl();
if(vP.size()!=0||bufferImpl.allOutBuffer().size()!=0) {/*如果购物车还有记录*/
CloseDialog closeDialog = new CloseDialog(this,vP);
closeDialog.setVisible(true);
}else
System.exit(0);
}
}
@Override
public void windowClosed(WindowEvent e) {
// 窗口关闭事件,未实现
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// 窗口最小化事件,未实现
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// 窗口恢复事件,未实现
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// 窗口激活事件,未实现
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// 窗口失活事件,未实现
// TODO Auto-generated method stub
}
}
}

@ -1,18 +1,14 @@
package com.lingnan.supermarket.view;
import javax.swing.UIManager;
// 用于设置Java Swing界面的Nimbus风格
public class Nimbus {
// 用于设置Java Swing界面呈现为Nimbus风格
/*nimbus风格*/
public static void Nimbus() {
try {
// 通过UIManager的setLookAndFeel方法来设置界面的外观风格为Nimbus风格
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (Exception e) {
// 如果在设置外观风格的过程中出现异常,则打印异常堆栈信息
e.printStackTrace();
}
}
}
}

@ -230,7 +230,7 @@ public class StorageView extends JPanel implements ActionListener{ // 定义Stor
}
}

@ -38,7 +38,7 @@ public class UserView extends JPanel implements ActionListener {
// 用于触发搜索操作的按钮
private JButton searchBtn;
// 用于存放操作按钮的面板
// 用于存放操作按钮(添加、更新、删除等)的面板
private JPanel opePanel;
// 用于触发添加用户操作的按钮
private JButton addBtn, updateBtn, deleteBtn;
@ -86,9 +86,9 @@ public class UserView extends JPanel implements ActionListener {
searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// 创建一个显示当前位置提示信息的标签,这里显示为"当前位置>人员管理"
locationLabel = new JLabel("当前位置>人员管理");
// 设置标签的字体为通过FontUtil类获取的特定字体
// 设置标签的字体为通过FontUtil类获取的特定字体这里假设FontUtil类用于统一管理字体相关设置
locationLabel.setFont(new FontUtil().userFont);
// 设置标签的前景色为特定的蓝色
// 设置标签的前景色(文字颜色)为特定的蓝色RGB值为18, 150, 219
locationLabel.setForeground(new Color(18, 150, 219));
// 创建一个显示"姓名"文字的标签,用于提示用户在旁边的文本框中输入姓名进行搜索
nameLabel = new JLabel("姓名");
@ -97,7 +97,7 @@ public class UserView extends JPanel implements ActionListener {
// 创建一个按钮,使用指定路径下的图标文件作为按钮的图标,用于触发搜索操作
searchBtn = new JButton(new ImageIcon("static\\icon\\search.png"));
// 创建一个新的面板opePanel设置其布局为FlowLayout且组件右对齐用于存放操作按钮
// 创建一个新的面板opePanel设置其布局为FlowLayout且组件右对齐用于存放操作按钮(添加、更新、删除)
opePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
// 创建一个按钮,使用指定路径下的图标文件("static\\icon\\add.png")作为按钮的图标,用于触发添加用户操作
addBtn = new JButton(new ImageIcon("static\\icon\\add.png"));
@ -106,7 +106,7 @@ public class UserView extends JPanel implements ActionListener {
// 创建一个按钮,使用指定路径下的图标文件("static\\icon\\delete.png")作为按钮的图标,用于触发删除用户操作
deleteBtn = new JButton(new ImageIcon("static\\icon\\delete.png"));
// 为添加、更新、删除和搜索按钮添加点击事件监听器,将按钮的点击事件绑定到当前类的actionPerformed方法上以便处理相应的操作逻辑
// 为添加、更新、删除和搜索按钮添加点击事件监听器,将按钮的点击事件绑定到当前类实现了ActionListener接口的actionPerformed方法上以便处理相应的操作逻辑
addBtn.addActionListener(this);
updateBtn.addActionListener(this);
deleteBtn.addActionListener(this);
@ -123,18 +123,18 @@ public class UserView extends JPanel implements ActionListener {
searchPanel.add(nameSearchTF);
searchPanel.add(searchBtn);
// 将搜索面板添加到toolBarPanel的西边区域将操作按钮面板添加到toolBarPanel的东边区域
// 将搜索面板添加到toolBarPanel的西边(左侧)区域将操作按钮面板添加到toolBarPanel的东边(右侧)区域
toolBarPanel.add(searchPanel, "West");
toolBarPanel.add(opePanel, "East");
// 创建用户表格数据模型对象
userTableModel = new UserTableModel();
// 调用数据模型的方法获取所有用户数据,用于初始化表格显示内容
// 调用数据模型的方法获取所有用户数据,用于初始化表格显示内容这里假设UserTableModel类中的all方法用于从数据库等数据源获取全部用户数据并填充到模型中
userTableModel.all();
// 创建一个JTable对象使用前面创建的用户表格数据模型userTableModel来管理表格中的数据展示和交互
userTable = new JTable(userTableModel);
// 设置表格的字体为通过FontUtil类获取的适用于表格的特定字体
// 设置表格的字体为通过FontUtil类获取的适用于表格的特定字体假设FontUtil类中定义了相关字体常量
userTable.setFont(FontUtil.tableFont);
// 设置表格每行的高度为50像素调整表格的显示样式
userTable.setRowHeight(50);
@ -143,29 +143,29 @@ public class UserView extends JPanel implements ActionListener {
// 创建一个新的面板bottomPanel设置其布局为FlowLayout且组件左对齐用于存放记录数相关提示信息
bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
// 创建一个显示用户记录总数的标签,初始文本为"总共"加上通过用户表格数据模型获取的行数
// 创建一个显示用户记录总数的标签,初始文本为"总共"加上通过用户表格数据模型获取的行数假设UserTableModel类的getRowCount方法返回当前模型中的数据行数以及"条"字
countInfoLabel = new JLabel("总共" + userTableModel.getRowCount() + "条");
// 将记录数标签添加到bottomPanel面板中
bottomPanel.add(countInfoLabel);
// 将顶部工具栏面板添加到当前面板的北部区域
// 将顶部工具栏面板添加到当前面板UserView的北部(上方)区域
this.add(toolBarPanel, "North");
// 将包含用户表格的滚动面板添加到当前面板的中部区域,使其在界面中间显示
// 将包含用户表格的滚动面板添加到当前面板UserView的中部区域,使其在界面中间显示
this.add(tableScrollPane, "Center");
// 将记录数面板添加到当前面板的南部区域
// 将记录数面板添加到当前面板UserView的南部(下方)区域
this.add(bottomPanel, "South");
// 设置当前面板可见,使其在界面上显示出来
// 设置当前面板UserView可见,使其在界面上显示出来
setVisible(true);
}
// 处理按钮点击等用户交互动作的方法实现了ActionListener接口中的方法
@Override
public void actionPerformed(ActionEvent e) {
// 获取触发事件的源组件
// 获取触发事件的源组件(即被点击的按钮等组件)
Object source = e.getSource();
if (addBtn == source) {
// 如果点击的是添加按钮执行以下操作:
// 如果点击的是添加按钮执行以下操作:
// 创建一个用于添加用户信息的对话框
UserDialog userDialog = new UserDialog(jFrame);
@ -189,9 +189,9 @@ public class UserView extends JPanel implements ActionListener {
// 弹出确认对话框询问用户是否确定删除指定id的用户记录提供"是"和"否"两个选项,返回用户选择的结果
int select = JOptionPane.showConfirmDialog(this, "是否删除id=" + id, "提示", JOptionPane.YES_NO_OPTION);
if (select == JOptionPane.YES_OPTION) {
// 如果用户选择了是,执行以下操作:
// 如果用户选择了""(确认删除),执行以下操作:
// 调用用户服务接口的删除用户方法传入要删除的用户id尝试从数据库中删除对应的用户记录并获取返回结果
// 调用用户服务接口的删除用户方法传入要删除的用户id尝试从数据库中删除对应的用户记录并获取返回结果假设返回1表示删除成功其他值表示失败
if (userService.deleteUser(id) == 1) {
// 如果删除成功,弹出提示框显示"删除成功"的消息,提示框的图标为信息图标
JOptionPane.showMessageDialog(this, "删除成功", "提示", JOptionPane.INFORMATION_MESSAGE);
@ -203,7 +203,7 @@ public class UserView extends JPanel implements ActionListener {
// 无论删除操作是否成功,都调用刷新用户数据的方法,更新界面上的用户数据显示,确保表格等显示内容与数据库中的最新数据一致
refreshUser();
} else {
// 如果点击的是搜索按钮,执行以下操作:
// 如果点击的是搜索按钮(即其他未明确匹配的按钮点击情况,这里目前代码逻辑中只存在搜索按钮可能进入此分支),执行以下操作:
System.out.println("搜索");
// 调用刷新按姓名搜索结果的方法,根据用户在姓名搜索文本框中输入的内容进行数据刷新和表格显示更新

@ -2,92 +2,70 @@ package com.lingnan.supermarket.view.base;
import java.awt.Toolkit;
import java.util.Vector;
import javax.swing.JFrame;
// 导入相关的业务数据对象类,用于在视图相关操作中可能涉及的数据传递等情况
import com.lingnan.supermarket.dto.Production;
import com.lingnan.supermarket.dto.User;
// 定义抽象类BaseView继承自JFrame用于统一管理视图的一些通用属性和行为
public abstract class BaseView extends JFrame {
// 基本构造方法,用于创建一个具有指定初始宽度、高度和标题的窗口,并进行一些初始化设置
public BaseView(int initWidth, int initHeigth, String title) {
// 设置窗口的标题
public BaseView(int initWidth,int initHeigth,String title) {
this.setTitle(title);
// 设置窗口的初始大小
this.setSize(initWidth, initHeigth);
// 通过Toolkit.getDefaultToolkit().getScreenSize()方法获取屏幕尺寸信息
this.setSize(initWidth,initHeigth);
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
// 通过计算屏幕中心与窗口大小差值的一半来确定窗口左上角坐标
this.setLocation((width - getWidth()) / 2, (height - getHeight()) / 2);
this.setLocation((width-getWidth())/2,(height-getHeight())/2);
// 调用抽象方法initView()
initView();
// 设置窗口为可见状态,使其显示出来
this.setVisible(true);
// 设置窗口关闭操作的默认行为,当关闭窗口时,整个应用程序将退出
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
// 用于创建一个具有指定初始宽度、高度、标题以及关联用户信息和皮肤相关参数的窗口,并进行一些初始化设置
public BaseView(int initWidth, int initHeigth, String title, User user, int skin) {
// 设置窗口的标题
/*带对象参数的构造方法*/
public BaseView(int initWidth,int initHeigth,String title,User user,int skin) {
this.setTitle(title);
// 设置窗口的初始大小
this.setSize(initWidth, initHeigth);
// 获取屏幕的宽度和高度
this.setSize(initWidth,initHeigth);
int width = Toolkit.getDefaultToolkit().getScreenSize().width;
int height = Toolkit.getDefaultToolkit().getScreenSize().height;
// 设置窗口在屏幕中的位置,使其居中显示
this.setLocation((width - getWidth()) / 2, (height - getHeight()) / 2);
this.setLocation((width-getWidth())/2,(height-getHeight())/2);
// 设置窗口为可见状态,使其显示出来
this.setVisible(true);
// 设置窗口关闭操作的默认行为这里设置为DO_NOTHING_ON_CLOSE表示关闭窗口时不执行任何默认操作通常由子类根据具体需求自定义关闭行为
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
// 抽象方法,由具体的子类实现,用于进行特定视图的初始化操作,比如添加各种组件、设置布局等
protected abstract void initView();
protected abstract void initView(User user,int skin);
// 抽象方法,由具体的子类实现,用于进行特定视图的初始化操作
protected abstract void initView(User user, int skin);
// 根据传入的权限值判断对应的权限角色,并返回相应的角色名称字符串
/*判断权限并返回字符*/
public String Usuper(int usuper) {
String x = null;
// 如果权限值为0则对应的角色是管理员
if (usuper == 0)
x = "管理员";
// 如果权限值为1则对应的角色是进货员
else if (usuper == 1)
x = "进货员";
// 如果权限值为2则对应的角色是收银员
else if (usuper == 2)
x = "收银员";
// 如果权限值为3则对应的角色是超级管理员
else if (usuper == 3)
x = "超级管理员";
String x=null;
if(usuper==0)
x="管理员";
else if(usuper==1)
x="进货员";
else if(usuper==2)
x="收银员";
return x;
}
// 根据传入的权限值判断对应的权限角色,并返回相应角色对应的图标文件地址字符串
/*判断权限并返回icon地址*/
public String UsuperIcon(int usuper) {
String x = null;
// 如果权限值为0则返回管理员角色对应的图标文件地址
if (usuper == 0)
x = "static\\icon\\admin.png";
// 如果权限值为1则返回进货员角色对应的图标文件地址
else if (usuper == 1)
x = "static\\icon\\carrier.png";
// 如果权限值为2则返回收银员角色对应的图标文件地址
else if (usuper == 2)
x = "static\\icon\\cashier.png";
String x=null;
if(usuper==0)
x="static\\icon\\admin.png";
else if(usuper==1)
x="static\\icon\\carrier.png";
else if(usuper==2)
x="static\\icon\\cashier.png";
return x;
}
}
}

Loading…
Cancel
Save