java学生管理系统报告_《java程序设计》学生管理系统报告

《《java程序设计》学生管理系统报告》由会员分享,可在线阅读,更多相关《《java程序设计》学生管理系统报告(21页珍藏版)》请在人人文库网上搜索。

1、Java程序设计结课报告课程名称 JAVA程序设计 设计题目 学生信息管理系统 专业班级 信科101班 学 号 09 学生姓名 XX 教 师 彭 洁 信息工程系目 录目 录II第1章 系统简介31.1 系统功能31.2 系统引用例子3第2章 表的设计42.1 系统数据库表结构4第3章 连接数据库的实现53.1 SQL Server数据库连接的关键代码5第4章 系统详细设计64.1系统登录模块设计64.2 系统主界面详细设计94.3 学生信息增删改模块设计104.4 学生信息查询模块设计124.5 注册子管理员模块设计15答辩记录20成绩考核表20学生信息管理系统第1章 系统简介1.1 系统功能。

2、本系统主要功能:1) 通过数据校验如果数据校验成功,显示主界面;2)登入后查询所有学生信息;3)窗体实现对学生信息的增加、删除、修改;4)模糊查询,根据姓名或者一个字查询;5)实现子管理员的注册,并且写入注册信息到记事本,并实现可以用新注册的管理账号登入系统主界面1.2 系统引用例子课本P275页 15.5和课本P386页 21.6第2章 表的设计2.1 系统数据库表结构将系统数据库表结构用表的形式画出,如:字段名字段类型长度主/外键字段值约束对应中文名SNOInt10PNot null学生编号SNAMEVarchar20Not null学生名字SSEXVarchar1Not null学生性别。

3、表2.1 用户表(JBXX)SAGEInt2Not null学生年龄字段名字段类型长度主/外键字段值约束对应中文名SNOInt10PNot null学生编号JNAMEVarchar20Not null家长名字JTELInt10Not null家庭电话表2.2 家庭信息表(JTXX)注册子管理员的记事本1111.TXT内信息如下:yyyy#yyyylinlin#linlinadmin1#1111admin2#2222admin3#3333admin4#4444opop#opopuuuu#uuuubbbb#bbbbtttt#tttt第3章 连接数据库的实现3.1 SQL Server数据库连接的关。

4、键代码public class DButil Connection con = null;String name = linqun;String passname = linqun;String ul1 = jdbc:oracle:thin:127.0.0.1:1521:orcl;public Connection getconn() try Class.forName(oracle.jdbc.driver.OracleDriver);System.out.println(数据库驱动加载成功);con = DriverManager.getConnection(ul1, name, passn。

5、ame);System.out.println(数据库连接成功); catch (Exception e) System.out.println(e);return con;public void dbclose(Connection conn, Statement sta, ResultSet rs) try if (rs != null)rs.close();if (conn != null)conn.close();if (sta != null)sta.close(); catch (Exception e) e.printStackTrace();finallySystem.out.。

6、println(数据库释放!);第4章 系统详细设计4.1 系统登录模块设计4.1.1、运行效果图图 4.1 登录主界面效果图4.1.2、主要代码public class login extends JDialog static PreparedStatement SQL;private static final long serialVersionUID = 1L;private JLabel l_Id = new JLabel(登陆账户, JLabel.CENTER);private JLabel l_pw = new JLabel(登陆密码, JLabel.CENTER);private。

