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

📄 student.txt

📁 学生学籍管理系统
💻 TXT
📖 第 1 页 / 共 3 页
字号:
package main;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.sql.*;
/////////////////////////////////////
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
//////////////////////////////////////////////
//程序说明
//作者:郭静
//建立一个数据库
//属性为:id sex name score major
//都为字符型
//然后建立数据源
//表名:xuesheng
//////////////////////////////////////////////


//主函数、主要类

public class Main{
public static void main(String []args)
{
new Frm_Main();
}
}


//实现类
class Frm_Main implements ActionListener //throws IOException
{
    public JFrame frame;
    public Container c;
    public JMenuBar menuBar;
    public JMenu mainMenu1;
    public JMenu mainMenu2;
    public JMenu mainMenu3;
    public JMenuItem subMenu1[] = new JMenuItem[5];
    public JMenuItem subMenu2[] = new JMenuItem[7];
    public JMenuItem subMenu3[] = new JMenuItem[2];
    JLabel Pic=new JLabel(); 
    JButton toolBarButton[] = new JButton[8];
    
    public JToolBar toolBar;
    JButton shang=new JButton("上传o(∩_∩)o...");
    Object a[][]=new Object[60][5];
    String title[]={"学号","姓名","成绩","性别","专业"};
    public JTable table=new JTable(a,title);
    JScrollPane scroll;
  
    JButton roder1=new JButton("按成绩+排序");
    JButton roder2=new JButton("按成绩-排序");
    JButton cake=new JButton("显示饼状图");
//////////////////////////////////////////////
    String strTip[] = {"查询您要找的学生记录...","添加学生记录...","删除已有的学生记录","修改学生记录...","使您修改的学生记录生效...","使您添加的学生记录生效...","确认删除当前记录...","显示所有在册学生:-)"};
//////////////////////////////////////////////
    String id = new String();
    String name = new String();
    String sex = new String();
    String major = new String();
    String score = new String();
    String birthday = new String();
    String pic=new String();
   
//////////////////////////////////////////////
    Connection con;
    ResultSet rs;
    Statement st;

///////////////////////////////////////////////
    public JLabel idL = new JLabel("学号:");
    public JLabel nameL = new JLabel("姓名:");
    public JLabel sexL = new JLabel("性别:");
    public JLabel majorL = new JLabel("专业:");
    public JLabel scoreL = new JLabel("成绩:");
    public JLabel photoL=new JLabel("照片:");
 //   public JLabel birthdayL=new JLabel("生日:");
   
    public JTextField idT = new JTextField();
    public JTextField nameT = new JTextField();
    public JTextField sexT = new JTextField();
    public JTextField majorT = new JTextField();
    public JTextField scoreT = new JTextField();
   // public JTextField birthdayT = new JTextField();
  
