School Management System Project Java With Source Code
The School Management System Java Project is developed using Java Programming Language, this School Management System Java is an application developed for schools.
School Management System Project Report In Java is an application developed in Java that is used to store all school-related records.
It stores information related to students, staff, and teachers. The database used is MS Access.
The objective of developing such a system was to reduce the errors that creep in the manual system where it was very difficult to store the records.
A School Management System In Java also provides the facility to calculate the attendance of the student. There are four types of login for this system administrator, student, teacher, and staff login.
This Project is handled by the administrator who has all the rights to edit or modify any school member information.
This School Management System In Java Netbeans was developed to provide a secure, easy-to-use reliable system.
In this Java Code For School Management System was created to handle all the school-related information and save it in records.
This School Management System Project Report In Java also includes a downloadable School Management System In Java Source Code for free, just find the downloadable source code below and click to start downloading.
To start creating a School Management System Java Project, make sure that you have NeatBeans IDE or any platform of Java installed in your computer.
About the School Management System Project In Java
Project Name: | School Management System Project |
Language/s Used: | JAVA |
Database: | None |
Type: | Desktop Application |
Developer: | IT SOURCECODE |
Updates: | 0 |
School Management System Java Project Features
- Student Records Management
- Staff Records Management
- Teacher Record Management
- Admission Form
- Login/Logout System
School Management System Project in Java With Source Code: Steps on how to create the project
Time needed: 5 minutes
These are the steps on how to create a School Management System Java Project With Source Code
- Step 1: Create a project.
First, open the file and then click “project” to create.
- Step 2: Create a project name.
Second, name your project.
- Step 3: Create JFrame.
Third, create a “JFrame” form.
- Step 4: Create a JFrame name.
Fourth, name your JFrame form.
- Step 5: Project Design.
Fifth, The actual design of the project.
The Code Given Below Is For The Log In Module
private void loginButtonActionPerformed(java.awt.event.ActionEvent evt) {
con=Connect.ConnectDB();
String sql= "select * from Users where Username= '" + userNameField.getText() + "' and User_Password ='" + passwordField.getText() + "'";
try
{
pst=con.prepareStatement(sql);
rs= pst.executeQuery();
//(""==usernamField.getText())
if("".equals(userNameField.getText()) && "".equals(passwordField.getText())){
JOptionPane.showMessageDialog(null,"Please Enter Username and Password!");
}
else if (rs.next()){
this.hide();
MainMenu menu=new MainMenu();
menu.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null, "Login Failed..Try again !","Access denied",JOptionPane.ERROR_MESSAGE);
userNameField.setText("");
passwordField.setText("");
userNameField.requestFocus();
}
}
catch(SQLException | HeadlessException e)
{
JOptionPane.showMessageDialog(null, e);
}
}
private void passwordFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void passwordFieldKeyPressed(java.awt.event.KeyEvent evt) {
if(evt.getKeyCode()==KeyEvent.VK_ENTER){
con=Connect.ConnectDB();
String sql= "select * from Users where Username= '" + userNameField.getText() + "' and User_Password ='" + passwordField.getText() + "'";
try
{
pst=con.prepareStatement(sql);
rs= pst.executeQuery();
if("".equals(userNameField.getText()) && "".equals(passwordField.getText())){
JOptionPane.showMessageDialog(null,"Please Enter Username and Password!");
}
else if (rs.next()){
this.hide();
MainMenu menu=new MainMenu();
menu.setVisible(true);
}
else{
JOptionPane.showMessageDialog(null, "Login Failed..Try again !","Access denied",JOptionPane.ERROR_MESSAGE);
userNameField.setText("");
passwordField.setText("");
userNameField.requestFocus();
}
}
catch(SQLException | HeadlessException e)
{
JOptionPane.showMessageDialog(null, e);
}
}
}
private void userNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
In this module which is the login module of the system.
The Code Given Below Is For The Student From Module
package GUI;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author M Azhar Durrani
*/
public class StudentForm extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form StudentForm1
*/
public StudentForm() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
stud = new javax.swing.JSplitPane();
jPanel6 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
firstNameLabel = new javax.swing.JLabel();
firstNameField = new javax.swing.JTextField();
lastNameLabel = new javax.swing.JLabel();
lastNameField = new javax.swing.JTextField();
fatherNameLabel = new javax.swing.JLabel();
fatherNameField = new javax.swing.JTextField();
cnicLabel = new javax.swing.JLabel();
cnicField = new javax.swing.JTextField();
mobileLabel = new javax.swing.JLabel();
mobileField = new javax.swing.JTextField();
addressLabel = new javax.swing.JLabel();
addressField = new javax.swing.JTextField();
genderLabel = new javax.swing.JLabel();
cmbGender = new javax.swing.JComboBox<>();
dobLabel = new javax.swing.JLabel();
dobField = new javax.swing.JTextField();
PhoneLabel1 = new javax.swing.JLabel();
phoneField = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
studentIdField = new javax.swing.JTextField();
studentIdLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
admissionClass = new javax.swing.JTextField();
doaLabel = new javax.swing.JLabel();
doaField = new javax.swing.JTextField();
lastSchoolLabel = new javax.swing.JLabel();
lastSchoolAttendedField = new javax.swing.JTextField();
lastClassLabel = new javax.swing.JLabel();
lastClassAttendedField = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
backButton = new javax.swing.JButton();
newButton = new javax.swing.JButton();
updateButton = new javax.swing.JButton();
saveButton = new javax.swing.JButton();
getDataButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
studentRecord = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Student Form");
stud.setDividerLocation(0);
stud.setAutoscrolls(true);
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 727, Short.MAX_VALUE)
);
stud.setLeftComponent(jPanel6);
jLabel1.setBackground(new java.awt.Color(153, 153, 153));
jLabel1.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(0, 153, 153));
jLabel1.setText(" Student's Details");
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 4));
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
jPanel1.setMaximumSize(new java.awt.Dimension(1366, 720));
jPanel1.setMinimumSize(new java.awt.Dimension(1366, 700));
jPanel1.setPreferredSize(new java.awt.Dimension(1366, 710));
jPanel2.setBackground(new java.awt.Color(102, 102, 102));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Basic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel2.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setBackground(new java.awt.Color(0, 0, 0));
firstNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
firstNameLabel.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setText("First Name:");
firstNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
firstNameField.setToolTipText("Enter First Name here");
firstNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
firstNameFieldActionPerformed(evt);
}
});
firstNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
firstNameFieldKeyTyped(evt);
}
});
lastNameLabel.setBackground(new java.awt.Color(0, 0, 0));
lastNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
lastNameLabel.setForeground(new java.awt.Color(255, 255, 255));
lastNameLabel.setText("Last Name:");
lastNameLabel.setToolTipText("");
lastNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
lastNameField.setToolTipText("Enter Last Name Here");
lastNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lastNameFieldActionPerformed(evt);
}
});
lastNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
lastNameFieldKeyTyped(evt);
}
});
fatherNameLabel.setBackground(new java.awt.Color(0, 0, 0));
fatherNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
fatherNameLabel.setForeground(new java.awt.Color(255, 255, 255));
fatherNameLabel.setText("Father's Name:");
fatherNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
fatherNameField.setToolTipText("Enter Father's Name here");
fatherNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fatherNameFieldActionPerformed(evt);
}
});
fatherNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
fatherNameFieldKeyTyped(evt);
}
});
cnicLabel.setBackground(new java.awt.Color(0, 0, 0));
cnicLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
cnicLabel.setForeground(new java.awt.Color(255, 255, 255));
cnicLabel.setText("Father's CNIC:");
cnicField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cnicField.setToolTipText("Enter Father's CNIC Number");
cnicField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
cnicFieldKeyTyped(evt);
}
});
mobileLabel.setBackground(new java.awt.Color(0, 0, 0));
mobileLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
mobileLabel.setForeground(new java.awt.Color(255, 255, 255));
mobileLabel.setText("Father's Mobile: ");
mobileField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
mobileField.setToolTipText("Enter Father's Mobile Number here");
mobileField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
mobileFieldKeyTyped(evt);
}
});
addressLabel.setBackground(new java.awt.Color(0, 0, 0));
addressLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
addressLabel.setForeground(new java.awt.Color(255, 255, 255));
addressLabel.setText("Address:");
addressField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
addressField.setToolTipText("EnterStudent's Address here");
addressField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addressFieldActionPerformed(evt);
}
});
genderLabel.setBackground(new java.awt.Color(0, 0, 0));
genderLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
genderLabel.setForeground(new java.awt.Color(255, 255, 255));
genderLabel.setText("Gender:");
cmbGender.setBackground(new java.awt.Color(102, 102, 102));
cmbGender.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cmbGender.setForeground(new java.awt.Color(255, 255, 255));
cmbGender.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "Male", "Female" }));
dobLabel.setBackground(new java.awt.Color(0, 0, 0));
dobLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
dobLabel.setForeground(new java.awt.Color(255, 255, 255));
dobLabel.setText("Date of Birth:");
dobField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dobField.setToolTipText("Enter Student's Date of Birth here");
dobField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dobFieldActionPerformed(evt);
}
});
PhoneLabel1.setBackground(new java.awt.Color(0, 0, 0));
PhoneLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
PhoneLabel1.setForeground(new java.awt.Color(255, 255, 255));
PhoneLabel1.setText("Father's Phone:");
phoneField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
phoneField.setToolTipText("Enter Father's Phone Number here");
phoneField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
phoneFieldActionPerformed(evt);
}
});
phoneField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
phoneFieldKeyTyped(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fatherNameLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(firstNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(fatherNameField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(dobLabel)
.addGap(30, 30, 30)
.addComponent(dobField, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mobileLabel)
.addComponent(cnicLabel)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lastNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(cnicField)
.addComponent(mobileField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(addressField)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(PhoneLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(343, 343, 343))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fatherNameLabel)
.addComponent(fatherNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cnicLabel)
.addComponent(cnicField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(mobileLabel)
.addComponent(mobileField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dobLabel)
.addComponent(dobField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(PhoneLabel1)
.addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
jPanel3.setBackground(new java.awt.Color(102, 102, 102));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Academic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel3.setForeground(new java.awt.Color(255, 255, 255));
studentIdField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
studentIdField.setToolTipText("Enter Student ID here");
studentIdField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentIdFieldActionPerformed(evt);
}
});
studentIdField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
studentIdFieldKeyTyped(evt);
}
});
studentIdLabel.setBackground(new java.awt.Color(0, 0, 0));
studentIdLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
studentIdLabel.setForeground(new java.awt.Color(255, 255, 255));
studentIdLabel.setText("Student ID:");
jLabel2.setBackground(new java.awt.Color(0, 0, 0));
jLabel2.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Admission in Class:");
admissionClass.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
doaLabel.setBackground(new java.awt.Color(0, 0, 0));
doaLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
doaLabel.setForeground(new java.awt.Color(255, 255, 255));
doaLabel.setText("Date of Admission:");
doaField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
doaField.setToolTipText("Enter Student's Date of Admission here");
doaField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
doaFieldActionPerformed(evt);
}
});
lastSchoolLabel.setBackground(new java.awt.Color(0, 0, 0));
lastSchoolLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
lastSchoolLabel.setForeground(new java.awt.Color(255, 255, 255));
lastSchoolLabel.setText("Last School Attended:");
lastSchoolAttendedField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
lastSchoolAttendedField.setToolTipText("Enter Last School Name");
lastSchoolAttendedField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lastSchoolAttendedFieldActionPerformed(evt);
}
});
lastClassLabel.setBackground(new java.awt.Color(0, 0, 0));
lastClassLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
lastClassLabel.setForeground(new java.awt.Color(255, 255, 255));
lastClassLabel.setText("Last Class Attended:");
lastClassAttendedField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
lastClassAttendedField.setToolTipText("Enter Last Class Attended");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(studentIdLabel)
.addGap(82, 82, 82))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(lastSchoolLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(studentIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(99, 99, 99)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(admissionClass, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lastSchoolAttendedField))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 111, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(doaLabel)
.addGap(44, 44, 44)
.addComponent(doaField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addComponent(lastClassLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lastClassAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(29, 29, 29))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(3, 3, 3)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(studentIdLabel)
.addComponent(studentIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(admissionClass, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(doaField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(doaLabel)))
.addGap(25, 25, 25)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lastClassAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastClassLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastSchoolLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastSchoolAttendedField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4.setBackground(new java.awt.Color(102, 102, 102));
backButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
backButton.setText("Back");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
newButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
newButton.setText("New");
newButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newButtonActionPerformed(evt);
}
});
updateButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
updateButton.setText("Update");
updateButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
updateButtonActionPerformed(evt);
}
});
saveButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
saveButton.setText("Save");
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
getDataButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
getDataButton.setText("Get Data");
getDataButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
getDataButtonActionPerformed(evt);
}
});
deleteButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
deleteButton.setText("Delete");
deleteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deleteButtonActionPerformed(evt);
}
});
studentRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
studentRecord.setText("Student Record");
studentRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentRecordActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(backButton)
.addGap(18, 18, 18)
.addComponent(newButton)
.addGap(18, 18, 18)
.addComponent(saveButton)
.addGap(18, 18, 18)
.addComponent(updateButton)
.addGap(18, 18, 18)
.addComponent(deleteButton)
.addGap(18, 18, 18)
.addComponent(getDataButton)
.addGap(18, 18, 18)
.addComponent(studentRecord)
.addGap(185, 185, 185))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, studentRecord, updateButton});
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(deleteButton)
.addComponent(getDataButton)
.addComponent(studentRecord)
.addComponent(updateButton)
.addComponent(saveButton)
.addComponent(newButton)
.addComponent(backButton))
.addContainerGap(28, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(72, 72, 72)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(32, 32, 32)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 666, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
stud.setRightComponent(jPanel5);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(stud, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(stud)
);
pack();
}// </editor-fold>
private void firstNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void lastNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void fatherNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void dobFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void phoneFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void studentIdFieldActionPerformed(java.awt.event.ActionEvent evt) {
}
private void doaFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void lastSchoolAttendedFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu menu=new MainMenu();
this.hide();
menu.setVisible(true);
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
firstNameField.setText("");
studentIdField.setText("");
lastNameField.setText("");
lastSchoolAttendedField.setText("");
fatherNameField.setText("");
phoneField.setText("");
mobileField.setText("");
cnicField.setText("");
lastClassAttendedField.setText("");
addressField.setText("");
cmbGender.setSelectedIndex(0);
admissionClass.setText("");
dobField.setText("");
doaField.setText("");
deleteButton.setEnabled(false);
updateButton.setEnabled(false);
studentIdField.requestFocus();
}
private void getDataButtonActionPerformed(java.awt.event.ActionEvent evt) {
this.hide();
StudentRecord record=new StudentRecord();
record.setVisible(true);
}
private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
String sql = "update StudentRecord set FirstName='"+firstNameField.getText()+"',LastName='"+lastNameField.getText()+"',DateOfBirth='"+dobField.getText()+"',FatherName='"+fatherNameField.getText()+"',FatherCNIC='"+cnicField.getText()+"',FatherPhone='"+phoneField.getText()+"',FatherMobile='"+mobileField.getText()+"',Address='"+addressField.getText()+"',DOA='"+doaField.getText()+"',LCA='"+lastClassAttendedField.getText()+"',PSN='"+lastSchoolAttendedField.getText()+"',Gender='"+cmbGender.getSelectedItem()+"',Class='"+ admissionClass.getText()+"'where StudentID='"+studentIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
if("".equals(studentIdField.getText())){
JOptionPane.showMessageDialog(null, "Please select a record to update!");
return;
}
JOptionPane.showMessageDialog(this, "Updated Successfully!","Record",JOptionPane.INFORMATION_MESSAGE);
updateButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
if("".equals(studentIdField.getText())){
JOptionPane.showMessageDialog(null, "Please Enter Student ID", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
Statement st;
st = con.createStatement();
String sql1="select StudentID from StudentRecord where StudentID='"+studentIdField.getText()+"'";
rs = st.executeQuery(sql1);
if(rs.next()){
JOptionPane.showMessageDialog(null, "Student ID already exists", "Error", JOptionPane.ERROR_MESSAGE);
studentIdField.setText("");
studentIdField.requestDefaultFocus();
return;
}
String sql= "insert into StudentRecord(StudentID,FirstName,LastName,DateOfBirth,FatherName,FatherCNIC,FatherPhone,FatherMobile,Address,DOA,LCA,PSN,Gender,Class) values ('"+studentIdField.getText()+"','"+firstNameField.getText()+"','"+lastNameField.getText()+"','"+dobField.getText()+"','"+fatherNameField.getText()+"','"+cnicField.getText()+"','"+phoneField.getText()+"','"+mobileField.getText()+"','"+addressField.getText()+"','"+doaField.getText()+"','"+lastClassAttendedField.getText()+"','"+lastSchoolAttendedField.getText()+"','"+cmbGender.getSelectedItem()+"','"+admissionClass.getText()+"')";
pst = con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Successfully Registered!", "Student", JOptionPane.INFORMATION_MESSAGE);
saveButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
if("".equals(studentIdField.getText())){
JOptionPane.showMessageDialog(null, "Please enter Student ID to delete record!");
return;
}
int d = JOptionPane.showConfirmDialog(this, "Are sure want to delete.?", "Confirmation", JOptionPane.YES_NO_OPTION);
if(d==0){
con = Connect.ConnectDB();
String sql = "delete from StudentRecord where StudentID='"+studentIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE);
reset();
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex);
}
}
private void studentRecordActionPerformed(java.awt.event.ActionEvent evt) {
StudentRecord record = new StudentRecord();
this.hide();
record.setVisible(true);
}
private void cnicFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void mobileFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void studentIdFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void phoneFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void firstNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void fatherNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void lastNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
void reset(){
firstNameField.setText("");
studentIdField.setText("");
lastNameField.setText("");
lastSchoolAttendedField.setText("");
fatherNameField.setText("");
phoneField.setText("");
mobileField.setText("");
cnicField.setText("");
lastClassAttendedField.setText("");
addressField.setText("");
cmbGender.setSelectedIndex(0);
admissionClass.setText("");
dobField.setText("");
doaField.setText("");
deleteButton.setEnabled(false);
updateButton.setEnabled(false);
studentIdField.requestFocus();
}
In this module which is the student form module.
The Code Given Below Is For The Student Record Module
package GUI;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
/**
*
* @author M Azhar Durrani
*/
public class StudentRecord extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form StudentRecord
*/
public StudentRecord() {
initComponents();
con=Connect.ConnectDB();
Get_Data();
setLocationRelativeTo(null);
}
private void Get_Data(){
String sql = "select StudentID as [Student ID], FirstName"+" +"+"LastName as [Full Name], Class as [Class] from StudentRecord";
try{
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
dataTable.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
dataTable = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
teacherRecord = new javax.swing.JButton();
staffRecord = new javax.swing.JButton();
teacherForm = new javax.swing.JButton();
staffForm = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
backButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Student Record");
dataTable.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dataTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8", "Title 9", "Title 10", "Title 11", "Title 12", "Title 13", "Title 14"
}
));
dataTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dataTableMouseClicked(evt);
}
});
jScrollPane1.setViewportView(dataTable);
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
teacherRecord.setText("Teacher Record");
teacherRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherRecordActionPerformed(evt);
}
});
staffRecord.setText("Staff Record");
staffRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffRecordActionPerformed(evt);
}
});
teacherForm.setText("Teacher Form");
teacherForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherFormActionPerformed(evt);
}
});
staffForm.setText("Staff Form");
staffForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffFormActionPerformed(evt);
}
});
jButton11.setText("Logout");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
backButton.setText("Main Menu");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(96, 96, 96)
.addComponent(backButton)
.addGap(18, 18, 18)
.addComponent(teacherRecord)
.addGap(18, 18, 18)
.addComponent(staffRecord)
.addGap(18, 18, 18)
.addComponent(teacherForm)
.addGap(18, 18, 18)
.addComponent(staffForm)
.addGap(18, 18, 18)
.addComponent(jButton11)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, jButton11, staffForm, staffRecord, teacherForm, teacherRecord});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(24, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(teacherForm)
.addComponent(staffForm)
.addComponent(jButton11))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(teacherRecord)
.addComponent(staffRecord)
.addComponent(backButton)))
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1050, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(64, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void dataTableMouseClicked(java.awt.event.MouseEvent evt) {
try{
con = Connect.ConnectDB();
int row = dataTable.getSelectedRow();
String tableClick = dataTable.getModel().getValueAt(row, 0).toString();
String sql = "select * from StudentRecord where StudentID= "+tableClick;
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
if(rs.next()){
this.hide();
StudentForm student=new StudentForm();
student.setVisible(true);
String add1 = rs.getString("StudentID");
student.studentIdField.setText(add1);
String add2 = rs.getString("FirstName");
student.firstNameField.setText(add2);
String add3 = rs.getString("LastName");
student.lastNameField.setText(add3);
String add4 = rs.getString("DateOfBirth");
student.dobField.setText(add4);
String add5 = rs.getString("FatherName");
student.fatherNameField.setText(add5);
String add6 = rs.getString("FatherCNIC");
student.cnicField.setText(add6);
String add7 = rs.getString("FatherPhone");
student.phoneField.setText(add7);
String add8 = rs.getString("FatherMobile");
student.mobileField.setText(add8);
String add9 = rs.getString("Address");
student.addressField.setText(add9);
String add10 = rs.getString("DOA");
student.doaField.setText(add10);
String add11 = rs.getString("LCA");
student.lastClassAttendedField.setText(add11);
String add12 = rs.getString("PSN");
student.lastSchoolAttendedField.setText(add12);
String add13 = rs.getString("Gender");
student.cmbGender.setSelectedItem(add13);
String add14 = rs.getString("Class");
student.admissionClass.setText(add14);
student.updateButton.setEnabled(true);
student.deleteButton.setEnabled(true);
student.saveButton.setEnabled(true);
//student.studentIdField.setEnabled(true);
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
private void teacherRecordActionPerformed(java.awt.event.ActionEvent evt) {
TeacherRecord record=new TeacherRecord();
this.hide();
record.setVisible(true);
}
private void staffRecordActionPerformed(java.awt.event.ActionEvent evt) {
StaffRecord record=new StaffRecord();
this.hide();
record.setVisible(true);
}
private void teacherFormActionPerformed(java.awt.event.ActionEvent evt) {
TeacherForm form=new TeacherForm();
this.hide();
form.setVisible(true);
}
private void staffFormActionPerformed(java.awt.event.ActionEvent evt) {
StaffForm form=new StaffForm();
this.hide();
form.setVisible(true);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
Login login=new Login();
this.hide();
login.setVisible(true);
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
/*StudentForm menu=new StudentForm();
this.hide();
menu.setVisible(true);*/
MainMenu m=new MainMenu();
m.setVisible(true);
this.hide();
}
private void formWindowClosing(java.awt.event.WindowEvent evt) {
this.hide();
StudentForm form = new StudentForm();
form.setVisible(true);
}
In this module which is the student record module .
The Code Given Below Is For The Teacher Form Module
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author M Azhar Durrani
*/
public class TeacherForm extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form TeacherForm1
*/
public TeacherForm() {
initComponents();
}
void reset(){
firstNameField.setText("");
teacherIdField.setText("");
lastNameField.setText("");
salaryField.setText("");
fatherNameField.setText("");
emailAddress.setText("");
mobileField.setText("");
cnicField.setText("");
designationField.setText("");
aqField.setText("");
addressField.setText("");
cmbGender.setSelectedIndex(0);
experienceField.setText("");
dobField.setText("");
deleteButton.setEnabled(false);
updateButton.setEnabled(false);
teacherIdField.requestFocus();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
firstNameLabel = new javax.swing.JLabel();
firstNameField = new javax.swing.JTextField();
lastNameLabel = new javax.swing.JLabel();
lastNameField = new javax.swing.JTextField();
fatherNameLabel = new javax.swing.JLabel();
fatherNameField = new javax.swing.JTextField();
cnicLabel = new javax.swing.JLabel();
cnicField = new javax.swing.JTextField();
mobileLabel = new javax.swing.JLabel();
mobileField = new javax.swing.JTextField();
addressLabel = new javax.swing.JLabel();
addressField = new javax.swing.JTextField();
genderLabel = new javax.swing.JLabel();
cmbGender = new javax.swing.JComboBox<>();
dobLabel = new javax.swing.JLabel();
dobField = new javax.swing.JTextField();
PhoneLabel1 = new javax.swing.JLabel();
emailAddress = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
designationField = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
aqField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
experienceField = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
salaryField = new javax.swing.JTextField();
teacherIdField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
joinningDateField = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
newButton = new javax.swing.JButton();
backButton = new javax.swing.JButton();
saveButton = new javax.swing.JButton();
updateButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
getDataButton = new javax.swing.JButton();
teacherRecord = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Teacher Form");
setMinimumSize(new java.awt.Dimension(1366, 700));
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
jPanel1.setMaximumSize(new java.awt.Dimension(1366, 720));
jPanel1.setMinimumSize(new java.awt.Dimension(1366, 720));
jPanel1.setPreferredSize(new java.awt.Dimension(1666, 720));
jLabel1.setBackground(new java.awt.Color(0, 0, 0));
jLabel1.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText(" Teacher's Details");
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 4));
jPanel2.setBackground(new java.awt.Color(102, 102, 102));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Basic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel2.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setBackground(new java.awt.Color(0, 0, 0));
firstNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
firstNameLabel.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setText("First Name:");
firstNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
firstNameField.setToolTipText("Enter First Name here");
firstNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
firstNameFieldActionPerformed(evt);
}
});
firstNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
firstNameFieldKeyTyped(evt);
}
});
lastNameLabel.setBackground(new java.awt.Color(0, 0, 0));
lastNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
lastNameLabel.setForeground(new java.awt.Color(255, 255, 255));
lastNameLabel.setText("Last Name:");
lastNameLabel.setToolTipText("");
lastNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
lastNameField.setToolTipText("Enter Last Name Here");
lastNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lastNameFieldActionPerformed(evt);
}
});
lastNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
lastNameFieldKeyTyped(evt);
}
});
fatherNameLabel.setBackground(new java.awt.Color(0, 0, 0));
fatherNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
fatherNameLabel.setForeground(new java.awt.Color(255, 255, 255));
fatherNameLabel.setText("Father's Name:");
fatherNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
fatherNameField.setToolTipText("Enter Father's Name here");
fatherNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fatherNameFieldActionPerformed(evt);
}
});
fatherNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
fatherNameFieldKeyTyped(evt);
}
});
cnicLabel.setBackground(new java.awt.Color(0, 0, 0));
cnicLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
cnicLabel.setForeground(new java.awt.Color(255, 255, 255));
cnicLabel.setText("CNIC:");
cnicField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cnicField.setToolTipText("Enter Father's CNIC Number");
cnicField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
cnicFieldKeyTyped(evt);
}
});
mobileLabel.setBackground(new java.awt.Color(0, 0, 0));
mobileLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
mobileLabel.setForeground(new java.awt.Color(255, 255, 255));
mobileLabel.setText("Mobile Number: ");
mobileField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
mobileField.setToolTipText("Enter Father's Mobile Number here");
mobileField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
mobileFieldKeyTyped(evt);
}
});
addressLabel.setBackground(new java.awt.Color(0, 0, 0));
addressLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
addressLabel.setForeground(new java.awt.Color(255, 255, 255));
addressLabel.setText("Address:");
addressField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
addressField.setToolTipText("EnterStudent's Address here");
addressField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addressFieldActionPerformed(evt);
}
});
genderLabel.setBackground(new java.awt.Color(0, 0, 0));
genderLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
genderLabel.setForeground(new java.awt.Color(255, 255, 255));
genderLabel.setText("Gender:");
cmbGender.setBackground(new java.awt.Color(102, 102, 102));
cmbGender.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cmbGender.setForeground(new java.awt.Color(255, 255, 255));
cmbGender.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "Male", "Female" }));
dobLabel.setBackground(new java.awt.Color(0, 0, 0));
dobLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
dobLabel.setForeground(new java.awt.Color(255, 255, 255));
dobLabel.setText("Date of Birth:");
dobField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dobField.setToolTipText("Enter Student's Date of Birth here");
dobField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dobFieldActionPerformed(evt);
}
});
PhoneLabel1.setBackground(new java.awt.Color(0, 0, 0));
PhoneLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
PhoneLabel1.setForeground(new java.awt.Color(255, 255, 255));
PhoneLabel1.setText("Email Address:");
emailAddress.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
emailAddress.setToolTipText("Enter Father's Phone Number here");
emailAddress.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
emailAddressActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fatherNameLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(firstNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(fatherNameField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(dobLabel)
.addGap(30, 30, 30)
.addComponent(dobField, javax.swing.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mobileLabel)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cnicLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lastNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(cnicField)
.addComponent(mobileField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56)
.addComponent(addressField))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 413, Short.MAX_VALUE)
.addComponent(PhoneLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(emailAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(343, 343, 343))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fatherNameLabel)
.addComponent(fatherNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cnicLabel)
.addComponent(cnicField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(mobileLabel)
.addComponent(mobileField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dobLabel)
.addComponent(dobField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(PhoneLabel1)
.addComponent(emailAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(25, Short.MAX_VALUE))
);
jPanel3.setBackground(new java.awt.Color(102, 102, 102));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Education & Experience", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
designationField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
designationField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
designationFieldActionPerformed(evt);
}
});
jLabel10.setBackground(new java.awt.Color(0, 0, 0));
jLabel10.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Designation:");
jLabel11.setBackground(new java.awt.Color(0, 0, 0));
jLabel11.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel11.setForeground(new java.awt.Color(255, 255, 255));
jLabel11.setText("Academic Qualification:");
aqField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
jLabel2.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Experience:");
experienceField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
experienceField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
experienceFieldActionPerformed(evt);
}
});
jLabel12.setBackground(new java.awt.Color(0, 0, 0));
jLabel12.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel12.setForeground(new java.awt.Color(255, 255, 255));
jLabel12.setText("Salary:");
salaryField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
salaryField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
salaryFieldKeyTyped(evt);
}
});
teacherIdField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
teacherIdField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherIdFieldActionPerformed(evt);
}
});
teacherIdField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
teacherIdFieldKeyTyped(evt);
}
});
jLabel3.setBackground(new java.awt.Color(0, 0, 0));
jLabel3.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Teacher ID:");
jLabel4.setBackground(new java.awt.Color(0, 0, 0));
jLabel4.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Joinning Date:");
joinningDateField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
joinningDateField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
joinningDateFieldActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(aqField))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(designationField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(58, 58, 58)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(experienceField, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(salaryField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(teacherIdField)
.addComponent(joinningDateField, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(teacherIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(designationField, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(salaryField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(31, 31, 31)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(aqField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(experienceField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(joinningDateField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(36, Short.MAX_VALUE))
);
jPanel4.setBackground(new java.awt.Color(102, 102, 102));
newButton.setBackground(new java.awt.Color(102, 102, 102));
newButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
newButton.setForeground(new java.awt.Color(255, 255, 255));
newButton.setText("New");
newButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newButtonActionPerformed(evt);
}
});
backButton.setBackground(new java.awt.Color(102, 102, 102));
backButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
backButton.setForeground(new java.awt.Color(255, 255, 255));
backButton.setText("Back");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
saveButton.setBackground(new java.awt.Color(102, 102, 102));
saveButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
saveButton.setForeground(new java.awt.Color(255, 255, 255));
saveButton.setText("Save");
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
updateButton.setBackground(new java.awt.Color(102, 102, 102));
updateButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
updateButton.setForeground(new java.awt.Color(255, 255, 255));
updateButton.setText("Update");
updateButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
updateButtonActionPerformed(evt);
}
});
deleteButton.setBackground(new java.awt.Color(102, 102, 102));
deleteButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
deleteButton.setForeground(new java.awt.Color(255, 255, 255));
deleteButton.setText("Delete");
deleteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deleteButtonActionPerformed(evt);
}
});
getDataButton.setBackground(new java.awt.Color(102, 102, 102));
getDataButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
getDataButton.setForeground(new java.awt.Color(255, 255, 255));
getDataButton.setText("Get Data");
getDataButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
getDataButtonActionPerformed(evt);
}
});
teacherRecord.setBackground(new java.awt.Color(102, 102, 102));
teacherRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
teacherRecord.setForeground(new java.awt.Color(255, 255, 255));
teacherRecord.setText("Teacher Record");
teacherRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherRecordActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(182, 182, 182)
.addComponent(backButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(newButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(updateButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(getDataButton)
.addGap(18, 18, 18)
.addComponent(teacherRecord, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, teacherRecord, updateButton});
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(backButton)
.addComponent(newButton)
.addComponent(saveButton)
.addComponent(updateButton)
.addComponent(deleteButton)
.addComponent(getDataButton)
.addComponent(teacherRecord))
.addContainerGap(50, Short.MAX_VALUE))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, teacherRecord, updateButton});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGap(263, 263, 263))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1337, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(16, 16, 16))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1366, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void firstNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void lastNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void fatherNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void dobFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void emailAddressActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void teacherIdFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
reset();
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu menu=new MainMenu();
this.hide();
menu.setVisible(true);
}
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
if("".equals(teacherIdField.getText())){
JOptionPane.showMessageDialog(null, "Please Enter Teacher ID", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
Statement st;
st = con.createStatement();
String sql1="select TeacherID from TeacherRecord where TeacherID='"+teacherIdField.getText()+"'";
rs = st.executeQuery(sql1);
if(rs.next()){
JOptionPane.showMessageDialog(null, "Teacher ID already exists", "Error", JOptionPane.ERROR_MESSAGE);
teacherIdField.setText("");
teacherIdField.requestDefaultFocus();
return;
}
String sql= "insert into TeacherRecord(TeacherID,FirstName,LastName,FatherName,EmailAddress,ContactNo,CNIC,Salary,Designation,AcademicQualification,Address,Gender,Experience,DateOfBirth,DateOfJoinning)values('"+teacherIdField.getText()+"','"+firstNameField.getText()+"','"+lastNameField.getText()+"','"+fatherNameField.getText()+"','"+emailAddress.getText()+"','"+mobileField.getText()+"','"+cnicField.getText()+"','"+salaryField.getText()+"','"+designationField.getText()+"','"+aqField.getText()+"','"+addressField.getText()+"','"+cmbGender.getSelectedItem()+"','"+dobField.getText()+"','"+experienceField.getText()+"','"+joinningDateField.getText()+"')";
pst = con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Successfully Registered!", "Teacher", JOptionPane.INFORMATION_MESSAGE);
saveButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
String sql = "update TeacherRecord set FirstName='"+firstNameField.getText()+"',LastName='"+lastNameField.getText()+"',FatherName='"+fatherNameField.getText()+"',EmailAddress='"+emailAddress.getText()+"',ContactNo='"+mobileField.getText()+"',CNIC='"+cnicField.getText()+"',Salary='"+salaryField.getText()+"',Designation='"+designationField.getText()+"',AcademicQualification='"+aqField.getText()+"',Address='"+addressField.getText()+"',Gender='"+cmbGender.getSelectedItem()+"',Experience='"+experienceField.getText()+"',DateOfBirth='"+ dobField.getText()+"',DateOfJoinning='"+joinningDateField.getText()+"'where TeacherID='"+teacherIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
if("".equals(teacherIdField.getText())){
JOptionPane.showMessageDialog(null, "Please select a record to update!");
return;
}
JOptionPane.showMessageDialog(this, "Updated Successfully!","Record",JOptionPane.INFORMATION_MESSAGE);
updateButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
if("".equals(teacherIdField.getText())){
JOptionPane.showMessageDialog(null, "Please enter Teacher ID to delete record!");
return;
}
int d = JOptionPane.showConfirmDialog(this, "Are sure want to delete.?", "Confirmation", JOptionPane.YES_NO_OPTION);
if(d==0){
con = Connect.ConnectDB();
String sql = "delete from TeacherRecord where TeacherID='"+teacherIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE);
reset();
}
}
catch(Exception ex){
}
}
private void getDataButtonActionPerformed(java.awt.event.ActionEvent evt) {
this.hide();
TeacherRecord teacher=new TeacherRecord();
teacher.setVisible(true);
}
private void experienceFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void designationFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void joinningDateFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void salaryFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void mobileFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void cnicFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9' || input=='-') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void firstNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void fatherNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void lastNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void teacherRecordActionPerformed(java.awt.event.ActionEvent evt) {
TeacherRecord record=new TeacherRecord();
this.hide();
record.setVisible(true);
}
private void teacherIdFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "ID can not contain any letters Please enter digits!");
}
}
In this module which is the teacher form module.
The Code Given Below Is For The Teacher Record Module
package GUI;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
/**
*
* @author M Azhar Durrani
*/
public class TeacherRecord extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form TeacherRecord
*/
public TeacherRecord() {
initComponents();
con=Connect.ConnectDB();
Get_Data();
setLocationRelativeTo(null);
}
private void Get_Data(){
String sql = "select TeacherID as [Teacher ID], FirstName as [First Name], LastName as [Last Name], FatherName as [Father Name], EmailAddress as [Email Address], ContactNo as [Contact Number], CNIC as [CNIC], Salary as [Salary], Designation as [Designation], AcademicQualification as [Academic Qualification], Address as [Address], Gender as [Gender] from TeacherRecord";
try{
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
dataTableTeacher.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
dataTableTeacher = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
backButton = new javax.swing.JButton();
staffRecord = new javax.swing.JButton();
teacherForm = new javax.swing.JButton();
staffForm = new javax.swing.JButton();
studentRecord = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Teacher Record");
dataTableTeacher.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dataTableTeacher.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8", "Title 9", "Title 10", "Title 11", "Title 12"
}
));
dataTableTeacher.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dataTableTeacherMouseClicked(evt);
}
});
jScrollPane1.setViewportView(dataTableTeacher);
backButton.setText("Main Menu");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
staffRecord.setText("Staff Record");
staffRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffRecordActionPerformed(evt);
}
});
teacherForm.setText("Teacher Form");
teacherForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherFormActionPerformed(evt);
}
});
staffForm.setText("Staff Form");
staffForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffFormActionPerformed(evt);
}
});
studentRecord.setText("Student Record");
studentRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentRecordActionPerformed(evt);
}
});
jButton11.setText("Logout");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(backButton)
.addGap(18, 18, 18)
.addComponent(staffRecord)
.addGap(18, 18, 18)
.addComponent(teacherForm)
.addGap(18, 18, 18)
.addComponent(staffForm)
.addGap(18, 18, 18)
.addComponent(studentRecord)
.addGap(18, 18, 18)
.addComponent(jButton11)
.addGap(41, 41, 41))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, jButton11, staffForm, staffRecord, studentRecord, teacherForm});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(teacherForm)
.addComponent(staffForm)
.addComponent(studentRecord)
.addComponent(jButton11))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(staffRecord)
.addComponent(backButton)))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {backButton, jButton11, staffForm, staffRecord, studentRecord, teacherForm});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1400, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(138, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void dataTableTeacherMouseClicked(java.awt.event.MouseEvent evt) {
try{
con = Connect.ConnectDB();
int row = dataTableTeacher.getSelectedRow();
String tableClick = dataTableTeacher.getModel().getValueAt(row, 0).toString();
String sql = "select * from TeacherRecord where TeacherID='"+tableClick+"'";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
if(rs.next()){
this.hide();
TeacherForm teacher=new TeacherForm();
teacher.setVisible(true);
String add1 = rs.getString("TeacherID");
teacher.teacherIdField.setText(add1);
String add2 = rs.getString("FirstName");
teacher.firstNameField.setText(add2);
String add3 = rs.getString("LastName");
teacher.lastNameField.setText(add3);
String add4 = rs.getString("FatherName");
teacher.fatherNameField.setText(add4);
String add5 = rs.getString("EmailAddress");
teacher.emailAddress.setText(add5);
String add6 = rs.getString("ContactNo");
teacher.mobileField.setText(add6);
String add7 = rs.getString("CNIC");
teacher.cnicField.setText(add7);
String add8 = rs.getString("Salary");
teacher.salaryField.setText(add8);
String add9 = rs.getString("Designation");
teacher.designationField.setText(add9);
String add10 = rs.getString("AcademicQualification");
teacher.aqField.setText(add10);
String add11 = rs.getString("Address");
teacher.addressField.setText(add11);
String add12 = rs.getString("Gender");
teacher.cmbGender.setSelectedItem(add12);
String add14 = rs.getString("Experience");
teacher.experienceField.setText(add14);
String add13 = rs.getString("DateOfJoinning");
teacher.joinningDateField.setText(add13);
teacher.updateButton.setEnabled(true);
teacher.deleteButton.setEnabled(true);
teacher.saveButton.setEnabled(false);
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu m =new MainMenu();
m.setVisible(true);
this.hide();
}
private void staffRecordActionPerformed(java.awt.event.ActionEvent evt) {
StaffRecord record=new StaffRecord();
this.hide();
record.setVisible(true);
}
private void teacherFormActionPerformed(java.awt.event.ActionEvent evt) {
TeacherForm form=new TeacherForm();
this.hide();
form.setVisible(true);
}
private void staffFormActionPerformed(java.awt.event.ActionEvent evt) {
StaffForm form=new StaffForm();
this.hide();
form.setVisible(true);
}
private void studentRecordActionPerformed(java.awt.event.ActionEvent evt) {
StudentRecord record = new StudentRecord();
this.hide();
record.setVisible(true);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
Login login=new Login();
this.hide();
login.setVisible(true);
}
In this module which is the teacher record module.
The Code Given Below Is For The Staff Form Module
package GUI;
/**
*
* @author M Azhar Durrani
*/
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
public class StaffForm extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form StaffForm1
*/
public StaffForm() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
firstNameLabel = new javax.swing.JLabel();
firstNameField = new javax.swing.JTextField();
lastNameLabel = new javax.swing.JLabel();
lastNameField = new javax.swing.JTextField();
fatherNameLabel = new javax.swing.JLabel();
fatherNameField = new javax.swing.JTextField();
cnicLabel = new javax.swing.JLabel();
cnicField = new javax.swing.JTextField();
mobileLabel = new javax.swing.JLabel();
mobileField = new javax.swing.JTextField();
addressLabel = new javax.swing.JLabel();
addressField = new javax.swing.JTextField();
genderLabel = new javax.swing.JLabel();
cmbGender = new javax.swing.JComboBox<>();
dobLabel = new javax.swing.JLabel();
dobField = new javax.swing.JTextField();
PhoneLabel1 = new javax.swing.JLabel();
emailAddressField = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
designationField = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
aqField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
experienceField = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
salaryField = new javax.swing.JTextField();
staffIdField = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
dojField = new javax.swing.JTextField();
jPanel4 = new javax.swing.JPanel();
newButton = new javax.swing.JButton();
backButton = new javax.swing.JButton();
saveButton = new javax.swing.JButton();
updateButton = new javax.swing.JButton();
deleteButton = new javax.swing.JButton();
getDataButton = new javax.swing.JButton();
staffRecord = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Staff Form");
setBackground(new java.awt.Color(102, 102, 102));
setMinimumSize(new java.awt.Dimension(1366, 730));
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
jPanel1.setMaximumSize(new java.awt.Dimension(1366, 740));
jPanel1.setMinimumSize(new java.awt.Dimension(1366, 700));
jPanel1.setName("Staff Details"); // NOI18N
jLabel1.setBackground(new java.awt.Color(0, 0, 0));
jLabel1.setFont(new java.awt.Font("Dialog", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText(" Staff's Details");
jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 4));
jPanel2.setBackground(new java.awt.Color(102, 102, 102));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(""), "Basic Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
jPanel2.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setBackground(new java.awt.Color(0, 0, 0));
firstNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
firstNameLabel.setForeground(new java.awt.Color(255, 255, 255));
firstNameLabel.setText("First Name:");
firstNameField.setBackground(new java.awt.Color(255, 255, 255));
firstNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
firstNameField.setForeground(new java.awt.Color(0, 0, 0));
firstNameField.setToolTipText("Enter First Name here");
firstNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
firstNameFieldActionPerformed(evt);
}
});
firstNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
firstNameFieldKeyTyped(evt);
}
});
lastNameLabel.setBackground(new java.awt.Color(0, 0, 0));
lastNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
lastNameLabel.setForeground(new java.awt.Color(255, 255, 255));
lastNameLabel.setText("Last Name:");
lastNameLabel.setToolTipText("");
lastNameField.setBackground(new java.awt.Color(255, 255, 255));
lastNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
lastNameField.setForeground(new java.awt.Color(0, 0, 0));
lastNameField.setToolTipText("Enter Last Name Here");
lastNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
lastNameFieldActionPerformed(evt);
}
});
lastNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
lastNameFieldKeyTyped(evt);
}
});
fatherNameLabel.setBackground(new java.awt.Color(0, 0, 0));
fatherNameLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
fatherNameLabel.setForeground(new java.awt.Color(255, 255, 255));
fatherNameLabel.setText("Father's Name:");
fatherNameField.setBackground(new java.awt.Color(255, 255, 255));
fatherNameField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
fatherNameField.setForeground(new java.awt.Color(0, 0, 0));
fatherNameField.setToolTipText("Enter Father's Name here");
fatherNameField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fatherNameFieldActionPerformed(evt);
}
});
fatherNameField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
fatherNameFieldKeyTyped(evt);
}
});
cnicLabel.setBackground(new java.awt.Color(0, 0, 0));
cnicLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
cnicLabel.setForeground(new java.awt.Color(255, 255, 255));
cnicLabel.setText("CNIC Number:");
cnicField.setBackground(new java.awt.Color(255, 255, 255));
cnicField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cnicField.setForeground(new java.awt.Color(0, 0, 0));
cnicField.setToolTipText("Enter Father's CNIC Number");
cnicField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
cnicFieldKeyTyped(evt);
}
});
mobileLabel.setBackground(new java.awt.Color(0, 0, 0));
mobileLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
mobileLabel.setForeground(new java.awt.Color(255, 255, 255));
mobileLabel.setText("Mobile Number: ");
mobileField.setBackground(new java.awt.Color(255, 255, 255));
mobileField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
mobileField.setForeground(new java.awt.Color(0, 0, 0));
mobileField.setToolTipText("Enter Father's Mobile Number here");
mobileField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
mobileFieldKeyTyped(evt);
}
});
addressLabel.setBackground(new java.awt.Color(0, 0, 0));
addressLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
addressLabel.setForeground(new java.awt.Color(255, 255, 255));
addressLabel.setText("Address:");
addressField.setBackground(new java.awt.Color(255, 255, 255));
addressField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
addressField.setForeground(new java.awt.Color(0, 0, 0));
addressField.setToolTipText("EnterStudent's Address here");
addressField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addressFieldActionPerformed(evt);
}
});
genderLabel.setBackground(new java.awt.Color(0, 0, 0));
genderLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
genderLabel.setForeground(new java.awt.Color(255, 255, 255));
genderLabel.setText("Gender:");
cmbGender.setBackground(new java.awt.Color(102, 102, 102));
cmbGender.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
cmbGender.setForeground(new java.awt.Color(255, 255, 255));
cmbGender.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "Male", "Female" }));
dobLabel.setBackground(new java.awt.Color(0, 0, 0));
dobLabel.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
dobLabel.setForeground(new java.awt.Color(255, 255, 255));
dobLabel.setText("Date of Birth:");
dobField.setBackground(new java.awt.Color(255, 255, 255));
dobField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dobField.setForeground(new java.awt.Color(0, 0, 0));
dobField.setToolTipText("Enter Student's Date of Birth here");
dobField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dobFieldActionPerformed(evt);
}
});
PhoneLabel1.setBackground(new java.awt.Color(0, 0, 0));
PhoneLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
PhoneLabel1.setForeground(new java.awt.Color(255, 255, 255));
PhoneLabel1.setText("Email Address:");
emailAddressField.setBackground(new java.awt.Color(255, 255, 255));
emailAddressField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
emailAddressField.setForeground(new java.awt.Color(0, 0, 0));
emailAddressField.setToolTipText("Enter Father's Phone Number here");
emailAddressField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
emailAddressFieldActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(fatherNameLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(firstNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(fatherNameField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(dobLabel)
.addGap(30, 30, 30)
.addComponent(dobField)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mobileLabel)
.addComponent(cnicLabel)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(lastNameField, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(cnicField)
.addComponent(mobileField)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(4, 4, 4)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(addressField)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(PhoneLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(emailAddressField, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addGap(343, 343, 343))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(firstNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(firstNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lastNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(fatherNameLabel)
.addComponent(fatherNameField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cnicLabel)
.addComponent(cnicField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(mobileLabel)
.addComponent(mobileField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dobLabel)
.addComponent(dobField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(addressLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(addressField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(genderLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbGender, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(PhoneLabel1)
.addComponent(emailAddressField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(25, Short.MAX_VALUE))))
);
jPanel3.setBackground(new java.awt.Color(102, 102, 102));
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Other Info", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18), new java.awt.Color(255, 255, 255))); // NOI18N
designationField.setBackground(new java.awt.Color(255, 255, 255));
designationField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
designationField.setForeground(new java.awt.Color(0, 0, 0));
jLabel10.setBackground(new java.awt.Color(0, 0, 0));
jLabel10.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Designation:");
jLabel11.setBackground(new java.awt.Color(0, 0, 0));
jLabel11.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel11.setForeground(new java.awt.Color(255, 255, 255));
jLabel11.setText("Academic Qualification:");
aqField.setBackground(new java.awt.Color(255, 255, 255));
aqField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
aqField.setForeground(new java.awt.Color(0, 0, 0));
jLabel2.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("Experience:");
experienceField.setBackground(new java.awt.Color(255, 255, 255));
experienceField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
experienceField.setForeground(new java.awt.Color(0, 0, 0));
jLabel12.setBackground(new java.awt.Color(0, 0, 0));
jLabel12.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel12.setForeground(new java.awt.Color(255, 255, 255));
jLabel12.setText("Salary:");
salaryField.setBackground(new java.awt.Color(255, 255, 255));
salaryField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
salaryField.setForeground(new java.awt.Color(0, 0, 0));
salaryField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
salaryFieldActionPerformed(evt);
}
});
salaryField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
salaryFieldKeyPressed(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
salaryFieldKeyTyped(evt);
}
});
staffIdField.setBackground(new java.awt.Color(255, 255, 255));
staffIdField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
staffIdField.setForeground(new java.awt.Color(0, 0, 0));
staffIdField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffIdFieldActionPerformed(evt);
}
});
staffIdField.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
staffIdFieldKeyTyped(evt);
}
});
jLabel3.setBackground(new java.awt.Color(0, 0, 0));
jLabel3.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Staff ID:");
jLabel4.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Date of joining:");
dojField.setBackground(new java.awt.Color(255, 255, 255));
dojField.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
dojField.setForeground(new java.awt.Color(0, 0, 0));
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(aqField))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(designationField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(96, 96, 96)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(experienceField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(salaryField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(staffIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dojField, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(staffIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(designationField, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(salaryField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(aqField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(experienceField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(33, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(dojField, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24))))
);
jPanel4.setBackground(new java.awt.Color(102, 102, 102));
newButton.setBackground(new java.awt.Color(0, 0, 0));
newButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
newButton.setForeground(new java.awt.Color(255, 255, 255));
newButton.setText("New");
newButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newButtonActionPerformed(evt);
}
});
backButton.setBackground(new java.awt.Color(0, 0, 0));
backButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
backButton.setForeground(new java.awt.Color(255, 255, 255));
backButton.setText("Back");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
saveButton.setBackground(new java.awt.Color(0, 0, 0));
saveButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
saveButton.setForeground(new java.awt.Color(255, 255, 255));
saveButton.setText("Save");
saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveButtonActionPerformed(evt);
}
});
updateButton.setBackground(new java.awt.Color(0, 0, 0));
updateButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
updateButton.setForeground(new java.awt.Color(255, 255, 255));
updateButton.setText("Update");
updateButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
updateButtonActionPerformed(evt);
}
});
deleteButton.setBackground(new java.awt.Color(0, 0, 0));
deleteButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
deleteButton.setForeground(new java.awt.Color(255, 255, 255));
deleteButton.setText("Delete");
deleteButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
deleteButtonActionPerformed(evt);
}
});
getDataButton.setBackground(new java.awt.Color(0, 0, 0));
getDataButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
getDataButton.setForeground(new java.awt.Color(255, 255, 255));
getDataButton.setText("Get Data");
getDataButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
getDataButtonActionPerformed(evt);
}
});
staffRecord.setBackground(new java.awt.Color(0, 0, 0));
staffRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
staffRecord.setForeground(new java.awt.Color(255, 255, 255));
staffRecord.setText("Staff Record");
staffRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffRecordActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(218, 218, 218)
.addComponent(backButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(newButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(saveButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(updateButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(deleteButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(getDataButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(staffRecord)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, staffRecord, updateButton});
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(staffRecord)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(backButton)
.addComponent(newButton)
.addComponent(saveButton)
.addComponent(updateButton)
.addComponent(deleteButton)
.addComponent(getDataButton)))
.addContainerGap(42, Short.MAX_VALUE))
);
jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {backButton, deleteButton, getDataButton, newButton, saveButton, updateButton});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void firstNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void lastNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void fatherNameFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void dobFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void emailAddressFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {
reset();
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu menu=new MainMenu();
this.hide();
menu.setVisible(true);
}
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
if("".equals(staffIdField.getText())){
JOptionPane.showMessageDialog(null, "Please Enter Staff ID", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
Statement st;
st = con.createStatement();
String sql1="select StaffID from StaffRecord where StaffID='"+staffIdField.getText()+"'";
rs = st.executeQuery(sql1);
if(rs.next()){
JOptionPane.showMessageDialog(null, "Staff ID already exists", "Error", JOptionPane.ERROR_MESSAGE);
staffIdField.setText("");
staffIdField.requestDefaultFocus();
return;
}
String sql= "insert into StaffRecord(StaffID,FirstName,LastName,FatherName,EmailAddress,ContactNo,CNIC,Salary,Designation,AcademicQualification,Address,Gender,Experience,DateOfBirth,DateOfJoinning) values ('"+staffIdField.getText()+"','"+firstNameField.getText()+"','"+lastNameField.getText()+"','"+fatherNameField.getText()+"','"+emailAddressField.getText()+"','"+mobileField.getText()+"','"+cnicField.getText()+"','"+salaryField.getText()+"','"+designationField.getText()+"','"+aqField.getText()+"','"+addressField.getText()+"','"+cmbGender.getSelectedItem()+"','"+experienceField.getText()+"','"+dobField.getText()+"','"+dojField.getText()+"')";
pst = con.prepareStatement(sql);
pst.execute();
JOptionPane.showMessageDialog(null, "Successfully Registered!", "Staff", JOptionPane.INFORMATION_MESSAGE);
saveButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
void reset(){
firstNameField.setText("");
staffIdField.setText("");
lastNameField.setText("");
salaryField.setText("");
fatherNameField.setText("");
emailAddressField.setText("");
mobileField.setText("");
cnicField.setText("");
designationField.setText("");
aqField.setText("");
addressField.setText("");
cmbGender.setSelectedIndex(0);
experienceField.setText("");
dobField.setText("");
dojField.setText("");
deleteButton.setEnabled(false);
updateButton.setEnabled(false);
staffIdField.requestFocus();
}
private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
con = Connect.ConnectDB();
String sql = "update StaffRecord set FirstName='"+firstNameField.getText()+"',LastName='"+lastNameField.getText()+"',FatherName='"+fatherNameField.getText()+"',EmailAddress='"+emailAddressField.getText()+"',ContactNo='"+mobileField.getText()+"',CNIC='"+cnicField.getText()+"',Salary='"+salaryField.getText()+"',Designation='"+designationField.getText()+"',AcademicQualification='"+aqField.getText()+"',Address='"+addressField.getText()+"',Gender='"+cmbGender.getSelectedItem()+"',Experience='"+experienceField.getText()+"',DateOfBirth='"+ dobField.getText()+"',DateOfJoinning='"+dojField.getText()+"'where StaffID='"+staffIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
if("".equals(staffIdField.getText())){
JOptionPane.showMessageDialog(null, "Please Select a record to update");
return;
}
JOptionPane.showMessageDialog(this, "Updated Successfully!","Record",JOptionPane.INFORMATION_MESSAGE);
updateButton.setEnabled(false);
}
catch(HeadlessException | SQLException ex){
JOptionPane.showMessageDialog(this,ex);
}
}
private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {
try{
if("".equals(staffIdField.getText())){
JOptionPane.showMessageDialog(null, "Please enter Staff ID to delete record!");
return;
}
int d = JOptionPane.showConfirmDialog(this, "Are sure want to delete.?", "Confirmation", JOptionPane.YES_NO_OPTION);
if(d==0){
con = Connect.ConnectDB();
String sql = "delete from StaffRecord where StaffID='"+staffIdField.getText()+"'";
pst = con.prepareStatement(sql);
pst.execute();
if("".equals(staffIdField.getText())){
JOptionPane.showMessageDialog(null, "Please select a record to delete!");
return;
}
JOptionPane.showMessageDialog(this,"Successfully deleted","Record",JOptionPane.INFORMATION_MESSAGE);
reset();
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(this, ex);
}
}
private void getDataButtonActionPerformed(java.awt.event.ActionEvent evt) {
this.hide();
StaffRecord staff=new StaffRecord();
staff.setVisible(true);
}
private void staffIdFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void salaryFieldKeyPressed(java.awt.event.KeyEvent evt) {
}
private void salaryFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void salaryFieldActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void staffRecordActionPerformed(java.awt.event.ActionEvent evt) {
StaffRecord record=new StaffRecord();
this.hide();
record.setVisible(true);
}
private void cnicFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void mobileFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Please enter digits!");
}
}
private void staffIdFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if((input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "ID can not be accepted in Letters Please enter digits!");
}
}
private void firstNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void fatherNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
private void lastNameFieldKeyTyped(java.awt.event.KeyEvent evt) {
char input = evt.getKeyChar();
if(!(input<'0' || input>'9') && input!='\b'){
evt.consume();
JOptionPane.showMessageDialog(this, "Name does not contain any numbers!");
}
}
In this module which is the staff form module.
The Code Given Below Is For The Staff Record Module
package GUI;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
/**
*
* @author M Azhar Durrani
*/
public class StaffRecord extends javax.swing.JFrame {
Connection con=null;
ResultSet rs=null;
PreparedStatement pst=null;
/**
* Creates new form StaffRecord
*/
public StaffRecord() {
initComponents();
con=Connect.ConnectDB();
Get_Data();
setLocationRelativeTo(null);
}
private void Get_Data(){
String sql = "select StaffID as [StaffID], FirstName+LastName as [Full Name], EmailAddress as [Email Address], Designation as [Designation],DateOfJoinning as [Date Of Joinning], Experience as [Experience] from StaffRecord";
try{
pst=con.prepareStatement(sql);
rs=pst.executeQuery();
dataTable.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jButton11 = new javax.swing.JButton();
studentRecord = new javax.swing.JButton();
staffForm = new javax.swing.JButton();
teacherForm = new javax.swing.JButton();
teacherRecord = new javax.swing.JButton();
backButton = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
dataTable = new javax.swing.JTable();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Staff Record");
jButton11.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
jButton11.setText("Logout");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
studentRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
studentRecord.setText("Student Record");
studentRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentRecordActionPerformed(evt);
}
});
staffForm.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
staffForm.setText("Staff Form");
staffForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
staffFormActionPerformed(evt);
}
});
teacherForm.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
teacherForm.setText("Teacher Form");
teacherForm.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherFormActionPerformed(evt);
}
});
teacherRecord.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
teacherRecord.setText("Teacher Record");
teacherRecord.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
teacherRecordActionPerformed(evt);
}
});
backButton.setFont(new java.awt.Font("Dialog", 1, 12)); // NOI18N
backButton.setText("Main Menu");
backButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
backButtonActionPerformed(evt);
}
});
dataTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4", "Title 5", "Title 6", "Title 7", "Title 8", "Title 9", "Title 10", "Title 11", "Title 12"
}
));
dataTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
dataTableMouseClicked(evt);
}
});
jScrollPane1.setViewportView(dataTable);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(backButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(teacherRecord)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(teacherForm)
.addGap(18, 18, 18)
.addComponent(staffForm)
.addGap(18, 18, 18)
.addComponent(studentRecord)
.addGap(18, 18, 18)
.addComponent(jButton11)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {backButton, jButton11, staffForm, studentRecord, teacherForm, teacherRecord});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(24, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(teacherForm)
.addComponent(staffForm)
.addComponent(studentRecord)
.addComponent(jButton11)
.addComponent(teacherRecord)
.addComponent(backButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(6, 6, 6))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(39, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void dataTableMouseClicked(java.awt.event.MouseEvent evt) {
try{
con = Connect.ConnectDB();
int row = dataTable.getSelectedRow();
String table_Clicked = dataTable.getModel().getValueAt(row, 0).toString();
String sql = "select * from StaffRecord where StaffID='"+table_Clicked+"'";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
if(rs.next()){
this.hide();
StaffForm staff=new StaffForm();
staff.setVisible(true);
String add = rs.getString("StaffID");
staff.staffIdField.setText(add);
String add1 = rs.getString("FirstName");
staff.firstNameField.setText(add1);
String add2 = rs.getString("LastName");
staff.lastNameField.setText(add2);
String add3 = rs.getString("FatherName");
staff.fatherNameField.setText(add3);
String add4 = rs.getString("EmailAddress");
staff.emailAddressField.setText(add4);
String add5 = rs.getString("ContactNo");
staff.mobileField.setText(add5);
String add6 = rs.getString("CNIC");
staff.cnicField.setText(add6);
String add7 = rs.getString("Salary");
staff.salaryField.setText(add7);
String add8 = rs.getString("Designation");
staff.designationField.setText(add8);
String add9 = rs.getString("AcademicQualification");
staff.aqField.setText(add9);
String add10 = rs.getString("Address");
staff.addressField.setText(add10);
String add11 = rs.getString("Gender");
staff.cmbGender.setSelectedItem(add11);
String add12 = rs.getString("Experience");
staff.experienceField.setText(add12);
String add13 = rs.getString("DateOfBirth");
staff.dobField.setText(add13);
String add14 = rs.getString("DateOfJoinning");
staff.dojField.setText(add14);
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
Login login=new Login();
this.hide();
login.setVisible(true);
}
private void studentRecordActionPerformed(java.awt.event.ActionEvent evt) {
StudentRecord record = new StudentRecord();
this.hide();
record.setVisible(true);
}
private void staffFormActionPerformed(java.awt.event.ActionEvent evt) {
StaffForm form=new StaffForm();
this.hide();
form.setVisible(true);
}
private void teacherFormActionPerformed(java.awt.event.ActionEvent evt) {
TeacherForm form=new TeacherForm();
this.hide();
form.setVisible(true);
}
private void teacherRecordActionPerformed(java.awt.event.ActionEvent evt) {
TeacherRecord record=new TeacherRecord();
this.hide();
record.setVisible(true);
}
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
MainMenu m=new MainMenu();
this.hide();
m.setVisible(true);
}
In this module which is the staff record module.
Downloadable Source Code Below
Anyway, if you want to level up your programming knowledge, especially Java, try this new article I’ve made for you Best Java Projects With Source Code For Beginners Free Download.
Summary
The Chat Program In Java With Source Code is built fully in Java and MySQL Database. It has full-featured Graphical User Interface (GUI) with all the functionalities.
This Article is the way to enhance and develop our skills and logic ideas which is important in practicing the Java programming language which is most well known and most usable programming language in many company.
Related article below
- Load data from MySQL database to Combo box Using Java
- Update Data using MySQL Database and Java with Netbeans IDE
- Join Two String Value using MySQL CONCAT Function in Java
- How to convert text to speech in Java Tutorial using Netbeans IDE
- How to Load data from Mysql Database to Table Element Using Java
Inquiries
If you have any questions or suggestions about School Management System Java Project With Source Code, please feel free to leave a comment below.