You are on page 1of 3

Component(s)

JButton(Submit)
JButton(Back To Dashboard)
JBuuton(Back to Gift Card
Menu)
JButton(Check Another One)

Name
Assigned
butsub
butback
butgcm

Properties Modified

butcao

Font Tahoma 14 Bold

Font Aharoni 24 Plain


Font Aharoni 24 Plain
Font Tahoma 14 Bold

Coding for BACK TO DASHBOARD Button :Refer to FRAME NO. IRTRS_07 (BACK TO DASHBOARD BUTTON)

Coding for BACK Button :private void butbackActionPerformed(java.awt.event.ActionEvent evt) {


dispose(); new giftcard().setVisible(true);}

Coding for SUBMIT Button :private void butsubActionPerformed(java.awt.event.ActionEvent evt) {


String gc = txtgc.getText();
DefaultTableModel model = (DefaultTableModel)table_gc.getModel();
String gifpin = txtgifpin.getText();
if(!(gc.length()==18))
{JOptionPane.showMessageDialog(this,"Please check that you have entered 18 Digit Gift
Card. ");}
else{if(gc.equals("")){JOptionPane.showMessageDialog(this,"Gift Card No. not Entered");}
else{if(gifpin.equals("")){JOptionPane.showMessageDialog(this,"GIFPIN not Entered");}
else{if(!(gifpin.equals("") && gc.equals(""))){try { Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/irtrc","root","654321");
Statement stmt = (Statement) con.createStatement();
String Query2 = "SELECT * from giftcard where id = '"+gc+"';";
ResultSet rs2=stmt.executeQuery(Query2);
if (rs2.next()){String gc_no = rs2.getString("id");
String gif = rs2.getString("gifpin");
if(gifpin.equals(gif)&& gc_no.equals(gc) ){try
{ Class.forName("java.sql.DriverManager");
Connection con1 = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/irtrc","root","654321");
Statement stmt1 = (Statement) con1.createStatement();

String Query1 = "SELECT txnid,balance from giftcard where id = '"+gc+"' && gifpin
= '"+gifpin+"';";
ResultSet rs1=stmt1.executeQuery(Query1);
if (rs1.next()){String balance1 = rs1.getString("balance");
String txnid1 = rs1.getString("txnid");
lblgcb.setText(""+balance1);
lbltxn.setText(""+txnid1);}
try {Class.forName("java.sql.DriverManager");
Connection con2 = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/irtrc","root","654321");
Statement stmt2 = (Statement) con2.createStatement();
String Query ="SELECT txn_desc,debit,balance FROM giftcard_txn where gcno =
'"+gc+"';";
ResultSet rs=stmt2.executeQuery(Query);
while (rs.next()){String txn_desc = rs.getString("txn_desc");
String debit = rs.getString("debit");
String balance = rs.getString("balance");
model.addRow(new Object[] {txn_desc,debit,balance});
lblgcb.setVisible(true);
lbltxn.setVisible(true);
gcb.setVisible(true);
txn.setVisible(true);
txtgc.setEditable(false);
txtgifpin.setEditable(false);butback.setVisible(false);butsub.setEnabled(false);
butbtd.setVisible(true);butcao.setVisible(true);
butgcm.setVisible(true);}}
catch (Exception e) {JOptionPane.showMessageDialog (this,e.getMessage());}}
catch (Exception e) {JOptionPane.showMessageDialog (this,e.getMessage());}}
else{JOptionPane.showMessageDialog(this,"Invalid Credentials Entered. ");}}}
catch (Exception e) {JOptionPane.showMessageDialog (this,e.getMessage());}}}}}
}

Coding for CHECK ANOTHER ONE Button :private void butcaoActionPerformed(java.awt.event.ActionEvent evt) {
dispose(); new checkgc().setVisible(true);}

Coding for BACK TO GIFT CARD MENU Button :private void butgcmActionPerformed(java.awt.event.ActionEvent evt) {
dispose(); new giftcard().setVisible(true);}

You might also like