Eclipse+Java+Swing实现学生宿舍管理系统(下)

简介: Eclipse+Java+Swing实现学生宿舍管理系统

MainFrm2.java

package com.sjsq.view;
import javax.swing.JDesktopPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
/**
 * 
 * 学生主页面
 * 
 * @author shuijianshiqing
 *
 * @date 2020-09-01 07:52
 *
 */
public class MainFrm2 extends javax.swing.JFrame {
  private JMenu jMenu1;
  private JMenu jMenu3;
  private JMenu jMenu2;
  private JMenuBar jMenuBar1;
  private JMenuItem jMenuItem1;
  private JMenuItem jMenuItem2;
  private JMenuItem jMenuItem3;
  private JMenuItem jMenuItem4;
  private JMenuItem jMenuItem5;
  private JMenuItem jMenuItem6;
  private JDesktopPane table;
  /**
   * 创建窗体
   */
  public MainFrm2() {
    initComponents();
    // 设置位置
    setBounds(100, 200, 1050, 650);
    // 居中显示
    this.setLocationRelativeTo(null);
  }
  /**
   * 初始化窗体
   */
  private void initComponents() {
    table = new JDesktopPane();
    jMenuBar1 = new JMenuBar();
    jMenu1 = new JMenu();
    jMenuItem2 = new JMenuItem();
    jMenuItem3 = new JMenuItem();
    jMenu2 = new JMenu();
    jMenuItem1 = new JMenuItem();
    jMenuItem4 = new JMenuItem();
    jMenu3 = new JMenu();
    jMenuItem5 = new JMenuItem();
    jMenuItem6 = new JMenuItem();
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("学生信息管理学生页面");
    // 设置导航栏
    jMenu1.setText("学生入住");
    jMenuItem2.setText("办理入住");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem2ActionPerformed(evt);
      }
    });
    jMenu1.add(jMenuItem2);
    jMenuItem3.setText("信息修改");
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem3ActionPerformed(evt);
      }
    });
    jMenu1.add(jMenuItem3);
    jMenuBar1.add(jMenu1);
    jMenu2.setText("信息查询");
    jMenuItem1.setText("寝室查询");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem1ActionPerformed(evt);
      }
    });
    jMenu2.add(jMenuItem1);
    jMenuItem4.setText("人员查询");
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem4ActionPerformed(evt);
      }
    });
    jMenu2.add(jMenuItem4);
    jMenuBar1.add(jMenu2);
    jMenu3.setText("帮助服务");
    jMenuItem5.setText("关于系统");
    jMenu3.add(jMenuItem5);
    jMenuItem6.setText("退出系统");
    jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jMenuItem6ActionPerformed(evt);
      }
    });
    jMenu3.add(jMenuItem6);
    jMenuBar1.add(jMenu3);
    setJMenuBar(jMenuBar1);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(table, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(table, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE));
    pack();
  }
  // 事件监控
  private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {
    int a = JOptionPane.showConfirmDialog(null, "确定要退出?");
    if (a == 0) {
      this.dispose();
    }
  }
  private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
    RoomSearchInterFrm roomSearch = new RoomSearchInterFrm();
    roomSearch.setVisible(true);
    this.table.add(roomSearch);
  }
  private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {
    StudentSearchInterFrm StudentSearch = new StudentSearchInterFrm();
    StudentSearch.setVisible(true);
    this.table.add(StudentSearch);
  }
  private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
    StudentModifyInterFrm StudentModify = new StudentModifyInterFrm();
    StudentModify.setVisible(true);
    this.table.add(StudentModify);
  }
  private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
    StudentAddInterFrm Student = new StudentAddInterFrm();
    Student.setVisible(true);
    this.table.add(Student);
  }
  // 主函数
  public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        new MainFrm2().setVisible(true);
      }
    });
  }
}

RoomAddInterFrm.java

package com.sjsq.view;
import java.sql.Connection;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import com.sjsq.dao.RoomDao;
import com.sjsq.model.Room;
import com.sjsq.util.DMUtil;
/**
 * 
 * 房间信息添加
 * 
 * @author shuijianshiqing
 *
 * @date 2020-09-01 20:51
 *
 */
public class RoomAddInterFrm extends javax.swing.JInternalFrame {
  private JTextField dm_leader;
  private JTextField dm_number;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JButton jb_add;
  private JButton jb_reset;
  DMUtil dmutil = new DMUtil();
  RoomDao roomdao = new RoomDao();
  public RoomAddInterFrm() {
    initComponents();
    this.setLocation(200, 50);
  }
  private void initComponents() {
    jLabel1 = new JLabel();
    dm_number = new JTextField();
    jLabel2 = new JLabel();
    dm_leader = new JTextField();
    jb_add = new JButton();
    jb_reset = new JButton();
    jLabel3 = new JLabel();
    setClosable(true);
    setIconifiable(true);
    setTitle("宿舍添加");
    jLabel1.setText("宿舍号:");
    jLabel2.setText("寝室长:");
    jb_add.setText("添加");
    jb_add.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_addActionPerformed(evt);
      }
    });
    jb_reset.setText("重置");
    jb_reset.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_resetActionPerformed(evt);
      }
    });
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup().addGap(150, 150, 150)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dm_leader, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup().addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dm_number, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                layout.createSequentialGroup().addComponent(jb_add).addGap(18, 18, 18)
                    .addComponent(jb_reset)))
        .addGap(4, 4, 4).addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 170,
            javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(25, 25, 25)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING).addGroup(layout
            .createSequentialGroup().addGap(29, 29, 29)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1).addComponent(dm_number, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(70, 70, 70)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2).addComponent(dm_leader, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 91, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jb_reset).addComponent(jb_add)))
            .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                layout.createSequentialGroup().addGap(27, 27, 27).addComponent(jLabel3,
                    javax.swing.GroupLayout.PREFERRED_SIZE, 222,
                    javax.swing.GroupLayout.PREFERRED_SIZE)))
        .addContainerGap(40, Short.MAX_VALUE)));
    pack();
  }
  private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {
    String name = dm_number.getText();
    String leader = dm_leader.getText();
    Room room = new Room(name, leader);
    Connection con = null;
    try {
      con = dmutil.getCon();
      int a = roomdao.roomAdd(con, room);
      if (a == 1) {
        JOptionPane.showMessageDialog(null, "添加成功!");
        this.resetValue();
      } else {
        JOptionPane.showMessageDialog(null, "添加失败!");
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "添加失败!");
      e.printStackTrace();
    } finally {
      try {
        dmutil.closeCon(con);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  private void resetValue() {
    this.dm_leader.setText("");
    this.dm_number.setText("");
  }
  private void jb_resetActionPerformed(java.awt.event.ActionEvent evt) {
    this.dm_number.setText("");
    this.dm_leader.setText("");
  }
}

RoomDeleteInterFrm.java

package com.sjsq.view;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import com.sjsq.dao.RoomDao;
import com.sjsq.model.Room;
import com.sjsq.util.DMUtil;
import com.sjsq.util.StringUtil;
/**
 * 
 * 删除房间信息
 * 
 * @author shuijianshiqing
 *
 * @date 2020-09-01 20:40
 *
 */
public class RoomDeleteInterFrm extends javax.swing.JInternalFrame {
  // 定义变量
  private JLabel jLabel1;
  private JScrollPane jScrollPane1;
  private JButton jb_delete;
  private JButton jb_exit;
  private JButton jb_search;
  private JTextField roomNum;
  private JTable table;
  DMUtil dmutil = new DMUtil();
  RoomDao roomdao = new RoomDao();
  // 构造函数
  public RoomDeleteInterFrm() {
    initComponents();
    this.setLocation(200, 50);
    this.fillTable(new Room());
  }
  // 填充表格
  private void fillTable(Room room) {
    DefaultTableModel dtm = (DefaultTableModel) table.getModel();
    dtm.setRowCount(0);
    Connection con = null;
    try {
      con = dmutil.getCon();
      ResultSet rs = roomdao.roomList(con, room);
      while (rs.next()) {
        Vector v = new Vector();
        v.add(rs.getString("id"));
        v.add(rs.getString("member"));
        v.add(rs.getString("leader"));
        dtm.addRow(v);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        dmutil.closeCon(con);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  // 初始化
  private void initComponents() {
    jLabel1 = new JLabel();
    roomNum = new JTextField();
    jb_search = new JButton();
    jScrollPane1 = new JScrollPane();
    table = new JTable();
    jb_delete = new JButton();
    jb_exit = new JButton();
    setClosable(true);
    setIconifiable(true);
    setTitle("房间删除");
    jLabel1.setText("房间号:");
    jb_search.setText("查询");
    jb_search.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_searchActionPerformed(evt);
      }
    });
    table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {
    }, new String[] { "编号", "寝室号 ", "寝室长" }) {
      boolean[] canEdit = new boolean[] { false, false, false };
      public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit[columnIndex];
      }
    });
    jScrollPane1.setViewportView(table);
    jb_delete.setText("删除");
    jb_delete.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_deleteActionPerformed(evt);
      }
    });
    jb_exit.setText("退出");
    jb_exit.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_exitActionPerformed(evt);
      }
    });
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup().addGap(64, 64, 64).addComponent(jLabel1).addGap(18, 18, 18)
            .addComponent(roomNum, javax.swing.GroupLayout.PREFERRED_SIZE, 142,
                javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(29, 29, 29).addComponent(jb_search).addContainerGap(41, Short.MAX_VALUE))
        .addGroup(layout.createSequentialGroup().addGap(76, 76, 76).addComponent(jb_delete)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 123, Short.MAX_VALUE)
            .addComponent(jb_exit).addGap(86, 86, 86))
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 379,
                    javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup().addGap(28, 28, 28)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jb_search)
            .addComponent(jLabel1).addComponent(roomNum, javax.swing.GroupLayout.PREFERRED_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addGap(18, 18, 18)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 216,
            javax.swing.GroupLayout.PREFERRED_SIZE)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jb_delete)
            .addComponent(jb_exit))
        .addGap(27, 27, 27)));
    pack();
  }
  private void jb_deleteActionPerformed(java.awt.event.ActionEvent evt) {
    int row = this.table.getSelectedRow();
    String member = (String) this.table.getValueAt(row, 1);
    if (StringUtil.isEmpty(member)) {
      JOptionPane.showMessageDialog(null, "请选择要删除的记录!");
      return;
    }
    int n = JOptionPane.showConfirmDialog(null, "确定要删除这条记录么");
    if (n == 0) {
      Connection con = null;
      try {
        con = dmutil.getCon();
        Room room = new Room(member);
        int deleteNum = roomdao.roomDelete(con, room);
        if (deleteNum == 1) {
          JOptionPane.showMessageDialog(null, "删除成功");
          this.roomNum.setText("");
          this.fillTable(new Room());
        } else {
          JOptionPane.showMessageDialog(null, "删除失败");
        }
      } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "删除失败");
        e.printStackTrace();
      } finally {
        try {
          dmutil.closeCon(con);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
  private void jb_exitActionPerformed(java.awt.event.ActionEvent evt) {
    int a = JOptionPane.showConfirmDialog(null, "确认要退出?");
    if (a == 0) {
      this.dispose();
    }
  }
  private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) {
    String member = roomNum.getText();
    Room room = new Room(member);
    this.fillTable(room);
  }
}

