?? mystudentsearchpanel.java~4~
字號(hào):
package superframe.factionpanels.searchpanel;
import java.awt.event.ActionEvent;
import superframe.factionpanels.infopanel.StudentInfoPanel;
import javax.swing.tree.DefaultMutableTreeNode;
import superframe.link.SQLRunner;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MyStudentSearchPanel extends SearchPanel {
public MyStudentSearchPanel(String cno, boolean e){
infoPanel=new StudentInfoPanel(e);
initialize(cno, e);
}
public void addNodes() {
try {
if(top!=null)top.removeAllChildren();
ResultSet rs=SQLRunner.getResult("select * from college where college_no='"+college_no+"'");
if(!rs.next())return;
top=new DefaultMutableTreeNode(college_no+rs.getString("coname"));
ResultSet rdp=SQLRunner.getResult("select * from department where department.college_no='"+college_no+"'");
while (rdp.next()) {
String dno=rdp.getString("DEPART_NO");
String dpname=rdp.getString("dpname");
DefaultMutableTreeNode dp=new DefaultMutableTreeNode(dno+'/'+dpname);
top.add(dp);
ResultSet rcl=SQLRunner.getResult("select * from class where class.depart_no='"+dno+"'");
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 where student.class_no='"+clno+"'");
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("院")){
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,class_no from Student where class_no='"+clno+"'");
}else{
String sno=s.substring(0,8);
System.out.println(sno);
showLeavesView(sno);
}
}
public void showLeavesView() {
tablePanel.setVisible(false);
welcomePanel.setVisible(false);
infoPanel.setVisible(true);
}
public void jButton_new_actionPerformed(ActionEvent e) {
tablePanel.setVisible(false);
welcomePanel.setVisible(false);
infoPanel.setVisible(true);
infoPanel.setAllNew();
infoPanel.updateModel=false;
}
public void showTableView(String sql) {
infoPanel.setVisible(false);
welcomePanel.setVisible(false);
tablePanel.resetTable(sql);
tablePanel.setVisible(true);
}
void showWelcomeView(){
infoPanel.setVisible(false);
tablePanel.setVisible(false);
welcomePanel.setVisible(true);
}
/*public void actionPerformed(ActionEvent e) {
}*/
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -