?? mainui.java
字號:
final JLabel label_17 = new JLabel();
label_17.setText("注意兩個復選框都不選為查詢所有數據");
label_17.setBounds(10, 97, 236, 15);
searchzyt.add(label_17);
JPanel searchzrpanel = new JPanel();
searchzrpanel.setBorder(new TitledBorder(null, "查詢結果", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, null, null));
searchzrpanel.setLayout(null);
searchzrpanel.setBounds(287, 13, 368, 219);
searchzypanel.add(searchzrpanel);
sczy.setBounds(14, 23, 344, 156);
searchzrpanel.add(sczy);
sczy.setViewportView(tablezy);
tablezy.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String zyname=dtmzy.getValueAt((tablezy.getSelectedRow()), 0).toString();
ld.getZhuanYeInfo(zyname);
}
public void mouseEntered(MouseEvent e) {
tablezy.requestFocus();
}
});
btmozys.setText("修改");
btmozys.setBounds(14, 185, 90, 25);
searchzrpanel.add(btmozys);
btsdelzy.setText("刪除");
btsdelzy.setBounds(268, 185, 90, 25);
searchzrpanel.add(btsdelzy);
btexitzhuanyep.setText("退出專業面板");
btexitzhuanyep.setBounds(260, 400, 140, 40);
zhuanyepanel.add(btexitzhuanyep);
setSize(785,600); //設置窗口大小
cw=this.getWidth();
ch=this.getHeight();
int cx=(int) ((Toolkit.getDefaultToolkit().getScreenSize().width-this.getWidth()))/2;
int cy=(int) ((Toolkit.getDefaultToolkit().getScreenSize().height-this.getHeight()))/2;
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //關閉方式
setLocation(cx,cy);//窗口起始坐標
this.setVisible(true);//顯示窗口
}//----------------------------------------------------------end struct
//start main
public static void main(String[] args) {
new mainUI();
}//end main
//------------------------event
public void actionPerformed(ActionEvent e) {
if(e.getSource()==btclass){
hideAllPanel();
classpanel.setVisible(true);
}//end if btclass
if(e.getSource()==btteacher){
hideAllPanel();
teacherpanel.setVisible(true);
}//end if btteacher
if(e.getSource()==minteacher){
hideAllPanel();
teacherpanel.setVisible(true);
teachertabbedPane.setSelectedIndex(0);
}
if(e.getSource()==mseteacher){
hideAllPanel();
teacherpanel.setVisible(true);
teachertabbedPane.setSelectedIndex(1);
}
if(e.getSource()==btstudent){
hideAllPanel();
studentpanel.setVisible(true);
}//end if btstudent
if(e.getSource()==btzhuanye){
hideAllPanel();
zhuanyepanel.setVisible(true);
}//end if btzhuanye
if(e.getSource()==btexitzhuanyep||e.getSource()==btexitstudentp||e.getSource()==btexitteacherp||e.getSource()==btexitclassp){
hideAllPanel();
}
if(e.getSource()==btinzy){
boolean addok=ld.addZhuanye(tfzyid.getText(),tfzyname.getText(), tazyms.getText(), tazybz.getText());//調用業務中的添加
if(addok==true){
initZhuanyeInfo();//重新初始化專業信息
}
}//end if 專業錄入
if(e.getSource()==btmozy){
if(ld.updateZhuanye(tfzyid.getText(),tfzyname.getText(),tazyms.getText(),tazybz.getText())==true){
initZhuanyeInfo();//重新初始化專業信息
}
}//修改專業
if(e.getSource()==btdelzy){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個專業嗎?")==0){
if(ld.delInfobyID("zhuanyet", "zyid",tfzyid.getText())==true){
initZhuanyeInfo();//重新初始化專業
}
}
}
if(e.getSource()==btsearchzy){
dtmzy.setDataVector(ld.searchResult(cbzyname.isSelected(), cbzyms.isSelected(), tfszyname.getText(), tfszyms.getText()), zytbhead);
}//結束賣主查詢事件
if(e.getSource()==btmozys){
String[] zyinfo=ld.getZhuanYeInfo(dtmzy.getValueAt((tablezy.getSelectedRow()), 0).toString());
tfzyid.setText(zyinfo[0]);
tfzyname.setText(zyinfo[1]);
tazyms.setText(zyinfo[2]);
tazybz.setText(zyinfo[3]);
tbpzy.setSelectedIndex(0);
cbszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//重新初始化學生面板中專業
cbsszhuanye.setModel(new DefaultComboBoxModel(ld.getName("zhuanyet", "zyname")));//重新初始化查詢學生面板中專業
}//專業面板上修改按鈕
if(e.getSource()==btinteacher){
if(ld.addTeacher(tftid.getText(), tftname.getText(), tinman.isSelected(),jcbtinage.getSelectedItem().toString(), tftyear.getText()+"年 "+cbtmonth.getSelectedItem(), tftsfid.getText(), tfnaddr.getText(), tftphone.getText(), cbtstatus.getSelectedItem().toString())==true){
initTeacherInfo();
}
}//教師錄入
if(e.getSource()==btdelteacher){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個教師嗎?")==0){
if(ld.delInfobyID("teachert", "tid", tftid.getText())==true){
initTeacherInfo();//刪除完成后重新初始化教師信息
}
}
}//教師刪除
if(e.getSource()==btmodifyteacher){
if(ld.updateTeacher(tftid.getText(), tftname.getText(), tinman.isSelected(),jcbtinage.getSelectedItem().toString(), tftyear.getText()+"年 "+cbtmonth.getSelectedItem(), tftsfid.getText(), tfnaddr.getText(), tftphone.getText(), cbtstatus.getSelectedItem().toString())==true){
initTeacherInfo();//修改完成后重新初始化教師信息
}
}
if(e.getSource()==btmots){
if(tablesteacher.isFocusable()==true){
String[] tinfo=ld.getTeacherInfo(dtmtr.getValueAt((tablesteacher.getSelectedRow()), 4).toString());
tftid.setText(tinfo[0]);
tftname.setText(tinfo[1]);
boolean se=true;
if(tinfo[2].equals("女")){
se=false;
tinwoman.setSelected(true);
}
tinman.setSelected(se);
jcbtinage.setSelectedItem(tinfo[3]);
String[] workind=tinfo[4].split(" ");
tftyear.setText(workind[0].substring(0,workind[0].length()-1));
cbtmonth.setSelectedItem(workind[1]);
tftsfid.setText(tinfo[5]);
tfnaddr.setText(tinfo[6]);
tftphone.setText(tinfo[7]);
cbtstatus.setSelectedItem(tinfo[8]);
teachertabbedPane.setSelectedIndex(0);
}
}//教師查詢面板上修改
if(e.getSource()==btsdelt){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個教師嗎?")==0){
if(ld.delInfobyID("teachert", "tid", ld.getIDs("teachert", "tsfid", "tid", dtmtr.getValueAt((tablesteacher.getSelectedRow()), 4).toString()))==true){
initTeacherInfo();
}
}
}//教師查詢上刪除
if(e.getSource()==btsearcht){
dtmtr.setDataVector(ld.searchResultteacher(cbtsname.isSelected(), cbtssex.isSelected(), cbtsage.isSelected(), cbtsinwork.isSelected(), cbtsstat.isSelected(), tftsname.getText(), rtsman.isSelected(), jcbtsage.getSelectedItem().toString(), tftsinworkyear.getText(),jcbtsts.getSelectedItem().toString()),thead);
}
if(e.getSource()==btinclass){
if(ld.addClassinfo(tfcid.getText(), tfcyear.getText()+"年 "+cbcmonth.getSelectedItem().toString()+" "+cbcday.getSelectedItem().toString(), tfcname.getText(), tfcmansum.getText(), banzhurenming.getSelectedItem().toString(), cbincstatus.getSelectedItem().toString(), tacbz.getText())==true){
initClassInfo();
}
}//班級錄入
if(e.getSource()==btmoclass){
if(ld.updateClassInfo(tfcid.getText(), tfcyear.getText()+"年 "+cbcmonth.getSelectedItem().toString()+" "+cbcday.getSelectedItem().toString(), tfcname.getText(), tfcmansum.getText(), banzhurenming.getSelectedItem().toString(), cbincstatus.getSelectedItem().toString(), tacbz.getText())==true){
initClassInfo();//調用重新初始化班級
}
}//班級更新
if(e.getSource()==btdelclass){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個班級嗎?")==0){
if(ld.delInfobyID("classt", "cid",tfcid.getText())==true){
initClassInfo();//調用重新初始化班級
}
}
}
if(e.getSource()==btsclass){
dtmcs.setDataVector(ld.searchClassResult(cbuscname.isSelected(), cbuscstatus.isSelected(), cbusbzrm.isSelected(), tfscname.getText(),cbscstat.getSelectedItem().toString(), tfscbzname.getText()), vchead);
}//班級查詢
if(e.getSource()==minclass){
hideAllPanel();
initClassInfo();//調用重新初始化班級
classtabpanel.setSelectedIndex(0);
classpanel.setVisible(true);
}//菜單錄入班級
if(e.getSource()==mseclass){
hideAllPanel();
classpanel.setVisible(true);
classtabpanel.setSelectedIndex(1);
}//menu search class
if(e.getSource()==btsdelclass){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個班級嗎?")==0){
if(ld.delInfobyID("classt", "cid",ld.getIDs("classt", "cname", "cid",dtmcs.getValueAt(tbclass.getSelectedRow(), 1).toString()))==true){
initClassInfo();//刪除完成后重新初始化班級信息
}
}
}//專業查詢上刪除
if(e.getSource()==btsmclass){
String[] cinfo=ld.getClassInfo((dtmcs.getValueAt(tbclass.getSelectedRow(), 1).toString()));
tfcid.setText(cinfo[0]);
String[] cda=cinfo[1].split(" ");
tfcyear.setText(cda[0].substring(0, cda[0].length()-1));
cbcmonth.setSelectedItem(cda[1]);
cbcday .setSelectedItem(cda[2]);
tfcname.setText(cinfo[2]);
tfcmansum.setText(cinfo[3]);
banzhurenming.setSelectedItem(cinfo[4]);
cbincstatus.setSelectedItem(cinfo[5]);
tacbz.setText(cinfo[6]);
tbpzy.setSelectedIndex(0);
classtabpanel.setSelectedIndex(0);
}//查詢面板上的修改
if(e.getSource()==minstudent){
hideAllPanel();
studentpanel.setVisible(true);
studenttabbedPane.setSelectedIndex(0);
}//學生錄入菜單
if(e.getSource()==msestudent){
hideAllPanel();
studentpanel.setVisible(true);
studenttabbedPane.setSelectedIndex(1);
} //學生查詢菜單
if(e.getSource()==musersm||e.getSource()==btuserm){
new usersUI();
}//用戶管理
if(e.getSource()==mcontest){
new dbconUI();
}//測試數據庫連接
if(e.getSource()==moffconn){
ld.closeDB();
}//關閉數據庫
if(e.getSource()==minzy){
hideAllPanel();
zhuanyepanel.setVisible(true);
tbpzy.setSelectedIndex(0);
}//專業錄入菜單
if(e.getSource()==msezy){
hideAllPanel();
zhuanyepanel.setVisible(true);
tbpzy.setSelectedIndex(1);
}//專業查詢菜單
if(e.getSource()==btinstudent){
if(ld.addStudentInfo(tfsinid.getText(),tfsinname.getText(),sinsman.isSelected(),tfinsage.getText(),tfinsyear.getText()+"年 "+cbsinmonth.getSelectedItem().toString(),cbszhuanye.getSelectedItem().toString(), cbsclass.getSelectedItem().toString(), tfinssfid.getText(),tfinsnowaddres.getText(),tfinsphone.getText(),cbinsstatus.getSelectedItem().toString())==true){
initStudentInfo();
}
}//學生錄入
if(e.getSource()==btexita||e.getSource()==mexita){
ld.closeDB();//關閉數據庫連接
dispose();
}
if(e.getSource()==btsdelzy){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除這個專業嗎?")==0){
if(ld.delInfobyID("zhuanyet", "zyid",ld.getIDs("zhuanyet", "zyname", "zyid",dtmzy.getValueAt((tablezy.getSelectedRow()), 0).toString()))==true){
initZhuanyeInfo();
}
}
}//專業查詢上刪除
if(e.getSource()==btsstudent){
dtmst.setDataVector(ld.searchStudentResult(cbssname.isSelected(), cbsssex.isSelected(), cbssage.isSelected(), cbssyear.isSelected(), cbsszy.isSelected(), cbssclass.isSelected(), cbssstatus.isSelected(), tfssname.getText(), ssman.isSelected(), tfssage.getText(), tfssindate.getText(), cbsszhuanye.getSelectedItem().toString(), cbsssclass.getSelectedItem().toString(), cbsstatuss.getSelectedItem().toString()), vsthead);
}//學生查詢
if(e.getSource()==btdelsst){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除嗎?")==0){
ld.delInfobyID("studentt", "ssfid",dtmst.getValueAt((tablesearchs.getSelectedRow()), 6).toString());
initStudentInfo();
}
}//學生查詢上刪除
if(e.getSource()==btmostudent){
String stsfid=dtmst.getValueAt((tablesearchs.getSelectedRow()), 6).toString();
if(stsfid.length()>0){
String[] stinf=ld.getStudentInfo(stsfid);
tfsinid.setText(stinf[0]);
tfsinname.setText(stinf[1]);
boolean se=true;
if(stinf[2].equals("女")){
se=false;
sinswoman.setSelected(true);
}
sinsman.setSelected(se);
tfinsage.setText(stinf[3]);
String[] sins=stinf[4].split(" ");
tfinsyear.setText(sins[0].substring(0,sins[0].length()-1));
cbsinmonth.setSelectedItem(sins[1]);
cbszhuanye.setSelectedItem(stinf[5]);
cbsclass.setSelectedItem(stinf[6]);
tfinssfid.setText(stinf[7]);
tfinsnowaddres.setText(stinf[8]);
tfinsphone.setText(stinf[9]);
cbinsstatus.setSelectedItem(stinf[10]);
studenttabbedPane.setSelectedIndex(0);//激活學生錄入面板
}
}//學生查詢上修改
if(e.getSource()==btmodifystudent){
if(ld.updateStudentInfo(tfsinid.getText(),tfsinname.getText(),sinsman.isSelected(),tfinsage.getText(),tfinsyear.getText()+"年 "+cbsinmonth.getSelectedItem().toString(),cbszhuanye.getSelectedItem().toString(), cbsclass.getSelectedItem().toString(), tfinssfid.getText(),tfinsnowaddres.getText(),tfinsphone.getText(),cbinsstatus.getSelectedItem().toString())==true){
initStudentInfo();//重新初始化學生信息
}
}//學生錄入上修改
if(e.getSource()==btdelstudent){
if(JOptionPane.showConfirmDialog(null, "你確定要刪除學生嗎?")==0){
if(ld.delInfobyID("studentt", "sid", tfsinid.getText())){
initStudentInfo();
}
}
}//學生錄入上刪除
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -