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

📄 mainui.java

📁 这是一个班级 教师 学生 课程管理的软件实现对学生教师课程的添加修改删除查询
💻 JAVA
📖 第 1 页 / 共 5 页
字号:

		  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 + -