7、 JTextField t_Id = new JTextField(10);private JPasswordField t_pw = new JPasswordField(10);private JButton btnLogin;private JButton btnAdd;private JButton btnClose;int num = 3;public login() super();Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();this.setLocation(screenSize.width 。

8、- 300) / 2,(screenSize.height - 200) / 2);this.setResizable(false);getContentPane().setBackground(new Color(225, 225, 225);getContentPane().setLayout(null);initialize();protected void initialize() setTitle(系统登录);l_Id.setBounds(48, 43, 53, 25);t_Id.setBounds(110, 43, 150, 25);l_pw.setBounds(48, 93, 5。

9、3, 25);t_pw.setBounds(110, 93, 150, 25);getContentPane().add(l_Id);getContentPane().add(l_pw);getContentPane().add(t_Id);getContentPane().add(t_pw);btnLogin = new JButton();btnLogin.setText(登 录);btnLogin.setBounds(20, 142, 85, 28);btnLogin.setBackground(new Color(244, 243, 239);btnLogin.addActionLis。

10、tener(new ActionListener() public void actionPerformed(ActionEvent e) addBtnLoginActionListener(););getContentPane().add(btnLogin);btnAdd = new JButton();btnAdd.setText(注册);btnAdd.setBounds(105, 142, 85, 28);btnAdd.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) add。

11、New zc = new addNew();setVisible(false);zc.setVisible(true););getContentPane().add(btnAdd);btnClose = new JButton();btnClose.setText(关 闭);btnClose.setBounds(190, 142, 85, 28);btnClose.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) dispose();System.exit(-1););getCon。

