Professional Documents
Culture Documents
Table of contents
LoginPage.java 2
HomePage.java 6
AddingStudentDetails.java 12
UpdateStudentDetails.java 20
DeleteStudentDetails.java 29
DisplayStudentDetails.java 37
AddInstrumentInformation.java 44
UpdateInstrumentInformation.java 51
DeleteInsrumentInformation.java 58
DisplayInstrumentDetails.java 65
1
LoginPage.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class LoginPage extends javax.swing.JFrame {
/**
* Creates new form LoginPage
*/
public LoginPage() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
2
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jPasswordField1ActionPerformed(evt);
}
});
jPanel1.add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(337,
288, 250, -1));
jButton1.setText("Login");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
3
}
});
jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(337, 318, -1,
-1));
jButton2.setText("Close");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(487, 318, -1,
-1));
jLabel4.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/record-e-drums-960x6
00-1.png"))); // NOI18N
jLabel4.setText("jLabel4");
jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(-10, 0, 760,
560));
pack();
}// </editor-fold>
4
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if (jTextField1.getText().equals("Maadhav") &&
jPasswordField1.getText().equals("admin"))
{
setVisible(false);
new HomePage().setVisible(true);
}
else
JOptionPane.showMessageDialog(null, "Incorrect username or password");
// TODO {}add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
5
java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginPage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
}
//</editor-fold>
HomePage.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
/**
*
* @author maadhavsood
*/
public class HomePage extends javax.swing.JFrame {
6
/**
* Creates new form HomePage
*/
public HomePage() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(0, 61, 104));
7
});
jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 110,
270, 43));
8
}
});
jPanel1.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 419,
270, 47));
jButton9.setText("Log out");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jPanel1.add(jButton9, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 613,
270, 49));
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/466996.png"))); //
NOI18N
jLabel2.setText("jLabel2");
jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 680,
690));
9
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>
10
new LoginPage().setVisible(true);
} // TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
11
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.S
EVERE, null, ex);
}
//</editor-fold>
AddingStudentDetails.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
12
*/
package cs.ia.maadhavsood;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class AddingStudentDetails extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form AddingStudentDetails
*/
public AddingStudentDetails() {
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() {
13
jLabel12 = new javax.swing.JLabel();
canvas1 = new java.awt.Canvas();
jButton3 = new javax.swing.JButton();
Update = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
14
jPanel2.add(jTextField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 111,
190, -1));
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});
jPanel2.add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 193,
190, -1));
jTextField5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField5ActionPerformed(evt);
}
});
jPanel2.add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 234,
190, -1));
jTextField6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField6ActionPerformed(evt);
}
});
jPanel2.add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 272,
190, -1));
15
jButton3.setText("Return to home page");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 320,
230, 70));
jLabel11.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/2022_math_reading_i
mage.jpeg"))); // NOI18N
jLabel11.setText("jLabel11");
jPanel2.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
16
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
pack();
}// </editor-fold>
if (contactnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Contact number can only contain digits");
}
else if (identnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Identification number can only contain
digits");
}
}
else {
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "Insert into student values
('"+firstname+"','"+lastname+"','"+identnum+"','"+contactnum+"','"+address+"','"+school+"')";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully Added!");
setVisible(false);
17
new AddingStudentDetails().setVisible(true);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
setVisible(false);
new HomePage().setVisible(true);
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
18
java.util.logging.Logger.getLogger(AddingStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddingStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddingStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddingStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>
19
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
// End of variables declaration
}
UpdateStudentDetails.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import java.sql.ResultSet;
/**
*
* @author maadhavsood
*/
public class UpdateStudentDetails extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form UpdateStudentDetails
*/
public UpdateStudentDetails() {
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() {
20
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel8 = new javax.swing.JLabel();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
canvas1 = new java.awt.Canvas();
jButton3 = new javax.swing.JButton();
Update = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
21
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});
jTextField5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField5ActionPerformed(evt);
}
});
jTextField6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField6ActionPerformed(evt);
}
});
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
22
jLabel9.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/2022_math_reading_i
mage.jpeg"))); // NOI18N
jLabel9.setText("jLabel9");
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(60, 60, 60)
.addComponent(Update, javax.swing.GroupLayout.PREFERRED_SIZE, 170,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel12))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel6))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(570, 570, 570)
.addComponent(jButton1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel3))
.addComponent(jLabel4)
.addGroup(jPanel2Layout.createSequentialGroup()
23
.addGap(62, 62, 62)
.addComponent(jLabel1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel2))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel7))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(340, 340, 340)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE,
230, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(347, 347, 347)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
190, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel8))
.addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 673,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 169,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(272, 272, 272)
.addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(340, 340, 340)
.addComponent(Update, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(234, 234, 234)
.addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(70, 70, 70)
24
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(275, 275, 275)
.addComponent(jLabel12))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(155, 155, 155)
.addComponent(jLabel6))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(150, 150, 150)
.addComponent(jButton1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(111, 111, 111)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(114, 114, 114)
.addComponent(jLabel3))
.addComponent(jLabel4)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jLabel2))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(196, 196, 196)
.addComponent(jLabel7))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(152, 152, 152)
.addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(340, 340, 340)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(193, 193, 193)
.addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(237, 237, 237)
.addComponent(jLabel8))
.addComponent(jLabel9)
.addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(19, 19, 19)
25
.addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 58,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
setVisible(false);
new HomePage().setVisible(true);
}
26
if (firstname.length()<=0 || identnum.length()<=0 || lastname.length()<=0 ||
contactnum.length()<=0 || address.length()<=0 || school.length()<=0 ||
contactnum.length()!=10){
JOptionPane.showMessageDialog(null,"Please fill in all the fields");
if (contactnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Contact number can only contain digits");
}
else if (identnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Identification number can only contain
digits");
}
}
else {
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "Insert into student values
('"+firstname+"','"+lastname+"','"+identnum+"','"+contactnum+"','"+address+"','"+school+"')";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully Added!");
setVisible(false);
new AddingStudentDetails().setVisible(true);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
while(rs.next()){
String firstname=rs.getString("firstname");
String lastname=rs.getString("lastname");
String contactnum=rs.getString("contactnum");
String address=rs.getString("address");
String school=rs.getString("school");
27
jTextField1.setText(firstname);
jTextField2.setText(lastname);
jTextField4.setText(contactnum);
jTextField5.setText(address);
jTextField6.setText(school);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UpdateStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UpdateStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UpdateStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UpdateStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
28
}
//</editor-fold>
DeleteStudentDetails.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
29
import static cs.ia.maadhavsood.UpdateStudentDetails.DB_URL;
import static cs.ia.maadhavsood.UpdateStudentDetails.PASS;
import static cs.ia.maadhavsood.UpdateStudentDetails.USER;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class DeleteStudentDetails extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form DeleteStudentDetails
*/
public DeleteStudentDetails() {
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() {
30
jTextField6 = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
canvas1 = new java.awt.Canvas();
jButton3 = new javax.swing.JButton();
Update = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
31
jPanel2.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(62, 196, -1,
-1));
jPanel2.add(jTextField3, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 152,
190, -1));
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});
jPanel2.add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 193,
190, -1));
jTextField5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField5ActionPerformed(evt);
}
});
jPanel2.add(jTextField5, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 234,
190, -1));
jTextField6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField6ActionPerformed(evt);
}
});
jPanel2.add(jTextField6, new org.netbeans.lib.awtextra.AbsoluteConstraints(347, 272,
190, -1));
32
});
jPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(307, 320,
230, 70));
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel2.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 150, -1,
-1));
jLabel9.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/2022_math_reading_i
mage.jpeg"))); // NOI18N
jLabel9.setText("jLabel9");
jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 670, -1));
33
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
34
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "delete from student where identification='"+identnum+"'";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully deleted!");
setVisible(false);
new DeleteStudentDetails().setVisible(true);
} catch (SQLException e) {
e.printStackTrace();
} // TODO add your handling code here:
}
String identnum=jTextField3.getText();
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "select firstname,lastname,contactnum,address,school from
student where identification='"+identnum+"'";
ResultSet rs= stmt.executeQuery(sql);
while(rs.next()){
String firstname=rs.getString("firstname");
String lastname=rs.getString("lastname");
String contactnum=rs.getString("contactnum");
String address=rs.getString("address");
String school=rs.getString("school");
jTextField1.setText(firstname);
jTextField2.setText(lastname);
jTextField4.setText(contactnum);
jTextField5.setText(address);
jTextField6.setText(school);
} catch (SQLException e) {
e.printStackTrace();
}
// TODO add your handling code here:
}
/**
* @param args the command line arguments
35
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DeleteStudentDetails.class.getName()).log(java.util.loggin
g.Level.SEVERE, null, ex);
}
//</editor-fold>
36
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
private javax.swing.JTextField jTextField5;
private javax.swing.JTextField jTextField6;
// End of variables declaration
}
DisplayStudentDetails.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import javax.swing.JOptionPane;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
import java.sql.ResultSet;
import javax.swing.JFileChooser;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
37
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
/**
*
* @author maadhavsood
*/
public class DisplayStudentDetails extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form DisplayStudentDetails
*/
public DisplayStudentDetails() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTable1.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},
38
{null, null, null, null, null, null}
},
new String [] {
"First Name", "Last Name", "Identificaton Number", "Contact Number", "Address",
"School"
}
){
Class[] types = new Class [] {
java.lang.String.class, java.lang.String.class, java.lang.Integer.class,
java.lang.Integer.class, java.lang.String.class, java.lang.String.class
};
39
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(62, 62, 62)
.addComponent(jLabel1))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
1158, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(383, 383, 383)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 215,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 230,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(41, 41, 41)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 230,
javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G, false)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 70,
Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
40
);
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>
setVisible(false);
new HomePage().setVisible(true);
// TODO add your handling code here:
}
String tbData[]={firstname,lastname,identification,contactnum,address,school,};
DefaultTableModel tblModel= (DefaultTableModel)jTable1.getModel();
tblModel.addRow(tbData);
} catch (SQLException e) {
e.printStackTrace();
}
}
41
String path="";
JFileChooser j=new JFileChooser();
j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int x=j.showSaveDialog(this);
{
path=j.getSelectedFile().getPath();
}
Document doc=new Document();
try
{
PdfWriter.getInstance(doc, new FileOutputStream(path+"InformationOfStudent.pdf"));
doc.open();
PdfPTable tb1=new PdfPTable(5);
tb1.addCell("First Name");
tb1.addCell("Last Name");
tb1.addCell("Identification");
tb1.addCell("Contact Number");
tb1.addCell("Address");
tb1.addCell("School");
for(int i=0;i<jTable1.getRowCount();i++)
{
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,"PDF was not generated");
}
doc.close();
}
/**
42
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DisplayStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DisplayStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DisplayStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DisplayStudentDetails.class.getName()).log(java.util.loggi
ng.Level.SEVERE, null, ex);
}
//</editor-fold>
43
private javax.swing.JButton jButton5;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}
AddInstrumentInformation.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class AddInstrumentInformation extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form AddInstrumentInformation
*/
public AddInstrumentInformation() {
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() {
44
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
canvas1 = new java.awt.Canvas();
jLabel14 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
Add = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
45
jLabel9.setForeground(new java.awt.Color(242, 242, 242));
jLabel9.setText("Teacher Name");
jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 173, -1,
-1));
jTextField7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField7ActionPerformed(evt);
}
});
jPanel2.add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 130,
190, -1));
jTextField8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField8ActionPerformed(evt);
}
});
jPanel2.add(jTextField8, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 170,
190, -1));
jTextField9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField9ActionPerformed(evt);
}
});
jPanel2.add(jTextField9, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 210,
190, -1));
jPanel2.add(canvas1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
46
jButton3.setText("Return to home page");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 310,
230, 70));
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/drums.jpg"))); //
NOI18N
jLabel2.setText("jLabel2");
jPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
47
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 405,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
setVisible(false);
new HomePage().setVisible(true);
}
48
if (identnum.length()<=0 || gradeint.length()<=0 || teacher.length()<=0 ||
instrument.length()<=0 || typeofstudent.length()<=0 )
JOptionPane.showMessageDialog(null,"Please fill in all the fields");
if(identnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Contact number can only contain digits");
}
else if (gradeint.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Identification number can only contain
digits");
}
else {
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "Insert into instrument values
('"+identnum+"','"+gradeint+"','"+teacher+"','"+instrument+"','"+typeofstudent+"')";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully updated!");
} catch (SQLException e) {
e.printStackTrace();
}
}// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
49
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddInstrumentInformation.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddInstrumentInformation.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddInstrumentInformation.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddInstrumentInformation.class.getName()).log(java.util.l
ogging.Level.SEVERE, null, ex);
}
//</editor-fold>
50
private javax.swing.JTextField jTextField9;
// End of variables declaration
}
UpdateInstrumentInformation.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class UpdateInstrumentInformation extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form UpdateInstrumentInformation
*/
public UpdateInstrumentInformation() {
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() {
51
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
jTextField7 = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
jTextField8 = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jTextField9 = new javax.swing.JTextField();
canvas1 = new java.awt.Canvas();
jLabel14 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
Update = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField7.addActionListener(new java.awt.event.ActionListener() {
52
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField7ActionPerformed(evt);
}
});
jPanel2.add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 130,
190, -1));
jTextField8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField8ActionPerformed(evt);
}
});
jPanel2.add(jTextField8, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 170,
190, -1));
jTextField9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField9ActionPerformed(evt);
}
});
jPanel2.add(jTextField9, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 210,
190, -1));
jPanel2.add(canvas1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
53
jPanel2.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 310,
230, 70));
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel2.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 90, -1,
-1));
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/drums.jpg"))); //
NOI18N
jLabel2.setText("jLabel2");
jPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
54
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
while(rs.next()){
String gradeofinst=rs.getString("gradeofinst");
String teachername=rs.getString("teachername");
String instrument=rs.getString("instrument");
String typestudent=rs.getString("typestudent");
jTextField7.setText(gradeofinst);
jTextField8.setText(teachername);
jTextField9.setText(instrument);
jComboBox1.setSelectedItem(typestudent);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
String identnum=jTextField3.getText();
String gradeint=jTextField7.getText();
String teacher=jTextField8.getText();
String instrument=jTextField9.getText();
55
String typeofstudent=(String)jComboBox1.getSelectedItem();
if (identnum.length()<=0 || gradeint.length()<=0 || teacher.length()<=0 ||
instrument.length()<=0 || typeofstudent.length()<=0 )
JOptionPane.showMessageDialog(null,"Please fill in all the fields");
if(identnum.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Contact number can only contain digits");
}
else if (gradeint.matches("[a-z]+")){
JOptionPane.showMessageDialog(null,"Identification number can only contain
digits");
}
else {
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "Update instrument set
gradeofinst='"+gradeint+"',teachername='"+teacher+"',instrument='"+instrument+"',typestude
nt='"+typeofstudent+"' where identification='"+identnum+"'";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully updated!");
} catch (SQLException e) {
e.printStackTrace();
}
}
}
setVisible(false);
new HomePage().setVisible(true);
}
/**
* @param args the command line arguments
56
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UpdateInstrumentInformation.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UpdateInstrumentInformation.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UpdateInstrumentInformation.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UpdateInstrumentInformation.class.getName()).log(java.u
til.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
57
private javax.swing.JButton jButton3;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration
}
DeleteInstrumentInformation.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
/**
*
* @author maadhavsood
*/
public class DeleteInstrumentInformation extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form DeleteInstrumentInformation
*/
58
public DeleteInstrumentInformation() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
59
jLabel5.setForeground(new java.awt.Color(242, 242, 242));
jPanel2.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
jTextField7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField7ActionPerformed(evt);
}
});
jPanel2.add(jTextField7, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 130,
190, -1));
jTextField8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField8ActionPerformed(evt);
}
});
jPanel2.add(jTextField8, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 170,
190, -1));
jTextField9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField9ActionPerformed(evt);
}
});
jPanel2.add(jTextField9, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 210,
190, -1));
60
jPanel2.add(canvas1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
jButton1.setText("Search");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
61
});
jPanel2.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 90, -1,
-1));
jLabel2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/cs/ia/maadhavsood/drums.jpg"))); //
NOI18N
jLabel2.setText("jLabel2");
jPanel2.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));
pack();
}// </editor-fold>
setVisible(false);
new HomePage().setVisible(true);
}
62
String identification=jTextField3.getText();
String gradeofint=jTextField7.getText();
String teachername=jTextField8.getText();
String instrument=jTextField9.getText();
String typestudent=(String)jComboBox1.getSelectedItem();
try(Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
){
String sql = "delete from instrument where identification='"+identification+"'";
stmt.executeUpdate(sql);
JOptionPane.showMessageDialog(null,"Successfully updated!");
} catch (SQLException e) {
e.printStackTrace();
}
}
while(rs.next()){
String gradeofinst=rs.getString("gradeofinst");
String teachername=rs.getString("teachername");
String instrument=rs.getString("instrument");
String typestudent=rs.getString("typestudent");
jTextField7.setText(gradeofinst);
jTextField8.setText(teachername);
jTextField9.setText(instrument);
jComboBox1.setSelectedItem(typestudent);
}
} catch (SQLException e) {
e.printStackTrace();
}
63
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DeleteInstrumentInformation.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DeleteInstrumentInformation.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DeleteInstrumentInformation.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DeleteInstrumentInformation.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
64
// Variables declaration - do not modify
private javax.swing.JButton Update;
private java.awt.Canvas canvas1;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField7;
private javax.swing.JTextField jTextField8;
private javax.swing.JTextField jTextField9;
// End of variables declaration
}
DisplayInstrumentDetails.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change
this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this
template
*/
package cs.ia.maadhavsood;
import javax.swing.JOptionPane;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
import java.sql.ResultSet;
import javax.swing.JFileChooser;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
65
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
/**
*
* @author maadhavsood
*/
public class DisplayInstrumentDetails extends javax.swing.JFrame {
static final String DB_URL = "jdbc:mysql://localhost/sarva";
static final String USER = "root";
static final String PASS = "root@123";
/**
* Creates new form DisplayInstrumentDetails
*/
public DisplayInstrumentDetails() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
66
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null},
{null, null, null, null, null}
},
new String [] {
"Identificaton Number", "Grade of Instrument", "Teachers Name", "Instrument ",
"Type of Student"
}
){
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.Integer.class, java.lang.String.class,
java.lang.String.class, java.lang.String.class
};
67
}
});
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN
G)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(62, 62, 62)
.addComponent(jLabel1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
1158, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 230,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 230,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 230,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(76, 76, 76))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1)
.addGap(33, 33, 33)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI
NE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE)
68
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 70,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}// </editor-fold>
setVisible(false);
new HomePage().setVisible(true);
// TODO add your handling code here:
}
69
String sql = "select identification, gradeofinst, teachername, instrument, typestudent
from instrument";
ResultSet rs= stmt.executeQuery(sql);
while(rs.next()){
String identification=rs.getString("identification");
String gradeofinst=rs.getString("gradeofinst");
String teachername=rs.getString("teachername");
String instrument=rs.getString("instrument");
String typestudent=rs.getString("typestudent");
String tbData[]={identification,gradeofinst,teachername,instrument,typestudent};
DefaultTableModel tblModel= (DefaultTableModel)jTable1.getModel();
tblModel.addRow(tbData);
} catch (SQLException e) {
e.printStackTrace();
}
}
for(int i=0;i<jTable1.getRowCount();i++)
{
70
String I=jTable1.getValueAt(i, 3).toString();
String TS=jTable1.getValueAt(i, 4).toString();
tb1.addCell(IN);
tb1.addCell(GI);
tb1.addCell(TN);
tb1.addCell(I);
tb1.addCell(TS);
}
doc.add(tb1);
JOptionPane.showMessageDialog(null,"PDF has been generated");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(null,"PDF was not generated");
}
doc.close();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and
feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DisplayInstrumentDetails.class.getName()).log(java.util.lo
gging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DisplayInstrumentDetails.class.getName()).log(java.util.lo
gging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
71
java.util.logging.Logger.getLogger(DisplayInstrumentDetails.class.getName()).log(java.util.lo
gging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DisplayInstrumentDetails.class.getName()).log(java.util.lo
gging.Level.SEVERE, null, ex);
}
//</editor-fold>
72