java课程设计参考——学生信息管理系统

更新时间:2024-05-17 14:31:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

一.引言

1.1 1.2

项目的名称 项目背景和目标

商品房销售中的客户信息管理系统

商品房销售中的客户信息管理系统主要对客户的个人基本信

息进行管理,对商家提供查询信息、增添信息、删除信息等操作功能;对客户提供信息查询功能。我们的目标就是为该系统提供后台连接数据库程序设计以及前台用户界面设

1.3 项目的可行性研究

设计此系统需要java面向对象编程基础,数据库应用知识以及功能分析。根据目前所开设的课程,学生已经具备这样的知识,有能力综合java编程知识和数据库应用知识做出一个这样的客户信息管理系统

二、 需求分析

2.1系统概述

此系统提供给客户和商家。商家登陆后可以对基本信息

表进行查看、增添新记录和删除记录等操作。客户登陆后能查询客户信息。

2.2系统运行环境

Java运行在eclipse软件上,数据库用mysql数据库

2.3功能需求描述

商品房销售中的客户信息管理系统要面对商家和客户。对于

教师,需要查询全部学生的基本信息和成绩信息,并且可以对其进行修改。对于学生,不需要查询自己的基本信息,只需要查询成绩。为了保护学生成绩隐私,每位学生登录系统后只能查询自己的成绩,而无法看到别人的成绩

三、系统设计

3.1开发与设计的总体思想

教师方面:教师通过自己的用户名和密码登录后,进入教

师主界面,在这个主界面里,可以选择要操作的类别,即查询功能还是修改功能。在查询功能里面,可以选择是查询学生基本信息,还是查询学生成绩信息。在查询学生基本信息时,可以从依据不同字段,即学生信息表的不同属性进行查找。在查找学生成绩信息时,只能依据学生姓名和学号进行查找。在修改功能里面,包括对学生基本信息表和学生成绩表进行增加和删除记录

学生方面:学生通过自己的用户名和密码登录此系统后, 可以查询自己本学期的各科成绩信息

3.2系统模块结构图

商品房销售中的客户信息管理系统

房型与房价信息 商家操作界面 客户登陆 商家登陆

3.3数据库结构设计

为了支持此学生信息管理系统,创建数据库studentmanage。在这个数据库中包含四个表:student表,teacher表,studentlogin表和score表。截图如下:

在student(学生基本信息)表中,有五个属性列,分别为:num(学号),sname(学生姓名姓名),sex(性别),age(年龄),dept(系别)。其基本数据类型分别为:int,char,char,int,char。当查询学生基本信息时,从此表中获取数据。截图如下:

在teacher(教师登陆)表中,有两个属性列,分别为:tname(教师姓名),password(登录密码)。其基本数据类型分别为:char,char。当教师用户登陆此系统时,从该表获取数据。截图如下:

在studentlogin(学生登录)表中,有两个属性列,分别为:sname(学生姓名),password(登录密码)。其基本数据类型分别为:char,char。当学生用户登陆此系统时,从该表获取数据。截图如下:

在score(学生成绩)表中,有五个属性列,分别为:num(学号),sname(学生姓名),course(课程名称),score(考试成绩),credit(学分)。其基本数据类型分别为:int,char,char,int,int。当查询学生成绩信息时,从此表获取数据。截图如下:

}

}

}

Score score = new Score(rs.getInt(1),

.getString(3), rs.getInt(4), rs.getInt(5));

rs.getString(2), rs

lis.add(score);

} catch (SQLException e) {

e.printStackTrace();

return lis;

public ArrayList queryScore1(String key) { }

ArrayList lis = new ArrayList();

Connection con = DBConnection.getConnection(); Statement stm; try { }

return lis;

stm = con.createStatement();

String sql = \

+ \

+ StudentLoginUI.st1

System.out.println(sql);

ResultSet rs = stm.executeQuery(sql); while (rs.next()) { }

e.printStackTrace();

Score score = new Score(rs.getInt(1),

.getString(3), rs.getInt(4), rs.getInt(5));

rs.getString(2), rs

lis.add(score);

} catch (SQLException e) {

public boolean deleteScore(String key) {

Connection con = DBConnection.getConnection(); Statement stm; try {

stm = con.createStatement();

String sql = \System.out.println(sql);

int count = stm.executeUpdate(sql); if (count == 1)

return true; else

public boolean addScore(int num, String sname, String course, int }

int credit) {

score,

Connection con = DBConnection.getConnection(); PreparedStatement pst; try { }

return false;

pst = con.prepareStatement(\pst.setInt(1, num); pst.setString(2, sname); pst.setString(3, course); pst.setInt(4, score); pst.setInt(5, credit);

int count = pst.executeUpdate();// 返回修改的记录数 if (count == 1)

return true; return false; else

values(?,?,?,?,?)\

} catch (SQLException e) {

e.printStackTrace();

key + \

}

}

}

return false;

} catch (SQLException e) {

e.printStackTrace();

return false;

3.model包中的类:

(1)Score类:此类中有五个成员变量,int num;String sname;String course;

int score;int credit;十个成员方法,分别获取和设置这五个变量,即为score表中五个属性的记录值,均为getXXX()setXXX()方法,还有一个构造方法,用于调用其对象时对成员变量赋值 Score类源代码:

package model;

public class Score { int num; String sname; String course; int score; int credit;

public int getNum() { }

public void setNum(int num) { }

public String getSname() { }

public void setSname(String sname) { }

public String getCourse() {

this.sname = sname; return sname; this.num = num; return num;

}

return course;

public void setCourse(String course) { }

public int getScore() { }

public void setScore(int score) { }

public int getCredit() { }

public void setCredit(int credit) { }

public Score(int num, String sname, String course, int score,int credit) {

super(); this.num = num; this.sname = sname; this.course = course; this.score = score; this.credit = credit; } }

this.credit = credit; return credit; this.score = score; return score;

this.course = course;

(2)Student类:

此类中有五个成员变量,int num;String sname;String sex;int age;String dept; 十个成员方法,分别获取和设置这五个变量,即为student表中五个属性的记录值,均为getXXX()setXXX()方法,还有一个构造方法,用于调用其对象时对成员变量赋值 Student类源代码:

package model;

public class Student { int num; String sname; String sex; int age; String dept;

public int getNum() { }

public void setNum(int num) { }

public String getSname() { }

public void setSname(String sname) { }

public String getSex() { }

public void setSex(String sex) { }

public int getAge() { }

public void setAge(int age) { }

public String getDept() { }

public void setDept(String dept) {

this.dept = dept; return dept; this.age = age; return age; this.sex = sex; return sex;

this.sname = sname; return sname; this.num = num; return num;

}

public Student(int num, String sname, String sex, int age,String dept) } }

