Professional Documents
Culture Documents
Project XI
Project XI
/**
*
* @author prithvijay
*/
import java.awt.HeadlessException;
import java.sql.*;
import javax.swing.JOptionPane;
public class Login extends javax.swing.JFrame {
/**
* Creates new form Login
*/
/**
* 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(51, 43, 166));
jPanel1.setName(""); // NOI18N
username.setToolTipText("Username");
username.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
usernameActionPerformed(evt);
}
});
login.setText("Login");
login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginActionPerformed(evt);
}
});
password.setToolTipText("Password");
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 111,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE,
344, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE,
344, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 344,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(221, 221, 221)
.addComponent(jLabel2)))
.addContainerGap(20, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(87, 87, 87)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 49,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(56, 56, 56)
.addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(183, 183, 183)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(36, 36, 36)
.addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 41,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
pack();
}// </editor-fold>
try{
stmt = conn.createStatement();
String user = username.getText();
String pass = password.getText();
rs = stmt.executeQuery(query);
if(rs.next())
{
setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}
else
{
if(user.equals("") && pass.equals(""))
JOptionPane.showMessageDialog(null,"Please Enter Your Details");
else if(user.equals(""))
JOptionPane.showMessageDialog(null,"Username Field cannot be Empty!");
else if(pass.equals(""))
JOptionPane.showMessageDialog(null,"Password Field cannot be Empty!");
else
JOptionPane.showMessageDialog(null,"Username or Password is Invalid");
}
}
catch(HeadlessException | SQLException e)
{
JOptionPane.showMessageDialog(null,e);
}
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
/**
*
* @author jhuma
*/
public class HomePage extends javax.swing.JFrame {
/**
* 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);
setResizable(false);
setSize(new java.awt.Dimension(1920, 1080));
studentRecords.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
studentRecordsActionPerformed(evt);
}
});
addStd.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addStdActionPerformed(evt);
}
});
logout1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
logout1ActionPerformed(evt);
}
});
/**
* @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 fe
* 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.SEV
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HomePage.class.getName()).log(java.util.logging.Level.SEV
null, ex);
}
//</editor-fold>
OUTPUT SCREEN:
3.Show All Student Records
CODE:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to chang
license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this te
*/
/**
*
* @author jhuma
*/
import java.sql.*;
import javax.swing.JOptionPane;
import java.util.*;
import javax.swing.RowFilter;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import net.proteanit.sql.DbUtils;
/**
* Creates new form StudentRecords
*/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public StudentRecords() {
super("Student");
initComponents();
conn = jdbcDriver.createConnection();
showRecords();
myinitComponenets();
/**
* 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() {
jMenu1.setText("File");
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
search.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchActionPerformed(evt);
}
});
search.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyReleased(java.awt.event.KeyEvent evt) {
searchKeyReleased(evt);
}
public void keyTyped(java.awt.event.KeyEvent evt) {
searchKeyTyped(evt);
}
});
records.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}
},
new String [] {
"ID", "First Name", "Class", "Stream", "Section", "Roll No", "DOB(dd/mm/yy)", "Pa
Name", "Parent's Email", "Phone"
}
){
Class[] types = new Class [] {
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Objec
java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,
java.lang.Object.class, java.lang.String.class
};
boolean[] canEdit = new boolean [] {
true, true, true, true, true, true, true, true, false, true
};
pack();
}// </editor-fold>
setVisible(false);
HomePage hp = new HomePage();
hp.setVisible(true);
}
/**
* @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 fe
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/p
*/
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(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StudentRecords.class.getName()).log(java.util.logging.Lev
null, ex);
}
//</editor-fold>
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to chang
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this te
*/
/**
*
* @author jhuma
*/
import java.sql.*;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import java.util.*;
import javax.swing.ComboBoxEditor;
import javax.swing.JComboBox;
import static oracle.sql.NUMBER.e;
public class AddRecord extends javax.swing.JFrame {
/**
* Creates new form AddRecord
*/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
public AddRecord() {
super("Add");
initComponents();
conn = jdbcDriver.createConnection();
}
/**
* 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);
name.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nameActionPerformed(evt);
}
});
jLabel2.setText("Class");
jLabel3.setText("Name");
jLabel4.setText("Section");
jLabel5.setText("Stream");
jLabel6.setText("Parent Name");
jLabel7.setText("Date of Birth");
pName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pNameActionPerformed(evt);
}
});
pEmail.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pEmailActionPerformed(evt);
}
});
jLabel8.setText("Phone Number");
jLabel9.setText("Parent's Email");
phone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
phoneActionPerformed(evt);
}
});
addR.setText("Add Record");
addR.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addRActionPerformed(evt);
}
});
searchByID.setText("Search By ID");
searchByID.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchByIDActionPerformed(evt);
}
});
searchBar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
searchBarActionPerformed(evt);
}
});
oldGrade.setName("");
oldGrade.setText("N/A");
oldGrade.setEditable(false);
oldGrade.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldGradeActionPerformed(evt);
}
});
oldStr.setText("N/A");
oldStr.setEditable(false);
oldStr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldStrActionPerformed(evt);
}
});
oldSec.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oldSecActionPerformed(evt);
}
});
update1.setText("Delete Record");
update1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
update1ActionPerformed(evt);
}
});
oldGrade.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>
}
private void phoneActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
stmt = conn.createStatement();
String id = (String)searchBar.getText();
String qr = "SELECT * FROM STUDENT_DATA WHERE ID ='"+id+"'";
rs = stmt.executeQuery(qr);
if(rs.next())
{
name.setText(rs.getString("NAME"));
oldGrade.setText(rs.getString("CLASS"));
oldGrade.setEditable(false);
oldStr.setText(rs.getString("STREAM"));
oldStr.setEditable(false);
String d = rs.getString("DOB");
java.util.Date date_Birth = new SimpleDateFormat("dd-MM-yyyy").parse(d);
Dob.setDate(date_Birth);
pName.setText(rs.getString("PARENT_NAME"));
pEmail.setText(rs.getString("PARENTTEMAIL"));
phone.setText(rs.getString("PHONENO"));
}
else
JOptionPane.showMessageDialog(null,"Invalid ID");
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,e);
}
/**
* @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 fe
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/p
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalled
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddRecord.class.getName()).log(java.util.logging.L
}
//</editor-fold>