NEW FRAME 2
Transcript of NEW FRAME 2
NEW FRAME 2
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.*;
import javax.swing.JOptionPane;
/**
*
* @author puchu
*/
public class NewJFrame2 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame2
*/
public NewJFrame2() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jTextField4 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(450, 450));
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(51, 0, 51));
jLabel1.setText("ADD CUSTOMER ");
getContentPane().add(jLabel1);
jLabel1.setBounds(100, 10, 310, 33);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
getContentPane().add(jTextField1);
jTextField1.setBounds(200, 110, 134, 30);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
getContentPane().add(jTextField2);
jTextField2.setBounds(200, 150, 134, 30);
getContentPane().add(jTextField3);
jTextField3.setBounds(200, 190, 134, 30);
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});
getContentPane().add(jTextField4);
jTextField4.setBounds(200, 230, 134, 30);
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(210, 280, 100, 40);
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel2.setText("NAME :");
getContentPane().add(jLabel2);
jLabel2.setBounds(20, 110, 120, 22);
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel3.setText("PHONE NO :");
getContentPane().add(jLabel3);
jLabel3.setBounds(20, 150, 150, 22);
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel4.setText("ADDRESS :");
getContentPane().add(jLabel4);
jLabel4.setBounds(20, 190, 140, 22);
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel5.setText("SECURITY DEPOSIT :");
getContentPane().add(jLabel5);
jLabel5.setBounds(20, 200, 190, 80);
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.jpg"))); // NOI18N
jLabel6.setLabelFor(this);
jLabel6.setMinimumSize(new java.awt.Dimension(300, 250));
getContentPane().add(jLabel6);
jLabel6.setBounds(150, 50, 560, 300);
jButton2.setText("BACK");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(10, 50, 110, 40);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
customer c =new customer();
c.c_name=jTextField1.getText();
c.phone_no=Long.parseLong(jTextField2.getText());
c.c_add =jTextField3.getText();
c.Sec_amt= Integer.parseInt(jTextField4.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
stmt.executeUpdate("insert into customer(c_name,c_address,security_amount,phone_no) values('"+c.c_name+"','"+c.c_add+"','"+c.Sec_amt+"','"+c.phone_no+"');");
JOptionPane.showMessageDialog(null,"Inserted Successfully!");
stmt.close();
}
catch(Exception e)
{
System.out.println("error");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(this , "Invalid input");
}
}
private void jTextField2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextField4ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
// TODO add your handling code here:
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// 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(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame2.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 NewJFrame2().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
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.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
// End of variables declaration
}
NEW FRAME 3
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
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;
/**
*
* @author puchu
*/
public class NewJFrame3 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame3
*/
public NewJFrame3() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jButton3 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jTextField2 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton2 = new javax.swing.JButton();
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images (1).jpg"))); // NOI18N
jLabel3.setText("jLabel3");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(new java.awt.Rectangle(0, 0, 0, 0));
setMinimumSize(new java.awt.Dimension(450, 450));
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("BLACKLIST CUSTOMERS ");
getContentPane().add(jLabel1);
jLabel1.setBounds(0, 10, 452, 39);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/imageiuos.jpg"))); // NOI18N
getContentPane().add(jLabel4);
jLabel4.setBounds(290, 80, 550, 400);
jButton1.setText("BACK");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(20, 60, 90, 30);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
getContentPane().add(jTextField1);
jTextField1.setBounds(120, 100, 170, 30);
jButton3.setText("CHECK");
jButton3.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(210, 180, 80, 30);
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel5.setText("PHONE NO:");
getContentPane().add(jLabel5);
jLabel5.setBounds(20, 90, 100, 40);
jButton4.setText("ADD");
jButton4.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4);
jButton4.setBounds(20, 180, 80, 30);
getContentPane().add(jTextField2);
jTextField2.setBounds(120, 140, 170, 30);
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel6.setText("REASON:");
getContentPane().add(jLabel6);
jLabel6.setBounds(20, 140, 100, 30);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane2.setViewportView(jTextArea1);
getContentPane().add(jScrollPane2);
jScrollPane2.setBounds(20, 220, 260, 160);
jButton2.setText("UNDO");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(120, 180, 80, 30);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
customer c=new customer();
c.phone_no = Long.parseLong(jTextField1.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select c.c_id,c.c_name,c.phone_no,b.reason from customer c,blacklist_customerb where b.c_id=c.c_id AND c.phone_no='"+c.phone_no+"';");
if(rs.next()== false){ jTextArea1.setText("Not a blacklisted customer");}
rs.first();
//Retrieve by column name
c.c_id=rs.getInt("c.c_id");
c.c_name = rs.getString("c.c_name");
c.phone_no=Long.parseLong( rs.getString("c.phone_no"));
c.b_reason = rs.getString("b.reason");
jTextArea1.setText("Id:"+c.c_id+"\nName:"+c.c_name+"\nPhoneno:"+c.phone_no+"\nReason:"+c.b_reason+"");
//JOptionPane.showMessageDialog(null,"Id:"+c_id+"\nName:"+name+"\nPhone no:"+phone+"\n");
//Display values
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
// JOptionPane.showMessageDialog(null,"We Are Done");
// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
try{
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
customer c = new customer();
c.phone_no= Long.parseLong(jTextField1.getText());
c.b_reason= jTextField2.getText();
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select c.c_id from customer c where c.phone_no='"+c.phone_no+"';");
rs.first();
c.c_id = rs.getInt("c.c_id");
stmt1.executeUpdate("insert into blacklist_customer(c_id,reason)values('"+c.c_id+"','"+c.b_reason+"');");
jTextArea1.setText("Successfully added to blacklist");
//JOptionPane.showMessageDialog(null,"Success");
rs.close();
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
//JOptionPane.showMessageDialog(null,"We Are Done");
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
customer c =new customer();
c.phone_no= Long.parseLong(jTextField1.getText());
// final String reason= jTextField2.getText();
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select c.c_id from customer c where c.phone_no='"+c.phone_no+"';");
rs.first();
c.c_id = rs.getInt("c.c_id");
stmt1.executeUpdate("delete from blacklist_customer where c_id='"+c.c_id+"';");
jTextArea1.setText("Successfully removed from blacklist");
} catch(Exception e)
{
System.out.println("error");
}
// 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(NewJFrame3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame3.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 NewJFrame3().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
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.JList jList1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}
NEW FRAME 4
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author puchu
*/
public class NewJFrame4 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame4
*/
public NewJFrame4() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jTextField3 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jTextField1 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane2 = new javax.swing.JScrollPane();
jList2 = new javax.swing.JList();
jScrollPane3 = new javax.swing.JScrollPane();
jList3 = new javax.swing.JList();
jScrollBar1 = new javax.swing.JScrollBar();
jLabel8 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jScrollPane5 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jCheckBox1 = new javax.swing.JCheckBox();
jLabel1 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jTextField4 = new javax.swing.JTextField();
jButton4 = new javax.swing.JButton();
jLabel12 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jScrollPane6 = new javax.swing.JScrollPane();
jTextArea3 = new javax.swing.JTextArea();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel2.setText("jLabel2");
jLabel3.setText("jLabel3");
jLabel4.setText("jLabel4");
jTextField3.setText("Customer Id");
jTextField2.setText("Dvd Id");
jTextField1.setText("Rent");
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
jList2.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane2.setViewportView(jList2);
jList3.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane3.setViewportView(jList3);
jButton1.setText("jButton1");
jButton2.setText("jButton2");
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane5.setViewportView(jTextArea2);
jCheckBox1.setText("jCheckBox1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(450, 450));
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("RENT RECORD");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, 290, 60));
jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel5.setText("Rent(Rs)");
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 110, 120, 24));
jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel6.setText("No Of Dvd`s");
getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 110, 110, -1));
jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel7.setText("Customer Id");
getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 100, 110, 24));
jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/imagrres.jpg"))); // NOI18N
getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 10, 180, 90));
jButton3.setText("BACK");
jButton3.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 70, 30));
jTextField4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField4ActionPerformed(evt);
}
});
getContentPane().add(jTextField4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, 110, 30));
jButton4.setText("SUBMIT");
jButton4.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
getContentPane().add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, 90, 30));
jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel12.setText("Due Date");
getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 110, 80, -1));
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTextArea1MouseClicked(evt);
}
});
jScrollPane4.setViewportView(jTextArea1);
getContentPane().add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 270, 560, 130));
jTextArea3.setColumns(20);
jTextArea3.setRows(5);
jScrollPane6.setViewportView(jTextArea3);
getContentPane().add(jScrollPane6, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 146, 290, 80));
jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel10.setText("ID");
getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 250, 40, 14));
jLabel11.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel11.setText("DUE DATE");
getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 250, 80, -1));
jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel13.setText("NO OF DVD`S");
getContentPane().add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 250, 100, -1));
jLabel14.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel14.setText("RENT(Rs.)");
getContentPane().add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 250, 80, -1));
jLabel15.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel15.setText("PHONE NO");
getContentPane().add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 250, 80, -1));
pack();
}// </editor-fold>
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
customer c=new customer();
c.c_id=Integer.parseInt(jTextField4.getText());
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT C_ID, COUNT(C_ID)AS NO_OF_DVDs,DUE_DATE,SUM(RENT) AS RENT FROM LEND_RECORD group by C_ID,due_date HAVING C_ID='"+c.c_id+"';") ;
jTextArea3.setText(" ");
while(rs.next()){
//Retrieve by column name
c.dvd_count = rs.getInt("NO_of_DVDs");
c.rent = rs.getInt("RENT");
c.date= rs.getString("DUE_DATE");
//String s1= ""+jlabel10.getText() + "text u want to append"
jTextArea3.append("\n "+c.dvd_count );
jTextArea3.append("\t "+c.rent);
jTextArea3.append("\t "+c.date);
}
} catch (Exception e) {
System.out.println("error");
}
// TODO add your handling code here:
}
private void jTextField4ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextArea1MouseClicked(java.awt.event.MouseEvent evt){
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
// try{
// final String dvd_title= jTextField2.getText();
// int c_id =Integer.parseInt(jTextField1.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select l.c_id ,due_date ,count(l.c_id) ,sum(rent),c.phone_no as rent from lend_record l,customer c group by c.c_id,due_date having c.c_id=l.c_id;") ;
// TODO add your handling code here:
jTextArea1.setText("");
while (rs.next()) {
jTextArea1.append(""+rs.getInt(1)+""); //set text
jTextArea1.append(" "); //set text
jTextArea1.append("\t"+rs.getString(2)); //set text
jTextArea1.append(" "); //set text
jTextArea1.append("\t\t"+rs.getString(3));
jTextArea1.append(" ");
jTextArea1.append("\t"+rs.getString(4));
jTextArea1.append(" ");
jTextArea1.append("\t"+rs.getString(5));
jTextArea1.append("\n");
//textArea.setText(rs.getString(3)); //set text
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"error");
}
// 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(NewJFrame4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame4.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame4.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 NewJFrame4().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
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.JList jList1;
private javax.swing.JList jList2;
private javax.swing.JList jList3;
private javax.swing.JScrollBar jScrollBar1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextArea jTextArea3;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
private javax.swing.JTextField jTextField4;
// End of variables declaration
}
NEW FRAME 5
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.Connection;
import java.sql.DriverManager;
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;
/**
*
* @author puchu
*/
public class NewJFrame5 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame5
*/
public NewJFrame5() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton3 = new javax.swing.JButton();
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.png"))); // NOI18N
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images (1).jpg"))); // NOI18N
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(600, 600));
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("CUSTOMER DETAILS");
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, 380, 33));
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel2.setText("PHONE NO:");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 100, 150, 30));
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
getContentPane().add(jTextField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 100, 190, 30));
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 140, 80, 30));
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.jpg"))); // NOI18N
getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 130, 250, 330));
jButton2.setText("BACK");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, 70, 30));
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane2.setViewportView(jTextArea1);
getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 190, 220, 220));
jButton3.setText("DELETE RECORD");
jButton3.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 140, 140, 30));
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
customer c=new customer();
c.phone_no= Long.parseLong(jTextField1.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select c_id,c_name,phone_no,security_amount from customer where phone_no='"+c.phone_no+"';") ;
while(rs.next()){
//Retrieve by column name
c.c_id = rs.getInt("c_id");
c.c_name = rs.getString("c_name");
c.phone_no= Long.parseLong(rs.getString("phone_no"));
c.Sec_amt = rs.getInt("security_amount");
ResultSet rs1 = stmt1.executeQuery("select c_id from blacklist_customer where c_id='"+c.c_id+"';");
if(rs1.next() == false){
String s= "Id:"+c.c_id+"\nName:"+c.c_name+"\nPhone no:"+c.phone_no+"\nDeposit:"+c.Sec_amt+"\nBlacklisted:-No";
jTextArea1.setText(s);
}
else{
String s= "Id:"+c.c_id+"\nName:"+c.c_name+"\nPhone no:"+c.phone_no+"\nDeposit:"+c.Sec_amt+"\nBlacklisted:-YES";
jTextArea1.setText(s);
}
//JOptionPane.showMessageDialog(null,"Id:"+c_id+"\nName:"+name+"\nPhone no:"+phone+"\nDeposit:"+deposit+"");
//Display values
}
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
//JOptionPane.showMessageDialog(null,"We Are Done");
// TODO add your handling code here:
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
customer c =new customer();
c.phone_no= Long.parseLong(jTextField1.getText());
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt1.executeQuery("select c.c_id,c.c_name,c.phone_no from customer c where c.phone_no='"+c.phone_no+"';");
rs.first();
c.c_id=rs.getInt("c.c_id");
Statement stmt2 = conn.createStatement();
stmt2.executeUpdate("delete from lend_record where c_id ='"+c.c_id+"';");
stmt.executeUpdate("delete from customer where phone_no ='"+c.phone_no+"';") ;
//while(rs.next()){
//Retrieve by column name
// int c_id = rs.getInt("c_id");
// String name = rs.getString("c_name");
// String phone = rs.getString("phone_no");
// int deposit = rs.getInt("security_amount");
// String s= "Id:"+c_id+"\nName:"+name+"\nPhone no:"+phone+"\nDeposit:"+deposit+"";
jTextArea1.setText("RECORD DELTETED SUCCESSFULLY.....");
//JOptionPane.showMessageDialog(null,"Id:"+c_id+"\nName:"+name+"\nPhone no:"+phone+"\nDeposit:"+deposit+"");
//Display values
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
// 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(NewJFrame5.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame5.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame5.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame5.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 NewJFrame5().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JList jList1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
NEW FRAME 6
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author puchu
*/
public class NewJFrame6 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame6
*/
public NewJFrame6() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane1.setViewportView(jList1);
jLabel2.setText("DVD ID");
jTextField1.setText("jTextField1");
jLabel5.setText("jLabel5");
jLabel6.setText("jLabel6");
jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/imageiuos.jpg"))); // NOI18N
jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images (1).jpg"))); // NOI18N
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane2.setViewportView(jTextArea1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(450, 450));
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("DVD STOCK");
getContentPane().add(jLabel1);
jLabel1.setBounds(80, 10, 240, 33);
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel3.setText("DVD TITLE:");
getContentPane().add(jLabel3);
jLabel3.setBounds(90, 85, 110, 22);
jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel4.setText("NO. OF DVDS:");
getContentPane().add(jLabel4);
jLabel4.setBounds(264, 85, 120, 22);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
getContentPane().add(jTextField2);
jTextField2.setBounds(90, 117, 120, 30);
jTextField3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField3ActionPerformed(evt);
}
});
getContentPane().add(jTextField3);
jTextField3.setBounds(264, 117, 110, 30);
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(90, 160, 100, 40);
jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images (1).jpg"))); // NOI18N
getContentPane().add(jLabel9);
jLabel9.setBounds(0, 100, 210, 300);
jButton2.setText("BACK");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(10, 50, 70, 30);
jButton3.setText("SEARCH");
jButton3.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3);
jButton3.setBounds(250, 160, 100, 40);
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane3.setViewportView(jTextArea2);
getContentPane().add(jScrollPane3);
jScrollPane3.setBounds(220, 220, 166, 140);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
dvd d=new dvd();
d.dvd_title=jTextField2.getText();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select dvd_title ,DVD_COUNT as NO_of_DVDs from dvd_stock where dvd_title='"+d.dvd_title+"';") ;
rs.first();
//Retrieve by column name
d.dvd_id = rs.getInt("NO_of_DVDs");
jTextField3.setText(""+d.dvd_id );
} catch (Exception e) {
System.out.println("error");
}
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
// TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextField3ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
dvd d=new dvd();
d.dvd_title=jTextField2.getText();
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select dvd_id,dvd_title ,DVD_COUNT as NO_of_DVDs from dvd_stock where dvd_title='"+d.dvd_title+"';") ;
if(rs.first()==false){jTextArea2.setText("DVD IS NOT IN STOCK");}
else{
rs.first();
//Retrieve by column name
d.dvd_id = rs.getInt("dvd_id");
d.dvd_title=rs.getString("dvd_title");
d.dvd_count=rs.getInt("NO_of_DVDs");
jTextArea2.setText("ID:"+d.dvd_id+"\nTITLE:"+d.dvd_title+"\nNO_of_DVDs:" +d.dvd_count+"\n");
}
} catch (Exception e) {
System.out.println("error");
}
// 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(NewJFrame6.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame6.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame6.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame6.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 NewJFrame6().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
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.JList jList1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
private javax.swing.JTextField jTextField3;
// End of variables declaration
}
NEW FORM 7
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import static com.sun.org.apache.xalan.internal.lib.ExsltDatetime.date;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
/**
*
* @author puchu
*/
public class NewJFrame7 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame7
*/
public NewJFrame7() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel7 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.jpg"))); // NOI18N
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.png"))); // NOI18N
jButton3.setText("jButton3");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(450, 450));
getContentPane().setLayout(null);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel1.setText("DVD LEND");
getContentPane().add(jLabel1);
jLabel1.setBounds(100, 10, 220, 48);
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel2.setText("Dvd tilte");
getContentPane().add(jLabel2);
jLabel2.setBounds(70, 90, 90, 20);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel3.setText("Customer Id");
getContentPane().add(jLabel3);
jLabel3.setBounds(230, 90, 120, 27);
getContentPane().add(jLabel4);
jLabel4.setBounds(269, 86, 68, 27);
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(140, 170, 110, 40);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
getContentPane().add(jTextField1);
jTextField1.setBounds(230, 130, 110, 30);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
getContentPane().add(jTextField2);
jTextField2.setBounds(60, 130, 110, 30);
jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/newswingapplication/images.png"))); // NOI18N
getContentPane().add(jLabel6);
jLabel6.setBounds(120, 10, 200, 210);
jButton2.setText("BACK");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(10, 30, 70, 30);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseMoved(java.awt.event.MouseEvent evt) {
jTextArea1MouseMoved(evt);
}
});
jTextArea1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTextArea1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTextArea1);
getContentPane().add(jScrollPane1);
jScrollPane1.setBounds(10, 260, 380, 130);
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel8.setText("DVD TITLE");
getContentPane().add(jLabel8);
jLabel8.setBounds(20, 230, 110, 20);
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel9.setText("NO OF DVD`S");
getContentPane().add(jLabel9);
jLabel9.setBounds(180, 230, 100, 20);
pack();
}// </editor-fold>
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
customer c=new customer();
dvd d=new dvd();
d.dvd_title= jTextField2.getText();
c.c_id =Integer.parseInt(jTextField1.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select dvd_id ,dvd_title,dvd_count from dvd_stock where dvd_title='"+d.dvd_title+"';") ;
rs.first();
//Retrieve by column name
d.dvd_id = rs.getInt("dvd_id");
//System.out.println(dvd_id);
d.dvd_count=rs.getInt("dvd_count");
if(d.dvd_count==0){
jTextArea1.setText("");
JOptionPane.showMessageDialog(null,"Out of Stock");
}
else{
String sql = "insert into lend_record(c_id,dvd_id,rent,due_date) values('"+c.c_id+"','"+d.dvd_id+"','100',current_date()+INTERVAL 7 DAY);";
stmt1.executeUpdate(sql);
Statement stmt2 =conn.createStatement();
sql= "update dvd_stock set dvd_count=dvd_count-1 where dvd_id='"+d.dvd_id+"';";
stmt2.executeUpdate(sql);
jTextArea1.setText("successfully lended");
//Display values
}
}catch(SQLException se){
}
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
// JOptionPane.showMessageDialog(null,"We Are Done");
// TODO add your handling code here:
}
private void jTextArea1MouseMoved(java.awt.event.MouseEvent evt) {
//jTextArea1.setText("");
}
private void jTextArea1MouseClicked(java.awt.event.MouseEvent evt){
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
// try{
// final String dvd_title= jTextField2.getText();
// int c_id =Integer.parseInt(jTextField1.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select dvd_title,dvd_count from dvd_stock ;") ;
// TODO add your handling code here:
jTextArea1.setText("");
while (rs.next()) {
jTextArea1.append("\n "+rs.getString(1)+""); //set text
jTextArea1.append(" "); //set text
jTextArea1.append("\t\t"+rs.getInt(2)); //set text
jTextArea1.append(""); //set text
//textArea.setText(rs.getString(3)); //set text
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"error");
}
// 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(NewJFrame7.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame7.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame7.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame7.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 NewJFrame7().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
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.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}
NEW FORM 8
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author GAUTAMGARIMAPC
*/
public class NewJFrame8 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame8
*/
public NewJFrame8() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel3 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
jLabel3.setText("jLabel3");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText("DVD_TITLE:");
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("YEAR:");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel4.setText("ADD AND UPDATE DVD RECORD");
jButton1.setText("NEW");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("UPDATE");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("BACK");
jButton3.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imageiuos.jpg"))); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(jLabel2))
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addComponent(jTextField2)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)
.addGap(16, 16, 16)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
.addComponent(jLabel5)
.addGap(19, 19, 19))
.addGroup(layout.createSequentialGroup()
.addGap(115, 115, 115)
.addComponent(jLabel4)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
.addComponent(jLabel1)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jLabel5))
.addContainerGap(23, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
dvd d=new dvd();
d.dvd_title=jTextField1.getText();
d.year=Integer.parseInt(jTextField2.getText());
// final String c_address=jTextField3.getText();
//final int security= Integer.parseInt(jTextField4.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt1.executeQuery("select * from dvd_stock where dvd_title ='"+d.dvd_title+"';");
if(rs.next() != false){ JOptionPane.showMessageDialog(null,"already exist");}
else{
stmt.executeUpdate("insert into dvd_stock(dvd_title,year,rent,DVD_COUNT) values('"+d.dvd_title+"','"+d.year+"','100','10');");
JOptionPane.showMessageDialog(null,"Inserted Successfully!");
stmt.close();
}
}
catch(Exception e)
{
System.out.println("error");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(this , "Invalid input");
}
// TODO add your handling code here:
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
dvd d =new dvd();
d.dvd_title=jTextField1.getText();
//final int year=Integer.parseInt(jTextField2.getText());
// final String c_address=jTextField3.getText();
//final int security= Integer.parseInt(jTextField4.getText());
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs= stmt1.executeQuery("select * from dvd_stock where dvd_title ='"+d.dvd_title+"';");
if(rs.next() == false){ JOptionPane.showMessageDialog(null,"Doesn`t exist");}
else{
stmt.executeUpdate("update dvd_stock set dvd_count=dvd_count+10 where dvd_title="+d.dvd_title+";");
JOptionPane.showMessageDialog(null,"Inserted Successfully!");
stmt.close();
}
}
catch(Exception e)
{
System.out.println("error");
}
}
catch(Exception e){
JOptionPane.showMessageDialog(this , "Invalid input");
}
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 us = new NewJFrame1();
us.setVisible(true);
dispose();
// 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(NewJFrame8.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame8.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame8.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame8.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 NewJFrame8().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}
NEW FORM 9
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package newswingapplication;
import java.sql.Connection;
import java.sql.DriverManager;
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;
/**
*
* @author GAUTAMGARIMAPC
*/
public class NewJFrame9 extends javax.swing.JFrame {
/**
* Creates new form NewJFrame9
*/
public NewJFrame9() {
initComponents();
}
/**
* This method is called from within the constructor to initializethe form.
* WARNING: Do NOT modify this code. The content of this method isalways
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jLabel4 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("RETURN DVD");
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("DVD_TITLE:");
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel3.setText("CUSTOMER_ID:");
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jButton1.setText("SUBMIT");
jButton1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imageiuos.jpg"))); // NOI18N
jButton2.setText("BACK");
jButton2.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(115, 115, 115)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addGap(155, 155, 155)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jButton2)))
.addGap(29, 29, 29)
.addComponent(jLabel4)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jLabel1)
.addGap(3, 3, 3)
.addComponent(jButton2)
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)))
.addGap(44, 44, 44)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(34, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
final String JDBC_DRIVER="com.mysql.jdbc.Driver";
final String DB_URL = "jdbc:mysql://localhost:3306/dvd";
final String USER="root";
final String PASS="root";
try{
customer c=new customer();
dvd d=new dvd();
d.dvd_title= jTextField1.getText();
c.c_id =Integer.parseInt(jTextField2.getText());
try
{
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewJFrame3.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn=DriverManager.getConnection(DB_URL,USER,PASS);
Statement stmt = conn.createStatement();
Statement stmt1 = conn.createStatement();
ResultSet rs = stmt.executeQuery("select dvd_id ,dvd_title,dvd_count from dvd_stock where dvd_title='"+d.dvd_title+"';") ;
rs.first();
//Retrieve by column name
d.dvd_id = rs.getInt("dvd_id");
//System.out.println(dvd_id);
d.dvd_count=rs.getInt("dvd_count");
//if(dvd_c==0){
// jTextArea1.setText("");
//JOptionPane.showMessageDialog(null,"Out of Stock");
// }
String sql = "delete from lend_record where c_id='"+c.c_id+"'AND dvd_id='"+d.dvd_id+"';";
stmt1.executeUpdate(sql);
Statement stmt2 =conn.createStatement();
sql= "update dvd_stock set dvd_count=dvd_count+1 where dvd_id='"+d.dvd_id+"';";
stmt2.executeUpdate(sql);
jTextArea1.setText("successfully returned");
//Display values
}catch(SQLException se){
}
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
// TODO add your handling code here:
}
private void jTextField1ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jTextField2ActionPerformed(java.awt.event.ActionEventevt) {
// TODO add your handling code here:
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 ds = new NewJFrame1();
ds.setVisible(true);
dispose();
// 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(NewJFrame9.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame9.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame9.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame9.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 NewJFrame9().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration
}