You are on page 1of 43

Student Information System

An Information Management Project Requirement


Presented to Modesto T. Tarrazona
University of Mindanao
Matina, Davao City

In partial Fulfillment of the Requirement in CCE104L


1st Semester, 1st Term S.Y. 2022-2023

Submitted by:

Concepcion, Klent
Cabaya, Geraldine
Barcarcil, Almar Jay
Maraon, Bernard Gaspar

October 2022
Description of the Study
Nowadays we are surrounded by technology and people rely on technology in their

daily lives. Computers have become more important due to their improved productivity

and efficiency. The computer is capable of storing large volumes of data. Student

Management System (SMS) is one system that serves as both a building block of

information and a source of instruction for students. To keep all of the most recent

records of the students as simple as possible, they must maintain a proper database of

the student.

One of the main problems with traditional enrollment is they need to write their

information on a registration form and the registration staff will manually type does

information into excel. The challenges encountered by the registration staff are the

duplicates of information, wrong spelling, and typing wrong because of handwritten or

technical errors. Which takes more time and effort for the registration staff. We develop

this system to help our registration staff to aid with this problem.

This system is developed for academic purposes. The registration staff can use

Student Information System (SIS) to register and maintain all the personal information

of the students they provide, including their full name, parent's maiden name, gender,

physical address, contact information, academic year, and Strand. The system can only

manipulate by the registration staff by managing ( add, update, delete, search, edit). To

in sure the registration staff will be able to get the complete information of the students,

our system will give a prompt message if there is missing information (red highlighted

*). Aside from, we also require to accept the terms and conditions for the privacy of the

students. Since the student will provide sperosnal information, if not it will give the
prompt message (please accept the terms and conditions).

The Student Management System has improved the effectiveness and efficiency of

the education sector. With its well-organized information, user-friendly, and dependable

online school management software.


Business Rules
 Students should have one unique student ID.
 Students attending the school must complete the registration process.
 Students are required to provide at least one or two contact information for
emergencies.
 Students require to have one permanent address.
 Students require to register for their class.
Entity Relationship Diagram (ERD)

Description of Each Table


