添加了进货员角色并修改了用户权限

pull/10/head
cwfeng 10 months ago
parent 3bc2dbaac8
commit 3b68c7ff00

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

@ -52,9 +52,10 @@ public class inOrderServiceImpl implements inOrderService{
try { try {
// 准备SQL语句根据订单号查找特定的订单 // 准备SQL语句根据订单号查找特定的订单
preparedStatement = conn.prepareStatement("select * from inOrder where iNumber = ?"); preparedStatement = conn.prepareStatement("select * from inOrder where iNumber = ?"); //根据订单号查询订单
preparedStatement.setString(1, iNumber); // 设置订单号参数 preparedStatement.setString(1, iNumber); // 设置订单号参数
resultSet = preparedStatement.executeQuery(); // 执行查询 resultSet = preparedStatement.executeQuery(); // 执行查询
// 设置查询到的订单的属性到InOrder对象中
if (resultSet.next()) { // 如果找到对应记录 if (resultSet.next()) { // 如果找到对应记录
// 从结果集中获取属性并设置到inOrder对象 // 从结果集中获取属性并设置到inOrder对象
inOrder.setiNumber(resultSet.getString("iNumber")); inOrder.setiNumber(resultSet.getString("iNumber"));

@ -39,7 +39,7 @@ public class UserDialog extends JDialog implements ActionListener {
// 下拉框组件,用于选择用户权限 // 下拉框组件,用于选择用户权限
private JComboBox<String> combo; private JComboBox<String> combo;
// 下拉框中的选项内容,包括请选择身份以及不同的权限角色 // 下拉框中的选项内容,包括请选择身份以及不同的权限角色
private String[] identity = { "请选择身份", "收银员", "管理员", "超级管理员" }; private String[] identity = { "请选择身份", "进货员","收银员", "管理员", "超级管理员" };
// 构造函数,用于创建添加用户信息的对话框 // 构造函数,用于创建添加用户信息的对话框
public UserDialog(JFrame parent) { public UserDialog(JFrame parent) {
@ -168,6 +168,13 @@ public class UserDialog extends JDialog implements ActionListener {
} }
// 内部类实现了ItemListener接口用于监听下拉框选项变化事件 // 内部类实现了ItemListener接口用于监听下拉框选项变化事件
/**
*
*
* cwf
* 2024/12/11
*/
static class MyItemListener implements ItemListener { static class MyItemListener implements ItemListener {
@Override @Override
@ -182,6 +189,8 @@ public class UserDialog extends JDialog implements ActionListener {
sSuper = 2; sSuper = 2;
else if (sSuper1.equals("管理员")) else if (sSuper1.equals("管理员"))
sSuper = 1; sSuper = 1;
else if (sSuper1.equals("进货员")) // 2024/12/11 添加进货员权限
sSuper = 3; // 2024/12/11 添加进货员权限
else else
sSuper = 0; sSuper = 0;
} }

@ -44,7 +44,7 @@ public class UserInfDialog extends JDialog implements ActionListener {
// 下拉框组件,用于选择用户权限(这里部分代码被注释掉,可能原本有完整的权限选择功能,后简化了) // 下拉框组件,用于选择用户权限(这里部分代码被注释掉,可能原本有完整的权限选择功能,后简化了)
private JComboBox<String> combo; private JComboBox<String> combo;
// 下拉框中的选项内容,包括当前权限以及不同的权限角色 // 下拉框中的选项内容,包括当前权限以及不同的权限角色
private String[] identity = { "当前权限", "收银员", "管理员", "超级管理员" }; private String[] identity = { "当前权限", "进货员","收银员", "管理员", "超级管理员" };
// 父窗口JFrame的引用可能用于在某些操作后对父窗口进行处理 // 父窗口JFrame的引用可能用于在某些操作后对父窗口进行处理
private JFrame JFrame; private JFrame JFrame;
@ -189,6 +189,14 @@ public class UserInfDialog extends JDialog implements ActionListener {
} }
// 内部类实现了ItemListener接口用于监听下拉框选项变化事件这里部分代码被注释掉可能原本有完整的权限选择功能后简化了 // 内部类实现了ItemListener接口用于监听下拉框选项变化事件这里部分代码被注释掉可能原本有完整的权限选择功能后简化了
/**
* cwf 2024/12/11
*
* sSuper1.equals("进货员")
* sSuper = 3;
*/
public class MyItemListener implements ItemListener { public class MyItemListener implements ItemListener {
@Override @Override
@ -198,13 +206,15 @@ public class UserInfDialog extends JDialog implements ActionListener {
// 获取当前选中的下拉框选项内容 // 获取当前选中的下拉框选项内容
String sSuper1 = (String) cb.getSelectedItem(); String sSuper1 = (String) cb.getSelectedItem();
if (sSuper1.equals("当前权限")) if (sSuper1.equals("当前权限"))
sSuper = user.getUsuper(); sSuper = user.getUsuper(); // 保持原权限
else if (sSuper1.equals("收银员")) else if (sSuper1.equals("收银员"))
sSuper = 2; sSuper = 2; // 收银员权限
else if (sSuper1.equals("管理员")) else if (sSuper1.equals("管理员")) // 新增权限角色
sSuper = 1; sSuper = 1;
else if (sSuper1.equals("进货员")) // 新增权限角色
sSuper = 3;
else else
sSuper = 0; sSuper = 0; // 超级管理员
} }
} }
} }

@ -486,7 +486,7 @@ public class InView extends JPanel implements ActionListener{
CreateOrder createOrder = new CreateOrder(); CreateOrder createOrder = new CreateOrder();
String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice,uname); String OrderText = createOrder.CreateOrder(v, s[0], s[1], allPrice,uname);
try {/*发送邮件*/ try {/*发送邮件*/
SendQQMailUtil QQEmail = new SendQQMailUtil("sender@qq.com","自行获取 SMTP 授权码","receiver@qq.com","@新民超市进货需求申请",OrderText); SendQQMailUtil QQEmail = new SendQQMailUtil("cwfeng5@qq.com","wlcinslohrgpdiac","1912638153@qq.com","@新民超市进货需求申请",OrderText);
} catch (MessagingException e1) { } catch (MessagingException e1) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e1.printStackTrace(); e1.printStackTrace();

@ -126,7 +126,6 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
this.addWindowListener(this); this.addWindowListener(this);
//获得未进货的信息 //获得未进货的信息
Vector<InOrder> vInOrder; Vector<InOrder> vInOrder;
vInOrder = inOrderImpl.findUnconfirmInOrder(); vInOrder = inOrderImpl.findUnconfirmInOrder();
@ -364,63 +363,120 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
} }
@Override/*左侧菜单栏点击事件*/
/**
* cwf 2024/12/11
*
*/
@Override
/* 左侧菜单栏点击事件 */
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
Object source = e.getSource(); Object source = e.getSource(); // 获取点击事件的来源
// 如果点击的是首页菜单
if (source == homeMenuLabel) { if (source == homeMenuLabel) {
rightPanelLayout.show(rightPanel,"0"); rightPanelLayout.show(rightPanel, "0"); // 显示首页界面
location=0; location = 0; // 设置当前位置为首页
}else if(source==userMenuLabel) { }
if(sSuper==0) // 如果点击的是人员管理菜单
rightPanelLayout.show(rightPanel,"1"); else if (source == userMenuLabel) {
// 如果用户是管理员 (sSuper == 0) 或进货员 (sSuper == 1)
if (sSuper == 0 || sSuper == 1) {
rightPanelLayout.show(rightPanel, "1"); // 显示人员管理界面
}
// 如果用户是普通用户 (sSuper == 3)
else if (sSuper == 3) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如普通用户权限)
else { else {
rightPanelLayout.show(rightPanel,"7"); rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
} }
location=1; location = 1; // 设置当前位置为人员管理
} }
// 如果点击的是进货系统菜单
else if (source == inMenuLabel) { else if (source == inMenuLabel) {
if(sSuper==2) // 如果用户是普通用户 (sSuper == 2) 或进货员 (sSuper == 1)
rightPanelLayout.show(rightPanel,"7"); if (sSuper == 2 || sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else { else {
rightPanelLayout.show(rightPanel,"2"); rightPanelLayout.show(rightPanel, "2"); // 显示进货系统界面
} }
location=2; location = 2; // 设置当前位置为进货系统
} }
// 如果点击的是收银系统菜单
else if (source == outMenuLabel) { else if (source == outMenuLabel) {
rightPanelLayout.show(rightPanel,"3"); // 如果用户是普通用户 (sSuper == 3) 或进货员 (sSuper == 1)
location=3; if (sSuper == 3 || sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "3"); // 显示收银系统界面
location = 3; // 设置当前位置为收银系统
}
} }
// 如果点击的是库存系统菜单
else if (source == storageMenuLabel) { else if (source == storageMenuLabel) {
rightPanelLayout.show(rightPanel,"4"); // 如果用户是进货员 (sSuper == 1)
location=4; if (sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
} }
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "4"); // 显示库存系统界面
location = 4; // 设置当前位置为库存系统
}
}
// 如果点击的是供应商菜单
else if (source == supplierMenuLabel) { else if (source == supplierMenuLabel) {
rightPanelLayout.show(rightPanel,"5"); // 如果用户是进货员 (sSuper == 1)
if (sSuper == 1) {
location=5; rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "5"); // 显示供应商界面
location = 5; // 设置当前位置为供应商
}
} }
// 如果点击的是商品目录菜单
else if (source == catalogMenuLabel) { else if (source == catalogMenuLabel) {
rightPanelLayout.show(rightPanel,"6"); // 如果用户是进货员 (sSuper == 1)
location=6; if (sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}else if(source==remindMenuLabel) { }
if(sSuper==2) // 其他情况(例如管理员权限)
rightPanelLayout.show(rightPanel,"7");
else { else {
rightPanelLayout.show(rightPanel,"8"); rightPanelLayout.show(rightPanel, "6"); // 显示商品目录界面
location = 6; // 设置当前位置为商品目录
} }
location=7; }
}else if(source==userMenuLabel1){ // 如果点击的是提醒菜单
else if (source == remindMenuLabel) {
UserInfDialog userInfDialog = new UserInfDialog(this,user); // 如果用户是普通用户 (sSuper == 2) 或进货员 (sSuper == 1)
userInfDialog.setVisible(true); if (sSuper == 2 || sSuper == 1) {
location=8; rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "8"); // 显示进货信息提示界面
}
location = 7; // 设置当前位置为提醒
}
// 如果点击的是用户信息菜单
else if (source == userMenuLabel1) {
UserInfDialog userInfDialog = new UserInfDialog(this, user); // 创建用户信息对话框
userInfDialog.setVisible(true); // 显示用户信息对话框
location = 8; // 设置当前位置为用户信息
} }
refreshRemove(); refreshRemove(); // 刷新当前界面的位置信息
} }
//获取当前位置 //获取当前位置
public void refreshRemove(){ public void refreshRemove(){
@ -488,8 +544,7 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
}else if(source==catalogMenuLabel) { }else if(source==catalogMenuLabel) {
catalogMenuLabel.setForeground(new Color(18, 150, 219)); catalogMenuLabel.setForeground(new Color(18, 150, 219));
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png")); catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog2.png"));
} } else if(source==userMenuLabel1) {
else if(source==userMenuLabel1) {
userMenuLabel1.setForeground(new Color(18, 150, 219)); userMenuLabel1.setForeground(new Color(18, 150, 219));
} }
@ -501,8 +556,7 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
if(source==homeMenuLabel) { if(source==homeMenuLabel) {
homeMenuLabel.setForeground(Color.white); homeMenuLabel.setForeground(Color.white);
homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png")); homeMenuLabel.setIcon(new ImageIcon("static\\icon\\home1.png"));
} } else if(source==userMenuLabel) {
else if(source==userMenuLabel) {
userMenuLabel.setForeground(Color.white); userMenuLabel.setForeground(Color.white);
userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png")); userMenuLabel.setIcon(new ImageIcon("static\\icon\\user1.png"));
}else if(source==inMenuLabel) { }else if(source==inMenuLabel) {
@ -520,8 +574,7 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
}else if(source==catalogMenuLabel) { }else if(source==catalogMenuLabel) {
catalogMenuLabel.setForeground(Color.white); catalogMenuLabel.setForeground(Color.white);
catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png")); catalogMenuLabel.setIcon(new ImageIcon("static\\icon\\catalog1.png"));
} } else {
else {
userMenuLabel1.setForeground(Color.white); userMenuLabel1.setForeground(Color.white);
} }

Loading…
Cancel
Save