    //////////////////////////////////////////////

//////////////////////////////////////////////
    public Frm_Main()
    {
        frame = new JFrame("学生学籍管理系统");
        c = frame.getContentPane();
        c.setLayout(null);
        menuBar = new JMenuBar();
        toolBar = new JToolBar();
      
        toolBar.setFloatable(true);
        frame.setJMenuBar(menuBar);
        frame.setResizable(true);
////////////////////////////////////////////////
    
        mainMenu1 = new JMenu("按时间查找");
        String str1[] = {"按出生日期查找","按学号查找","按成绩查找"," ","退出"};
          for(int i=0;i<5;i++)
           {
                if(i==3)
                   mainMenu1.addSeparator();
                else
                   {
                    subMenu1[i] = new JMenuItem(str1[i]);
                    subMenu1[i].addActionListener(this);
                    mainMenu1.add(subMenu1[i]);
                     }
            }
         menuBar.add(mainMenu1);
/////////////////////////////////////////////////
         mainMenu2 = new JMenu("维护学生信息");
         String str2[] = {"查询记录","添加记录","删除记录","修改记录","提交修改","提交添加","确认删除"};
         for(int i=0;i<7;i++)
         {
             subMenu2[i] = new JMenuItem(str2[i]);
             subMenu2[i].addActionListener(this);
             mainMenu2.add(subMenu2[i]);
          }
         menuBar.add(mainMenu2);
         ////////////////////////////////////
         mainMenu3 = new JMenu("班级");
         String str3[] = {"信息安全","计算机"};
         for(int i=0;i<2;i++)
         {
             subMenu3[i] = new JMenuItem(str3[i]);
             subMenu3[i].addActionListener(this);
             mainMenu3.add(subMenu3[i]);
          }
          menuBar.add(mainMenu3);
////////////////////////////////////////////////
          String strToolBar[] ={"查询","添加","删除","修改","提交修改","提交添加","确认删除","学生"};

         for(int i=0;i<8;i++)
         {

              toolBarButton[i] = new JButton(strToolBar[i]);
              toolBarButton[i].setToolTipText(strTip[i]);
              toolBarButton[i].addActionListener(this);
              toolBar.add(toolBarButton[i]);

          }
          toolBar.setLocation(0,0);
          toolBar.setSize(400,30);
          c.add(toolBar);
          
          roder1.addActionListener(this);
          roder2.addActionListener(this);
          cake.addActionListener(this);
////////////////////////////////////////////////
          idL.setLocation(35,40);
          idL.setSize(40,20);
          c.add(idL);

          idT.setLocation(90,40);
          idT.setSize(200,20);
           c.add(idT);

          nameL.setLocation(35,70);
          nameL.setSize(40,20);
          c.add(nameL);

          nameT.setLocation(90,70);
          nameT.setSize(200,20);
          c.add(nameT);

          sexL.setLocation(35,100);
          sexL.setSize(40,20);
          c.add(sexL);

          sexT.setLocation(90,100);
          sexT.setSize(200,20);
          c.add(sexT);

          majorL.setLocation(35,130);
          majorL.setSize(40,20);
          c.add(majorL);

          majorT.setLocation(90,130);
          majorT.setSize(200,20);
          c.add(majorT);

         scoreL.setLocation(35,160);
         scoreL.setSize(40,20);
         c.add(scoreL);

         scoreT.setLocation(90,160);
         scoreT.setSize(200,20);
         c.add(scoreT);
         
        /* birthdayL.setLocation(35,190);
         birthdayL.setSize(40,20);
         c.add(birthdayL);*/

        /* birthdayT.setLocation(90,190);
         birthdayT.setSize(200,20);
         c.add(birthdayT);*/
         
         photoL.setLocation(35,190);
         photoL.setSize(40,20);
         c.add(photoL);

         shang.setLocation(90,410);
         shang.setSize(200,20);
         c.add(shang);

        scroll=new JScrollPane(table);
        scroll.setLocation(300,40);
        scroll.setSize(400,380);
        c.add(scroll);

        roder1.setLocation(330,430);
        roder1.setSize(100,30);
        c.add(roder1);

        roder2.setLocation(430,430);
        roder2.setSize(100,30);
        c.add(roder2);
        
        cake.setLocation(530,430);
        cake.setSize(100,30);
        c.add(cake);
////////////////////////////////////////////////
         JLabel information = new JLabel("o(∩_∩)o...");
         information.setFont(new Font("宋体",Font.BOLD,65));
         information.setSize(380,200);
         information.setLocation(180,420);
         c.add(information);
////////////////////////////////////////////////
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.setSize(800,650);
         frame.setLocation(200,200);
         frame.setVisible(true);
         conDB();

    }

    //以上是设置数据库面版、框架

    //以下是连接数据库
    public void conDB()
    {
      try
      {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

       }
      catch(ClassNotFoundException e)
       {
          JOptionPane.showMessageDialog(null,"提示:数据库加载失败了,呵呵!");
       }
      try
       {
          con = DriverManager.getConnection("jdbc:odbc:sun","","");
          st = con.createStatement();
        }
       catch(SQLException e)

⌨️ 快捷键说明

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