Sample Data Records from Each Table:
Student
Data Records Student Limit
Describe Login
Types of lo
Source Code
Login Class
package GUIPROJECT;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;
import javax.swing.JCheckBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.awt.Color;
import javax.swing.JPanel;
public class LoginCon {
private static JFrame frame;
private static JTextField txtUser;
private static JPasswordField txtPassword;
private JCheckBox cbTerms;
private JButton btnLogin,btnCancel,btnRegister;
private JSeparator separator_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
LoginCon
window = new LoginCon();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Connection con;
PreparedStatement pst;
ResultSet rs;
private JLabel lblNewLabel_1;
private JLabel lblNewLabel_2;
public LoginCon() {
initialize();
connect();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.getContentPane().setFont(new Font("Tahoma", Font.PLAIN, 16));
frame.setBounds(100, 100, 467, 388);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
ImageIcon img = new
ImageIcon(this.getClass().getResource("/logosr.png"));
lblNewLabel_2 = new JLabel("");
ImageIcon imgs3 = new
ImageIcon(this.getClass().getResource("/desb.png"));
lblNewLabel_2.setIcon(imgs3);
lblNewLabel_2.setForeground(new Color(128, 128, 128));
lblNewLabel_2.setBackground(new Color(128, 128, 128));
lblNewLabel_2.setBounds(187, 5, 197, 147);
frame.getContentPane().add(lblNewLabel_2);
txtUser = new JTextField();
txtUser.setFont(new Font("Tahoma", Font.PLAIN, 16));
txtUser.setBounds(158, 186, 214, 41);
frame.getContentPane().add(txtUser);
txtUser.setColumns(10);
JLabel lblUser = new JLabel("Enter Username:");
lblUser.setHorizontalAlignment(SwingConstants.RIGHT);
lblUser.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblUser.setBounds(19, 198, 133, 16);
frame.getContentPane().add(lblUser);

JLabel lblPass = new JLabel("Enter Password:");


lblPass.setHorizontalAlignment(SwingConstants.RIGHT);
lblPass.setFont(new Font("Tahoma", Font.PLAIN, 16));
lblPass.setBounds(19, 241, 133, 16);
frame.getContentPane().add(lblPass);
txtPassword = new JPasswordField();
txtPassword.setFont(new Font("Tahoma", Font.PLAIN, 16));
txtPassword.setBounds(158, 229, 214, 41);
frame.getContentPane().add(txtPassword);
ImageIcon imgs = new ImageIcon(this.getClass().getResource("/log-
in.png"));
btnCancel = new JButton("CANCEL");
btnCancel.setBackground(new Color(255, 255, 0));
btnCancel.setFont(new Font("Tahoma", Font.PLAIN, 16));
btnCancel.setBounds(336, 297, 117, 52);
frame.getContentPane().add(btnCancel);
JSeparator separator_1 = new JSeparator();
separator_1.setBounds(21, 170, 436, 13);
frame.getContentPane().add(separator_1);
cbTerms = new JCheckBox("Accept Terms & Conditions");
cbTerms.setBounds(177, 269, 200, 23);
frame.getContentPane().add(cbTerms);
separator_1 = new JSeparator();
separator_1.setBounds(3, 158, 473, 12);
frame.getContentPane().add(separator_1);
btnRegister = new JButton("REGISTER");
btnRegister.setBackground(new Color(0, 255, 0));
btnRegister.setFont(new Font("Tahoma", Font.PLAIN, 16));
btnRegister.setBounds(193, 297, 117, 52);
frame.getContentPane().add(btnRegister);
btnLogin = new JButton("LOGIN");
btnLogin.setBackground(new Color(255, 0, 0));
btnLogin.setForeground(new Color(0, 0, 0));
btnLogin.setIcon(imgs);
btnLogin.setFont(new Font("Tahoma", Font.PLAIN, 16));
btnLogin.setBounds(4, 298, 155, 52);
frame.getContentPane().add(btnLogin);
JLabel lblHead = new JLabel("");
lblHead.setIcon(img);
lblHead.setHorizontalAlignment(SwingConstants.CENTER);
lblHead.setFont(new Font("Lucida Grande", Font.PLAIN, 35));
lblHead.setBounds(3, 5, 197, 147);
frame.getContentPane().add(lblHead);
JLabel lblNewLabel = new JLabel("");
ImageIcon img1 = new
ImageIcon(this.getClass().getResource("/refs.png"));
lblNewLabel.setIcon(img1);
lblNewLabel.setBounds(386, 235, 53, 45);
frame.getContentPane().add(lblNewLabel);
lblNewLabel_1 = new JLabel("");
ImageIcon img2 = new
ImageIcon(this.getClass().getResource("/userss.png"));
lblNewLabel_1.setIcon(img2);
lblNewLabel_1.setBounds(382, 186, 53, 45);
frame.getContentPane().add(lblNewLabel_1);
ImageIcon img3 = new
ImageIcon(this.getClass().getResource("/des.png"));
actions();
}
public void actions() {
txtPassword.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if(txtPassword.getText().length()>6) {
errorMessage("Maximum character length","Error");
txtPassword.setText("");
return;
}
}
});
txtUser.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if(txtUser.getText().length()>6) {
errorMessage("Maximum character length","Error");
txtUser.setText("");
return;
}
}
});
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String username = txtUser.getText(),password =
txtPassword.getText();
boolean isChecked = cbTerms.isSelected();
login(username, password, isChecked);
}
});
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
btnRegister.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
boolean isChecked = cbTerms.isSelected();
String username,password;
username= txtUser.getText();
password = txtPassword.getText().toString();
register(username, password, isChecked);
try {//string values then inserted in the database sql
pst=con.prepareStatement("insert into
login(user,pass)values(?,?)");
pst.setString(1, txtUser.getText());
pst.setString(2, txtPassword.getText().toString());
pst.executeUpdate();
}catch(SQLException e1) {
e1.printStackTrace();
}
if(username.equals("")&&password.equals("")) {
errorMessage("Empty textfield", "ERROR");
return;
}
txtUser.setText("");
txtPassword.setText("");
if(username.equals("")&&(password.equals(""))) {
errorMessage("Empty textfield", "ERROR");
return;
}
txtUser.setText("");
txtPassword.setText("");
return;

}
});
}
@SuppressWarnings("unlikely-arg-type")
public static void login (String username, String password, boolean isChecked)
{
if(username.equals("")) {
errorMessage("Please type your username", "Error");
return;
}
if(password.equals("")) {
errorMessage("Please type your password", "Error");
return;
}
if(!isChecked) {
errorMessage("Please check the Terms and Conditions", "Error");
return;
}
try {
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/studentdb","root","");
Statement stm=con.createStatement();
String sql="Select * from login where user='"+txtUser.getText()+"'
and pass = '"+txtPassword.getText().toString()+"'";
ResultSet rs=stm.executeQuery(sql);
if(rs.next()) {
successMessage("Login Succesfull", "Success");
Student newform = new Student();
newform.main(null);
frame.setVisible(false);
}
else
errorMessage("Invalid Account! Please try again!", "Error");
txtUser.setText("");
txtPassword.setText("");
return;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void successMessage(String info, String status) {
JOptionPane.showMessageDialog(null, info, status,
JOptionPane.INFORMATION_MESSAGE);

}
public static void errorMessage(String error, String status) {
JOptionPane.showMessageDialog(null, error, status,
JOptionPane.INFORMATION_MESSAGE);
}
public static void register(String username, String password, boolean
isChecked) {
if(username.equals("")) {
errorMessage("Please type your username", "Error");
return;
}
if(password.equals("")) {
errorMessage("Please type your password", "Error");
return;
}
if(!isChecked) {
errorMessage("Please check the Terms and Conditions", "Error");
return;
}

errorMessage("Succesfully registered", "SUCCESS");


}
public void connect() {
try {
Class.forName("com.mysql.jdbc.Driver");
try {
con =
DriverManager.getConnection("jdbc:mysql://localhost/studentdb","root","");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

StudentMenu Class
package GUIPROJECT;

import java.awt.EventQueue;
import java.util.*;
import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTabbedPane;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextPane;
import javax.swing.JEditorPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import java.awt.Font;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import net.proteanit.sql.DbUtils;

import javax.swing.JScrollPane;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;

public class Student {

JFrame frame;
JPanel contentPane;
JTextField Fstnm;
JTextField Lstnm;
JTextField Mname;
JTextField Cnctnm;
JTextField Address;
JTextField FstP;
JTextField LstP;
JTextField MP;
JTextField FstP1;
JTextField LstP1;
JTextField MP1;
JButton btnAddstnd, Show,btnInfo,Logout;
JComboBox Strand, Semc,Year,Sex;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Student window = new Student();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
//for backup
File file = new File("data.txt");
private JTable table;
//for database connection
Connection con;
PreparedStatement pst;
ResultSet rs;
private JTable table_1;
public void connect() {
try {
Class.forName("com.mysql.jdbc.Driver");
try {
con =
DriverManager.getConnection("jdbc:mysql://localhost/studentdb","root","");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public Student() {
initialize();
connect();
createFile();
}
//create txtfile backup
public void createFile() {
if(!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 1739, 701);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);

JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);


tabbedPane.setBounds(10, 11, 1350, 652);
frame.getContentPane().add(tabbedPane);

JPanel panel_2 = new JPanel();


tabbedPane.addTab("Admin", null, panel_2, null);
panel_2.setLayout(null);
panel_2.setBackground(Color.GRAY);

JLabel lblNewLabel = new JLabel("STUDENT");


lblNewLabel.setToolTipText("");
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel.setFont(new Font("Arial", Font.BOLD, 11));
lblNewLabel.setBounds(611, 240, 91, 20);
panel_2.add(lblNewLabel);
JTextPane txtpnAwssda = new JTextPane();
txtpnAwssda.setToolTipText("");
txtpnAwssda.setBounds(268, 218, 766, 20);
panel_2.add(txtpnAwssda);

JLabel lblFirst = new JLabel("FIRST NAME:");


lblFirst.setToolTipText("");
lblFirst.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst.setForeground(Color.WHITE);
lblFirst.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst.setBounds(293, 263, 91, 20);
panel_2.add(lblFirst);

JLabel lblLastName = new JLabel("LAST NAME:");


lblLastName.setToolTipText("");
lblLastName.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName.setForeground(Color.WHITE);
lblLastName.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName.setBounds(568, 263, 91, 20);
panel_2.add(lblLastName);

JLabel lblM = new JLabel("M.I:");


lblM.setToolTipText("");
lblM.setHorizontalAlignment(SwingConstants.CENTER);
lblM.setForeground(Color.WHITE);
lblM.setFont(new Font("Arial", Font.BOLD, 11));
lblM.setBounds(804, 262, 91, 20);
panel_2.add(lblM);

JLabel lblContactNo = new JLabel("CONTACT NO:");


lblContactNo.setToolTipText("");
lblContactNo.setHorizontalAlignment(SwingConstants.CENTER);
lblContactNo.setForeground(Color.WHITE);
lblContactNo.setFont(new Font("Arial", Font.BOLD, 11));
lblContactNo.setBounds(290, 305, 91, 20);
panel_2.add(lblContactNo);

JLabel lblAddress = new JLabel("ADDRESS:");


lblAddress.setToolTipText("");
lblAddress.setHorizontalAlignment(SwingConstants.CENTER);
lblAddress.setForeground(Color.WHITE);
lblAddress.setFont(new Font("Arial", Font.BOLD, 11));
lblAddress.setBounds(575, 300, 91, 20);
panel_2.add(lblAddress);

JLabel lblSex = new JLabel("SEX:");


lblSex.setToolTipText("");
lblSex.setHorizontalAlignment(SwingConstants.CENTER);
lblSex.setForeground(Color.WHITE);
lblSex.setFont(new Font("Arial", Font.BOLD, 11));
lblSex.setBounds(735, 350, 91, 20);
panel_2.add(lblSex);

JLabel lblDepartment = new JLabel("STRAND:");


lblDepartment.setToolTipText("");
lblDepartment.setHorizontalAlignment(SwingConstants.CENTER);
lblDepartment.setForeground(Color.WHITE);
lblDepartment.setFont(new Font("Arial", Font.BOLD, 11));
lblDepartment.setBounds(428, 352, 75, 20);
panel_2.add(lblDepartment);

JLabel lblClass = new JLabel("YEAR LEVEL:");


lblClass.setToolTipText("");
lblClass.setHorizontalAlignment(SwingConstants.CENTER);
lblClass.setForeground(Color.WHITE);
lblClass.setFont(new Font("Arial", Font.BOLD, 11));
lblClass.setBounds(567, 350, 91, 20);
panel_2.add(lblClass);

JLabel lblParents = new JLabel("PARENTS");


lblParents.setToolTipText("");
lblParents.setHorizontalAlignment(SwingConstants.CENTER);
lblParents.setFont(new Font("Arial", Font.BOLD, 11));
lblParents.setBounds(601, 402, 91, 20);
panel_2.add(lblParents);

JTextPane txtpnAwssda_1 = new JTextPane();


txtpnAwssda_1.setToolTipText("");
txtpnAwssda_1.setBounds(258, 381, 766, 20);
panel_2.add(txtpnAwssda_1);

JLabel lblFirst_1 = new JLabel("FIRST NAME:");


lblFirst_1.setToolTipText("");
lblFirst_1.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst_1.setForeground(Color.WHITE);
lblFirst_1.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst_1.setBounds(283, 433, 91, 20);
panel_2.add(lblFirst_1);

JLabel lblLastName_1 = new JLabel("MAIDEN NAME:");


lblLastName_1.setToolTipText("");
lblLastName_1.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName_1.setForeground(Color.WHITE);
lblLastName_1.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName_1.setBounds(551, 433, 91, 20);
panel_2.add(lblLastName_1);

JLabel lblM_1 = new JLabel("M.I:");


lblM_1.setToolTipText("");
lblM_1.setHorizontalAlignment(SwingConstants.CENTER);
lblM_1.setForeground(Color.WHITE);
lblM_1.setFont(new Font("Arial", Font.BOLD, 11));
lblM_1.setBounds(794, 432, 91, 20);
panel_2.add(lblM_1);

JLabel lblFirst_2 = new JLabel("FIRST NAME:");


lblFirst_2.setToolTipText("");
lblFirst_2.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst_2.setForeground(Color.WHITE);
lblFirst_2.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst_2.setBounds(283, 507, 91, 20);
panel_2.add(lblFirst_2);

JLabel lblLastName_2 = new JLabel("LAST NAME:");


lblLastName_2.setToolTipText("");
lblLastName_2.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName_2.setForeground(Color.WHITE);
lblLastName_2.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName_2.setBounds(558, 507, 91, 20);
panel_2.add(lblLastName_2);

JLabel lblM_2 = new JLabel("M.I:");


lblM_2.setToolTipText("");
lblM_2.setHorizontalAlignment(SwingConstants.CENTER);
lblM_2.setForeground(Color.WHITE);
lblM_2.setFont(new Font("Arial", Font.BOLD, 11));
lblM_2.setBounds(794, 506, 91, 20);
panel_2.add(lblM_2);

btnAddstnd = new JButton("ADD STUDENT");


btnAddstnd.setToolTipText("");
btnAddstnd.setBounds(592, 574, 137, 23);
panel_2.add(btnAddstnd);

Fstnm = new JTextField();


Fstnm.setToolTipText("");
Fstnm.setColumns(10);
Fstnm.setBounds(384, 263, 175, 20);
panel_2.add(Fstnm);

Lstnm = new JTextField();


Lstnm.setToolTipText("");
Lstnm.setColumns(10);
Lstnm.setBounds(648, 263, 175, 20);
panel_2.add(Lstnm);

Mname = new JTextField();


Mname.setToolTipText("");
Mname.setColumns(10);
Mname.setBounds(873, 263, 137, 20);
panel_2.add(Mname);

Cnctnm = new JTextField();


Cnctnm.setToolTipText("");
Cnctnm.setColumns(10);
Cnctnm.setBounds(384, 305, 175, 20);
panel_2.add(Cnctnm);

Address = new JTextField();


Address.setToolTipText("");
Address.setColumns(10);
Address.setBounds(648, 300, 155, 20);
panel_2.add(Address);

FstP = new JTextField();


FstP.setToolTipText("");
FstP.setColumns(10);
FstP.setBounds(374, 433, 175, 20);
panel_2.add(FstP);

LstP = new JTextField();


LstP.setToolTipText("");
LstP.setColumns(10);
LstP.setBounds(638, 433, 175, 20);
panel_2.add(LstP);

MP = new JTextField();
MP.setToolTipText("");
MP.setColumns(10);
MP.setBounds(863, 433, 137, 20);
panel_2.add(MP);

FstP1 = new JTextField();


FstP1.setToolTipText("");
FstP1.setColumns(10);
FstP1.setBounds(374, 507, 175, 20);
panel_2.add(FstP1);

LstP1 = new JTextField();


LstP1.setToolTipText("");
LstP1.setColumns(10);
LstP1.setBounds(638, 507, 175, 20);
panel_2.add(LstP1);

MP1 = new JTextField();


MP1.setToolTipText("");
MP1.setColumns(10);
MP1.setBounds(863, 507, 137, 20);
panel_2.add(MP1);

Logout = new JButton("Logout");


Logout.setToolTipText("");
Logout.setBounds(304, 574, 91, 23);
panel_2.add(Logout);

JLabel Sem = new JLabel("SEM:");


Sem.setToolTipText("");
Sem.setHorizontalAlignment(SwingConstants.CENTER);
Sem.setForeground(Color.WHITE);
Sem.setFont(new Font("Arial", Font.BOLD, 11));
Sem.setBounds(293, 352, 91, 20);
panel_2.add(Sem);

JLabel lblNewLabel_3 = new JLabel("");


ImageIcon imgs = new
ImageIcon(this.getClass().getResource("/deps.png"));
lblNewLabel_3.setIcon(imgs);
lblNewLabel_3.setBounds(473, 18, 360, 189);
panel_2.add(lblNewLabel_3);

JLabel lblNewLabel_2 = new JLabel("");


ImageIcon img = new
ImageIcon(this.getClass().getResource("/logosr.png"));
lblNewLabel_2.setIcon(img);
lblNewLabel_2.setBounds(249, 20, 197, 192);
panel_2.add(lblNewLabel_2);

Strand = new JComboBox();


Strand.setModel(new DefaultComboBoxModel(new String[] {"HUMSS",
"STEM", "ABM"}));
Strand.setBounds(491, 350, 73, 21);
panel_2.add(Strand);

Semc = new JComboBox();


Semc.setModel(new DefaultComboBoxModel(new String[] {"1st", "2nd"}));
Semc.setBounds(359, 351, 73, 21);
panel_2.add(Semc);

Year = new JComboBox();


Year.setModel(new DefaultComboBoxModel(new String[] {"11", "12"}));
Year.setBounds(649, 350, 73, 21);
panel_2.add(Year);

Sex = new JComboBox();


Sex.setModel(new DefaultComboBoxModel(new String[] {"Male",
"Female"}));
Sex.setBounds(796, 350, 73, 21);
panel_2.add(Sex);

JPanel panel_1 = new JPanel();


tabbedPane.addTab("Database", null, panel_1, null);
panel_1.setBackground(Color.CYAN);

JButton Show = new JButton("UPDATE");


Show.setBounds(28, 5, 91, 23);
Show.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
display();
}
});
panel_1.setLayout(null);
Show.setBackground(new Color(192, 192, 192));
panel_1.add(Show);

btnInfo = new JButton("STUDENT INFO");


btnInfo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//new frame will appear
Update newform = new Update();
newform.main(null);
}
});
btnInfo.setBounds(145, 5, 117, 23);
btnInfo.setBackground(Color.ORANGE);
panel_1.add(btnInfo);

table_1 = new JTable();


table_1.setBounds(4, 65, 1333, 559);
panel_1.add(table_1);

JScrollPane scrollPane = new JScrollPane();


scrollPane.setBounds(3, 63, 1334, 561);
panel_1.add(scrollPane);
table = new JTable();
scrollPane.setViewportView(table);
table.setModel(new DefaultTableModel(
new Object[][] {
},
new String[] {
"ID", "First Name", "Last Name", "M.I", "Contact no", "Address",
"Sex", "Strand", "Year", "Sem", "First Name", "Last Name", "M.I", "First Name", "Last
Name", "M.I"
}
));

JButton btnNewButton = new JButton("STUDENT");


btnNewButton.setBackground(new Color(199, 234, 151));
btnNewButton.setBounds(10, 43, 816, 14);
panel_1.add(btnNewButton);

JButton btnParent = new JButton("PARENT");


btnParent.setBackground(new Color(130, 208, 255));
btnParent.setBounds(845, 43, 484, 14);
panel_1.add(btnParent);
table.getColumnModel().getColumn(0).setPreferredWidth(48);
table.getColumnModel().getColumn(1).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(119);
actions();
}
public void actions() {
addbutton();
Logout();
}
public void addbutton() {
btnAddstnd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int go = JOptionPane.showConfirmDialog(null,
"Do you want to add this student?", "Are you sure?",
JOptionPane.YES_NO_OPTION);
if(go==JOptionPane.YES_OPTION) {;
String
Fstnms,Lstnms,Mnames,Cnctnms,Addresss,Sexs,Strnds,Yrs,Semtxts,FstPs,LstPs,MPs,Fst
P1s,LstP1s,MP1s;
Fstnms=Fstnm.getText();//get all the textfield values then
store it in the string values
Lstnms=Lstnm.getText();
Mnames=Mname.getText();
Cnctnms=Cnctnm.getText();
Addresss=Address.getText();
Sexs=Sex.getSelectedItem().toString();
Strnds=Strand.getSelectedItem().toString();
Yrs=Year.getSelectedItem().toString();
Semtxts=Semc.getSelectedItem().toString();
FstPs=FstP.getText();
LstPs=LstP.getText();
MPs=MP.getText();
FstP1s=FstP1.getText();
LstP1s=LstP1.getText();
MP1s=MP1.getText();
try {
ifs(Fstnms,Lstnms,Mnames,Cnctnms,Addresss,FstPs,LstPs,MPs,FstP1s,LstP1s,MP1s);
//string values
then inserted in the database sql column titles

row values
that will input from all the txtfields
pst=con.prepareStatement("insert into
student(First_Name,Last_Name,Middle_Name,Contact_No,Address,Sex,Strand,Year,Sem
,First_Namep,Last_Namep,Middle_Namep,First_Namepp,Last_Namepp,Middle_Namepp)
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pst.setString(1, Fstnms);
pst.setString(2, Lstnms);
pst.setString(3, Mnames);
pst.setString(4, Cnctnms);
pst.setString(5, Addresss);
pst.setString(6, Sexs);
pst.setString(7, Strnds);
pst.setString(8, Yrs);
pst.setString(9, Semtxts);
pst.setString(10, FstPs);
pst.setString(11, LstPs);
pst.setString(12, MPs);
pst.setString(13, FstP1s);
pst.setString(14, LstP1s);
pst.setString(15, MP1s);
pst.executeUpdate();
insertData();
display();
clear();
}catch(SQLException e1) {
LoginCon.errorMessage("Wrong Contact Number Details
Please try again", "ERROR");
Cnctnm.setText("");
e1.printStackTrace();
}
//createFile();
//insertData();
//clear();
}

}
});
}
public void insertData() {
line();
try {//to access the txtfile where ever it is located
RandomAccessFile ran = new RandomAccessFile(file,"rw");
int line =0;
for(int i=0;i<=line ;i++) {
ran.readLine();
}
ran.writeBytes(Fstnm.getText()+","+Lstnm.getText()
+","+Mname.getText()+","+Cnctnm.getText()+","+Address.getText()
+","+Sex.getSelectedItem().toString()+","+Strand.getSelectedItem().toString()
+","+Year.getSelectedItem().toString()+","+Semc.getSelectedItem().toString()
+","+FstP.getText()+","+LstP.getText()+","+MP.getText()+","+FstP1.getText()
+","+LstP1.getText()+","+MP1.getText());
ran.writeBytes(System.lineSeparator());
ran.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void clear() {//clear method
Fstnm.setText("");
Lstnm.setText("");
Mname.setText("");
Cnctnm.setText("");
Address.setText("");
FstP.setText("");
LstP.setText("");
MP.setText("");
FstP1.setText("");
LstP1.setText("");
MP1.setText("");
Fstnm.requestFocus();
}
public void line() {//read the line and if the line is null the next value will print
int line = 0;
try {
RandomAccessFile ran = new RandomAccessFile(file,"rw");
while(ran.readLine() !=null) {
line++;
}
ran.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void display() {//get the database value then display it in the table

try {
pst = con.prepareStatement("select * from student");
rs = pst.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(rs));
}catch(SQLException e) {
e.printStackTrace();
}
}public void Logout() {
Logout.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int go = JOptionPane.showConfirmDialog(null,
"Do you want to logout?", "Are you sure?",
JOptionPane.YES_NO_OPTION);

if(go==JOptionPane.YES_OPTION)
{ JOptionPane.showMessageDialog(MP, "Thank You for using the system!");
LoginCon newform = new LoginCon();
newform.main(null);
frame.setVisible(false);
}
}
});
}public void ifs(String a,String b,String c,String d,String e,String f,String g,String
h,String i,String j,String k) {
String
Fstnms,Lstnms,Mnames,Cnctnms,Addresss,Sexs,Strnds,Yrs,Semtxts,FstPs,LstPs,MPs,Fst
P1s,LstP1s,MP1s;
Fstnms=Fstnm.getText();//get all the textfield values then store it in the
string values
Lstnms=Lstnm.getText();
Mnames=Mname.getText();
Cnctnms=Cnctnm.getText();
Addresss=Address.getText();
FstPs=FstP.getText();
LstPs=LstP.getText();
MPs=MP.getText();
FstP1s=FstP1.getText();
LstP1s=LstP1.getText();
MP1s=MP1.getText();
if(Fstnms.equals("")||Lstnms.equals("")||Mnames.equals("")||
Cnctnms.equals("")||Addresss.equals("")||FstPs.equals("")||LstPs.equals("")||
MPs.equals("")||FstP1s.equals("")||LstP1s.equals("")||MP1s.equals("")) {
LoginCon.errorMessage("Empty textfield", "ERROR");
return;
}
JOptionPane.showMessageDialog(MP, "Successfully Added");
}
}

Update Class
package GUIPROJECT;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Update extends Student {

private JFrame frame;


private JTextField fname;
private JTextField Lname;
private JTextField Middlenm;
private JTextField Cntcnm;
private JTextField address;
private JTextField Sx;
private JTextField Strnd;
private JTextField Yr;
private JTextField Sm;
private JTextField Fnamep;
private JTextField Lnamep;
private JTextField Middlep;
private JTextField Fnamep1;
private JTextField Lnamep1;
private JTextField Middlep1;
private JButton btnUpdates,btnNewButton;
private JTextField SID;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Update window = new Update();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public Update() {
initialize();
}

/**
* Initialize the contents of the frame.
*/
public void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(128, 128, 128));
frame.setBounds(100, 100, 748, 439);
frame.getContentPane().setLayout(null);

JLabel lblNewLabel = new JLabel("STUDENT INFORMATION");


lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 20));
lblNewLabel.setBounds(291, 11, 226, 33);
frame.getContentPane().add(lblNewLabel);

JLabel lblFirst = new JLabel("FIRST NAME:");


lblFirst.setToolTipText("");
lblFirst.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst.setForeground(Color.WHITE);
lblFirst.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst.setBounds(20, 86, 91, 20);
frame.getContentPane().add(lblFirst);

fname = new JTextField();


