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

📄 classesinformationinput.java

📁 学生信息管理系统,包括成绩查询,成绩排序,用ACCESS做数据库连接
💻 JAVA
字号:
package Chapter1;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Rectangle;
import java.sql.*;
public class ClassesInformationInput extends JFrame implements ActionListener
{
   public static final int WIDTH=400;
   public static final int HEIGHT=400;
  JLabel jLabel2 = new JLabel();
  JTextField jTextField1 = new JTextField();
  JLabel jLabel3 = new JLabel();
  JTextField jTextField2 = new JTextField();
  JLabel jLabel5 = new JLabel();
  JTextField jTextField3 = new JTextField();
  JLabel jLabel6 = new JLabel();
  JTextField jTextField4 = new JTextField();
  JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JTextField jTextField6 = new JTextField();
  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();
  JLabel jLabel4 = new JLabel();
  JLabel jLabel7 = new JLabel();
  JTextField jTextField5 = new JTextField();
  JLabel jLabel10 = new JLabel();
  JLabel jLabel1 = new JLabel();
  JTextField jTextField10 = new JTextField();
  JComboBox jComboBox1 = new JComboBox();
  JComboBox jComboBox2 = new JComboBox();
  JComboBox jComboBox3 = new JComboBox();
  public ClassesInformationInput()
   {
       setTitle("课程信息录入");
       setSize(WIDTH,HEIGHT);
       Container contentPane=getContentPane();
       contentPane.setBackground(Color.magenta);
       contentPane.setLayout(new FlowLayout());
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
   }
  public void actionPerformed(ActionEvent e)
  {
     if(e.getActionCommand().equals("提交"))
     {
         try
         {
           String url="jdbc:odbc:MySecondAccess";
           Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
           Connection con=DriverManager.getConnection(url,"","");
           Statement stmt=con.createStatement();
           String  num1=jTextField1.getText();   //课程号
           String  num2=jTextField2.getText();   //课序号
           String  name=jTextField3.getText();   //课程名
           String  teacher=jTextField4.getText() ;  //授课教师
           String  time=jTextField5.getText();      //上课时间
           String  place=jTextField6.getText();  //上课地点
           String  goal=(String)(jComboBox2.getSelectedItem());//学分
           String  kind=(String)(jComboBox1.getSelectedItem());           //课程性质
           String  testKind=(String)(jComboBox3.getSelectedItem());     //考试形式
           String  addition=jTextField10.getText();   //备注
           String  SQLOrder="INSERT INTO ClassesInformation VALUES('"+jTextField1.getText()+"','"+jTextField2.getText()+"','"+jTextField3.getText()+"','"+jTextField4.getText()+"','"+jTextField5.getText()+"','"+jTextField6.getText()+"','"+goal+"','"+kind+"','"+testKind+"','"+jTextField10.getText()+"')";
           stmt.executeUpdate(SQLOrder);
           stmt.close();
           con.close();
           JOptionPane.showMessageDialog(null,"课程信息"+name+"录入成功!","提示信息",JOptionPane.INFORMATION_MESSAGE);
           jTextField1.setText("");
           jTextField2.setText("");
           jTextField3.setText("");
           jTextField4.setText("");
           jTextField5.setText("");
           jTextField6.setText("");
           jTextField10.setText("");
         }
         catch(Exception ex)
         {
            JOptionPane.showMessageDialog(null,ex.getMessage(),"警告信息",JOptionPane.WARNING_MESSAGE);
            JOptionPane.showMessageDialog(null,ex.getStackTrace(),"警告信息",JOptionPane.WARNING_MESSAGE);
         }
     }
    else if(e.getActionCommand().equals("重置"))
    {
      jTextField1.setText("");
      jTextField2.setText("");
      jTextField3.setText("");
      jTextField4.setText("");
      jTextField5.setText("");
      jTextField6.setText("");
      jTextField10.setText("");
    }
    else if(e.getActionCommand().equals("返回"))
    {
          this.dispose();
          ManagerInterface n1= new ManagerInterface();
          StudentInterface n2=new  StudentInterface();
          if(Login.jComboBox1.getSelectedIndex()==0)
                {  n1.setVisible(true);  n2.dispose();}
          else if(Login.jComboBox1.getSelectedIndex()==1)
                {  n2.setVisible(true);  n1.dispose(); }
    }
  }
  public static void main(String[] args)
  {
       ClassesInformationInput  n = new ClassesInformationInput();
        n.setVisible(true);
  }
  private void jbInit() throws Exception
  {
    this.getContentPane().setLayout(null);
    jLabel2.setRequestFocusEnabled(true);
    jLabel2.setText("课程号:");
    jLabel2.setBounds(new Rectangle(74, 28, 49, 21));
    jTextField1.setText("");
    jTextField1.setBounds(new Rectangle(121, 30, 69, 20));
    jLabel3.setText("课序号:");
    jLabel3.setBounds(new Rectangle(222, 31, 52, 17));
    jTextField2.setText("");
    jTextField2.setBounds(new Rectangle(262, 29, 70, 20));
    jLabel5.setText("课程名:");
    jLabel5.setBounds(new Rectangle(75, 72, 47, 16));
    jTextField3.setText("");
    jTextField3.setBounds(new Rectangle(121, 70, 70, 18));
    jLabel6.setText("授课教师:");
    jLabel6.setBounds(new Rectangle(208, 71, 62, 17));
    jTextField4.setText("");
    jTextField4.setBounds(new Rectangle(262, 70, 71, 19));
    jLabel8.setText("上课时间:");
    jLabel8.setBounds(new Rectangle(62, 113, 58, 21));
    jLabel9.setText("上课地点:");
    jLabel9.setBounds(new Rectangle(209, 110, 60, 21));
    jTextField6.setText("");
    jTextField6.setBounds(new Rectangle(262, 110, 71, 18));
    jButton1.setBounds(new Rectangle(73, 236, 69, 32));
    jButton1.setText("提交");
    jButton2.setBounds(new Rectangle(180, 235, 75, 32));
    jButton2.setText("重置");
    jButton3.setBounds(new Rectangle(290, 234, 73, 32));
    jButton3.setText("返回");
    jLabel4.setText("学分:");
    jLabel4.setBounds(new Rectangle(84, 150, 31, 20));
    jLabel7.setText("课程性质:");
    jLabel7.setBounds(new Rectangle(208, 149, 55, 21));
    jTextField5.setBounds(new Rectangle(121, 109, 69, 20));
    jLabel10.setText("考试形式:");
    jLabel10.setBounds(new Rectangle(59, 188, 56, 22));
    jLabel1.setText("备注:");
    jLabel1.setBounds(new Rectangle(228, 194, 43, 21));
    jTextField10.setText("");
    jTextField10.setBounds(new Rectangle(262, 193, 70, 20));
    jComboBox1.setBounds(new Rectangle(263, 150, 73, 19));
    if(!(jComboBox1.getItemCount()==3))
    {
      jComboBox1.addItem("必修");
      jComboBox1.addItem("限选");
      jComboBox1.addItem("任选");
    }
    jComboBox2.setBounds(new Rectangle(121, 152, 72, 20));
    if(!(jComboBox2.getItemCount()==9))
    {
      jComboBox2.addItem("0分");
      jComboBox2.addItem("1分");
      jComboBox2.addItem("2分");
      jComboBox2.addItem("3分");
      jComboBox2.addItem("4分");
      jComboBox2.addItem("5分");
      jComboBox2.addItem("6分");
      jComboBox2.addItem("7分");
      jComboBox2.addItem("8分");
    }
    jComboBox3.setBounds(new Rectangle(122, 193, 73, 20));
    if(!(jComboBox3.getItemCount()==2))
    {
      jComboBox3.addItem("考试");
      jComboBox3.addItem("考查");
    }
    this.getContentPane().add(jLabel5, null);
    this.getContentPane().add(jTextField3, null);
    this.getContentPane().add(jTextField4, null);
    this.getContentPane().add(jLabel8, null);
    this.getContentPane().add(jTextField6, null);
    this.getContentPane().add(jTextField1, null);
    this.getContentPane().add(jTextField2, null);
    this.getContentPane().add(jLabel2, null);
    this.getContentPane().add(jLabel4);
    this.getContentPane().add(jTextField5);
    this.getContentPane().add(jButton1, null);
    this.getContentPane().add(jButton2, null);
    this.getContentPane().add(jButton3);
    this.getContentPane().add(jLabel10);
    this.getContentPane().add(jTextField10, null);
    this.getContentPane().add(jLabel1, null);
    this.getContentPane().add(jLabel7);
    this.getContentPane().add(jLabel9, null);
    this.getContentPane().add(jLabel6, null);
    this.getContentPane().add(jLabel3, null);
    this.getContentPane().add(jComboBox1, null);
    this.getContentPane().add(jComboBox2, null);
    this.getContentPane().add(jComboBox3, null);
    jButton1.addActionListener(this);
    jButton2.addActionListener(this);
    jButton3.addActionListener(this);
  }

}

⌨️ 快捷键说明

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