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

📄 mainface.java

📁 可以用的成绩管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    	jpl1.add("forth",jpa14);
    	
    	btn1 = new JButton("添加学生信息");
    	btn1.addActionListener(this);
    	btn2 = new JButton("添加教师信息");
    	btn2.addActionListener(this);
    	btn3 = new JButton("学生成绩登记");
    	btn3.addActionListener(this);
    	btn4 = new JButton("浏览学生信息");
    	btn4.addActionListener(this);
    	btn5 = new JButton("退出");
    	btn5.addActionListener(this);
    	
    	jpl2.setBounds(400,0,500,400);
    	jpl2.setLayout(new GridLayout(5,1,5,50));
    	jpl2.add(btn1);
    	jpl2.add(btn2);
    	jpl2.add(btn3);
    	jpl2.add(btn4);
    	jpl2.add(btn5);
    	
    	jl = new JLabel("欢迎登陆学生成绩管理系统!");
    	jpl3.add(jl);
    	mf.setLayout(new BorderLayout());
    	mf.add(jpl3,BorderLayout.NORTH);
    	mf.add(jpl1,BorderLayout.CENTER);
    	mf.add(jpl2,BorderLayout.EAST);
    	mf.setVisible(true);
    }
    
    public void mouseReleased(MouseEvent e){
    	Object o = e.getSource();
    	if(o.equals(sjta)){
    		mainStr =(String)sjta.getValueAt(sjta.getSelectedRow(),0);
    		
    		new StudentFace();
    		StudentFace.jb1.setVisible(false);
    		StudentFace.jb2.setVisible(false);
    		StudentFace.jb4.setVisible(false);
    		StudentFace.jb5.setVisible(true);
    	}
    }
    
    public void mouseClicked(MouseEvent e){};
    public void mousePressed(MouseEvent e){};
    public void mouseEntered(MouseEvent e){};
    public void mouseExited(MouseEvent e){};
    
    public void actionPerformed(ActionEvent e){
    	
    	Object o = e.getSource();
    	if(o.equals(btn1)){
    		card.show(jpl1,"second");
    	}
    	if(o.equals(btn2)){
    		card.show(jpl1,"third");
    	}
    	if(o.equals(btn4)){
    		card.show(jpl1,"forth");
    	}
    	if(o.equals(btn3)){
    		new AddScore();
    		mf.dispose();
    	}
    	if(o.equals(btn5)){
    		
    		System.exit(0);
    	}
    	if(o.equals(jbtn)){
    		
  			String 	strSQL="insert Student_Info(Student_ID,Student_Name,Student_Sex,Student_Dept,Student_Mjor)values('"+jt1.getText()+"','"
					+jt2.getText()+"','"
					+jcb.getSelectedItem()+"','"
					+jt4.getText()+"','"
					+jt5.getText()+"')";
			
				
			while(true){
				if(jt1.getText().trim().equals("")){
					JOptionPane.showMessageDialog(null,"请输入学号!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(jt2.getText().trim().equals("")){
			
					JOptionPane.showMessageDialog(null,"请输入姓名!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(jt4.getText().trim().equals("")){
				
					JOptionPane.showMessageDialog(null,"请输入院系!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(jt5.getText().trim().equals("")){
			
					JOptionPane.showMessageDialog(null,"请输入专业!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(db.updateSql(strSQL)){
						
					JOptionPane.showMessageDialog(null,"添加学生信息成功!","提示",JOptionPane.INFORMATION_MESSAGE);
					
					jt1.setEditable(false);
					jt2.setEditable(false);	
					jt4.setEditable(false);	
					jt5.setEditable(false);	
						
					break;		
				}else{
							
					JOptionPane.showMessageDialog(null,"添加学生信息失败!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}
		
			}
    	}
    	if(o.equals(tjbtn)){
    		
    		String 	strSQL="insert teacher_Info(teacher_ID,teacher_Name,teacher_sex,teacher_dept,teacher_post)values('"+tjt1.getText()+"','"
					+tjt2.getText()+"','"
					+tjcb.getSelectedItem()+"','"
					+tjt4.getText()+"','"
					+tjt5.getText()+"')";
			
				
			while(true){
				if(tjt1.getText().trim().equals("")){
					JOptionPane.showMessageDialog(null,"请输入教工号!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(tjt2.getText().trim().equals("")){
			
					JOptionPane.showMessageDialog(null,"请输入姓名!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(tjt4.getText().trim().equals("")){
				
					JOptionPane.showMessageDialog(null,"请输入院系!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(tjt5.getText().trim().equals("")){
			
					JOptionPane.showMessageDialog(null,"请输入职称!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}else if(db.updateSql(strSQL)){
						
					JOptionPane.showMessageDialog(null,"添加教师信息成功!","提示",JOptionPane.INFORMATION_MESSAGE);
					
					tjt1.setEditable(false);
					tjt2.setEditable(false);	
					tjt4.setEditable(false);	
					tjt5.setEditable(false);	
						
					break;		
				}else{
							
					JOptionPane.showMessageDialog(null,"添加教师信息失败!","提示",JOptionPane.INFORMATION_MESSAGE);
					break;
				}
		
			}
    		
    	}
    	if(o.equals(sjbtn)){
    		
    		for(int i =model.getRowCount()-1;i>=0;i--){
				model.removeRow(i);
				jpl1.repaint();
			}


    		int type = sjcb.getSelectedIndex();
    		switch(type){
    			case 0:  
    				try{
					
						String strSQL="select *from  Student_Info where Student_ID='"+sjtf.getText().trim()+"'";
				
						rs =db.getResult(strSQL);
				
						while(rs.next()){	
						Object data[] = {rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)};
						model.addRow(data);//addRow()需要Object数组类型!
						jpl1.repaint();
						}
						if(model.getRowCount()==0){
							
							JOptionPane.showMessageDialog(null,"没有搜索到记录!","提示",JOptionPane.INFORMATION_MESSAGE);
						}		
						
					}catch(SQLException ex){
						System.out.println(ex);
					}catch(NullPointerException ex){
						System.out.println(ex);
					}
    				break;
    			case 1:	
    				try{
					
						String strSQL="select *from  Student_Info where Student_Name='"+sjtf.getText().trim()+"'";
				
						rs =db.getResult(strSQL);
				
						while(rs.next()){	
						Object data[] = {rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)};
						model.addRow(data);//addRow()需要Object数组类型!
						jpl1.repaint();
						}
						if(model.getRowCount()==0){
							
							JOptionPane.showMessageDialog(null,"没有搜索到记录!","提示",JOptionPane.INFORMATION_MESSAGE);
						}		
						
					}catch(SQLException ex){
						System.out.println(ex);
					}catch(NullPointerException ex){
						System.out.println(ex);
					}
    				break;
    			case 2:	
    				try{
					
						String strSQL="select *from  Student_Info where Student_Dept='"+sjtf.getText().trim()+"'";
				
						rs =db.getResult(strSQL);
				
						while(rs.next()){	
						Object data[] = {rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)};
						model.addRow(data);//addRow()需要Object数组类型!
						jpl1.repaint();
						}		
						
						if(model.getRowCount()==0){
							
							JOptionPane.showMessageDialog(null,"没有搜索到记录!","提示",JOptionPane.INFORMATION_MESSAGE);
						}
					}catch(SQLException ex){
						System.out.println(ex);
					}catch(NullPointerException ex){
						System.out.println(ex);
					}
    				break;
    			case 3:	
    				try{
					
						String strSQL="select *from  Student_Info where Student_Mjor='"+sjtf.getText().trim()+"'";
				
						rs =db.getResult(strSQL);
				
						while(rs.next()){	
						Object data[] = {rs.getString(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)};
						model.addRow(data);//addRow()需要Object数组类型!
						jpl1.repaint();
						}		
						
						if(model.getRowCount()==0){
							
							JOptionPane.showMessageDialog(null,"没有搜索到记录!","提示",JOptionPane.INFORMATION_MESSAGE);
						}
					}catch(SQLException ex){
						System.out.println(ex);
					}catch(NullPointerException ex){
						System.out.println(ex);
					}
    				break;
    		
    		}
    		
    	}
    
    }
}

⌨️ 快捷键说明

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