fname.setToolTipText("");
fname.setColumns(10);
fname.setBounds(111, 86, 175, 20);
frame.getContentPane().add(fname);
JLabel lblLastName = new JLabel("LAST NAME:");
lblLastName.setToolTipText("");
lblLastName.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName.setForeground(Color.WHITE);
lblLastName.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName.setBounds(295, 86, 91, 20);
frame.getContentPane().add(lblLastName);

JLabel lblNewLabel_1 = new JLabel("STUDENT");


lblNewLabel_1.setToolTipText("");
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_1.setFont(new Font("Arial", Font.BOLD, 11));
lblNewLabel_1.setBounds(355, 64, 91, 20);
frame.getContentPane().add(lblNewLabel_1);

Lname = new JTextField();


Lname.setToolTipText("");
Lname.setColumns(10);
Lname.setBounds(375, 86, 175, 20);
frame.getContentPane().add(Lname);

JLabel lblM = new JLabel("M.I:");


lblM.setToolTipText("");
lblM.setHorizontalAlignment(SwingConstants.CENTER);
lblM.setForeground(Color.WHITE);
lblM.setFont(new Font("Arial", Font.BOLD, 11));
lblM.setBounds(531, 85, 91, 20);
frame.getContentPane().add(lblM);

Middlenm = new JTextField();