RoomManagerInterFrm.java

package com.sjsq.view;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import com.sjsq.dao.RoomDao;
import com.sjsq.model.Room;
import com.sjsq.util.DMUtil;
public class RoomManagerInterFrm extends javax.swing.JInternalFrame {
  private JTextField idTxt;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JPanel jPanel1;
  private JScrollPane jScrollPane1;
  private javax.swing.JButton jb_exit;
  private javax.swing.JButton jb_modify;
  private javax.swing.JButton jb_search;
  private JTextField roomNum;
  private JTextField roomleader;
  private JTextField roomnumber;
  private JTable table;
  DMUtil dmutil = new DMUtil();
  RoomDao roomdao = new RoomDao();
  public RoomManagerInterFrm() {
    initComponents();
    this.setLocation(200, 50);
    this.fillTable(new Room());
  }
  private void fillTable(Room room) {
    DefaultTableModel dtm = (DefaultTableModel) table.getModel();
    dtm.setRowCount(0);
    Connection con = null;
    try {
      con = dmutil.getCon();
      ResultSet rs = roomdao.roomList(con, room);
      while (rs.next()) {
        Vector v = new Vector();
        v.add(rs.getString("id"));
        v.add(rs.getString("member"));
        v.add(rs.getString("leader"));
        dtm.addRow(v);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        dmutil.closeCon(con);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  private void initComponents() {
    jLabel1 = new JLabel();
    roomNum = new JTextField();
    jb_search = new javax.swing.JButton();
    jScrollPane1 = new JScrollPane();
    table = new JTable();
    jPanel1 = new JPanel();
    jLabel2 = new JLabel();
    idTxt = new JTextField();
    jLabel3 = new JLabel();
    roomnumber = new JTextField();
    jb_modify = new javax.swing.JButton();
    jb_exit = new javax.swing.JButton();
    jLabel4 = new JLabel();
    roomleader = new JTextField();
    setClosable(true);
    setIconifiable(true);
    setTitle("宿舍信息修改");
    jLabel1.setText("寝室号:");
    jb_search.setText("查询");
    jb_search.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_searchActionPerformed(evt);
      }
    });
    table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {
    }, new String[] { "编号", "寝室号", "寝室长" }) {
      boolean[] canEdit = new boolean[] { false, false, false };
      public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit[columnIndex];
      }
    });
    table.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mousePressed(java.awt.event.MouseEvent evt) {
        tableMousePressed(evt);
      }
    });
    jScrollPane1.setViewportView(table);
    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("表单操作"));
    jLabel2.setText("编号:");
    idTxt.setEditable(false);
    jLabel3.setText("寝室号:");
    jb_modify.setText("修改");
    jb_modify.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_modifyActionPerformed(evt);
      }
    });
    jb_exit.setText("退出");
    jb_exit.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_exitActionPerformed(evt);
      }
    });
    jLabel4.setText("寝室长:");
    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup().addGap(39, 39, 39).addComponent(jb_modify)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, Short.MAX_VALUE)
            .addComponent(jb_exit).addGap(64, 64, 64))
        .addGroup(jPanel1Layout.createSequentialGroup().addGap(21, 21, 21)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel4).addComponent(jLabel2))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(roomleader)
                .addComponent(idTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
            .addGap(18, 18, 18).addComponent(jLabel3).addGap(10, 10, 10)
            .addComponent(roomnumber, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
            .addGap(62, 62, 62)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addGap(19, 19, 19)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2)
                .addComponent(idTxt, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel3).addComponent(roomnumber, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(33, 33, 33)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4).addComponent(roomleader, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jb_modify).addComponent(jb_exit))
            .addContainerGap()));
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup().addGap(41, 41, 41).addComponent(jLabel1).addGap(18, 18, 18)
            .addComponent(roomNum, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jb_search)
            .addGap(80, 80, 80))
        .addGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, 0,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup().addGap(18, 18, 18)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
            .addComponent(jb_search).addComponent(roomNum, javax.swing.GroupLayout.PREFERRED_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
            javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGap(18, 18, 18).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        .addContainerGap()));
    pack();
  }
  private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) {
    String member = roomNum.getText();
    Room room = new Room(member);
    this.fillTable(room);
  }
  private void jb_modifyActionPerformed(java.awt.event.ActionEvent evt) {
    String roomNumber = roomnumber.getText();
    String roomLeader = roomleader.getText();
    String id = idTxt.getText();
    Connection con = null;
    try {
      con = dmutil.getCon();
      Room room = new Room(id, roomNumber, roomLeader);
      int a = roomdao.roomModify(con, room);
      if (a == 1) {
        JOptionPane.showMessageDialog(null, "修改成功!");
        resetValue();
        this.fillTable(new Room());
        return;
      } else {
        JOptionPane.showMessageDialog(null, "修改失败!");
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "修改失败!");
      e.printStackTrace();
    }
  }
  public void resetValue() {
    roomnumber.setText("");
    roomleader.setText("");
    idTxt.setText("");
  }
  private void jb_exitActionPerformed(java.awt.event.ActionEvent evt) {
    int result = JOptionPane.showConfirmDialog(null, "是否退出系统");
    if (result == 0) {
      this.dispose();
    }
  }
  private void tableMousePressed(java.awt.event.MouseEvent evt) {
    int row = table.getSelectedRow();
    idTxt.setText(table.getValueAt(row, 0) + "");
    roomnumber.setText(table.getValueAt(row, 1) + "");
    roomleader.setText(table.getValueAt(row, 2) + "");
  }
}

