学生学籍管理系统_管理员登陆对学生的信息进行操作

MInterface.java

package studentManage;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/*
 * 管理员
 * 操作界面接口类,可以直接扩展、调用。
 */

public class MInterface extends JFrame implements ActionListener {
	static JMenuBar jMenuBar = new JMenuBar();// 菜单条
	static JMenu jMenuFile = new JMenu("文件");// 菜单项
	static JMenu jMenuExit = new JMenu("退出");
	static JMenuItem jMenuItem2= new JMenuItem("信息查询");
	static JMenuItem jMenuItem3 = new JMenuItem("学生注册");
	static JLabel label3 = new JLabel("请选择操作项");
	static JLabel label4 = new JLabel("学籍管理系统");
	static JButton button2 = new JButton("信息查询");
	static JButton button3 = new JButton("学生注册");

	public MInterface() {
		this.setTitle("学籍管理系统");
		this.setLayout(null);
		this.setSize(400, 400);
		label3.setBounds(158, 92, 98, 33);
		label3.setFont(new Font("Dialog", Font.PLAIN, 15));
		label4.setFont(new Font("Dialog", Font.BOLD, 20));
		label4.setBounds(157, 37, 280, 40);
		button2.setBounds(74, 136, 97, 33);
		button3.setBounds(226, 136, 97, 33);
		this.add(button2);
		this.add(button3);
		this.add(label3);
		this.add(label4);
		setJMenuBar(jMenuBar);
		// ”文件“菜单项中加入子菜单
		jMenuFile.add(jMenuItem2);
		jMenuFile.add(jMenuItem3);
		jMenuBar.add(jMenuFile);// 将菜单项加入菜单条
		jMenuBar.add(jMenuExit);
		button2.addActionListener(this);// 本窗口向按钮事件源注册
		button3.addActionListener(this);
		// 本窗口菜单子项注册
		jMenuItem2.addActionListener(this);
		jMenuItem3.addActionListener(this);
		jMenuExit.addActionListener(this);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
	}

	public static void main(String[] args) {
		MInterface a = new MInterface();
	}

	public void actionPerformed(ActionEvent e) // 按钮事件的处理
	{
		if (e.getSource() == jMenuExit) {
			System.exit(0);
		} else if (e.getSource() == jMenuItem2 || e.getSource() == button2) {
			//对学生的信息进行查询
			try {
				MCx a = new MCx();
			} catch (Exception ee) {
			}
		} else if (e.getSource() == jMenuItem3 || e.getSource() == button3) {
			//注册学生
			try {
				Zhuce a = new Zhuce();
			} catch (Exception ed) {
			}
		}
	}

}

MCx.java