Middlenm.setToolTipText("");
Middlenm.setColumns(10);
Middlenm.setBounds(600, 86, 137, 20);
frame.getContentPane().add(Middlenm);

Cntcnm = new JTextField();


Cntcnm.setToolTipText("");
Cntcnm.setColumns(10);
Cntcnm.setBounds(111, 128, 175, 20);
frame.getContentPane().add(Cntcnm);

JLabel lblContactNo = new JLabel("CONTACT NO:");


lblContactNo.setToolTipText("");
lblContactNo.setHorizontalAlignment(SwingConstants.CENTER);
lblContactNo.setForeground(Color.WHITE);
lblContactNo.setFont(new Font("Arial", Font.BOLD, 11));
lblContactNo.setBounds(17, 128, 91, 20);
frame.getContentPane().add(lblContactNo);
JLabel lblAddress = new JLabel("ADDRESS:");
lblAddress.setToolTipText("");
lblAddress.setHorizontalAlignment(SwingConstants.CENTER);
lblAddress.setForeground(Color.WHITE);
lblAddress.setFont(new Font("Arial", Font.BOLD, 11));
lblAddress.setBounds(302, 123, 91, 20);
frame.getContentPane().add(lblAddress);

address = new JTextField();


address.setToolTipText("");
address.setColumns(10);
address.setBounds(375, 123, 155, 20);
frame.getContentPane().add(address);

