ПЗ автоматизації обліку успішності з фізичного виховання

Автор: Пользователь скрыл имя, 24 Мая 2013 в 04:40, курсовая работа

Описание работы

Целью такой программы является просмотр сдачи студентом определенных нормативов, указанных в учебном плане заведения. Таким образом сократиться время поиска студента среди всех членов группы, и просмотр нормативов будет удобным, так как будет отвечать только заданному студенту.

Содержание

Введение 2
1 Постановка задачи 4
1.1 Требования пользователя 4
1.1.1 Мандатные требования 4
1.1.2 Ограничительные требования 4
2 Анализ требований 6
2.1 Анализ и обзор предметной области 6
2.2 Глоссарий 6
2.3 Описание вариантов использования ПО 7
2.4 Требования к ПО 13
2.4.1 Функциональные требования 13
2.4.2 Нефункциональные требования 13
3 Архитектурное и детальное проектирование ПО 14
3.1 Архитектурное проектирование клиентской части ПО 14
3.2 Архитектурное проектирование серверной части ПО 15
3.2.1 Логическая модель даннях 15
3.2.1.1 Выделение сущностей и атрибутов предметной области 15
3.2.2 Выделение связей между сущностями 17
3.2.3 Построение логической схемы БД 17
3.3 Детальное проектирование ПО 18
3.3.1 Детальное проектирование клиентской части ПО 18
3.3.2 Детальное проектирование серверной части ПО 20
3.3.2.1 Описание таблиц БД на основе логической модели БД 20
4 Проверка работоспособности ПО 21
Выводы 24
Список литературы 25
Приложение А. Листинг исходных кодов SQL-сценариев для создания таблиц БД 26
Приложение В . Листинг исходного кода клиентской части приложения 28

Работа содержит 1 файл

lozovaya_kursach_java.docx

— 608.55 Кб (Скачать)

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.setSize(240, 140);

        frame.setResizable(false);

        frame.setLocationRelativeTo(null);

 

        Font font = new Font("Tahoma", Font.BOLD, 14);

 

        textFieldLogin = new JTextField();

        textFieldPassword = new JPasswordField();

        panelTextField = new JPanel();

        panelTextField.setLayout(new BoxLayout(panelTextField, BoxLayout.Y_AXIS));

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

        panelTextField.add(textFieldLogin);

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

        panelTextField.add(textFieldPassword);

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

 

        labelLogin = new JLabel("Логин");

        labelPassword = new JLabel("Пароль");

        labelLogin.setFont(font);

        labelPassword.setFont(font);

        panelLabel = new JPanel();

        panelLabel.setLayout(new BoxLayout(panelLabel, BoxLayout.Y_AXIS));

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelLogin);

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelPassword);

        panelLabel.add(Box.createVerticalStrut(10));

 

        panelLabelField = new JPanel();

        panelLabelField.setLayout(new BoxLayout(panelLabelField, BoxLayout.X_AXIS));

        panelLabelField.add(Box.createHorizontalStrut(8));

        panelLabelField.add(panelLabel);

        panelLabelField.add(Box.createHorizontalStrut(8));

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

        panelLabelField.add(panelTextField);

        panelLabelField.add(Box.createHorizontalStrut(8));

 

        buttonLogin = new JButton("Логин");

        buttonCancel = new JButton("Отмена");

        panelButton = new JPanel();

        panelButton.add(buttonLogin);

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

        panelButton.add(buttonCancel);

 

        frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));

        frame.add(panelLabelField);

        frame.add(panelButton);

        frame.add(Box.createVerticalStrut(5));

 

        pack();

        frame.setVisible(true);

 

        buttonLogin.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent arg0) {

                String sql = "Select * from lecturer where login_lecturer = ? and password_lecturer = ?";

                try {

                    con = ConnectionDB.ConnectionDB();

                    prst = con.prepareStatement(sql);

                    prst.setString(1, textFieldLogin.getText());

                    prst.setString(2, textFieldPassword.getText());

                    rs = prst.executeQuery();

                    if (rs.next()) {

                        Utils.setUser(textFieldLogin.getText());

                        new JFrameMain();

                        frame.dispose();

                    } else {

                        JOptionPane.showMessageDialog(null, "Ошибка ввода логина или пароля!");

                    }

                } catch (SQLException e1) {

                    JOptionPane.showMessageDialog(null, "Ошибка выполнения запроса к БД!");

                } catch (Exception e2) {

                    JOptionPane.showMessageDialog(null, "Ошибка создания соединения с БД!");

                } finally {

                    try {

                        con.close();

                        prst.close();

                    } catch (SQLException e) {

                        e.printStackTrace();

                    }

                }

            }

            public void mousePressed(MouseEvent e) {

            }

            public void mouseReleased(MouseEvent e) {

            }

            public void mouseEntered(MouseEvent e) {

            }

            public void mouseExited(MouseEvent e) {

            }

        });

        buttonCancel.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent arg0) {

                System.exit(0);

            }

            public void mousePressed(MouseEvent e) {

            }

            public void mouseReleased(MouseEvent e) {

            }

            public void mouseEntered(MouseEvent e) {

            }

            public void mouseExited(MouseEvent e) {

            }

        });

    }

    public static void main(String[] args) {

        SwingUtilities.invokeLater(new Runnable() {

            public void run() {

                new JFrameLogin();

            }

        });

    }

}

 