package studentManage;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class MCx extends JFrame implements ActionListener {
	static MCx s;
	static JLabel label1 = new JLabel("学号:");
	static JTextField textField1 = new JTextField("");
	static JLabel label2 = new JLabel("姓名:");
	static JTextField textField2 = new JTextField("");
	static JLabel label3 = new JLabel("班级:");
	static JTextField textField3= new JTextField("");
	static JLabel label4 = new JLabel("专业:");
	static JTextField textField4 = new JTextField("");
	static JLabel label5 = new JLabel("院系:");
	static JTextField textField5 = new JTextField("");
	static JLabel label6 = new JLabel("性别");
	static JTextField textField6 = new JTextField("");
	static JLabel label7 = new JLabel("年级:");
	static JTextField textField7 = new JTextField("");
	static JLabel label8 = new JLabel("生日");
	static JTextField textField8 = new JTextField("");
	static JLabel label9 = new JLabel("电话:");
	static JTextField textField9 = new JTextField("");
	static JLabel label10 = new JLabel("QQ:");
	static JTextField textField10 = new JTextField("");
	static JLabel label11 = new JLabel("状态:");
	static JTextField textField11 = new JTextField("");
	static JLabel label12 = new JLabel("密码:");
	static JTextField textField12 = new JTextField("");

	static JButton button3 = new JButton("按学号查询");
	static JButton button4 = new JButton("修改");
	static JButton button5 = new JButton("删除");
	static JButton button6 = new JButton("按姓名查询");

	//初始化界面
	public MCx() throws Exception {
		this.setTitle("查询学生信息");
		this.setLayout(null);
		this.setSize(600, 600);

		label1.setBounds(30, 11, 50, 30);	//学号
		textField1.setBounds(60, 16, 70, 20);

		label2.setBounds(160, 11, 50, 30);//姓名
		textField2.setBounds(190, 16, 70, 20);

		label3.setBounds(290, 11, 50, 30);//班级
		textField3.setBounds(320, 16, 70, 20);
		//===========

		label4.setBounds(30, 61, 50, 30);//专业
		textField4.setBounds(60, 66, 70, 20);

		label5.setBounds(160, 61, 50, 30);//系别
		textField5.setBounds(190, 66, 70, 20);

		label6.setBounds(290, 61,50, 30);//性别
		textField6.setBounds(320, 66, 70, 20);

		//===========

		label7.setBounds(30, 111, 50, 30);//年级
		textField7.setBounds(60, 116, 70, 20);	

		label8.setBounds(140, 111, 50, 30);//出生日期
		textField8.setBounds(190, 116, 70, 20);

		label9.setBounds(290, 111, 50, 30);//电话
		textField9.setBounds(320, 116, 70, 20);

		//=========

		label10.setBounds(30, 161, 50, 30);//QQ
		textField10.setBounds(60,166,70,20 );

		label11.setBounds(160, 161, 50, 30);//状态
		textField11.setBounds(190,166, 70, 20);

		label12.setBounds(290, 161, 51, 33);//密码
		textField12.setBounds(320,166, 70, 22);

		button6.setBounds(60, 241, 100, 33);
		button3.setBounds(180, 241, 100, 33);

		button4.setBounds(60, 300, 100, 33);
		button5.setBounds(180, 300, 100, 33);

		button3.addActionListener(this);
		button4.addActionListener(this);
		button5.addActionListener(this);
		button6.addActionListener(this);

		this.add(label1);
		this.add(label2);
		this.add(label3);
		this.add(label4);
		this.add(label5);
		this.add(label6);
		this.add(label7);
		this.add(label8);
		this.add(label9);
		this.add(label10);
		this.add(label11);
		this.add(label12);

		this.add(textField1);
		this.add(textField2);
		this.add(textField3);
		this.add(textField4);
		this.add(textField5);
		this.add(textField6);
		this.add(textField7);
		this.add(textField8);
		this.add(textField9);
		this.add(textField10);
		this.add(textField11);
		this.add(textField12);		

		this.add(button3);
		this.add(button4);
		this.add(button5);
		this.add(button6);

		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		this.setVisible(true);

	}

	public static void main(String[] args) throws Exception {
		MCx a = new MCx();
		a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == button6) {
			try {

				Class.forName("com.mysql.jdbc.Driver");
			} catch (ClassNotFoundException ce) {
				JOptionPane.showMessageDialog(s, ce.getMessage());
			}
			try {
				Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","111");
				Statement stmt = con.createStatement();

				ResultSet rs = stmt.executeQuery("select * from infor where name='"
								+ textField2.getText() + "'");
				if (textField2.getText().trim().equals("")) {
					JOptionPane.showMessageDialog(this, "姓名不可为空!");
				}
				else if (rs.next()) {
					textField1.setText(rs.getString("stuId"));
					textField2.setText(rs.getString("name"));
					textField3.setText(rs.getString("class"));
					textField4.setText(rs.getString("profess"));
					textField5.setText(rs.getString("depart"));
					textField6.setText(rs.getString("sex"));
					textField7.setText(rs.getString("grade"));
					textField8.setText(rs.getString("bir"));
					textField9.setText(rs.getString("phone"));
					textField10.setText(rs.getString("QQ"));
					textField11.setText(rs.getString("state"));
					textField12.setText(rs.getString("password"));

				} else {
					JOptionPane.showMessageDialog(this, "无此记录!!!");
				}
			}
			catch (SQLException se) {
				JOptionPane.showMessageDialog(s, se.getMessage());
			}
		}

		if (e.getSource() == button3) {
			try {

				Class.forName("com.mysql.jdbc.Driver");
			} catch (ClassNotFoundException ce) {
				JOptionPane.showMessageDialog(s, ce.getMessage());
			}
			try {
				Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","111");
				Statement stmt = con.createStatement();

				ResultSet rs = stmt.executeQuery("select * from infor where stuId='"
								+ textField1.getText() + "'");
				if (textField1.getText().trim().equals("")) {
					JOptionPane.showMessageDialog(this, "学号不可为空!");
				}
				else if (rs.next()) {
					textField1.setText(rs.getString("stuId"));
					textField2.setText(rs.getString("name"));
					textField3.setText(rs.getString("class"));
					textField4.setText(rs.getString("profess"));
					textField5.setText(rs.getString("depart"));
					textField6.setText(rs.getString("sex"));
					textField7.setText(rs.getString("grade"));
					textField8.setText(rs.getString("bir"));
					textField9.setText(rs.getString("phone"));
					textField10.setText(rs.getString("QQ"));
					textField11.setText(rs.getString("state"));
					textField12.setText(rs.getString("password"));

				} else {
					JOptionPane.showMessageDialog(this, "无此记录!!!");
				}
			}
			catch (SQLException se) {
				JOptionPane.showMessageDialog(s, se.getMessage());
			}
		}

		//修改表信息
		if(e.getSource()==button4)
	    {
				try{

						Class.forName("com.mysql.jdbc.Driver");
						}
				catch (ClassNotFoundException ce)
					{
						JOptionPane.showMessageDialog(s,ce.getMessage());
					}
				try
				{
					Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","111");

					Statement stmt = con.createStatement();

	     ResultSet rs=stmt.executeQuery("select * from infor where stuId='"+textField1.getText()+"'");
	                if(textField1.getText().trim().equals(""))
	                {
	                    JOptionPane.showMessageDialog(this,"学号不可为空!");
	                }else if(rs.next())
	               {
	                	 try{

	                	stmt.execute("update infor set name='"+
	               	          textField2.getText()+"',class='"+textField3.getText()+"',profess='"+
	               	                 textField4.getText()+"',depart='"+textField5.getText()+"',sex='"+
	               	                 textField6.getText()+"',grade='"+textField7.getText()+"',bir='"+
	               	                 textField8.getText()+ "',phone='"+textField9.getText()+"',QQ='"+textField10.getText()+
	               	                 "',state='"+textField11.getText()+"',password='"+textField12.getText()
	               	              +"'where stuId='"+textField1.getText

	               	           ()+"'");  

	                	stmt.execute("insert into operate(stuId,operate)values("+textField1.getText()+",'修改操作')");
	                				JOptionPane.showMessageDialog(null,"修改成功并把此次操作记录存入数据库");
	                	 }
	               	                 	//stmt.executeQuery(updateSql);}
	               	             // stmt.executeUpdate(updateSql);}
	               	                 	catch(SQLException se)
	               	                 	{
	               	                 	//JOptionPane.showMessageDialog(null,"请输入正确的信息");
	               	                 	JOptionPane.showMessageDialog(s,se.getMessage());
	               	                 	}      	                 

	               	}
	                     }
	      	catch(SQLException se)
	        {
	           JOptionPane.showMessageDialog(s,se.getMessage());
	          }
	    }

		if (e.getSource() == button5) {
			try {

				Class.forName("com.mysql.jdbc.Driver");
			} catch (ClassNotFoundException ce) {
				JOptionPane.showMessageDialog(s, ce.getMessage());
			}
			try {
				Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","111");
				Statement stmt = con.createStatement();
				ResultSet rs = stmt
						.executeQuery("select * from infor where stuId='"
								+ textField1.getText() + "'");
				if (textField1.getText().trim().equals("")) {
					JOptionPane.showMessageDialog(this, "学号不可为空!");
				}

				else if (rs.next()) {
					JOptionPane.showConfirmDialog(null,
							"确定要删除该信息嘛?\n删除的信息将不能恢复,继续?", "删除 确定",
							JOptionPane.OK_CANCEL_OPTION);// ,JOption.QUESTION_MESSAGE)==0;
					stmt.execute("delete  from infor where  stuId='"
							+ textField1.getText() + "'");
					stmt.execute("insert into operate(stuId,operate)values("+textField1.getText()+",'删除操作')");
					JOptionPane.showMessageDialog(null, "删除信息成功并把此次操作记录存入数据库!");
					this.dispose();
				} else
					JOptionPane.showMessageDialog(null, "无此学号对应信息", "警告",
							JOptionPane.WARNING_MESSAGE);
			} catch (Exception ed) {
				JOptionPane.showMessageDialog(s, ed.getMessage());
			}
		}
	}
}