12、tentPane().add(btnClose);private void addBtnLoginActionListener() String id = t_Id.getText();String password = new String(t_pw.getPassword();if (id.equals() JOptionPane.showMessageDialog(this, 帐号不可为空, 提示,JOptionPane.WARNING_MESSAGE);return; else if (password.equals() JOptionPane.showMessageDialog(th。

13、is, 密码不可为空, 提示,JOptionPane.WARNING_MESSAGE);return; else tools t = new tools();boolean success = false; / TODO:数据校验success = t.eqes(id, password);if (success) / 如果数据校验成功 显示主界面JOptionPane.showMessageDialog(this, 成功登录, 提示,JOptionPane.INFORMATION_MESSAGE);new mainView();this.dispose(); else -num;if (nu。

14、m = 0) JOptionPane.showMessageDialog(this, 用户名或者密码错误!您没有机会了);System.exit(0); else JOptionPane.showMessageDialog(this, 用户名或者密码错误!您还有 + num+ 次机会);public Dimension getPreferredSize() return new Dimension(320, 170);public void show() Toolkit tk = Toolkit.getDefaultToolkit();Dimension screen = tk.getScre。

15、enSize();Dimension d = getSize();this.setLocation(screen.width - d.width) / 2,(screen.height - d.height) / 2);/ 输入密码后回车相当于点击了登录按钮getRootPane().setDefaultButton(btnLogin);t_pw.requestFocus();setDefaultCloseOperation(DISPOSE_ON_CLOSE);setSize(300, 220);super.show();public static void main(String args)。

16、 DButil util = new DButil();util.getconn();login loginFrame = new login();loginFrame.setVisible(true);4.2 系统主界面详细设计4.2.1、运行效果图图 4.2 登录后系统界面效果图4.2.2、主要代码public mainView() super();setTitle(所有学生信息);setBounds(350, 150, 700, 400);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setVisible(true);final JScro。

17、llPane scrollPane = new JScrollPane();con = db.getconn();Vector tableValueV, columnNameV;/ 存放列名columnNameV = new Vector();columnNameV.add(学号);columnNameV.add(名字);columnNameV.add(性别);columnNameV.add(年龄);tableValueV = new Vector();scrollPane.setViewportView(table);final JPanel panel = new JPanel();get。

18、ContentPane().add(panel, BorderLayout.SOUTH);panel.add(new JLabel(编号:);aTextField = new JTextField(, 5);panel.add(aTextField);panel.add(new JLabel(姓名:);bTextField = new JTextField(, 5);panel.add(bTextField);panel.add(new JLabel(性别:);cTextField = new JTextField(, 5);panel.add(cTextField);panel.add(ne。

19、w JLabel(年龄:);dTextField = new JTextField(, 5);panel.add(dTextField);4.3 学生信息增删改模块设计4.3.1、增加信息(121,白娘子,M,22)后运行效果图如下:图 4.3 增加一个记录效果图4.3.2、主要代码final JButton addButton = new JButton(添加);addButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) userDao add = new userDa。

20、oImpl();user u = new user();u.setSno(Integer.parseInt(aTextField.getText();u.setsName(bTextField.getText();u.setSsex(cTextField.getText();u.setSage(Integer.parseInt(dTextField.getText();add.addUser(u);setVisible(false);new mainView(););panel.add(addButton);4.3.3、删除信息编号为120的学生信息后结果如下:图 4.4 删除一个记录效果图4。

21、.3.4、主要代码:final JButton delButton = new JButton(删除);delButton.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) userDao del = new userDaoImpl();user ud = new user();int selectedRow = table.getSelectedRow();/ 获得被选中行的索引if (selectedRow != -1)/ 判断是否存在被选中行del.deleUser(Inte。

22、ger.parseInt(aTextField.getText();setVisible(false);tableModel.removeRow(selectedRow););panel.add(delButton);4.3.5、修改信息(105,关美眉,F,41)为(105,关大侠,M,30)后运行效果图如下:图 4.5 修改一个记录效果图4.3.6、主要代码:panel.add(searchButton);final JButton updButton = new JButton(修改);updButton.addActionListener(new ActionListener() pu。

23、blic void actionPerformed(ActionEvent e) userDao update = new userDaoImpl();user upe = new user();aTextField.setEditable(false);int selectedRow = table.getSelectedRow();/ 获得被选中行的索引if (selectedRow != -1) / 判断是否存在被选中行upe.setSno(Integer.parseInt(aTextField.getText();upe.setsName(bTextField.getText();up。

24、e.setSsex(cTextField.getText();upe.setSage(Integer.parseInt(dTextField.getText();update.updateUser(upe);setVisible(false);new mainView(););panel.add(updButton);4.4 学生信息查询模块设计4.4.1、运行效果图图 4.6 查询记录集效果图查询姓赵的人信息:图 4.7 查询结果图查询名字带“山”的人信息:图 4.8 查询结果图4.4.2、主要代码:public search() setTitle(根据姓名查询学生信息);setLayout。

25、(new BorderLayout();setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);validate();setBounds(350, 150, 650, 400);final JPanel pane = new JPanel();jl=new JLabel(输入姓或者名查询);TextField = new JTextField(, 5);jb1 = new JButton(查询);jb2 = new JButton(返回);pane.add(jl);pane.add(TextField);pane.add(jb1);pane.add(jb2。

26、);getContentPane().add(pane, BorderLayout.NORTH);jb1.addActionListener(this);jb2.addActionListener(this);setVisible(true);public void actionPerformed(ActionEvent e) if (e.getActionCommand().equals(查询) JScrollPane jsp = new JScrollPane();Vector tableValueV,columnNameV;columnNameV = new Vector();colum。

27、nNameV.add(学号);columnNameV.add(名字);columnNameV.add(性别);columnNameV.add(年龄);tableValueV = new Vector();userDao user = new userDaoImpl();user u = user.searchByName(TextField.getText();Vector rowV = new Vector();rowV.add(u.getSno();rowV.add(u.getsName();rowV.add(u.getSsex();rowV.add(u.getSage();tableVa。

28、lueV.add(rowV);tableModel= new DefaultTableModel(tableValueV, columnNameV);table = new JTable(tableModel);jsp = new JScrollPane(table);jsp.setViewportView(table);getContentPane().add(jsp, BorderLayout.CENTER);setVisible(true);if (e.getActionCommand().equals(返回) new mainView();4.5 注册子管理员模块设计4.5.1、运行效。

29、果图图 4.9 注册子管理员效果图4.5.2、主要代码:public addNew() setDefaultCloseOperation(EXIT_ON_CLOSE);load();this.setVisible(true);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();this.setLocation(screenSize.width - 300) / 2,(screenSize.height - 200) / 2);this.setResizable(false);this.setTitle(注册子管理。

30、员界面);this.setVisible(true);this.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0););public void load() Pane = (JPanel) getContentPane();Pane.setLayout(null);setSize(new Dimension(410, 300);setTitle(管理员登入界面);t1.setBounds(70, 50, 100, 30);t2.setBounds(70, 80。

31、, 100, 30);t3.setBounds(70, 110, 100, 30);t4.setBounds(250, 50, 100, 30);t5.setBounds(250, 80, 100, 30);f1.setBounds(150, 50, 100, 20);f2.setBounds(150, 80, 100, 20);f3.setBounds(150, 110, 100, 20);b1.setFont(new java.awt.Font(Botton, Font.BOLD, 12);b1.setBounds(120, 140, 60, 50);b2.setFont(new java。

32、.awt.Font(Dialog, Font.BOLD, 12);b2.setBounds(200, 140, 60, 50);Pane.add(t1);Pane.add(t2);Pane.add(t3);Pane.add(t4);Pane.add(t5);Pane.add(f1);Pane.add(f2);Pane.add(f3);Pane.add(b1);Pane.add(b2);b1.addActionListener(this);b2.addActionListener(this);4.5.3、当注册名已经存在时效果如下:图 4.10 验证注册界面4.5.4、成功注册时效果如下:(用户。

33、名:qunqun;密码:qunqun)图 4.11 注册成功界面4.5.5、主要代码public void actionPerformed(ActionEvent e) if (e.getActionCommand().equals(注册) if (tools.indes(f1.getText() & tools.indes(f2.getText() if (tools.eqes(f1.getText(), f2.getText() JOptionPane.showMessageDialog(this, 该用户已被注册,请重新输入!);System.exit(0); else tools.ad。

34、dUser(f1.getText(), f1.getText();JOptionPane.showMessageDialog(this, 你已经成功注册);System.exit(0);if (f1.getText().equals() | f2.getText().equals() JOptionPane.showMessageDialog(this, 帐号或密码长度有误, 提示,JOptionPane.WARNING_MESSAGE);if (e.getActionCommand().equals(退出) System.exit(0);4.5.6、新注册管理员(用户名:qunqun;密码:。

35、qunqun)登入效果如下:图 4 .12 登录界面图 4 .13 登录成功界面4.5.7、主要代码:static boolean eqes(String admin, String passwd) boolean bool = true;try InputStream is = new FileInputStream(1111.txt);BufferedReader reader = new BufferedReader(new InputStreamReader(is);String line = reader.readLine(); while (line != null) / 如果 l。

36、ine 为空说明读完了String str = line.trim().split(#);for (int i = 0; i line.trim().split(#).length; i+) if (admin.equals(str0) if (passwd.equals(str1) return true; else bool = false; else bool = false;line = reader.readLine(); catch (Exception e) e.printStackTrace();return bool;static void addUser(String ad。

37、min, String passwd) File f = new File(1111.txt);String oldStr = ;try FileReader fr = new FileReader(f);BufferedReader bufr = new BufferedReader(fr);String line = null;while (line = bufr.readLine() != null) oldStr += line+rn; catch (FileNotFoundException e1) e1.printStackTrace(); catch (IOException e。

38、) e.printStackTrace();String content = oldStr+admin + # + passwd;try FileWriter fw=new FileWriter(f);BufferedWriter bufw = new BufferedWriter(fw);bufw.write(content);bufw.newLine();bufw.close();fw.close(); catch (Exception e) e.printStackTrace();答辩记录答辩日期答辩地点主要问题答辩要点成绩考核表成绩评定项 目参考权重实际权重原始成绩加权成绩1、作品质量程度(100分计)0.42、报告书写(100分计)0.23、答辩(100分计)0.4总 成 绩。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值