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

pull/10/head
cwfeng 9 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 else if (sSuper1.equals("进货员")) // 新增权限角色
sSuper = 0; sSuper = 3;
else
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();

@ -56,7 +56,7 @@ public class MainView extends BaseView implements ActionListener, MouseListener,
/*菜单栏*/ /*菜单栏*/
JLabel logoLabel,userMenuLabel1,homeMenuLabel,userMenuLabel,inMenuLabel, JLabel logoLabel,userMenuLabel1,homeMenuLabel,userMenuLabel,inMenuLabel,
outMenuLabel,storageMenuLabel,supplierMenuLabel,catalogMenuLabel; outMenuLabel,storageMenuLabel,supplierMenuLabel,catalogMenuLabel;
static JLabel remindMenuLabel;/*全局调用刷新*/ static JLabel remindMenuLabel;/*全局调用刷新*/
@ -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,92 +363,149 @@ 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) {
rightPanelLayout.show(rightPanel,"0"); // 如果点击的是首页菜单
location=0; if (source == homeMenuLabel) {
}else if(source==userMenuLabel) { rightPanelLayout.show(rightPanel, "0"); // 显示首页界面
if(sSuper==0) location = 0; // 设置当前位置为首页
rightPanelLayout.show(rightPanel,"1"); }
else{ // 如果点击的是人员管理菜单
rightPanelLayout.show(rightPanel,"7"); 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 {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
} }
location=1; location = 1; // 设置当前位置为人员管理
} }
else if(source==inMenuLabel) { // 如果点击的是进货系统菜单
if(sSuper==2) else if (source == inMenuLabel) {
rightPanelLayout.show(rightPanel,"7"); // 如果用户是普通用户 (sSuper == 2) 或进货员 (sSuper == 1)
else{ if (sSuper == 2 || sSuper == 1) {
rightPanelLayout.show(rightPanel,"2"); rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "2"); // 显示进货系统界面
} }
location=2; location = 2; // 设置当前位置为进货系统
} }
else if(source==outMenuLabel) { // 如果点击的是收银系统菜单
rightPanelLayout.show(rightPanel,"3"); else if (source == outMenuLabel) {
location=3; // 如果用户是普通用户 (sSuper == 3) 或进货员 (sSuper == 1)
if (sSuper == 3 || sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "3"); // 显示收银系统界面
location = 3; // 设置当前位置为收银系统
}
} }
else if(source==storageMenuLabel) { // 如果点击的是库存系统菜单
rightPanelLayout.show(rightPanel,"4"); else if (source == storageMenuLabel) {
location=4; // 如果用户是进货员 (sSuper == 1)
if (sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "4"); // 显示库存系统界面
location = 4; // 设置当前位置为库存系统
}
} }
else if(source==supplierMenuLabel) { // 如果点击的是供应商菜单
rightPanelLayout.show(rightPanel,"5"); else if (source == supplierMenuLabel) {
// 如果用户是进货员 (sSuper == 1)
location=5; if (sSuper == 1) {
rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
}
// 其他情况(例如管理员权限)
else {
rightPanelLayout.show(rightPanel, "5"); // 显示供应商界面
location = 5; // 设置当前位置为供应商
}
} }
else if(source==catalogMenuLabel) { // 如果点击的是商品目录菜单
rightPanelLayout.show(rightPanel,"6"); else if (source == catalogMenuLabel) {
location=6; // 如果用户是进货员 (sSuper == 1)
if (sSuper == 1) {
}else if(source==remindMenuLabel) { rightPanelLayout.show(rightPanel, "7"); // 显示普通用户界面
if(sSuper==2)
rightPanelLayout.show(rightPanel,"7");
else{
rightPanelLayout.show(rightPanel,"8");
} }
location=7; // 其他情况(例如管理员权限)
}else if(source==userMenuLabel1){ else {
rightPanelLayout.show(rightPanel, "6"); // 显示商品目录界面
UserInfDialog userInfDialog = new UserInfDialog(this,user); location = 6; // 设置当前位置为商品目录
userInfDialog.setVisible(true); }
location=8; }
// 如果点击的是提醒菜单
else if (source == remindMenuLabel) {
// 如果用户是普通用户 (sSuper == 2) 或进货员 (sSuper == 1)
if (sSuper == 2 || sSuper == 1) {
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(){
purposePanel.removeAll(); purposePanel.removeAll();
if(location==0){ if(location==0){
purposeLabel = new JLabel("当前位置是:"+homeMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+homeMenuLabel.getText());
}else if(location==1){ }else if(location==1){
purposeLabel = new JLabel("当前位置是:"+userMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+userMenuLabel.getText());
}else if(location==2){ }else if(location==2){
purposeLabel = new JLabel("当前位置是:"+inMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+inMenuLabel.getText());
}else if(location==3){ }else if(location==3){
purposeLabel = new JLabel("当前位置是:"+outMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+outMenuLabel.getText());
}else if(location==4){ }else if(location==4){
purposeLabel = new JLabel("当前位置是:"+storageMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+storageMenuLabel.getText());
}else if(location==5){ }else if(location==5){
purposeLabel = new JLabel("当前位置是:"+supplierMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+supplierMenuLabel.getText());
}else{ }else{
purposeLabel = new JLabel("当前位置是:"+catalogMenuLabel.getText()); purposeLabel = new JLabel("当前位置是:"+catalogMenuLabel.getText());
} }
purposePanel.add(purposeLabel); purposePanel.add(purposeLabel);
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
@ -488,11 +544,10 @@ 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));
} }
} }
@Override @Override
@ -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,11 +574,10 @@ 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