《java语言程序设计》课程设计报告题目:个人事务管理系统学生姓名:罗军 1400170125班级:信息安全141院系:计算机科学与信息学院专业年级: 20142016 年 12 月21 日目录1绪论: (3)2需求分析 (3)3系统分析: (3)3.1系统流程图 (4)3.1.1管理员需求分析 (4)3.1.2学生需求分析 (4)3.1.3教师需求分析 (4)2.2系统用例图分析: (5)3.2.1用户需求分析 (5)3.2.2管理员需求分析 (5)3.2.3学生需求分析 (6)3.2.4教师需求分析 (6)3.3系统数据库分析 (6).3.3.1数据库概念模型设计: (6).3.3.2数据库逻辑模型设计: (8).3.3.3数据库物理模型设计: (9)4界面设计 (13)4.1登录界面设计与实现 (13)4.1.1登录界面主要代码: (13)4.1.2登录界面效果 (18)4.2管理员界面设计与实现 (18)4.2.1菜单主要代码: (18)4.2.2菜单界面效果: (21)4.3教师界面设计与实现 (21)4.3.1菜单主要代码: (21)4.3.2菜单界面效果: (24)4.4学生界面设计与实现 (24)4.4.1菜单主要代码: (24)4.4.2菜单界面效果: (27)5总结 (27)6组内自评 (27)1绪论:通过这次的设计,主要是做出一个小型的管理系统,来加强对JAVA 所学知识的巩固和融会贯通,可以说是对一个学期所学知识的一个小结,加深对JAVA数据库的理解。
2需求分析2.1功能需求分析:该系统具备管理学生信息、课程信息、选课信息的功能:用户通过输入账号和密码进下该系统后,可以进行一些基础维护(学生信息维护、课程信息维护、选课信息维护)。
全部都可以进行增加、修改、删除、模糊查询,管理员:1.学生管理2.教师管理3.课程管理,教师:查看课程信息,成绩录入,学生:选课,修改选课.3系统分析:3.1系统流程图3.1.1管理员需求分析管理学生,教师的基本信息,设置起止时间。
3.1.2学生需求分析学生可以查看个人信息,选择课程,查看已经选课课程详细信息,删除已经选课课程,查看课程成绩。
3.1.3教师需求分析教师可以查和修改看个人信息,查看选课情况,设置课程详情,设置课程成绩。
2.2系统用例图分析:3.2.1用户需求分析用户包括教师,学生,管理员,用户可以注册,修改密码,登录系统就可以进行操作。
3.2.2管理员需求分析管理学生,教师的基本信息,设置起止时间。
3.2.3学生需求分析学生可以查看个人信息,选择课程,查看已经选课课程详细信息,删除已经选课课程,查看课程成绩。
3.2.4教师需求分析教师可以查和修改看个人信息,查看选课情况,设置课程详情,设置课程成绩。
3.3系统数据库分析:.3.3.1数据库概念模型设计:实体1:AdministratorAdministrator(no,name,password)no 为主码实体图:实体2:StudentStudent(no,name,gender,class,password,major,faculty)no为主码实体图实体3:TeacherTeacher(no,name,password,gender,p_职称,C_院系)no为主码实体图:实体4:CourseCourse(no,name,Tno,start,time,site,end,x_学分,y_已选人数,k_可选人数)no为主码实体图:.3.3.2数据库逻辑模型设计:E-R图:对应的关系模式:Administrator(no,name,password)Student(no,name,gender,class,password,major,faculty)Teacher(no,name,password,gender,p_职称,C_院系)no为主码Course(no,name,Tno,start,time,site,end,x_学分,y_已选人数,k_可选人数)Manage(A.no,T.no,S.no)SetUp(T.no ,C.no)X_选课(S.no,C.no).3.3.3数据库物理模型设计:数据库名称:XSXKXTAdministrator表:Student表:Teacher表:Course表:Manage表:SetUp表:X_选课表:4界面设计4.1登录界面设计与实现4.1.1登录界面主要代码:publicclass D_登录extends JFrame {privatestaticfinallong serialVersionUID = 2897071766481834392L;privatestaticint userName;privatestatic String nameStr;public D_登录() {}publicstatic String username(){return nameStr;}/*public static void setuserName(int userName){D_登录.userName=userName;}*/// 密码输入函数public D_登录(String s) {super("学生选课系统");setSize(250, 250);setLayout(new FlowLayout());setLocationRelativeTo(null); //设置窗口居中JPanel contentPane = new JPanel();setContentPane(contentPane);JLabel lab1 = new JLabel("账号:");JTextField tf = new JTextField(15);JLabel lab2 = new JLabel("密码:");JPasswordField keyField = new JPasswordField(15);keyField.setEchoChar('*');JCheckBox chk1 = new JCheckBox("管理员");JCheckBox chk2 = new JCheckBox("教师");JCheckBox chk3 = new JCheckBox("学生");JButton sureButton = new JButton("登录");JButton buildButton = new JButton("注册");JButton cancelButton = new JButton("取消");contentPane.add(lab1);contentPane.add(tf);contentPane.add(lab2);contentPane.add(keyField);contentPane.add(chk1);contentPane.add(chk2);contentPane.add(chk3);contentPane.add(sureButton);contentPane.add(buildButton);contentPane.add(cancelButton);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);setVisible(true);sureButton.addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {char[] key=keyField.getPassword();String keyStr = String.valueOf(key);String name = tf.getText().trim();D_登录 .nameStr = String.valueOf(name);//加载JDBC驱动String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//连接服务器和数据库sampleString dbURL = "jdbc:sqlserver://localhost:1433; DatabaseName=XSXKXT";String uid = "sa"; //默认用户名String pwd = "5201314"; //密码Connection dbConn=null;ResultSet resultSet=null;PreparedStatement statement=null;String sql=null;if(chk1.isSelected()==true){try{Class.forName(driverName);dbConn=DriverManager.getConnection(dbURL, uid, pwd);sql="select name,password from Administrator";statement=dbConn.prepareStatement(sql);resultSet=statement.executeQuery();while(resultSet.next()){String nowKey=resultSet.getString("password");String userName=resultSet.getString("name");if(keyStr.equals(nowKey)&&D_登录 .nameStr.equals(userName)){new M_管理员("管理员主界面"); //进入主界面dispose();}}}catch(SQLException |ClassNotFoundException e1){System.out.println("操作数据库失败!");e1.printStackTrace();}finally{try {dbConn.close();} catch (SQLException e1) {// TODO自动生成的 catch 块e1.printStackTrace();}}}elseif(chk2.isSelected()==true){try{Class.forName(driverName);dbConn=DriverManager.getConnection(dbURL, uid, pwd);sql="select name,password from Teacher";statement=dbConn.prepareStatement(sql);resultSet=statement.executeQuery();while(resultSet.next()){String nowKey=resultSet.getString("password");String userName=resultSet.getString("name");if(keyStr.equals(nowKey)&&D_登录 .nameStr.equals(userName)){System.out.println(userName);new M_教师("教师主界面"); //进入主界面dispose();}}}catch(SQLException |ClassNotFoundException e1){System.out.println("操作数据库失败!");e1.printStackTrace();}finally{try {dbConn.close();} catch (SQLException e1) {// TODO自动生成的 catch 块e1.printStackTrace();}}}elseif(chk3.isSelected()==true){try{Class.forName(driverName);dbConn=DriverManager.getConnection(dbURL, uid, pwd);sql="select name,password from Student";statement=dbConn.prepareStatement(sql);resultSet=statement.executeQuery();while(resultSet.next()){String nowKey=resultSet.getString("password");String userName=resultSet.getString("name");if(keyStr.equals(nowKey)&&D_登录 .nameStr.equals(userName)){new M_菜单("学生主界面"); //进入主界面dispose();}}}catch(SQLException |ClassNotFoundException e1){System.out.println("操作数据库失败!");e1.printStackTrace();}finally{try {dbConn.close();} catch (SQLException e1) {// TODO自动生成的 catch 块e1.printStackTrace();}}}else {JOptionPane.showMessageDialog(null, "您输入的密码或用户名不正确!", "警告!", JOptionPane.ERROR_MESSAGE);}}});buildButton.addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new Z_注册("学生选课系统");dispose();}});cancelButton.addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {System.exit(0);}});}}4.1.2登录界面效果4.2管理员界面设计与实现4.2.1菜单主要代码:publicclass M_管理员extends JFrame {privatestaticfinallong serialVersionUID = 5750226625631933273L;public M_管理员(String s) {super(s);setSize(800, 600);this.setLayout(null);setLocationRelativeTo(null); // 设置窗口居中JMenuBar menuBar = new JMenuBar();JMenu[] menu = new JMenu[] { new JMenu("系统管理"), new JMenu("系统功能"), new JMenu("基本资料"), new JMenu("帮助") };JMenuItem[] menuItem1 = new JMenuItem[] { new JMenuItem("关闭"), new JMenuItem("进入学生主菜单"),new JMenuItem("进入教室主菜单") };JMenuItem[] menuItem2= new JMenuItem[] { new JMenuItem("学生管理"), new JMenuItem("教师管理") };JMenuItem[] menuItem3 = new JMenuItem[] { new JMenuItem("查看个人信息") };JMenuItem[] menuItem4 = new JMenuItem[] { new JMenuItem("关于") };for (int i = 0; i<menu.length; i++) {menuBar.add(menu[i]);}for (int i = 0; i<menuItem1.length; i++) {menu[0].add(menuItem1[i]);}for (int i = 0; i<menuItem2.length; i++) {menu[1].add(menuItem2[i]);}for (int i = 0; i<menuItem3.length; i++) {menu[2].add(menuItem3[i]);}for (int i = 0; i<menuItem4.length; i++) {menu[3].add(menuItem4[i]);}setJMenuBar(menuBar);JLabel label = new JLabel("欢迎进入学生选课系统", JLabel.CENTER);label.setBounds(10, 150, 750, 50);label.setFont(new Font("黑体", Font.BOLD, 36));label.setHorizontalTextPosition(SwingConstants.CENTER);label.setForeground(Color.red);JLabel label1 = new JLabel("新用户请完善个人信息", JLabel.CENTER);label1.setBounds(10, 200, 750, 50);label1.setFont(new Font("黑体", Font.BOLD, 30));label1.setHorizontalTextPosition(SwingConstants.CENTER);label1.setForeground(Color.red);add(label1);add(label);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);setVisible(true);menuItem1[0].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {System.exit(0);}});menuItem1[1].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new M_菜单("学生菜单");}});menuItem1[2].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new M_教师("教师菜单");}});menuItem2[0].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new StudentManage("学生管理系统");}});menuItem2[1].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new TeacherManage("教师管理系统");}});menuItem3[0].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new CheckNewM("个人信息系统");}});menuItem4[0].addActionListener(new ActionListener() { // 给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new About();setVisible(false);}});}}4.2.2菜单界面效果:4.3教师界面设计与实现4.3.1菜单主要代码:publicclass M_教师 {public M_教师(String s){JFrame frame=new JFrame(s);frame.setSize(800,600);frame.setLocationRelativeTo(null);JMenuBar menuBar=new JMenuBar();JMenu[] menu = new JMenu[] { new JMenu ("系统管理"), new JMenu ("系统功能"),new JMenu ("基本资料"),new JMenu ("帮助") };JMenuItem[] menuItem1 = new JMenuItem[] { new JMenuItem ("关闭") };JMenuItem[] menuItem2 = new JMenuItem[] { new JMenuItem ("设置课程"),new JMenuItem ("查看选课情况") };JMenuItem[] menuItem3 = new JMenuItem[] { new JMenuItem ("查看个人信息") };JMenuItem[] menuItem4 = new JMenuItem[] { new JMenuItem ("关于") };for ( int i = 0; i<menu.length; i++ ){menuBar.add (menu[i]);}for ( int i = 0; i<menuItem1.length; i++ ){menu[0].add (menuItem1[i]);}for ( int i = 0; i<menuItem2.length; i++ ){menu[1].add (menuItem2[i]);}for ( int i = 0; i<menuItem3.length; i++ ){menu[2].add (menuItem3[i]);}for ( int i = 0; i<menuItem4.length; i++ ){menu[3].add (menuItem4[i]);}JLabel label=new JLabel("欢迎进入学生选课系统",JLabel.CENTER);label.setBounds(10, 100, 750, 200);label.setFont(new Font("黑体",Font.BOLD,36));label.setHorizontalTextPosition(SwingConstants.CENTER);label.setForeground(Color.red);JLabel label1=new JLabel("新用户请完善个人信息",JLabel.CENTER);label1.setBounds(10, 200, 750, 50);label1.setFont(new Font("黑体",Font.BOLD,30));label1.setHorizontalTextPosition(SwingConstants.CENTER);label1.setForeground(Color.red);frame.add(label);frame.add(label1);frame.setJMenuBar (menuBar);frame. setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);frame.setVisible (true);menuItem1[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {System.exit(0);}});menuItem2[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new SetGrade("设置课程");}});menuItem2[1].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new CheckChooseCourse("查看学生选课");}});menuItem3[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new CheckNewT("个人信息");}});menuItem4[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new About();}});}}4.3.2菜单界面效果:4.4学生界面设计与实现4.4.1菜单主要代码:publicclass M_菜单extends JFrame{privatestaticfinallong serialVersionUID = -1398247881143814899L;public M_菜单(String s){super(s);setSize(800,600);this.setLayout(null);setLocationRelativeTo(null); //设置窗口居中JMenuBar menuBar=new JMenuBar();JMenu[] menu = new JMenu[] { new JMenu ("系统管理"), new JMenu ("系统功能"),new JMenu ("基本资料"),new JMenu ("帮助") };JMenuItem[] menuItem1 = new JMenuItem[] { new JMenuItem ("关闭") };JMenuItem[] menuItem2 = new JMenuItem[] { new JMenuItem ("开始选课"), new JMenuItem ("查看课程表") };JMenuItem[] menuItem3 = new JMenuItem[] { new JMenuItem ("查看个人信息") };JMenuItem[] menuItem4 = new JMenuItem[] { new JMenuItem ("关于") };for ( int i = 0; i<menu.length; i++ ){menuBar.add (menu[i]);}for ( int i = 0; i<menuItem1.length; i++ ){menu[0].add (menuItem1[i]);}for ( int i = 0; i<menuItem2.length; i++ ){menu[1].add (menuItem2[i]);}for ( int i = 0; i<menuItem3.length; i++ ){menu[2].add (menuItem3[i]);}for ( int i = 0; i<menuItem4.length; i++ ){menu[3].add (menuItem4[i]);}setJMenuBar (menuBar);JLabel label=new JLabel("欢迎进入学生选课系统",JLabel.CENTER);label.setBounds(10, 100, 750, 100);label.setFont(new Font("黑体",Font.BOLD,36));label.setHorizontalTextPosition(SwingConstants.CENTER);label.setForeground(Color.red);JLabel label1=new JLabel("新用户请完善个人信息",JLabel.CENTER);label1.setBounds(10, 200, 750, 50);label1.setFont(new Font("黑体",Font.BOLD,30));label1.setHorizontalTextPosition(SwingConstants.CENTER);label1.setForeground(Color.red);add(label);add(label1);setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE);setVisible (true);menuItem1[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {System.exit(0);}});menuItem2[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new StartChooseCourse("开始选课界面");}});menuItem2[1].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new CheckCourse("查看选课界面");}});menuItem3[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new StudentManage("个人信息界面");}});menuItem4[0].addActionListener(new ActionListener() { //给'确定'按钮添加动作监听器publicvoid actionPerformed(ActionEvent e) {new About();setVisible(false);}});}}4.4.2菜单界面效果:5总结6组内自评。