JLabel lblSex = new JLabel("SEX:");


lblSex.setToolTipText("");
lblSex.setHorizontalAlignment(SwingConstants.CENTER);
lblSex.setForeground(Color.WHITE);
lblSex.setFont(new Font("Arial", Font.BOLD, 11));
lblSex.setBounds(529, 123, 91, 20);
frame.getContentPane().add(lblSex);

Sx = new JTextField();
Sx.setToolTipText("");
Sx.setColumns(10);
Sx.setBounds(600, 123, 137, 20);
frame.getContentPane().add(Sx);

JLabel Sem = new JLabel("SEM:");


Sem.setToolTipText("");
Sem.setHorizontalAlignment(SwingConstants.CENTER);
Sem.setForeground(Color.WHITE);
Sem.setFont(new Font("Arial", Font.BOLD, 11));
Sem.setBounds(20, 175, 91, 20);
frame.getContentPane().add(Sem);

Strnd = new JTextField();


Strnd.setToolTipText("");
Strnd.setColumns(10);
Strnd.setBounds(218, 174, 71, 20);
frame.getContentPane().add(Strnd);

JLabel lblDepartment = new JLabel("STRAND:");


lblDepartment.setToolTipText("");
lblDepartment.setHorizontalAlignment(SwingConstants.CENTER);
lblDepartment.setForeground(Color.WHITE);
lblDepartment.setFont(new Font("Arial", Font.BOLD, 11));
lblDepartment.setBounds(155, 175, 75, 20);
frame.getContentPane().add(lblDepartment);