JDialogStudents

 

package view;

 

import controls.ConnectionDB;

import controls.Utils;

import model.Group;

import model.Student;

import javax.imageio.ImageIO;

import javax.swing.*;

import java.awt.*;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.IOException;

import java.sql.*;

import java.util.ArrayList;

 

/**

* Форма добавления студента

 */

public class JDialogStudent extends JDialog {

    private PreparedStatement prst = null;

    private Connection con = null;

    private Statement сt = null;

    private ResultSet rs = null;

    private Student student;

    private boolean switcher = false;

 

    private JTextField textFldSurnameStudent;

    private JTextField textFldFirstnameStudent;

    private JTextField textFldMiddlenameStudent;

    private JComboBox comboBoxGroup;

    private JTextField textFldPhoneStudent;

 

    public void setValueTable(Student student) {

        this.student = student;

        switcher = true;

        textFldSurnameStudent.setText(student.getSurnameStudent());

        textFldFirstnameStudent.setText(student.getFirstnameStudent());

        textFldMiddlenameStudent.setText(student.getMiddlenameStudent());

        comboBoxGroup.setSelectedItem(student.getNameGroup());

        textFldPhoneStudent.setText(student.getPhoneStudent());

    }

    public JDialogStudent(String dialogTitle) {

        setTitle(dialogTitle);

        setResizable(false);

        setSize(300, 250);

        setModal(true);

        setLocationRelativeTo(null);

        Font fontLabel = new Font("Tahoma", Font.BOLD, 14);

        Font fontTextFld = new Font("Tahoma", Font.BOLD, 12);

 

        JPanel panelTextFld = new JPanel();

        textFldSurnameStudent = new JTextField("", 15);

        textFldFirstnameStudent = new JTextField("");

        textFldMiddlenameStudent = new JTextField("");

        comboBoxGroup = new JComboBox(Utils.getListGroups().getItems());

        textFldPhoneStudent = new JTextField("");

 

        panelTextFld.add(textFldSurnameStudent);

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

        panelTextFld.add(textFldFirstnameStudent);

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

        panelTextFld.add(textFldMiddlenameStudent);

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

        panelTextFld.add(comboBoxGroup);

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

        panelTextFld.add(textFldPhoneStudent);

 

        textFldSurnameStudent.setFont(fontTextFld);

        textFldFirstnameStudent.setFont(fontTextFld);

        textFldMiddlenameStudent.setFont(fontTextFld);

        comboBoxGroup.setFont(fontTextFld);

        textFldPhoneStudent.setFont(fontTextFld);

 

        JPanel panelLabelClick = new JPanel();

        final JLabel labelBackClick = new JLabel();

        try {

            labelBackClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/back.png"))));

        } catch (IOException e) {

            JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [back.png]");

            return;

        }

        labelBackClick.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent arg0) {

                setVisible(false);

            }

            public void mousePressed(MouseEvent e) {

            }

            public void mouseReleased(MouseEvent e) {

            }