Zhuce.java

package studentManage;

import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
import java.sql.*;

public class Zhuce extends JFrame implements ActionListener {
	static Zhuce s;
	static JLabel label1 = new JLabel("学号:");
	static JTextField textField1 = new JTextField("");
	static JLabel label2 = new JLabel("姓名:");
	static JTextField textField2 = new JTextField("");
	static JLabel label3 = new JLabel("班级:");
	static JTextField textField3= new JTextField("");
	static JLabel label4 = new JLabel("专业:");
	static JTextField textField4 = new JTextField("");

	static JLabel label5 = new JLabel("院系:");
	static JTextField textField5 = new JTextField("");

	//制作下拉框
	static JComboBox<String> ck=new JComboBox<String>();
	//ck.addItem("计算机");

	static JLabel label6 = new JLabel("性别");
	static JTextField textField6 = new JTextField("");
	static JLabel label7 = new JLabel("年级:");
	static JTextField textField7 = new JTextField("");
	static JLabel label8 = new JLabel("生日");
	static JTextField textField8 = new JTextField("");
	static JLabel label9 = new JLabel("电话:");
	static JTextField textField9 = new JTextField("");
	static JLabel label10 = new JLabel("QQ:");
	static JTextField textField10 = new JTextField("");
	static JLabel label11 = new JLabel("状态:");
	static JTextField textField11 = new JTextField("");
	static JLabel label12 = new JLabel("密码:");
	static JTextField textField12 = new JTextField("");

