教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 资格考试 >

学生成绩管理系统-数据库课程设计(3)

来源:网络收集 时间:2026-09-05
导读: 主要代码:class xiugai extends JFrame implements ActionListener { JFrame frame = new JFrame(修改成绩); JPanel imagePanel; ImageIcon bg; Button xiug; TextField input1, input2, input3; TextArea show; B

主要代码:class xiugai extends JFrame implements ActionListener {

JFrame frame = new JFrame("修改成绩");

JPanel imagePanel;

ImageIcon bg;

Button xiug;

TextField input1, input2, input3;

TextArea show;

Box box1, box2, box3;

Panel p1, p2;

int k, s1, j;

Connection con;

Statement sql;

int sum = 0;

ResultSet rs;

xiugai() {

Toolkit kit = Toolkit.getDefaultToolkit();

Image img = kit.getImage("tubiao.jpg");

frame.setIconImage(img);

p1 = new Panel();

p2 = new Panel();

xiug = new Button("修改");

10

input1 = new TextField(10);

input2 = new TextField(10);

input3 = new TextField(10);

show = new TextArea(6, 43);

Font f=new Font("宋体",Font.BOLD,15);

Label l1=new Label("输入学号");

l1.setFont(f);

l1.setForeground(Color.blue);

p1.add(l1);

p1.add(new Label("学号:"));

p1.add(input1);

box1 = Box.createVerticalBox();

box1.add(Box.createVerticalStrut(8));

box1.add(new Label("数学:"));

box1.add(Box.createVerticalStrut(8));

box1.add(new Label("英语:"));

box2 = Box.createVerticalBox();

box2.add(input2);

box2.add(Box.createVerticalStrut(8));

box2.add(input3);

box3 = Box.createHorizontalBox();

box3.add(box1);

box3.add(Box.createHorizontalStrut(1));

box3.add(box2);

Label l2=new Label("输入成绩");

l2.setFont(f);

l2.setForeground(Color.blue);

p2.add(l2);

p2.add(box3);

xiug.addActionListener(this);

show.setEditable(false);

bg = new ImageIcon("cru.jpg");

JLabel label = new JLabel(bg);

label.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight());

imagePanel = (JPanel) frame.getContentPane();

imagePanel.setOpaque(false);

imagePanel.setLayout(new FlowLayout());

imagePanel.add(p1);

imagePanel.add(p2);

11

imagePanel.add(xiug); imagePanel.add(show); frame.getLayeredPane().setLayout(null); frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE)); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(bg.getIconWidth(), bg.getIconHeight()); frame.setBounds(720, 220, 450, 390); frame.setResizable(false);//设置窗口大小不可改变 frame.setVisible(true); validate(); } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); public void actionPerformed(ActionEvent ee) { String s1, s2, s3, insert1, number; ; int m2, m3, math, english; s1 = input1.getText(); number = s1; s2 = input2.getText(); s3 = input3.getText(); m2 = Integer.parseInt(s2); math = m2; m3 = Integer.parseInt(s3); english = m3; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException eee) { System.out.println("" + eee); } try { con = DriverManager.getConnection("jdbc:odbc:sun", "gxy", "123"); sql = con.createStatement(); insert1 = "UPDATE chengjibiao SET math =" + math + ",english=" + english + " WHERE number = " + "'" + number + "'"; sql.executeUpdate(insert1); 12

show.setText("你将了:");

show.append("学号为 " + s1 + " 的学生 数学成绩更改为:" + math + " 英语成绩更改为:"

+ english);

show.append("\n");

} catch (SQLException e) {

System.out.println(e);

}

}

}

6.4 查找模块

首先由用户输入要查找的学生学号等,然后查找数据库中的该学生信息

主要代码:class chaxun extends JFrame implements ActionListener {

JFrame frame = new JFrame("查询记录");

JPanel imagePanel;

ImageIcon bg;

Button xunzhao;

TextField input;

TextArea show;

Box box;

String s;

Connection con;

Statement sql;

ResultSet rs;

chaxun() {

Toolkit kit = Toolkit.getDefaultToolkit();

Image img = kit.getImage("tubiao.jpg");

frame.setIconImage(img);

xunzhao = new Button("查找");

input = new TextField(10);

show = new TextArea(6, 43);

xunzhao.addActionListener(this);

show.setEditable(false);

box = Box.createHorizontalBox();

Label l1=new Label("输入学号");

13

l1.setFont(new Font("宋体",Font.BOLD,15)); l1.setForeground(Color.blue); box.add(l1); box.add(Box.createHorizontalStrut(8)); box.add(input); box.add(Box.createHorizontalStrut(8)); box.add(xunzhao); bg = new ImageIcon("chaxun.jpg"); JLabel label = new JLabel(bg); label.setBounds(0, 0, bg.getIconWidth(), bg.getIconHeight()); imagePanel = (JPanel) frame.getContentPane(); imagePanel.setOpaque(false); imagePanel.setLayout(new FlowLayout()); imagePanel.add(box, BorderLayout.NORTH); imagePanel.add(show, BorderLayout.CENTER); frame.getLayeredPane().setLayout(null); frame.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE)); //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(bg.getIconWidth(), bg.getIconHeight()); frame.setBounds(730, 230, 520, 350); frame.setResizable(false);//设置窗口大小不可改变 frame.setVisible(true); validate(); } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); } }); public void actionPerformed(ActionEvent ee) { boolean boo = true; s = input.getText(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException eee) { System.out.println("" + eee); } try { con = DriverManager.getConnection("jdbc:odbc:sun", "gxy", "123"); 14< …… 此处隐藏:3505字,全部文档内容请下载后查看。喜欢就下载吧 ……

学生成绩管理系统-数据库课程设计(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/91201.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)