open
// save file as open.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author hp
*/
public class open extends javax.swing.JFrame {
/**
* Creates new form open
*/
public open() {
initComponents();
}
public open(String a,String name)
{
String mail =a;
initComponents();
jLabel3.setText(a);
jLabel3.setVisible(false);
jLabel5.setText(name);
jLabel5.setVisible(false);
//System.out.println(a);
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox<>();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(new java.awt.Rectangle(450, 200, 0, 0));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "sbi", "hdfc", "pnb", "kotak" }));
jButton1.setText("Open Account ");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Bank Name :");
jLabel2.setText("Amount : ");
jButton2.setText("Back To Home Page");
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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel5))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(142, 142, 142)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(56, 56, 56)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 115, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(37, 37, 37)
.addComponent(jButton1)
.addGap(36, 36, 36)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
//open m = new open();
String bank = (String) jComboBox1.getSelectedItem();
int amount = Integer.parseInt(jTextField1.getText());
String a="";
if(jComboBox1.getSelectedItem()=="sbi")
{
a="SBI100";
}
if(jComboBox1.getSelectedItem()=="pnb")
{
a="PNB100";
}
if(jComboBox1.getSelectedItem()=="hdfc")
{
a="HDFC100";
}
if(jComboBox1.getSelectedItem()=="kotak")
{
a="KOTAK100";
}
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sambhav", "root", "sam");
PreparedStatement ps = con.prepareStatement("insert into "+bank+" (amount,mail,status) values (?,?,1)");
ps.setInt(1, amount);
ps.setString(2, jLabel3.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select ac_number from "+bank+" where mail='"+jLabel3.getText()+"'");
int acno=0;
while(rs.next())
{
acno= rs.getInt("ac_number");
}
// if(rs.getInt("ac_number")==0)
//{
//System.out.println(jLabel3.getText());
// ps = con.prepareStatement("update "+bank+" set ac_no=concat("+bank+","+acno+") where ac_numbaer="+acno);
//ps.executeUpdate();
String ac=a+acno;
System.out.println(ac);
PreparedStatement ps2 = con.prepareStatement("update "+bank+" set ac_no='"+ac+"' where ac_number="+acno);
ps2.executeUpdate();
System.out.println(ac);
String insertquery="update user1 set ac_number='"+ac+"',bname='"+bank+"' where email='"+jLabel3.getText()+"'";
PreparedStatement ps1=con.prepareStatement(insertquery);
ps1.executeUpdate();
JOptionPane.showMessageDialog(null, jLabel5.getText()+" your Account has been opened and your account number is "+ac);
new home().setVisible(true);
this.dispose();
//System.out.println("hello");
//}
//else
// {
// String insertquery="update user1 set ac_number=concat(ac_numbar,"+acno+"),bname=concat(bname,'"+bank+"') where email='"+jLabel3.getText()+"'";
// PreparedStatement ps1=con.prepareStatement(insertquery);
//ps1.executeUpdate();
// }
}
catch(Exception e)
{
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
new home().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @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(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(open.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 open().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
/**
*
* @author hp
*/
public class open extends javax.swing.JFrame {
/**
* Creates new form open
*/
public open() {
initComponents();
}
public open(String a,String name)
{
String mail =a;
initComponents();
jLabel3.setText(a);
jLabel3.setVisible(false);
jLabel5.setText(name);
jLabel5.setVisible(false);
//System.out.println(a);
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox<>();
jTextField1 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBounds(new java.awt.Rectangle(450, 200, 0, 0));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "sbi", "hdfc", "pnb", "kotak" }));
jButton1.setText("Open Account ");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel1.setText("Bank Name :");
jLabel2.setText("Amount : ");
jButton2.setText("Back To Home Page");
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(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jLabel5))
.addGroup(layout.createSequentialGroup()
.addGap(130, 130, 130)
.addComponent(jButton1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(142, 142, 142)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGap(56, 56, 56)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 115, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(37, 37, 37)
.addComponent(jButton1)
.addGap(36, 36, 36)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
//open m = new open();
String bank = (String) jComboBox1.getSelectedItem();
int amount = Integer.parseInt(jTextField1.getText());
String a="";
if(jComboBox1.getSelectedItem()=="sbi")
{
a="SBI100";
}
if(jComboBox1.getSelectedItem()=="pnb")
{
a="PNB100";
}
if(jComboBox1.getSelectedItem()=="hdfc")
{
a="HDFC100";
}
if(jComboBox1.getSelectedItem()=="kotak")
{
a="KOTAK100";
}
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sambhav", "root", "sam");
PreparedStatement ps = con.prepareStatement("insert into "+bank+" (amount,mail,status) values (?,?,1)");
ps.setInt(1, amount);
ps.setString(2, jLabel3.getText());
ps.executeUpdate();
JOptionPane.showMessageDialog(null, "Updated");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select ac_number from "+bank+" where mail='"+jLabel3.getText()+"'");
int acno=0;
while(rs.next())
{
acno= rs.getInt("ac_number");
}
// if(rs.getInt("ac_number")==0)
//{
//System.out.println(jLabel3.getText());
// ps = con.prepareStatement("update "+bank+" set ac_no=concat("+bank+","+acno+") where ac_numbaer="+acno);
//ps.executeUpdate();
String ac=a+acno;
System.out.println(ac);
PreparedStatement ps2 = con.prepareStatement("update "+bank+" set ac_no='"+ac+"' where ac_number="+acno);
ps2.executeUpdate();
System.out.println(ac);
String insertquery="update user1 set ac_number='"+ac+"',bname='"+bank+"' where email='"+jLabel3.getText()+"'";
PreparedStatement ps1=con.prepareStatement(insertquery);
ps1.executeUpdate();
JOptionPane.showMessageDialog(null, jLabel5.getText()+" your Account has been opened and your account number is "+ac);
new home().setVisible(true);
this.dispose();
//System.out.println("hello");
//}
//else
// {
// String insertquery="update user1 set ac_number=concat(ac_numbar,"+acno+"),bname=concat(bname,'"+bank+"') where email='"+jLabel3.getText()+"'";
// PreparedStatement ps1=con.prepareStatement(insertquery);
//ps1.executeUpdate();
// }
}
catch(Exception e)
{
}
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
new home().setVisible(true);
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
/**
* @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(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(open.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(open.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 open().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}
No comments:
Post a Comment