	static JButton button1 = new JButton("注册");

	public Zhuce() {
		this.setTitle("用户注册");
		this.setLayout(null);

        this.setSize(600, 600);

		label1.setBounds(30, 11, 50, 30);	//学号
		textField1.setBounds(60, 16, 70, 20);

		label2.setBounds(160, 11, 50, 30);//姓名
		textField2.setBounds(190, 16, 70, 20);

		label3.setBounds(290, 11, 50, 30);//班级
		textField3.setBounds(320, 16, 70, 20);
		//===========

		label4.setBounds(30, 61, 50, 30);//专业
		//textField4.setBounds(60, 66, 70, 20);

		ck.addItem("英语");
		ck.addItem("日语");
		ck.addItem("体育");
		ck.addItem("声乐");

		ck.setBounds(60, 66, 70, 20);

		label5.setBounds(160, 61, 50, 30);//系别
		textField5.setBounds(190, 66, 70, 20);

		label6.setBounds(290, 61,50, 30);//性别
		textField6.setBounds(320, 66, 70, 20);

		//===========

		label7.setBounds(30, 111, 50, 30);//年级
		textField7.setBounds(60, 116, 70, 20);	

		label8.setBounds(160, 111, 50, 30);//生日
		textField8.setBounds(190, 116, 70, 20);

		label9.setBounds(290, 111, 50, 30);//电话
		textField9.setBounds(320, 116, 70, 20);

		//=========

		label10.setBounds(30, 161, 50, 30);//QQ
		textField10.setBounds(60,166,70,20 );

		label11.setBounds(160, 161, 50, 30);//状态
		textField11.setBounds(190,166, 70, 20);

		label12.setBounds(290, 161, 51, 33);//密码
		textField12.setBounds(320,166, 70, 22);

		button1.setBounds(250, 241, 80, 33);

		this.add(label1);
		this.add(label2);
		this.add(label3);
		this.add(label4);
		this.add(label5);
		this.add(label6);
		this.add(label7);
		this.add(label8);
		this.add(label9);
		this.add(label10);
		this.add(label11);
		this.add(label12);

		this.add(textField1);
		this.add(textField2);
		this.add(textField3);
		//this.add(textField4);
		this.add(ck);

		this.add(textField5);
		this.add(textField6);
		this.add(textField7);
		this.add(textField8);
		this.add(textField9);
		this.add(textField10);
		this.add(textField11);
		this.add(textField12);

		this.add(button1);

		button1.addActionListener(this);

		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		this.setVisible(true);
	}

	public static void main(String[] args) throws Exception {
		Zhuce a = new Zhuce();
		a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	}

	public void actionPerformed(ActionEvent e)//事件处理程序
   {    if (e.getSource() == button1)
    {
    	try{
					//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    			Class.forName("com.mysql.jdbc.Driver");
			}
			catch (ClassNotFoundException ce)
				{
					JOptionPane.showMessageDialog(s,ce.getMessage());
				}
			try
			{
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/stu","root","111");
			Statement stmt = con.createStatement();
     ResultSet rs=stmt.executeQuery("select * from infor where stuId='"+textField1.getText()+"'");
         if(rs.next())
         {
         	JOptionPane.showMessageDialog(null,"此用户已经被注册");
         	}
         	else
         	{
         		stmt.execute("insert into infor (stuId,name,class,profess,depart,sex,grade,bir,phone,QQ,state,password) values ('"+
         		       textField1.getText()+"','"+textField2.getText()+"','" +textField3.getText()+"','" +ck.getSelectedIndex()+"','"
         		       +textField5.getText()+"','"+textField6.getText()+"','"+textField7.getText()+"','"
         		       +textField8.getText()+"','"+textField9.getText()+"','"+textField10.getText()+"','"
         		       +textField11.getText()+"','"+textField12.getText()
		               		 +"')");
    	    	JOptionPane.showMessageDialog(null,"添加用户成功");
           }
  }
  catch (SQLException se)
			{
				JOptionPane.showMessageDialog(s,se.getMessage());
			}
    	}
   }

}

