书店管理系统
书店管理系统可以说是设计模式及设计思想的一个比较经典的例子。
本系列将分为多个部分讲述此输电管理系统。
书店管理系统将分为:用户、图书、进货、销售和库存五个模块,另外还有公共包、工具包和登录包,另外还有一个框架。
对于分层设计,都是表现层可以调用逻辑层,逻辑层调用数据层,数据层调用工具和公共包,方向不可打乱,必须严格按照这种模式。
本篇将做用户模块部分。
同系列有:
系列一(概述):点击打开链接
系列三(工具包和公共类):点击打开链接
系列四(图书):点击打开链接
系列五(进货):点击打开链接
系列六(销售):点击打开链接
系列七(库存):点击打开链接
系列八(登录):点击打开链接
如前面所言,用户模块分为了数据层、业务逻辑层、表现层和值对象层
数据层和逻辑层又分了接口、实现和工厂三个包,里面分别存放接口、实现类和工厂类
表现层写的则是图形界面的文件
本系列所有的表现层界面全部都用面板写,因此需要有一个JFrame来承载,在这里写掉JFrame,后面的图形界面都用这个。
框架:
- /*
- * BookStore.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu;
- import java.awt.event.ActionEvent;
- import javax.swing.Icon;
- import javax.swing.ImageIcon;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import cn.hncu.book.ui.BookListPanel;
- import cn.hncu.login.ui.LoginPanel;
- import cn.hncu.out.ui.ListPanel;
- import cn.hncu.user.ui.UserListPanel;
- /**
- *
- * @author __USER__
- */
- public class BookStore extends javax.swing.JFrame {
- private final String dir = "./Images/";
- /** Creates new form BookStore */
- public BookStore() {
- setBack();
- initComponents();
- this.setContentPane(new LoginPanel(this));
- this.validate();
- }
- private void setBack() {
- //把当前JFrame的内容窗格设成透明,这样放在其中的组件就能够显示出背景
- ((JPanel) (this.getContentPane())).setOpaque(false);//1
- Icon bgImage = new ImageIcon(dir + "bg.png");//路径从项目根目录
- //Icon bgImage = new ImageIcon(dir+"a.gif");//显示gif动态图也可以
- JLabel bgLabel = new JLabel(bgImage);
- //根据给的整数值决定在上层还是下层显示,数值越小显示在越下面的位置
- this.getLayeredPane().add(bgLabel, new Integer(Integer.MIN_VALUE));//2
- bgLabel
- .setBounds(0, 0, bgImage.getIconWidth(), bgImage
- .getIconHeight());//3
- //以下是测试,看看上面的图片是不是能够显示成背景
- // JButton btn = new JButton("OK");
- // this.getLayeredPane().add(btn);
- // btn.setBounds(100, 100, 80, 50);
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- menuBar = new javax.swing.JMenuBar();
- fileMenu = new javax.swing.JMenu();
- openMenuItem = new javax.swing.JMenuItem();
- saveMenuItem = new javax.swing.JMenuItem();
- saveAsMenuItem = new javax.swing.JMenuItem();
- exitMenuItem = new javax.swing.JMenuItem();
- editMenu = new javax.swing.JMenu();
- cutMenuItem = new javax.swing.JMenuItem();
- copyMenuItem = new javax.swing.JMenuItem();
- pasteMenuItem = new javax.swing.JMenuItem();
- deleteMenuItem = new javax.swing.JMenuItem();
- jMenu1 = new javax.swing.JMenu();
- jMenuItemUser = new javax.swing.JMenuItem();
- jMenuItemBook = new javax.swing.JMenuItem();
- jMenuItemIn = new javax.swing.JMenuItem();
- jMenuItemOut = new javax.swing.JMenuItem();
- jMenuItemStock = new javax.swing.JMenuItem();
- jMenuItemLogout = new javax.swing.JMenuItem();
- helpMenu = new javax.swing.JMenu();
- contentsMenuItem = new javax.swing.JMenuItem();
- aboutMenuItem = new javax.swing.JMenuItem();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- setMinimumSize(new java.awt.Dimension(800, 600));
- getContentPane().setLayout(null);
- fileMenu.setText("File");
- openMenuItem.setText("Open");
- fileMenu.add(openMenuItem);
- saveMenuItem.setText("Save");
- fileMenu.add(saveMenuItem);
- saveAsMenuItem.setText("Save As ...");
- fileMenu.add(saveAsMenuItem);
- exitMenuItem.setText("Exit");
- exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- exitMenuItemActionPerformed(evt);
- }
- });
- fileMenu.add(exitMenuItem);
- menuBar.add(fileMenu);
- editMenu.setText("Edit");
- cutMenuItem.setText("Cut");
- editMenu.add(cutMenuItem);
- copyMenuItem.setText("Copy");
- editMenu.add(copyMenuItem);
- pasteMenuItem.setText("Paste");
- editMenu.add(pasteMenuItem);
- deleteMenuItem.setText("Delete");
- editMenu.add(deleteMenuItem);
- menuBar.add(editMenu);
- jMenu1.setText("Patterns");
- jMenuItemUser.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_U,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemUser.setText("user");
- jMenuItemUser.setEnabled(false);
- jMenuItemUser.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemUserActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemUser);
- jMenuItemBook.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_B,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemBook.setText("book");
- jMenuItemBook.setEnabled(false);
- jMenuItemBook.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemBookActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemBook);
- jMenuItemIn.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_I,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemIn.setText("in");
- jMenuItemIn.setEnabled(false);
- jMenuItemIn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemInActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemIn);
- jMenuItemOut.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_O,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemOut.setText("out");
- jMenuItemOut.setEnabled(false);
- jMenuItemOut.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemOutActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemOut);
- jMenuItemStock.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_S,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemStock.setText("stock");
- jMenuItemStock.setEnabled(false);
- jMenuItemStock.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemStockActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemStock);
- jMenuItemLogout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
- java.awt.event.KeyEvent.VK_L,
- java.awt.event.InputEvent.CTRL_MASK));
- jMenuItemLogout.setText("logout");
- jMenuItemLogout.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemLogoutActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItemLogout);
- menuBar.add(jMenu1);
- helpMenu.setText("Help");
- contentsMenuItem.setText("Contents");
- helpMenu.add(contentsMenuItem);
- aboutMenuItem.setText("About");
- helpMenu.add(aboutMenuItem);
- menuBar.add(helpMenu);
- setJMenuBar(menuBar);
- pack();
- }// </editor-fold>
- //GEN-END:initComponents
- private void jMenuItemLogoutActionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItemUser.setEnabled(false);
- jMenuItemBook.setEnabled(false);
- jMenuItemIn.setEnabled(false);
- jMenuItemOut.setEnabled(false);
- jMenuItemStock.setEnabled(false);
- this.setContentPane(new LoginPanel(this));
- this.validate();
- }
- public javax.swing.JMenuItem getjMenuItemBook() {
- return jMenuItemBook;
- }
- public javax.swing.JMenuItem getjMenuItemIn() {
- return jMenuItemIn;
- }
- public javax.swing.JMenuItem getjMenuItemOut() {
- return jMenuItemOut;
- }
- public javax.swing.JMenuItem getjMenuItemStock() {
- return jMenuItemStock;
- }
- public javax.swing.JMenuItem getjMenuItemUser() {
- return jMenuItemUser;
- }
- private void jMenuItemStockActionPerformed(java.awt.event.ActionEvent evt) {
- this.setContentPane(new cn.hncu.stock.ui.ListPanel(this));
- this.validate();
- }
- private void jMenuItemOutActionPerformed(java.awt.event.ActionEvent evt) {
- this.setContentPane(new ListPanel(this));
- this.validate();
- }
- private void jMenuItemInActionPerformed(java.awt.event.ActionEvent evt) {
- this.setContentPane(new cn.hncu.in.ui.ListPanel(this));
- this.validate();
- }
- protected void jMenuItemUserActionPerformed(ActionEvent evt) {
- this.setContentPane(new UserListPanel(this));
- this.validate();
- }
- private void jMenuItemBookActionPerformed(java.awt.event.ActionEvent evt) {
- this.setContentPane(new BookListPanel(this));
- this.validate();
- }
- private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
- System.exit(0);
- }//GEN-LAST:event_exitMenuItemActionPerformed
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new BookStore().setVisible(true);
- }
- });
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JMenuItem aboutMenuItem;
- private javax.swing.JMenuItem contentsMenuItem;
- private javax.swing.JMenuItem copyMenuItem;
- private javax.swing.JMenuItem cutMenuItem;
- private javax.swing.JMenuItem deleteMenuItem;
- private javax.swing.JMenu editMenu;
- private javax.swing.JMenuItem exitMenuItem;
- private javax.swing.JMenu fileMenu;
- private javax.swing.JMenu helpMenu;
- private javax.swing.JMenu jMenu1;
- private javax.swing.JMenuItem jMenuItemBook;
- private javax.swing.JMenuItem jMenuItemIn;
- private javax.swing.JMenuItem jMenuItemLogout;
- private javax.swing.JMenuItem jMenuItemOut;
- private javax.swing.JMenuItem jMenuItemStock;
- private javax.swing.JMenuItem jMenuItemUser;
- private javax.swing.JMenuBar menuBar;
- private javax.swing.JMenuItem openMenuItem;
- private javax.swing.JMenuItem pasteMenuItem;
- private javax.swing.JMenuItem saveAsMenuItem;
- private javax.swing.JMenuItem saveMenuItem;
- // End of variables declaration//GEN-END:variables
- }
数据层:
1、接口
- package cn.hncu.user.dao.dao;
- import java.util.List;
- import cn.hncu.user.vo.UserModel;
- import cn.hncu.user.vo.UserQueryModel;
- /**
- *
- * @author Lenovo
- * 用户模块的数据层接口
- */
- public interface UserDAO {
- public boolean create(UserModel user);
- public boolean delete(String uuid);
- public boolean upDate(UserModel user);
- public UserModel getSingle(String uuid);
- public List<UserModel> getAll();
- public List<UserModel> getByCondition(UserQueryModel uqm);
- }
- package cn.hncu.user.dao.impl;
- import java.util.ArrayList;
- import java.util.List;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.dao.dao.UserDAO;
- import cn.hncu.utils.FileIo;
- import cn.hncu.user.vo.UserModel;
- import cn.hncu.user.vo.UserQueryModel;
- public class UserDAOImpl implements UserDAO {
- private static final String FILE_NAME="user.txt";
- @Override
- public boolean create(UserModel user) {
- List<UserModel> list=FileIo.read(FILE_NAME);
- for (UserModel u:list){
- if (u.getUuid().equals(user.getUuid())){
- return false;
- }
- }
- list.add(user);
- FileIo.write(list, FILE_NAME);
- return true;
- }
- @Override
- public boolean delete(String uuid) {
- List<UserModel> list=FileIo.read(FILE_NAME);
- for (int i=0;i<list.size();i++){
- if (list.get(i).getUuid().equals(uuid)){
- list.remove(i);
- FileIo.write(list, FILE_NAME);
- return true;
- }
- }
- //该用户不存在
- return false;
- }
- @Override
- public List<UserModel> getAll() {
- List<UserModel> list=FileIo.read(FILE_NAME);
- return list;
- }
- @Override
- public List<UserModel> getByCondition(UserQueryModel uqm) {
- List<UserModel> list=getAll();
- List<UserModel> results=new ArrayList<UserModel>();
- for (UserModel user:list){
- //反逻辑,卫条件: 外层判断用户输入是否是查询条件;内层判断该对象是否符合查询条件
- if (uqm.getUuid()!=null&&uqm.getUuid().trim().length()>0){
- if (!uqm.getUuid().equals(user.getUuid())){
- continue;
- }
- }
- if (uqm.getName()!=null&&uqm.getName().trim().length()>0){
- if (user.getName().indexOf(uqm.getName())==-1){
- continue;
- }
- }
- if (uqm.getType()>0){
- if (uqm.getType()!=user.getType()){
- continue;
- }
- }
- results.add(user);
- }
- return results;
- }
- @Override
- public UserModel getSingle(String uuid) {
- List<UserModel> list=FileIo.read(FILE_NAME);
- for (UserModel u:list){
- if (u.getUuid().equals(uuid)){
- return u;
- }
- }
- //不存在该uuid对应的用户,返回空
- return null;
- }
- @Override
- public boolean upDate(UserModel user) {
- List<UserModel> list=FileIo.read(FILE_NAME);
- for (int i=0;i<list.size();i++){
- if (list.get(i).getUuid().equals(user.getUuid())){
- list.set(i, user);
- FileIo.write(list, FILE_NAME);
- return true;
- }
- }
- //不存在该用户,修改失败
- return false;
- }
- }
- package cn.hncu.user.dao.factory;
- import cn.hncu.user.dao.dao.UserDAO;
- import cn.hncu.user.dao.impl.UserDAOImpl;
- public class UserDAOFactory {
- public static UserDAO getUserDAO(){
- return new UserDAOImpl();
- }
- }
业务逻辑层:
1、接口
- package cn.hncu.user.business.ebi;
- import java.util.List;
- import cn.hncu.user.vo.UserModel;
- import cn.hncu.user.vo.UserQueryModel;
- public interface UserEbi {
- public boolean create(UserModel user);
- public boolean delete(String uuid);
- public boolean upDate(UserModel user);
- public UserModel getSingle(String uuid);
- public List<UserModel> getAll();
- public List<UserModel> getByCondition(UserQueryModel uqm);
- //此处可以在做到其他模块需要添加功能时来添加方法
- public List<UserModel> getAllIn();
- public UserModel getUserByName(String name);
- public List<UserModel> getAllOut();
- }
- package cn.hncu.user.business.ebo;
- import java.util.List;
- import cn.hncu.common.UserTypeEnum;
- import cn.hncu.common.UuidModelConstance;
- import cn.hncu.common.uuid.dao.factory.UuidDAOFactory;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.dao.dao.UserDAO;
- import cn.hncu.user.dao.factory.UserDAOFactory;
- import cn.hncu.user.vo.UserModel;
- import cn.hncu.user.vo.UserQueryModel;
- public class UserEbo implements UserEbi {
- UserDAO dao=UserDAOFactory.getUserDAO();
- @Override
- public boolean create(UserModel user) {
- String uuid=UuidDAOFactory.getUuidDAO().getNextUuid(UuidModelConstance.USER);
- user.setUuid(uuid);
- return dao.create(user);
- }
- @Override
- public boolean delete(String uuid) {
- return dao.delete(uuid);
- }
- @Override
- public List<UserModel> getAll() {
- return dao.getAll();
- }
- @Override
- public List<UserModel> getByCondition(UserQueryModel uqm) {
- return dao.getByCondition(uqm);
- }
- @Override
- public UserModel getSingle(String uuid) {
- return dao.getSingle(uuid);
- }
- @Override
- public boolean upDate(UserModel user) {
- return dao.upDate(user);
- }
- @Override
- public List<UserModel> getAllIn() {
- UserQueryModel uqm=new UserQueryModel();
- uqm.setType(UserTypeEnum.IN.getType());
- return getByCondition(uqm);
- }
- @Override
- public UserModel getUserByName(String name) {
- List<UserModel> list=getAll();
- for (UserModel user:list){
- if (user.getName().equals(name)){
- return user;
- }
- }
- return null;
- }
- @Override
- public List<UserModel> getAllOut() {
- UserQueryModel uqm=new UserQueryModel();
- uqm.setType(UserTypeEnum.OUT.getType());
- return getByCondition(uqm);
- }
- }
- package cn.hncu.user.business.factory;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.ebo.UserEbo;
- public class UserEbiFactory {
- public static UserEbi getUserEbi(){
- return new UserEbo();
- }
- }
用户类:
- package cn.hncu.user.vo;
- import java.io.Serializable;
- import cn.hncu.common.UserTypeEnum;
- public class UserModel implements Serializable{
- private String uuid;
- private String name;
- private int type;
- private String pwd;
- public UserModel() {
- super();
- }
- public String getUuid() {
- return uuid;
- }
- public void setUuid(String uuid) {
- this.uuid = uuid;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public int getType() {
- return type;
- }
- public void setType(int type) {
- this.type = type;
- }
- public String getPwd() {
- return pwd;
- }
- public void setPwd(String pwd) {
- this.pwd = pwd;
- }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- UserModel other = (UserModel) obj;
- if (uuid == null) {
- if (other.uuid != null)
- return false;
- } else if (!uuid.equals(other.uuid))
- return false;
- return true;
- }
- @Override
- public String toString() {
- return uuid+","+name+","+UserTypeEnum.getNameByType(type);
- }
- }
- package cn.hncu.user.vo;
- public class UserQueryModel extends UserModel{
- }
表现层:
用户列表:
- /*
- * ListPanel.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu.user.ui;
- import java.util.List;
- import javax.swing.Icon;
- import javax.swing.ImageIcon;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.vo.UserModel;
- /**
- *
- * @author __USER__
- */
- public class UserListPanel extends javax.swing.JPanel {
- private final String dir = "./Images/";
- private JFrame mainFrame = null;
- /** Creates new form ListPanel */
- public UserListPanel(JFrame mainFrame) {
- this.mainFrame = mainFrame;
- this.setOpaque(false);
- initComponents();
- myInit();
- // setBack();
- }
- public UserListPanel(JFrame mainFrame, List<UserModel> list) {
- this.mainFrame = mainFrame;
- initComponents();
- userList.setListData(list.toArray());
- }
- private void myInit() {
- UserEbi ebi = UserEbiFactory.getUserEbi();
- List<UserModel> list = ebi.getAll();
- userList.setListData(list.toArray());
- }
- // private void setBack() {
- // //把当前JFrame的内容窗格设成透明,这样放在其中的组件就能够显示出背景
- // ((JPanel)(this.getContentPane())).setOpaque(false);//1
- //
- // Icon bgImage = new ImageIcon(dir+"bg.png");//路径从项目根目录
- // //Icon bgImage = new ImageIcon(dir+"a.gif");//显示gif动态图也可以
- // JLabel bgLabel = new JLabel(bgImage);
- // //根据给的整数值决定在上层还是下层显示,数值越小显示在越下面的位置
- // this.getLayeredPane().add(bgLabel, new Integer(Integer.MIN_VALUE));//2
- // bgLabel.setBounds(0, 0, bgImage.getIconWidth(), bgImage.getIconHeight());//3
- // this.add(bgLabel);
- //
- // //以下是测试,看看上面的图片是不是能够显示成背景
- JButton btn = new JButton("OK");
- this.getLayeredPane().add(btn);
- btn.setBounds(100, 100, 80, 50);
- // }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- userList = new javax.swing.JList();
- queryBtn = new javax.swing.JButton();
- addBtn = new javax.swing.JButton();
- deleteBtn = new javax.swing.JButton();
- btnUpdate = new javax.swing.JButton();
- setLayout(null);
- jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24));
- jLabel1.setForeground(new java.awt.Color(102, 255, 102));
- jLabel1.setText("\u7528\u6237\u5217\u8868");
- add(jLabel1);
- jLabel1.setBounds(340, 40, 150, 70);
- userList.setModel(new javax.swing.AbstractListModel() {
- String[] strings = { "" };
- public int getSize() {
- return strings.length;
- }
- public Object getElementAt(int i) {
- return strings[i];
- }
- });
- jScrollPane1.setViewportView(userList);
- add(jScrollPane1);
- jScrollPane1.setBounds(240, 110, 300, 170);
- queryBtn.setText("\u67e5\u8be2");
- queryBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- queryBtnActionPerformed(evt);
- }
- });
- add(queryBtn);
- queryBtn.setBounds(530, 330, 63, 29);
- addBtn.setText("\u6dfb\u52a0");
- addBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- addBtnActionPerformed(evt);
- }
- });
- add(addBtn);
- addBtn.setBounds(190, 330, 63, 29);
- deleteBtn.setText("\u5220\u9664");
- deleteBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- deleteBtnActionPerformed(evt);
- }
- });
- add(deleteBtn);
- deleteBtn.setBounds(310, 330, 63, 29);
- btnUpdate.setText("\u4fee\u6539");
- btnUpdate.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnUpdateActionPerformed(evt);
- }
- });
- add(btnUpdate);
- btnUpdate.setBounds(420, 330, 63, 29);
- }// </editor-fold>
- //GEN-END:initComponents
- private void queryBtnActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new QueryPanel(mainFrame));
- mainFrame.validate();
- }
- private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
- UserModel user = (UserModel) userList.getSelectedValue();
- if (user == null) {
- JOptionPane.showMessageDialog(null, "请选择要修改的用户!");
- return;
- }
- String uuid = user.getUuid();
- mainFrame.setContentPane(new upDatePanel(mainFrame, uuid));
- mainFrame.validate();
- }
- private void deleteBtnActionPerformed(java.awt.event.ActionEvent evt) {
- UserModel user = (UserModel) userList.getSelectedValue();
- if (user == null) {
- JOptionPane.showMessageDialog(null, "请选择要删除的用户!");
- return;
- }
- String uuid = user.getUuid();
- mainFrame.setContentPane(new deletePanel(mainFrame, uuid));
- mainFrame.validate();
- }
- private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new AddPanel(mainFrame));
- mainFrame.validate();
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JButton addBtn;
- private javax.swing.JButton btnUpdate;
- private javax.swing.JButton deleteBtn;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JButton queryBtn;
- private javax.swing.JList userList;
- // End of variables declaration//GEN-END:variables
- }
- /*
- * AddPanel.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu.user.ui;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import cn.hncu.common.UserTypeEnum;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.vo.UserModel;
- /**
- *
- * @author __USER__
- */
- public class AddPanel extends javax.swing.JPanel {
- private JFrame mainFrame = null;
- /** Creates new form AddPanel */
- public AddPanel(JFrame mainFrame) {
- this.mainFrame = mainFrame;
- this.setOpaque(false);
- initComponents();
- myInit();
- }
- private void myInit() {
- for (UserTypeEnum type : UserTypeEnum.values()) {
- CombType.addItem(type.getName());
- }
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabelType = new javax.swing.JLabel();
- jLabelName = new javax.swing.JLabel();
- tfdName = new javax.swing.JTextField();
- CombType = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- Pwd1 = new javax.swing.JPasswordField();
- Pwd2 = new javax.swing.JPasswordField();
- btnAdd = new javax.swing.JButton();
- btnBack = new javax.swing.JButton();
- setLayout(null);
- jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24));
- jLabel1.setForeground(new java.awt.Color(102, 255, 102));
- jLabel1.setText("\u6dfb\u52a0\u7528\u6237");
- add(jLabel1);
- jLabel1.setBounds(300, 20, 140, 70);
- jLabelType.setForeground(new java.awt.Color(102, 255, 102));
- jLabelType.setText("\u7528\u6237\u7c7b\u578b\uff1a");
- add(jLabelType);
- jLabelType.setBounds(150, 180, 110, 30);
- jLabelName.setForeground(new java.awt.Color(102, 255, 102));
- jLabelName.setText("\u59d3\u540d\uff1a");
- add(jLabelName);
- jLabelName.setBounds(180, 130, 70, 30);
- add(tfdName);
- tfdName.setBounds(250, 130, 100, 26);
- CombType.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "请选择..." }));
- add(CombType);
- CombType.setBounds(250, 180, 170, 30);
- jLabel2.setForeground(new java.awt.Color(102, 255, 102));
- jLabel2.setText("\u5bc6\u7801\uff1a");
- add(jLabel2);
- jLabel2.setBounds(180, 240, 45, 20);
- jLabel3.setForeground(new java.awt.Color(102, 255, 102));
- jLabel3.setText("\u786e\u8ba4\u5bc6\u7801\uff1a");
- add(jLabel3);
- jLabel3.setBounds(150, 290, 100, 30);
- add(Pwd1);
- Pwd1.setBounds(250, 240, 230, 24);
- add(Pwd2);
- Pwd2.setBounds(250, 290, 230, 24);
- btnAdd.setText("\u6dfb\u52a0");
- btnAdd.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnAddActionPerformed(evt);
- }
- });
- add(btnAdd);
- btnAdd.setBounds(260, 370, 63, 29);
- btnBack.setText("\u8fd4\u56de");
- btnBack.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnBackActionPerformed(evt);
- }
- });
- add(btnBack);
- btnBack.setBounds(450, 370, 63, 29);
- }// </editor-fold>
- //GEN-END:initComponents
- private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- }
- private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {
- //收集参数
- // String uuid = tfdUuid.getText();
- String name = tfdName.getText();
- String pwd1 = new String(Pwd1.getPassword());
- String pwd2 = new String(Pwd2.getPassword());
- if (!pwd1.equals(pwd2)) {
- JOptionPane.showMessageDialog(null, "两次密码不一致,请重新输入!");
- return;
- }
- int type = 0;
- try {
- type = UserTypeEnum.getTypeByName(CombType.getSelectedItem()
- .toString());
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "请指定用户类型");
- return;
- }
- //组织参数
- UserModel user = new UserModel();
- user.setName(name);
- user.setPwd(pwd1);
- user.setType(type);
- // user.setUuid(uuid);
- //调用逻辑层
- UserEbi ebi = UserEbiFactory.getUserEbi();
- if (ebi.create(user)) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- } else {
- JOptionPane.showMessageDialog(null, "该用户已存在!");
- }
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JComboBox CombType;
- private javax.swing.JPasswordField Pwd1;
- private javax.swing.JPasswordField Pwd2;
- private javax.swing.JButton btnAdd;
- private javax.swing.JButton btnBack;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabelName;
- private javax.swing.JLabel jLabelType;
- private javax.swing.JTextField tfdName;
- // End of variables declaration//GEN-END:variables
- }
- /*
- * deletePanel.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu.user.ui;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import cn.hncu.common.UserTypeEnum;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.vo.UserModel;
- /**
- *
- * @author __USER__
- */
- public class deletePanel extends javax.swing.JPanel {
- private JFrame mainFrame = null;
- private String uuid = null;
- /** Creates new form deletePanel */
- public deletePanel(JFrame mainFrame, String uuid) {
- this.mainFrame = mainFrame;
- this.uuid = uuid;
- this.setOpaque(false);
- initComponents();
- myInit();
- }
- private void myInit() {
- UserEbi ebi = UserEbiFactory.getUserEbi();
- UserModel user = new UserModel();
- user = ebi.getSingle(uuid);
- tfdUuid.setText(uuid);
- tfdUuid.setEditable(false);
- tfdName.setText(user.getName());
- tfdName.setEditable(false);
- tfdType.setText(UserTypeEnum.getNameByType(user.getType()));
- tfdType.setEditable(false);
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabelType = new javax.swing.JLabel();
- jLabelName = new javax.swing.JLabel();
- tfdName = new javax.swing.JTextField();
- jLabel4 = new javax.swing.JLabel();
- tfdUuid = new javax.swing.JTextField();
- tfdType = new javax.swing.JTextField();
- btnDelete = new javax.swing.JButton();
- btnBack = new javax.swing.JButton();
- setLayout(null);
- jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24));
- jLabel1.setForeground(new java.awt.Color(102, 255, 102));
- jLabel1.setText("\u5220\u9664\u7528\u6237...");
- add(jLabel1);
- jLabel1.setBounds(290, 20, 160, 80);
- jLabelType.setForeground(new java.awt.Color(102, 255, 102));
- jLabelType.setText("\u7528\u6237\u7c7b\u578b\uff1a");
- add(jLabelType);
- jLabelType.setBounds(110, 230, 110, 30);
- jLabelName.setForeground(new java.awt.Color(102, 255, 102));
- jLabelName.setText("\u59d3\u540d\uff1a");
- add(jLabelName);
- jLabelName.setBounds(140, 180, 70, 30);
- add(tfdName);
- tfdName.setBounds(210, 180, 100, 26);
- jLabel4.setForeground(new java.awt.Color(102, 255, 102));
- jLabel4.setText("uuid\uff1a");
- add(jLabel4);
- jLabel4.setBounds(140, 140, 52, 20);
- add(tfdUuid);
- tfdUuid.setBounds(210, 140, 100, 26);
- add(tfdType);
- tfdType.setBounds(210, 230, 160, 26);
- btnDelete.setText("\u5220\u9664");
- btnDelete.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnDeleteActionPerformed(evt);
- }
- });
- add(btnDelete);
- btnDelete.setBounds(160, 360, 63, 29);
- btnBack.setText("\u8fd4\u56de");
- btnBack.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnBackActionPerformed(evt);
- }
- });
- add(btnBack);
- btnBack.setBounds(370, 360, 63, 29);
- }// </editor-fold>
- //GEN-END:initComponents
- private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- }
- private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {
- UserEbi ebi = UserEbiFactory.getUserEbi();
- if (ebi.delete(uuid)) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- } else {
- JOptionPane.showMessageDialog(null, "该用户不存在");
- }
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JButton btnBack;
- private javax.swing.JButton btnDelete;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabelName;
- private javax.swing.JLabel jLabelType;
- private javax.swing.JTextField tfdName;
- private javax.swing.JTextField tfdType;
- private javax.swing.JTextField tfdUuid;
- // End of variables declaration//GEN-END:variables
- }
- /*
- * upDatePanel.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu.user.ui;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import cn.hncu.common.UserTypeEnum;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.vo.UserModel;
- /**
- *
- * @author __USER__
- */
- public class upDatePanel extends javax.swing.JPanel {
- private JFrame mainFrame = null;
- private String uuid = null;
- /** Creates new form upDatePanel */
- public upDatePanel(JFrame mainFrame, String uuid) {
- this.mainFrame = mainFrame;
- this.uuid = uuid;
- this.setOpaque(false);
- initComponents();
- myInit();
- }
- private void myInit() {
- UserEbi ebi = UserEbiFactory.getUserEbi();
- UserModel user = ebi.getSingle(uuid);
- user = ebi.getSingle(uuid);
- tfdUuid.setText(uuid);
- tfdUuid.setEditable(false);
- tfdName.setText(user.getName());
- Pwd1.setText(user.getPwd());
- Pwd2.setText(user.getPwd());
- combType.removeAllItems();
- combType.addItem(UserTypeEnum.getNameByType(user.getType()));
- for (UserTypeEnum u : UserTypeEnum.values()) {
- if (u.getType() != user.getType()) {
- combType.addItem(u.getName());
- }
- }
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabelType = new javax.swing.JLabel();
- jLabelName = new javax.swing.JLabel();
- tfdName = new javax.swing.JTextField();
- jLabel = new javax.swing.JLabel();
- Pwd1 = new javax.swing.JPasswordField();
- jLabel4 = new javax.swing.JLabel();
- tfdUuid = new javax.swing.JTextField();
- btnUpDate = new javax.swing.JButton();
- btnBack = new javax.swing.JButton();
- combType = new javax.swing.JComboBox();
- jLabel2 = new javax.swing.JLabel();
- Pwd2 = new javax.swing.JPasswordField();
- setForeground(new java.awt.Color(102, 255, 102));
- setLayout(null);
- jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24));
- jLabel1.setForeground(new java.awt.Color(102, 255, 102));
- jLabel1.setText("\u4fee\u6539\u7528\u6237...");
- add(jLabel1);
- jLabel1.setBounds(260, 20, 160, 80);
- jLabelType.setForeground(new java.awt.Color(102, 255, 102));
- jLabelType.setText("\u7528\u6237\u7c7b\u578b\uff1a");
- add(jLabelType);
- jLabelType.setBounds(80, 180, 110, 30);
- jLabelName.setForeground(new java.awt.Color(102, 255, 102));
- jLabelName.setText("\u59d3\u540d\uff1a");
- add(jLabelName);
- jLabelName.setBounds(110, 130, 70, 30);
- add(tfdName);
- tfdName.setBounds(180, 130, 100, 26);
- jLabel.setForeground(new java.awt.Color(102, 255, 102));
- jLabel.setText("\u5bc6\u7801\uff1a");
- add(jLabel);
- jLabel.setBounds(110, 230, 45, 20);
- add(Pwd1);
- Pwd1.setBounds(180, 230, 230, 24);
- jLabel4.setForeground(new java.awt.Color(102, 255, 102));
- jLabel4.setText("uuid\uff1a");
- add(jLabel4);
- jLabel4.setBounds(110, 90, 52, 20);
- add(tfdUuid);
- tfdUuid.setBounds(180, 90, 100, 26);
- btnUpDate.setText("\u4fee\u6539");
- btnUpDate.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnUpDateActionPerformed(evt);
- }
- });
- add(btnUpDate);
- btnUpDate.setBounds(160, 360, 63, 29);
- btnBack.setText("\u8fd4\u56de");
- btnBack.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnBackActionPerformed(evt);
- }
- });
- add(btnBack);
- btnBack.setBounds(370, 360, 63, 29);
- combType.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "请选择" }));
- add(combType);
- combType.setBounds(180, 180, 200, 26);
- jLabel2.setForeground(new java.awt.Color(102, 255, 102));
- jLabel2.setText("\u786e\u8ba4\u5bc6\u7801\uff1a");
- add(jLabel2);
- jLabel2.setBounds(80, 270, 90, 20);
- add(Pwd2);
- Pwd2.setBounds(180, 270, 230, 24);
- }// </editor-fold>
- //GEN-END:initComponents
- private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- }
- private void btnUpDateActionPerformed(java.awt.event.ActionEvent evt) {
- //收集参数
- String uuid = tfdUuid.getText();
- String name = tfdName.getText();
- String pwd1 = new String(Pwd1.getPassword());
- String pwd2 = new String(Pwd2.getPassword());
- if (!pwd1.equals(pwd2)) {
- JOptionPane.showMessageDialog(null, "两次密码不一致,请重新输入!");
- return;
- }
- int type = 0;
- try {
- type = UserTypeEnum.getTypeByName(combType.getSelectedItem()
- .toString());
- } catch (Exception e) {
- JOptionPane.showMessageDialog(null, "请指定用户类型");
- return;
- }
- //组织参数
- UserModel user = new UserModel();
- user.setName(name);
- user.setPwd(pwd1);
- user.setType(type);
- user.setUuid(uuid);
- //调用逻辑层
- UserEbi ebi = UserEbiFactory.getUserEbi();
- if (ebi.upDate(user)) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- } else {
- JOptionPane.showMessageDialog(null, "该用户已不存在");
- }
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JPasswordField Pwd1;
- private javax.swing.JPasswordField Pwd2;
- private javax.swing.JButton btnBack;
- private javax.swing.JButton btnUpDate;
- private javax.swing.JComboBox combType;
- private javax.swing.JLabel jLabel;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabelName;
- private javax.swing.JLabel jLabelType;
- private javax.swing.JTextField tfdName;
- private javax.swing.JTextField tfdUuid;
- // End of variables declaration//GEN-END:variables
- }
- /*
- * QueryPanel.java
- *
- * Created on __DATE__, __TIME__
- */
- package cn.hncu.user.ui;
- import java.awt.event.ActionEvent;
- import java.util.List;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import cn.hncu.common.UserTypeEnum;
- import cn.hncu.user.business.ebi.UserEbi;
- import cn.hncu.user.business.factory.UserEbiFactory;
- import cn.hncu.user.vo.UserModel;
- import cn.hncu.user.vo.UserQueryModel;
- /**
- *
- * @author __USER__
- */
- public class QueryPanel extends javax.swing.JPanel {
- private JFrame mainFrame = null;
- /** Creates new form QueryPanel */
- public QueryPanel(JFrame mainFrame) {
- this.mainFrame = mainFrame;
- this.setOpaque(false);
- initComponents();
- MyInit();
- }
- private void MyInit() {
- for (UserTypeEnum user : UserTypeEnum.values()) {
- CombType.addItem(user.getName());
- }
- }
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- //GEN-BEGIN:initComponents
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- jLabelName = new javax.swing.JLabel();
- tfdName = new javax.swing.JTextField();
- btnQuery = new javax.swing.JButton();
- btnBack = new javax.swing.JButton();
- jLabel4 = new javax.swing.JLabel();
- tfdUuid = new javax.swing.JTextField();
- jLabel2 = new javax.swing.JLabel();
- CombType = new javax.swing.JComboBox();
- setLayout(null);
- jLabel1.setFont(new java.awt.Font("Microsoft YaHei UI", 1, 24));
- jLabel1.setForeground(new java.awt.Color(102, 255, 102));
- jLabel1.setText("\u67e5\u8be2\u7528\u6237");
- add(jLabel1);
- jLabel1.setBounds(280, 10, 140, 70);
- jLabelName.setForeground(new java.awt.Color(102, 255, 102));
- jLabelName.setText("\u59d3\u540d\uff1a");
- add(jLabelName);
- jLabelName.setBounds(380, 100, 70, 30);
- add(tfdName);
- tfdName.setBounds(450, 100, 100, 30);
- btnQuery.setText("\u67e5\u8be2");
- btnQuery.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnQueryActionPerformed(evt);
- }
- });
- add(btnQuery);
- btnQuery.setBounds(230, 310, 63, 30);
- btnBack.setText("\u8fd4\u56de");
- btnBack.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnBackActionPerformed(evt);
- }
- });
- add(btnBack);
- btnBack.setBounds(410, 310, 63, 30);
- jLabel4.setForeground(new java.awt.Color(102, 255, 102));
- jLabel4.setText("uuid\uff1a");
- add(jLabel4);
- jLabel4.setBounds(110, 100, 52, 20);
- add(tfdUuid);
- tfdUuid.setBounds(180, 100, 100, 30);
- jLabel2.setForeground(new java.awt.Color(102, 255, 102));
- jLabel2.setText("\u7528\u6237\u7c7b\u578b\uff1a");
- add(jLabel2);
- jLabel2.setBounds(80, 200, 100, 40);
- CombType.setModel(new javax.swing.DefaultComboBoxModel(
- new String[] { "请选择..." }));
- add(CombType);
- CombType.setBounds(180, 210, 190, 26);
- }// </editor-fold>
- //GEN-END:initComponents
- protected void btnQueryActionPerformed(ActionEvent evt) {
- //1收集参数
- String uuid = tfdUuid.getText();
- String name = tfdName.getText();
- int type = 0;
- if (CombType.getSelectedIndex() > 0) {
- type = UserTypeEnum.getTypeByName(CombType.getSelectedItem()
- .toString());
- }
- //2组织参数
- UserQueryModel uqm = new UserQueryModel();
- uqm.setUuid(uuid);
- uqm.setName(name);
- uqm.setType(type);
- //3调用逻辑层
- UserEbi ebi = UserEbiFactory.getUserEbi();
- List<UserModel> results = ebi.getByCondition(uqm);
- //4返回到不同的结果页面
- mainFrame.setContentPane(new UserListPanel(mainFrame, results));
- mainFrame.validate();
- }
- private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
- mainFrame.setContentPane(new UserListPanel(mainFrame));
- mainFrame.validate();
- }
- private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {
- //收集参数
- String uuid = tfdUuid.getText();
- String name = tfdName.getText();
- int type = 0;
- if (CombType.getSelectedIndex() > 0) {
- type = UserTypeEnum.getTypeByName(CombType.getSelectedItem()
- .toString());
- }
- //组织参数
- UserQueryModel uqm = new UserQueryModel();
- uqm.setName(name);
- uqm.setType(type);
- uqm.setUuid(uuid);
- //调用逻辑层
- UserEbi ebi = UserEbiFactory.getUserEbi();
- List<UserModel> list = ebi.getByCondition(uqm);
- mainFrame.setContentPane(new UserListPanel(mainFrame, list));
- mainFrame.validate();
- }
- //GEN-BEGIN:variables
- // Variables declaration - do not modify
- private javax.swing.JComboBox CombType;
- private javax.swing.JButton btnBack;
- private javax.swing.JButton btnQuery;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabelName;
- private javax.swing.JTextField tfdName;
- private javax.swing.JTextField tfdUuid;
- // End of variables declaration//GEN-END:variables
- }