Yr = new JTextField();
Yr.setToolTipText("");
Yr.setColumns(10);
Yr.setBounds(378, 173, 71, 20);
frame.getContentPane().add(Yr);

JLabel lblClass = new JLabel("YEAR LEVEL:");


lblClass.setToolTipText("");
lblClass.setHorizontalAlignment(SwingConstants.CENTER);
lblClass.setForeground(Color.WHITE);
lblClass.setFont(new Font("Arial", Font.BOLD, 11));
lblClass.setBounds(294, 173, 91, 20);
frame.getContentPane().add(lblClass);

Sm = new JTextField();
Sm.setToolTipText("");
Sm.setColumns(10);
Sm.setBounds(84, 175, 71, 20);
frame.getContentPane().add(Sm);

JLabel lblFirst_1 = new JLabel("FIRST NAME:");


lblFirst_1.setToolTipText("");
lblFirst_1.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst_1.setForeground(Color.WHITE);
lblFirst_1.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst_1.setBounds(10, 256, 91, 20);
frame.getContentPane().add(lblFirst_1);

Fnamep = new JTextField();


Fnamep.setToolTipText("");
Fnamep.setColumns(10);
Fnamep.setBounds(101, 256, 175, 20);
frame.getContentPane().add(Fnamep);

JLabel lblLastName_1 = new JLabel("LAST NAME:");


lblLastName_1.setToolTipText("");
lblLastName_1.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName_1.setForeground(Color.WHITE);
lblLastName_1.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName_1.setBounds(285, 256, 91, 20);
frame.getContentPane().add(lblLastName_1);

Lnamep = new JTextField();


Lnamep.setToolTipText("");
Lnamep.setColumns(10);
Lnamep.setBounds(365, 256, 175, 20);
frame.getContentPane().add(Lnamep);
JLabel lblParents = new JLabel("PARENTS");
lblParents.setToolTipText("");
lblParents.setHorizontalAlignment(SwingConstants.CENTER);
lblParents.setFont(new Font("Arial", Font.BOLD, 11));
lblParents.setBounds(355, 225, 91, 20);
frame.getContentPane().add(lblParents);

JLabel lblM_1 = new JLabel("M.I:");


lblM_1.setToolTipText("");
lblM_1.setHorizontalAlignment(SwingConstants.CENTER);
lblM_1.setForeground(Color.WHITE);
lblM_1.setFont(new Font("Arial", Font.BOLD, 11));
lblM_1.setBounds(521, 255, 91, 20);
frame.getContentPane().add(lblM_1);

Middlep = new JTextField();


Middlep.setToolTipText("");
Middlep.setColumns(10);
Middlep.setBounds(590, 256, 137, 20);
frame.getContentPane().add(Middlep);

JLabel lblFirst_2 = new JLabel("FIRST NAME:");


lblFirst_2.setToolTipText("");
lblFirst_2.setHorizontalAlignment(SwingConstants.CENTER);
lblFirst_2.setForeground(Color.WHITE);
lblFirst_2.setFont(new Font("Arial", Font.BOLD, 11));
lblFirst_2.setBounds(10, 330, 91, 20);
frame.getContentPane().add(lblFirst_2);

Fnamep1 = new JTextField();


Fnamep1.setToolTipText("");
Fnamep1.setColumns(10);
Fnamep1.setBounds(101, 330, 175, 20);
frame.getContentPane().add(Fnamep1);

JLabel lblLastName_2 = new JLabel("LAST NAME:");


lblLastName_2.setToolTipText("");
lblLastName_2.setHorizontalAlignment(SwingConstants.CENTER);
lblLastName_2.setForeground(Color.WHITE);
lblLastName_2.setFont(new Font("Arial", Font.BOLD, 11));
lblLastName_2.setBounds(285, 330, 91, 20);
frame.getContentPane().add(lblLastName_2);

Lnamep1 = new JTextField();


Lnamep1.setToolTipText("");
Lnamep1.setColumns(10);
Lnamep1.setBounds(365, 330, 175, 20);
frame.getContentPane().add(Lnamep1);
JLabel lblM_2 = new JLabel("M.I:");
lblM_2.setToolTipText("");
lblM_2.setHorizontalAlignment(SwingConstants.CENTER);
lblM_2.setForeground(Color.WHITE);
lblM_2.setFont(new Font("Arial", Font.BOLD, 11));
lblM_2.setBounds(521, 329, 91, 20);
frame.getContentPane().add(lblM_2);

Middlep1 = new JTextField();


Middlep1.setToolTipText("");
Middlep1.setColumns(10);
Middlep1.setBounds(590, 330, 137, 20);
frame.getContentPane().add(Middlep1);

btnNewButton = new JButton("CANCEL");


btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//closes the frame but still run in the background
Update window = new Update();
frame.setVisible(false);
}
});
btnNewButton.setBackground(new Color(255, 128, 64));
btnNewButton.setBounds(494, 378, 91, 23);
frame.getContentPane().add(btnNewButton);

btnUpdates = new JButton("EDIT");