管理员的相关功能代码

时间: 2024-10-12 20:40:12

学生学籍管理系统_管理员登陆对学生的信息进行操作的相关文章

学生学籍管理系统_学生登陆系统查询与修改信息

SCx.java package studentManage; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.sql.*; public class SCx extends JFrame implements ActionListener { static SCx s; static JLabel label1 = new JLabel("学号:"); static JText

JAVA学生学籍管理系统

每天记录学习,每天会有好心情.*^_^* 今天记录的项目是基于JAVA的学生学籍管理系统,基于JAVA的学生学籍管理系统项目是这么回事:电子学籍系统可对学生学籍注册.档案管理.学籍异动.升级.毕业.成长记录实现全程信息化管理.采用当前非常流行的B/S体系结构,以JAVA作为开发技术,主要依赖SSM技术框架,mysql数据库.2013年12月8日,教育部基础教育一司司长王定华在长春出席会议时表示,中小学电子学籍系统将在2013年年底全国联网,2014年正式实现开通,今后中央在一些经费支持方面,将与

[C语言练习]学生学籍管理系统

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86

学生学籍管理系统

<span style="color:#ff0000;"> 学生学籍管理系统</span> 这个项目用了一天半的时间就完成了,一开始我没打算用链表来实现的,但是我自学链表也有一段时间了,想看看自己对链表掌握了多少,所以选择了用链表.第一次用链表写了一个系统,难免会有Bug,希望各位程序猿能指点一下..... /********************************************** 学生学籍管理系统 每个学生的信息包括:学号.姓名.性别.三门

JAVA测验—学生学籍管理系统

设计思路: 创建基本的ScoreInfoemation类,创建基本的数据成员以及基本的设置方法.获取数据方法以及有无参的构造方法. 1 package Test; 2 3 import java.util.*; 4 5 public class ScoreInformation { 6 7 private String stunumber; 8 private String name; 9 private double mathematicsscore; 10 private double en

石家庄铁道大学软件工程系学生学籍管理系统2019版

//信1805-1 戴伟伟 20183773package dww; import java.util.Scanner; class ScoreInformation { private String stunumber; private String name; private double mathematicsscore; private double englishscore; private double networkscore; private double databasesco

C语言学生学籍管理系统源码,有实验报告噢!

设计一个学生成绩管理系统,对上学期的本班的学习成绩进行管理,具有查询和检索功能,并且能够对指定文件操作,也可将多个文件组成一个文件?. A . ??设计内容 1 .每一条记录包括一个学生的学号.姓名.性别.各门课成绩(上学期的科目).平均成绩. 2 .输入功能:可以一次完成若干条记录的输入. 3 .显示功能:完成全部学生记录的显示. 4 .查找功能:完成按姓名或学号查找学生记录,并显示. 5 .排序功能:按学生平均成绩进行排序. 6 .插入功能:按 学号顺序插入 一条学生记录. 7 .将学生记录

C语言实现---学生成绩管理系统

C语言实现了学生成绩管理系统,可以进行学生成绩的增加,删除,更新,查询,计算和展示. 完整代码如下: #include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct person //定义结构体 { char num[10]; //学号 char name[20]; //姓名 float cyuyan; //C语言成绩 float en; //物理学成绩 float ji; //原子物理成绩

Java编写学生成绩管理系统

思路:定义两个类,一个scoreinformation类,一个scoremanagement类,scoreinformation类用于编写姓名,学号,以及各项成绩的输入函数,scoreinformation类有七个私有变量,和各个变量的get(),set()函数,scoremanagement类用于表现各项功能,包括学生信息的引入函数,学生信息的添加函数,学生信息的修改函数,学生成绩绩点的计算函数,以及退出系统的函数,在最后的主函数中,首先调用存储学生信息的函数,然后运用switch,case函