Tải bản đầy đủ - 0 (trang)
CHƯƠNG IV. HIỆN THỰC BÀI TOÁN

CHƯƠNG IV. HIỆN THỰC BÀI TOÁN

Tải bản đầy đủ - 0trang

Giao diện chính của chương trình

-Danh sách các thí sinh ban đầu là các thí sinh đã có sẵn trong CSDL

-Tìm kiếm: nhập tên tỉnh thành/ mã sinh viên vào BirthPlace/StudentID và ấn nút

FITLER



Nguyễn Ngọc Trí –CNTT-K55



-Thêm thí sinh: ấn nút INSERT điền vào các trường

ID,NAME,BIRTHPLACE,DATE,SEX ,MATH,….và nhấn OK

Nguyễn Ngọc Trí –CNTT-K55



 Xóa thí sinh: Chọn thí sinh cần xóa, ấn nút DELETE



Nguyễn Ngọc Trí –CNTT-K55



- Sửa thí sinh: Chọn thí sinh, ấn vào EDIT, điền các thơng tin mới và ấn OK



Nguyễn Ngọc Trí –CNTT-K55



2Source Code:

2.1 AboutMe:

import java.awt.BorderLayout;

import java.awt.FlowLayout;

import javax.swing.JButton;

import javax.swing.JDialog;

import javax.swing.JPanel;

import javax.swing.border.EmptyBorder;

import javax.swing.JLabel;

import java.awt.Color;

Nguyễn Ngọc Trí –CNTT-K55



import javax.swing.border.LineBorder;

import javax.swing.border.TitledBorder;

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

public class aboutme extends JDialog {

private final JPanel contentPanel = new JPanel();

public static void main(String[] args) {

try {

aboutme dialog = new aboutme();

dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

dialog.setLocationRelativeTo(null);

dialog.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

public aboutme() {

setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

setTitle("About me");

setBounds(100, 100, 243, 122);

getContentPane().setLayout(new BorderLayout());

contentPanel.setBackground(new Color(255, 250, 240));

contentPanel.setBorder(null);

getContentPane().add(contentPanel, BorderLayout.CENTER);

contentPanel.setLayout(null);

JLabel lblGingVinHng = new JLabel("Chuong Trinh Quan Li Thi Sinh");

lblGingVinHng.setBounds(10, 45, 227, 34);

contentPanel.add(lblGingVinHng);

JLabel lblNgiThcHin = new JLabel("Nguyen Ngoc Tri");

lblNgiThcHin.setBounds(10, -4, 247, 49);

contentPanel.add(lblNgiThcHin);

JLabel lblLpCngNgh = new JLabel("CNTT55");

lblLpCngNgh.setBounds(10, 24, 170, 34);

contentPanel.add(lblLpCngNgh);

}

}

Nguyễn Ngọc Trí –CNTT-K55



2.2 ConnectDatabase:

import java.sql.Connection;

import java.sql.DriverManager;

public class ConnectDatabase {

public static Connection getConnection() {

Connection c = null;

try {

Class.forName("com.mysql.jdbc.Driver");

String host = "localhost";

String port = "3306";

String dbName = "student";

String url = "jdbc:mysql://" + host + ":" + port + "/" + dbName;

String user = "root";

String pass = "";

c = DriverManager.getConnection(url, user, pass);

} catch (Exception e) {

e.printStackTrace();

}

return c;

}

public static void closeConnection(Connection c) {

try {

if (c != null)

c.close();

} catch (Exception e) {

e.printStackTrace();

}

}

public static void main(String[] args) {

System.out.println(getConnection());

}

}

2.3 student:

import java.awt.Color;

import java.awt.Component;

Nguyễn Ngọc Trí –CNTT-K55



import java.awt.EventQueue;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.FocusAdapter;

import java.awt.event.FocusEvent;

import java.awt.event.InputEvent;

import java.awt.event.KeyEvent;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.sql.Date;

import java.util.ArrayList;

import javax.swing.UIManager;

import javax.swing.UIManager.*;

import javax.swing.ButtonGroup;

import javax.swing.DefaultComboBoxModel;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JScrollPane;

import javax.swing.JSeparator;

import javax.swing.JTable;

import javax.swing.JTextField;

import javax.swing.KeyStroke;

import javax.swing.UIManager;

import javax.swing.border.EmptyBorder;

import javax.swing.border.LineBorder;

import javax.swing.border.TitledBorder;

Nguyễn Ngọc Trí –CNTT-K55



import javax.swing.table.DefaultTableCellRenderer;

import javax.swing.table.DefaultTableModel;

import org.eclipse.wb.swing.FocusTraversalOnArray;

import java.awt.SystemColor;

public class student extends JFrame{

private JPanel contentPane;

private JTextField textField_BirthPlace;

private JTextField textField_StudentID;

private JTextField textField_ID;

private JTextField textField_Name;

private JTextField textField_Place;

private final ButtonGroup buttonGroup = new ButtonGroup();

private JTextField textField_Math;

private JTextField textField_Physical;

private JTextField textField_Chemistry;

private JTextField textField_Total;

double tongDiem;

private JRadioButton rdbtnMale;

private JRadioButton rdbtnFemale;

private JComboBox comboBox_ngay;

private JComboBox comboBox_thang;

private JComboBox comboBox_nam;

private JPanel panel;

private JPanel panel_1;

private JPanel panel_2;

private JPanel panel_3;

private JComboBox comboBox_BirthPlace;

int kt = 0;

private static JTable table;

/**

* Launch the application.

*/

public static void main(String[] args) {

Nguyễn Ngọc Trí –CNTT-K55



// Look And Feel

try {

for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {

if ("Nimbus".equals(info.getName())) {

UIManager.setLookAndFeel(info.getClassName());

break;

}

}

} catch (Exception e) {

// If Nimbus is not available, you can set the GUI to another look

// and feel.

}

EventQueue.invokeLater(new Runnable() {

@Override

public void run() {

try {

student frame = new student();

loadThiSinh();

frame.setLocationRelativeTo(null);

frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

/**

* Create the frame.

*/

public student() {

setResizable(false);

setForeground(Color.BLACK);

setBackground(Color.BLACK);

setTitle("Quản lý thí sinh");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100, 100, 683, 696);

Nguyễn Ngọc Trí –CNTT-K55



JMenuBar menuBar = new JMenuBar();

menuBar.setBackground(SystemColor.desktop);

setJMenuBar(menuBar);

JMenu mnNewMenu = new JMenu("File");

menuBar.add(mnNewMenu);

JMenuItem mnOpen = new JMenuItem("Open");

mnOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,

InputEvent.CTRL_MASK));

mnOpen.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

panel.setVisible(true);

panel_1.setVisible(true);

panel_2.setVisible(true);

panel_3.setVisible(true);

}

});

mnNewMenu.add(mnOpen);

JMenuItem mnClose = new JMenuItem("Close");

mnClose.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W,

InputEvent.CTRL_MASK));

mnClose.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

panel.setVisible(false);

panel_1.setVisible(false);

panel_2.setVisible(false);

panel_3.setVisible(false);

}

});

mnNewMenu.add(mnClose);

JSeparator separator = new JSeparator();

mnNewMenu.add(separator);

Nguyễn Ngọc Trí –CNTT-K55



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

CHƯƠNG IV. HIỆN THỰC BÀI TOÁN

Tải bản đầy đủ ngay(0 tr)

×