{ super(); this.num = num; this.sname = sname; this.sex = sex; this.age = age; this.dept = dept;

4.ui包中的类:

(1) LoginUI类:此类为登陆界面,在这个界面上,设置有

两个按钮,学生按钮,教师按钮。给这两个按钮注册事件addActionListener,分别在内部类TeacherLoginActionListene和

StudentLoginActionListener中的默认方法

actionPerformed()中创建TeacherLoginUI类和StudentLoginUI类的对象,即打开教师登陆界面和学生登录界面,并将原登陆界面关闭。 LoginUI类源代码:

package ui;

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

import javax.swing.*;

public class LoginUI extends JFrame {

public LoginUI() {

l1 = new JLabel(\请选择用户类型\bt1 = new JButton(\教师\JLabel l1; JButton bt1, bt2; Container cp;

}

bt2 = new JButton(\学生\JPanel p1 = new JPanel(); p1.setLayout(null);

l1.setBounds(150, 150, 120, 40); p1.add(l1);

bt1.setBounds(120, 230, 80, 30); p1.add(bt1);

bt2.setBounds(220, 230, 80, 30); p1.add(bt2);

bt1.addActionListener(new TeacherLoginActionListener());//bt2.addActionListener(new StudentLoginActionListener());//cp = getContentPane();

this.setBounds(200, 200, p1.getHeight(), p1.getHeight()); cp.add(p1);

this.setTitle(\用户登录界面\this.setSize(400, 400); this.setVisible(true);

this.addWindowListener(new WindowAdapter() { });

public void windowClosing(WindowEvent e) { }

System.exit(0);

注册事件 注册事件

class TeacherLoginActionListener implements ActionListener{ }

public void actionPerformed(ActionEvent e){ }

new TeacherLoginUI(); dispose();

class StudentLoginActionListener implements ActionListener{ public void actionPerformed(ActionEvent e){ }

}

new StudentLoginUI(); dispose();

public static void main(String[] args) { } }

new LoginUI();

执行截图如下:

(2)StudentLoginUI类:此类为学生登陆界面,在这个界面上有两个文本框,分别输入学生姓名和登录密码,还有两个按钮,登陆和退出。输入后,从两个文本框中获取用户输入的内容,点击“登陆”按钮时,调用StudentDao类中的studentLogin()方法验证是否存在该用户。若存在,则创建StudentScoreUI类的对象,即打开学生成绩界面,显示此登陆学生的成绩信息,若不存在,则提示密码错误。 StudentLoginUI类源代码: package ui;

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

import dao.StudentDao;

public class StudentLoginUI extends JFrame{ JLabel l1, l2; JTextField t1; JPasswordField t2;

JButton bt1, bt2; Container cp;

public static String st1; public String st2;

public StudentLoginUI(){

l1 = new JLabel(\学生姓名\l2 = new JLabel(\密码\t1 = new JTextField(12); t2 = new JPasswordField(12); bt1 = new JButton(\成绩查询\bt2 = new JButton(\退出\JPanel p1 = new JPanel(); p1.setLayout(null);

l1.setBounds(150, 150, 80, 40); p1.add(l1);

t1.setBounds(250, 150, 80, 30); p1.add(t1);

l2.setBounds(150, 190, 80, 40); p1.add(l2);

t2.setBounds(250, 190, 80, 30); p1.add(t2);

bt1.setBounds(150, 230, 120, 30); p1.add(bt1);

bt2.setBounds(280, 230, 80, 30); p1.add(bt2);

bt1.addActionListener(new LoginActionListener());//注册事件 bt2.addActionListener(new ExitActionListener());//注册事件

cp = getContentPane();

this.setBounds(200, 200, p1.getHeight(), p1.getHeight()); cp.add(p1);

this.setTitle(\学生登录界面\this.setSize(400, 400); this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

}

});

public void windowClosing(WindowEvent e) { }

System.exit(0);

class LoginActionListener implements ActionListener { }

class ExitActionListener implements ActionListener { }

public static void main(String[] args) { } }

new StudentLoginUI();

public void actionPerformed(ActionEvent e) { }

System.exit(0); }

st1 = t1.getText(); st2 = t2.getText();

StudentDao oneStudentDao = new StudentDao(); boolean isSuccess = oneStudentDao.studentLogin(st1, if (isSuccess) {

new StudentScoreUI(); dispose();

JOptionPane.showMessageDialog(null, \用户名密码错

JOptionPane.INFORMATION_MESSAGE);

public void actionPerformed(ActionEvent e) {

st2);

} else

误\提示信息\

执行截图如下:

本文来源:https://www.bwwdw.com/article/iwq7.html

Top