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);//QQtextField10.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();} elseJOptionPane.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);//QQtextField10.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());}}}}

管理员的相关功能代码

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

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

    SCx.java package studentManage;import javax.swing.*;import java.awt.*; import java.awt.event.*; impo ...

  2. 学生学籍管理系统_登陆界面设计

    Studnet.java package studentManage;/** 初始化界面,使主界面位于屏幕中间,且用户不能改变大小*/import javax.swing.UIManager; imp ...

  3. mysql学籍管理系统的开发背景,学生学籍管理系统的设计与实现(JSP,MySQL)

    学生学籍管理系统的设计与实现(JSP,MySQL)(任务书,开题报告,中期检查表,文献综述,外文翻译,毕业论文22000字,程序代码,MySQL数据库) 本课题根据学生学籍管理系统的流程及所需要的相关 ...

  4. 学生学籍管理系统 jsp mysql_学生学籍管理系统的设计与实现(JSP,MySQL)

    学生学籍管理系统的设计与实现(,MySQL)(任务书,开题报告,中期检查表,文献综述,外文翻译,毕业论文22000字,程序代码,MySQL数据库) 本课题根据学生学籍管理系统的流程及所需要的相关操作, ...

  5. 【计算机毕业设计】679学生学籍管理系统

    一.系统截图(需要演示视频可以私聊) 目 录 目 录 摘  要 ABSTRACT 1 绪论 1.1 课题背景 1.2 研究现状 1.3 研究内容 2 系统开发环境 2.1 vue技术 2.2 JAVA ...

  6. 用mysql设计学籍管理系统_学生学籍管理系统(SQL数据库系统设计)(完整版).pdf...

    . 数据库课程设计报告 < 学生学籍管理系统 > 专业 班级 小组成员 指导老师 开始时间 完成时间 word 专业资料 . 目录 数据库课程设计报告 1 1. 问题描述 3 1.1 背景 ...

  7. 用python写学籍管理系统_使用Python实现 学生学籍管理系统

    大家好,今天跟大家分享一个用Python实现的学生学籍管理系统: 该代码主体由五个函数组成: 1.add_stu() 添加 2.del_stu() 删除 3.print_stu()打印 4.exit_ ...

  8. 学籍管理系统 c语言流程图,程序设计基础 ——C语言第10章 综合应用案例——学生学籍管理系统...

    程序设计基础 第 10章 综合应用 案例 -学生学籍 管理系统 1 详细设计 需求分析 总体设计 第 10章 综合应用 案例 -学生学籍管理系统 编码实现 运行结果 2 设计一个利用 文件 处理方式, ...

  9. C语言课程设计——学生学籍管理系统

    #include<stdio.h> #include<string.h> #include<stdlib.h> #include<conio.h> #d ...

最新文章

  1. [昨花今拾]补记昨日
  2. 合肥天鹅湖万达广场机器人_王健林再考察合肥!瞄准政务、高新,年末合肥楼市出现区域分化...
  3. Android 高级进阶之overdraw分析及解决
  4. 杭电acm2043密码
  5. Tensorflow取消占用全部GPU
  6. Katu Puzzle(POJ-3678)
  7. 【熊猫多模式站群开发日志】 优化了关键词调度和模板调度
  8. 【AC自动机】HDU 2222 Keywords Search 裸题
  9. 免费自学编程的12个网站
  10. [转]java classLoader 体系结构
  11. Golang Go 语言简介
  12. 实现div半透明效果
  13. 初学者关于贝叶斯纳什均衡各类符号的一点理解
  14. 我去面试没带简历,你让我走人?
  15. Python用win32模块让窗体闪烁!附源码
  16. 【编程题】【Scratch二级】2020.06 小鸡捉害虫​
  17. 如何提高自己代码的可读性?
  18. Beacon API的应用
  19. macOS 安装lrzsz
  20. 爬虫----dex2jar工具的安装与使用

热门文章

  1. 代码生成MANIFEST.MF文件
  2. API ,批量添加
  3. Unity2018.3.11下载安装详细图文教程
  4. 悟透JavaScript(李站老师)-对象素描
  5. DEV pivotGridControl 单元格内容变色
  6. 手把手教你使用stata制作临床决策曲线
  7. 【数据技术】关于HP Vertica MPP列式数据库资源池设置的一点心得
  8. 鼠眼看Linux调度器 by raise_sail @ chinaunix
  9. githug通关部分黏贴(git代码练习)
  10. 2022年全国职业院校技能大赛赛项正式赛卷