btnUpdates.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {//get all the txtfield
values then store it in the string var
String
Fstnms,Lstnms,Mnames,Cnctnms,Addresss,Sexs,Strnds,Yrs,Semtxts,FstPs,LstPs,MPs,Fst
P1s,LstP1s,MP1s,sid;
Fstnms=fname.getText();
Lstnms=Lname.getText();
Mnames=Middlenm.getText();
Cnctnms=Cntcnm.getText();
Addresss=address.getText();
Sexs=Sx.getText();
Strnds=Strnd.getText();
Yrs=Yr.getText();
Semtxts=Sm.getText();
FstPs=Fnamep.getText();
LstPs=Lnamep.getText();
MPs=Middlep.getText();
FstP1s=Fnamep1.getText();
LstP1s=Lnamep1.getText();
MP1s=Middlep1.getText();
sid=SID.getText();
if(sid.equals("")) {
LoginCon.errorMessage("Empty Search ID texfield!",
"Error");
return;
}
try {//the values of all string var will changes the values of the
specific data
pst = con.prepareStatement("update student set
First_Name= ?,Last_Name=?,Middle_Name=?,Contact_No=?,Address=?,Sex=?,Strand=
?,Year=?,Sem=?,First_Namep=?,Last_Namep=?,Middle_Namep=?,First_Namepp=?,Last
_Namepp=?,Middle_Namepp=? where id =?");
pst.setString(1, Fstnms);
pst.setString(2, Lstnms);
pst.setString(3, Mnames);
pst.setString(4, Cnctnms);
pst.setString(5, Addresss);
pst.setString(6, Sexs);
pst.setString(7, Strnds);
pst.setString(8, Yrs);
pst.setString(9, Semtxts);
pst.setString(10, FstPs);
pst.setString(11, LstPs);
pst.setString(12, MPs);
pst.setString(13, FstP1s);
pst.setString(14, LstP1s);
pst.setString(15, MP1s);
pst.setString(16, sid);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record
Update!");
display();
clear();
SID.setText("");
}
catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "ERROR IN
SQL!");
e1.printStackTrace();
}
}
});
btnUpdates.setBackground(new Color(255, 255, 0));
btnUpdates.setBounds(243, 378, 91, 23);
frame.getContentPane().add(btnUpdates);

JLabel lblNewLabel_2 = new JLabel("Search ID");


lblNewLabel_2.setBounds(20, 382, 61, 14);
frame.getContentPane().add(lblNewLabel_2);
SID = new JTextField();
SID.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
SID.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
try {//get id in the txtfield
String id = SID.getText();
pst = con.prepareStatement("select
First_Name,Last_Name,Middle_Name,Contact_No,Address,Sex,Strand,Year,Sem,First_N
amep,Last_Namep,Middle_Namep,First_Namepp,Last_Namepp,Middle_Namepp from
student where ID = ?");
pst.setString(1, id);
ResultSet rs = pst.executeQuery();

if(rs.next()==true)
{ //if the id is found on the database, the blank
txtfields will be filled
String
Fstnms,Lstnms,Mnames,Cnctnms,Addresss,Sexs,Strnds,Yrs,Semtxts,FstPs,LstPs,MPs,Fst
P1s,LstP1s,MP1s;
Fstnms = rs.getString(1);
Lstnms = rs.getString(2);
Mnames = rs.getString(3);
Cnctnms = rs.getString(4);
Addresss = rs.getString(5);
Sexs = rs.getString(6);
Strnds = rs.getString(7);
Yrs = rs.getString(8);
Semtxts = rs.getString(9);
FstPs = rs.getString(10);
LstPs = rs.getString(11);
MPs = rs.getString(12);
FstP1s = rs.getString(13);
LstP1s = rs.getString(14);
MP1s = rs.getString(15);
fname.setText(Fstnms);
Lname.setText(Lstnms);
Middlenm.setText(Mnames);
Cntcnm.setText(Cnctnms);
address.setText(Addresss);
Sx.setText(Sexs);
Strnd.setText(Strnds);
Yr.setText(Yrs);
Sm.setText(Semtxts);
Fnamep.setText(FstPs);
Lnamep.setText(LstPs);
Middlep.setText(MPs);
Fnamep1.setText(FstP1s);
Lnamep1.setText(LstP1s);
Middlep1.setText(MP1s);
}
else
{
clear();
}
}
catch (SQLException ex) {

}
}
});
}
});
SID.setToolTipText("");
SID.setColumns(10);
SID.setBounds(102, 379, 71, 20);
frame.getContentPane().add(SID);

JButton btnDelete = new JButton("DELETE");


btnDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String sid;
sid = SID.getText();
if(sid.equals("")) {
LoginCon.errorMessage("Empty Search ID texfield!", "Error");
return;
}
try {
int go = JOptionPane.showConfirmDialog(frame,
"Do you want to delete student ID: "+sid+"?",
"Are you sure?",
JOptionPane.YES_NO_OPTION);
if(go==JOptionPane.YES_OPTION) {
pst = con.prepareStatement("delete from student
where id =?");
pst.setString(1, sid);
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "Record Delete!");
display();
clear();
SID.setText("");
}
}

catch (SQLException e1) {


e1.printStackTrace();
}
}
});
btnDelete.setBackground(new Color(255, 0, 0));
btnDelete.setBounds(367, 378, 91, 23);
frame.getContentPane().add(btnDelete);
}public void clear() {
fname.setText("");
Lname.setText("");
Middlenm.setText("");
Cntcnm.setText("");
address.setText("");
Sx.setText("");
Strnd.setText("");
Yr.setText("");
Sm.setText("");
Fnamep.setText("");
Lnamep.setText("");
Middlep.setText("");
Fnamep1.setText("");
Lnamep1.setText("");
Middlep1.setText("");
SID.requestFocus();
}
}
gin

You might also like