            public void mouseEntered(MouseEvent e) {

                try {

                    labelBackClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/back_.png"))));

                } catch (IOException e1) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [back_.png]");

                    return;

                }

            }

            public void mouseExited(MouseEvent e) {

                try {

                    labelBackClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/back.png"))));

                } catch (IOException e2) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [back.png]");

                    return;

                }

            }

        });

        final JLabel labelOkClick = new JLabel();

        try {

            labelOkClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/ok.png"))));

        } catch (IOException e) {

            JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [ok.png]",

                    "Ошибка", JOptionPane.ERROR_MESSAGE);

        }

        labelOkClick.addMouseListener(new MouseListener() {

            public void mouseClicked(MouseEvent arg0) {

                try {

                    labelOkClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/ok.png"))));

                } catch (IOException e) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [ok.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

                if (textFldSurnameStudent.getText().equals("") || textFldFirstnameStudent.getText().equals("")

                        || textFldMiddlenameStudent.getText().equals("") || textFldPhoneStudent.getText().equals("")) {

                    JOptionPane.showMessageDialog(null, "Заполните все поля",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                    return;

                }

                if (switcher) {

                    editStudentToBD();

                } else {

                    addStudentToBD();

                }

                updateStudentsBD();

                setVisible(false);

            }

            public void mousePressed(MouseEvent e) {

            }

            public void mouseReleased(MouseEvent e) {

            }

            public void mouseEntered(MouseEvent e) {

                try {

                    labelOkClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/ok_.png"))));

                } catch (IOException e1) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [ok_.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

            }

            public void mouseExited(MouseEvent e) {

                try {

                    labelOkClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/ok.png"))));

                } catch (IOException e2) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [ok.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

            }

        });

        final JLabel labelMinusClick = new JLabel();

        try {

            labelMinusClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/minus.png"))));

        } catch (IOException e) {

            JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [minus.png]",

                    "Ошибка", JOptionPane.ERROR_MESSAGE);

        }

        labelMinusClick.addMouseListener(new MouseListener() {

            @Override

            public void mouseClicked(MouseEvent arg0) {

                try {

                    labelMinusClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/minus.png"))));

                } catch (IOException e) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [minus.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

                if (switcher) {

                    deleteStudentToBD();

                    updateStudentsBD();

                    setVisible(false);

                } else {

                    textFldSurnameStudent.setText("");

                    textFldFirstnameStudent.setText("");

                    textFldMiddlenameStudent.setText("");

                    comboBoxGroup.setSelectedItem("");

                    textFldPhoneStudent.setText("");

                }

            }

            public void mousePressed(MouseEvent e) {

            }

            public void mouseReleased(MouseEvent e) {

            }

             public void mouseEntered(MouseEvent e) {

                try {

                    labelMinusClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/minus_.png"))));

                } catch (IOException e1) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [minus_.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

            }

            @Override

            public void mouseExited(MouseEvent e) {

                try {

                    labelMinusClick.setIcon(new ImageIcon(ImageIO.read(new File("src/images/minus.png"))));

                } catch (IOException e2) {

                    JOptionPane.showMessageDialog(null, "Ошибка загрузки картинки [minus.png]",

                            "Ошибка", JOptionPane.ERROR_MESSAGE);

                }

            }

        });

        panelLabelClick.add(labelBackClick);

        panelLabelClick.add(labelMinusClick);

        panelLabelClick.add(labelOkClick);

 

        JPanel panelLabel = new JPanel();

 

        JLabel labelSurnameStudent = new JLabel();

        JLabel labelFirstnameStudent = new JLabel();

        JLabel labelMiddlenameStudent = new JLabel();

        JLabel labelNameGroup = new JLabel();

        JLabel labelPhoneStudent = new JLabel();

 

        labelSurnameStudent.setText("Фамилиия");

        labelFirstnameStudent.setText("Имя");

        labelMiddlenameStudent.setText("Отчество");

        labelNameGroup.setText("Группа");

        labelPhoneStudent.setText("Телефон");

 

        labelSurnameStudent.setFont(fontLabel);

        labelFirstnameStudent.setFont(fontLabel);

        labelMiddlenameStudent.setFont(fontLabel);

        labelNameGroup.setFont(fontLabel);

        labelPhoneStudent.setFont(fontLabel);

 

        panelLabel.add(labelSurnameStudent);

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelFirstnameStudent);

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelMiddlenameStudent);

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelNameGroup);

        panelLabel.add(Box.createVerticalStrut(10));

        panelLabel.add(labelPhoneStudent);

 

        JPanel panelMain = new JPanel();

        panelMain.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 12));

 

        panelMain.add(panelLabel, BorderLayout.CENTER);

        panelMain.add(panelTextFld, BorderLayout.WEST);

        panelMain.add(panelLabelClick, BorderLayout.SOUTH);

        add(panelMain);

 

        panelTextFld.setLayout(new BoxLayout(panelTextFld, BoxLayout.Y_AXIS));

        panelLabel.setLayout(new BoxLayout(panelLabel, BoxLayout.Y_AXIS));

    }

    /**

     * Обновление  таблицы Студенты в БД

     */

    private void updateStudentsBD() {

        try {

            con = ConnectionDB.ConnectionDB();

            сt = con.createStatement();

            rs = сt.executeQuery("" +

                    "SELECT id_student, surname_student, firstname_student, middlename_student, name_group, phone_student " +

                    "FROM phusical_education.student, phusical_education.group " +

                    "WHERE phusical_education.student.id_group=phusical_education.group.id_group " +

                    "ORDER BY surname_student ASC;");

            ArrayList<Student> students = new ArrayList<Student>();

Информация о работе ПЗ автоматизації обліку успішності з фізичного виховання