RoomSearchInterFrm.java

package com.sjsq.view;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JTextField;
import javax.swing.JTable;
import com.sjsq.dao.RoomDao;
import com.sjsq.model.Room;
import com.sjsq.util.DMUtil;
public class RoomSearchInterFrm extends javax.swing.JInternalFrame {
  private JLabel jLabel1;
  private JScrollPane jScrollPane1;
  private JButton jb_search;
  private JTextField roomNumTxt;
  private JTable table;
  DMUtil dmutil = new DMUtil();
  RoomDao roomdao = new RoomDao();
  public RoomSearchInterFrm() {
    initComponents();
    this.setLocation(200, 50);
  }
  private void fillTable(Room room) {
    DefaultTableModel dtm = (DefaultTableModel) table.getModel();
    dtm.setRowCount(0);
    Connection con = null;
    try {
      con = dmutil.getCon();
      ResultSet rs = roomdao.roomList(con, room);
      while (rs.next()) {
        Vector v = new Vector();
        v.add(rs.getString("id"));
        v.add(rs.getString("member"));
        v.add(rs.getString("leader"));
        dtm.addRow(v);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        dmutil.closeCon(con);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  private void initComponents() {
    jLabel1 = new JLabel();
    roomNumTxt = new JTextField();
    jb_search = new JButton();
    jScrollPane1 = new JScrollPane();
    table = new JTable();
    setClosable(true);
    setIconifiable(true);
    setTitle("寝室查询");
    jLabel1.setText("寝室号:");
    jb_search.setText("查询");
    jb_search.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jb_searchActionPerformed(evt);
      }
    });
    table.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {
    }, new String[] { "编号", "寝室号", "寝室长" }) {
      boolean[] canEdit = new boolean[] { false, false, false };
      public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit[columnIndex];
      }
    });
    jScrollPane1.setViewportView(table);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addGap(46, 46, 46).addComponent(jLabel1).addGap(28, 28, 28)
            .addComponent(roomNumTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 132,
                javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(18, 18, 18).addComponent(jb_search))
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1,
                javax.swing.GroupLayout.PREFERRED_SIZE, 379, javax.swing.GroupLayout.PREFERRED_SIZE)))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
        .createSequentialGroup().addGap(23, 23, 23)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jb_search)
            .addComponent(roomNumTxt, javax.swing.GroupLayout.PREFERRED_SIZE,
                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addComponent(jLabel1))
        .addGap(18, 18, 18)
        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 292, Short.MAX_VALUE)
        .addContainerGap()));
    pack();
  }
  private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) {
    String member = roomNumTxt.getText();
    Room room = new Room(member);
    this.fillTable(room);
  }
}


四、其他


1.其他系统实现


JavaSwing系统系列实现

Java+Swing实现斗地主游戏

Java+Swing实现图书管理系统

Java+Swing实现医院管理系统

Java+Swing实现考试管理系统

Java+Swing实现酒店管理系统

Java+Swing实现超市管理系统

Java+Swing实现网上订餐系统

Java+Swing实现电影购票系统

Java+Swing实现仓库管理系统1

Java+Swing实现仓库管理系统2

Java+Swing实现进销存管理系统

Java+Swing实现通讯录管理系统

Java+Swing实现停车场管理系统

Java+Swing实现员工工资管理系统

Java+Swing实现学生宿舍管理系统

Java+Swing实现学生选课管理系统

Java+Swing实现学生成绩管理系统

Java+Swing实现学校教材管理系统

Java+Swing实现学校教务管理系统

Java+Swing实现企业人事管理系统

Java+Swing实现电子相册管理系统

Java+Swing实现学生信息管理系统1

Java+Swing实现学生信息管理系统2

Java+Swing实现自助取款机(ATM)系统


JavaSwing+Txt系统系列实现

Java+Swing实现超市管理系统-TXT存储信息

Java+Swing实现宠物商店管理系统-TXT存储信息

Java+Swing实现自助取款机(ATM)系统-TXT存储信息


Java+JSP系统系列实现

Java+JSP实现学生图书管理系统

Java+JSP实现学生信息管理系统

Java+JSP实现用户信息管理系统


Java+Servlet+JSP系统系列实现

Java+Servlet+JSP实现航空订票系统

Java+Servlet+JSP实现新闻发布系统

Java+Servlet+JSP实现图书管理系统

Java+Servlet+JSP实现停车场管理系统

Java+Servlet+JSP实现房屋租赁管理系统

Java+Servlet+JSP实现学生选课管理系统

Java+Servlet+JSP实现宠物诊所管理系统

Java+Servlet+JSP实现学生宿舍管理系统

Java+Servlet+JSP实现学生信息管理系统

Java+Servlet+JSP实现学生成绩管理系统1

Java+Servlet+JSP实现学生成绩管理系统2


Java+SSM系统系列实现

Java+SSM+JSP实现图书管理系统

Java+SSM+JSP实现宠物商城系统

Java+SSM+JSP实现超市订单系统

Java+SSM+JSP实现网上考试系统

Java+SSM+JSP实现学生成绩管理系统

Java+SSM+JSP实现学生信息管理系统

Java+SSM+Bootstrap+Maven实现网上书城系统

Java+SSM+Bootstrap+Maven实现学校教务管理系统


Java+SSH系统系列实现

Java+SSH+Bootstrap实现在线考试系统

Java+SSH+JSP实现医院在线挂号系统


Java+Springboot系统系列实现

Java+Springboot+H-ui+Maven实现营销管理系统

Java+Springboot+Bootstrap+Maven实现网上商城系统

Java+Springboot+Bootstrap+Maven实现景区旅游管理系统


2.获取源码


点击以下链接获取源码

Java+Swing+Mysql实现学生宿舍管理系统源码


3.备注


如有侵权请联系我删除。


4.鸡汤


积极的思考,积极的生活,积极的展望!


相关文章
|
4天前
|
Java
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
20 3
学院管理系统【JSP+Servlet+JavaBean】(Java课设)
|
4天前
|
Java
学校教师管理系统【JSP+Servlet+JavaBean】(Java课设)
学校教师管理系统【JSP+Servlet+JavaBean】(Java课设)
17 2
|
3天前
|
Java 关系型数据库 MySQL
java+B/S架构医院绩效考核管理系统源码 医院绩效管理系统4大特点
医院绩效考核管理系统,采用多维度综合绩效考核的形式,针对院内实际情况分别对工作量、KPI指标、科研、教学、管理等进行全面考核。医院可结合实际需求,对考核方案中各维度进行灵活配置,对各维度的权重、衡量标准、数据统计方式进行自定义维护。
11 0
|
4天前
|
监控 前端开发 Java
Java公立医院绩效考核管理系统 医院绩效考核系统的优势有哪些? 
医院绩效管理系统解决方案紧扣新医改形势下医院绩效管理的要求,以“工作量为基础的考核方案”为核心思想,结合患者满意度、服务质量、技术难度、工作效率、医德医风等管理发展目标的考核体系,形成医院的内部绩效考核与分配机制,通过信息化手段为绩效考评管理人员实施医院绩效考评工作提供了有效工具,扩展了信息管理范围,增加了信息分析的广度与深度。这不仅使绩效评价工作更加科学化、规范化和自动化,而且从根本上改变了绩效评估工作方式,实现了绩效评价数据网络化采集,评价结果透明化管理,奖金分配数据自动化生成,极大地提高了绩效评估的全面性、准确性、时效性、公正性。从而推进医院绩效管理的专业化、规范化和精细化管理,充分发挥
14 0
|
4天前
|
Java
学校人员管理系统【JSP+Servlet+JavaBean】(Java课设)
学校人员管理系统【JSP+Servlet+JavaBean】(Java课设)
13 2
|
4天前
|
Java
个人信息管理系统【JSP+Servlet+JavaBean】(Java课设)
个人信息管理系统【JSP+Servlet+JavaBean】(Java课设)
10 0
|
4天前
|
监控 前端开发 Java
Java基于B/S医院绩效考核管理平台系统源码 医院智慧绩效管理系统源码
医院绩效考核系统是一个关键的管理工具,旨在评估和优化医院内部各部门、科室和员工的绩效。一个有效的绩效考核系统不仅能帮助医院实现其战略目标,还能提升医疗服务质量,增强患者满意度,并促进员工的专业成长
20 0
|
4天前
|
小程序 Java 关系型数据库
Java毕设之社区生活超市管理系统
Java毕设之社区生活超市管理系统
20 1
|
4天前
|
小程序 Java 关系型数据库
Java毕设之人事管理系统
Java毕设之人事管理系统
17 3
|
4天前
|
小程序 Java PHP
Java毕设之人才公寓管理系统
Java毕设之人才公寓管理系统
15 2

推荐镜像

更多