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

📄 anewcourseinput.java

📁 学生成绩管理系统,可以修改
💻 JAVA
字号:

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AnewCourseInput extends JFrame implements ActionListener{
	 DataBaseManager db = new DataBaseManager();
	 ResultSet rs;
	 JList jList1;
     JLabel jLabel4;
     JComboBox jComboBox2;
     JLabel jLabel5;
     JComboBox jComboBox1;
     JTextField jTextField2;
     JLabel jLabel2;
     JLabel jLabel3;
	 JTextField jTextField3;
	 JButton jButton2;
	 JButton jButton1;
	 JTextField jTextField1;
     JLabel jLabel1;
                           public AnewCourseInput (){
                        	    this.setBounds(431, 223, 287, 314);
                        	    this.setVisible(true);
                        	    this.setLayout(null);
                        	    this.setTitle("录入重修科目");
                        	    this.setResizable(false);
                        	    {
                        	    	jLabel1 = new JLabel();
                        	    	getContentPane().add(jLabel1);
                        	    	jLabel1.setText("学号:");
                        	    	jLabel1.setBounds(41, 33, 50, 21);
                        	    }
                        	    {
                        	    	jTextField1 = new JTextField();
                        	    	getContentPane().add(jTextField1);
                        	    	jTextField1.setText("");
                        	    	jTextField1.setBounds(97, 30, 145, 27);
                        	    }
                        	    {
                        	    	jLabel4 = new JLabel();
                        	    	getContentPane().add(jLabel4);
                        	    	jLabel4.setText("科目名称:");
                        	    	jLabel4.setBounds(34, 188, 71, 23);
                        	    }
                        	    {
                        	    	jButton1 = new JButton();
                        	    	jButton1.addActionListener(this);
                        	    	getContentPane().add(jButton1);
                        	    	jButton1.setText("录入");
                        	    	jButton1.setBounds(65, 231, 75, 25);
                        	    }
                        	    {
                        	    	jButton2 = new JButton();
                        	    	jButton2.addActionListener(this);
                        	    	getContentPane().add(jButton2);
                        	    	jButton2.setText("关闭");
                        	    	jButton2.setBounds(168, 230, 75, 27);
                        	    }
                        	    {
                        	    	jLabel3 = new JLabel();
                        	    	getContentPane().add(jLabel3);
                        	    	jLabel3.setText("课程编号:");
                        	    	jLabel3.setBounds(33, 78, 56, 19);
                        	    }
                        	    {
                        	    	jTextField3 = new JTextField();
                        	    	getContentPane().add(jTextField3);
                        	    	jTextField3.setText("");
                        	    	jTextField3.setBounds(101, 75, 141, 24);
                        	    }
                        	    {
                        	    	jLabel2 = new JLabel();
                        	    	getContentPane().add(jLabel2);
                        	    	jLabel2.setText("任课教师:");
                        	    	jLabel2.setBounds(33, 154, 56, 15);
                        	    }
                        	    {
                        	    	jTextField2 = new JTextField();
                        	    	getContentPane().add(jTextField2);
                        	    	jTextField2.setText("");
                        	    	jTextField2.setBounds(101, 149, 143, 25);
                        	    }
                        	    {
                        	    	ComboBoxModel jComboBox1Model = 
                        	    		new DefaultComboBoxModel(
                        	    				new String[] { "java程序设计", "日语" ,"操作系统","专业英语","体育","数据库"});
                        	    	jComboBox1 = new JComboBox();
                        	    	getContentPane().add(jComboBox1);
                        	    	jComboBox1.setModel(jComboBox1Model);
                        	    	jComboBox1.setBounds(102, 188, 141, 23);
                        	    }
                        	    {
                        	    	jLabel5 = new JLabel();
                        	    	getContentPane().add(jLabel5);
                        	    	jLabel5.setText("学期名称:");
                        	    	jLabel5.setBounds(33, 120, 56, 15);
                        	    }
                        	    {
                        	    	ComboBoxModel jComboBox2Model = 
                        	    		new DefaultComboBoxModel(
                        	    				new String[] { "2008-2009上学期", "2008-2009下学期" });
                        	    	jComboBox2 = new JComboBox();
                        	    	getContentPane().add(jComboBox2);
                        	    	jComboBox2.setModel(jComboBox2Model);
                        	    	jComboBox2.setBounds(101, 111, 141, 27);
                        	    }

                           }
  public void actionPerformed(ActionEvent e){
	    if(e.getSource()==jButton2){
 	        this.dispose();
	        }

  		else if(e.getSource()==jButton1)
  		{
  			try
  			{
  				String strSQL="select * from AnewCourse where 学号='"+
  				jTextField1.getText().trim()+"'";
  				if(jTextField1.getText().trim().equals(""))
  				{
  					JOptionPane.showMessageDialog(null,"学号不能为空!");
  				}
  				else if(jTextField3.getText().trim().equals(""))
  				{
  					JOptionPane.showMessageDialog(null,"课程编号不能为空!");
  				}
  				else if(jTextField2.getText().trim().equals(""))
  				{
  					JOptionPane.showMessageDialog(null,"任课教师不能为空!");
  				}
  				else
  				{
  				    if(db.getResult(strSQL).absolute(6))
				        {
					         int result=JOptionPane.showOptionDialog(null, "当前学号的科目录入完毕是否要继续输入其他学生科目?", "系统提示", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] {"是","否"}, "否");
					         if(result==JOptionPane.YES_OPTION){
					                 new AnewCourseInput();
					         }
					         else{
					    	        this.dispose();
					       }
  				        }
  				         else 
  				         {
  				         	strSQL="insert into AnewCourse (学号,课程编号,学期名称,任课教师,科目名称) values ('"+jTextField1.getText().trim()+"','"+jTextField3.getText().trim()+"','" +jComboBox2.getSelectedItem()+"','"+jTextField2.getText().trim()+"','" +jComboBox1.getSelectedItem()+"')";
  				         	if(db.updateSql(strSQL))
  				         	{
  				         		this.dispose();
  				         		JOptionPane.showMessageDialog(null,"录入重修课程成功!");
  				         		
  				         	}
  				         	else
  				         	{
  				         		JOptionPane.showMessageDialog(null,"录入重修课程失败!");
  				         	}
  				         }
  				}
  			}
  			catch(SQLException sqle)
  			{
  				System.out.println(sqle.toString());
  			}
  			catch(Exception ex)
  			{
  				System.out.println(ex.toString());
  			}
  		}
  	}    
 }

⌨️ 快捷键说明

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