📄 studentsearchpanel.java~1~
字号:
package superframe;
import javax.swing.tree.DefaultMutableTreeNode;
import java.sql.ResultSet;
import java.sql.SQLException;
import superframe.link.SQLRunner;
public class StudentSearchPanel extends SearchPanel {
public StudentSearchPanel(boolean e){
infoPanel=new StudentInfoPanel(e);
tablePanel=new TablePanel("select * from college","coname","",e);
this.initialize(e);
readdNodes();
}
public void readdNodes(){
top.removeAllChildren();
try {
ResultSet rco=SQLRunner.getResult("select * from college");
while (rco.next()) {
String cno=rco.getString("college_no");
String coname=rco.getString("coname");
DefaultMutableTreeNode co=new DefaultMutableTreeNode(cno+'/'+coname);
top.add(co);
ResultSet rdp=SQLRunner.getResult("select * from department,college where department.college_no=college.college_no and coname='"+coname+"'");
while (rdp.next()) {
String dno=rdp.getString("DEPART_NO");
String dpname=rdp.getString("dpname");
DefaultMutableTreeNode dp=new DefaultMutableTreeNode(dno+'/'+dpname);
co.add(dp);
ResultSet rcl=SQLRunner.getResult("select * from department,class where department.depart_no=class.depart_no and dpname='"+dpname+"'");
while (rcl.next()) {
String clno=rcl.getString("class_no");
System.out.println(clno);
String clname=rcl.getString("clname");
DefaultMutableTreeNode cl=new DefaultMutableTreeNode(clno+'/'+clname);
dp.add(cl);
ResultSet rst=SQLRunner.getResult("select * from student,class where student.class_no=class.class_no and clname='"+clname+"'");
while (rst.next()) {
String sno=rst.getString("Stu_no");
System.out.println(clno);
String sname=rst.getString("sname");
DefaultMutableTreeNode s=new DefaultMutableTreeNode(sno+'/'+sname);
cl.add(s);
}
}
}
}
} catch (SQLException ex) {
}
}
public void setView(String s){
String sub=(s.trim());
sub=sub.substring(sub.length()-1,sub.length());
if(sub.trim().equals("大")){
showTableView("select coname,count(Stu_no) from Studentinfo group by coname");
}else if(sub.trim().equals("院")){
String cno=s.substring(0,2);
showTableView("select dpname,count(Stu_no) from Studentinfo where college_no='"+cno+"' group by dpname");
}else if(sub.trim().equals("系")){
String dno=s.substring(0,2);
showTableView("select clname,count(Stu_no) from Studentinfo where depart_no='"+dno+"' group by clname");
}else if(sub.trim().equals("班")){
String clno=s.substring(0,4);
showTableView("select stu_no,sname,sex,nation,source from Studentinfo where class_no='"+clno+"'");
}else{
String sno=s.substring(0,8);
System.out.println(sno);
showLeavesView(sno);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -