⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dormsearchpanel.java

📁 使用JBuilder基于Oracle数据库的课程作业
💻 JAVA
字号:
package StudentManageSystem.factionpanels.searchpanel;

import StudentManageSystem.factionpanels.infopanel.CollegeInfoPanel;
import javax.swing.tree.DefaultMutableTreeNode;
import java.sql.ResultSet;
import StudentManageSystem.link.SQLRunner;
import java.sql.SQLException;
import StudentManageSystem.factionpanels.infopanel.DormInfoPanel;

public class DormSearchPanel extends SearchPanel {
    public DormSearchPanel(String cno, boolean e){
        infoPanel=new DormInfoPanel(e);
        initialize(cno,e);
    }

    public void addNodes() {
        try {
            top=new DefaultMutableTreeNode("内大");
            ResultSet rdp=SQLRunner.getResult("select distinct build_no from dormitory");
            while (rdp.next()) {
               String dno=rdp.getString("build_no");
               String dpname="号楼";
               DefaultMutableTreeNode dp=new DefaultMutableTreeNode(dno+dpname);
               top.add(dp);
               ResultSet rcl=SQLRunner.getResult("select * from dormitory where build_no='"+dno+"'");
               while (rcl.next()) {
                   String clno=rcl.getString("APARTMENT_NO");
                   //System.out.println(clno);
                   String clname="房间";
                   DefaultMutableTreeNode cl=new DefaultMutableTreeNode(dno+"#"+clno+clname);
                   dp.add(cl);
              }
          }
        } catch (SQLException ex) {
        }

    }

    public void setView(String s) {
        String sub=(s.trim());
        sub=sub.substring(sub.length()-1,sub.length());
        if(sub.trim().equals("大")){
            //String cno=s.substring(0,1);
            showTableView("select * from dormitory");
        }else if(sub.trim().equals("楼")){
            String cno=s.substring(0,1);
            showTableView("select * from dormitory where build_no='"+cno+"'");
        }else{
            String no=s.substring(0,1);
            String cno=s.substring(2,5);
            showLeavesView(no+cno);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -