Anda di halaman 1dari 28

CODING

SAVE
private void saveActionPerformed(java.awt.event.ActionEvent evt) {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = null;

ResultSet rs = null;

String SQL = "SELECT * FROM loan";

stmt = con.createStatement();

rs = stmt.executeQuery(SQL);

String no = ID.getText();

String name = Name.getText();

String code = Desc.getText();

double price = Double.parseDouble(Price.getText());

int len=no.length();
if(len==4)

String strSQL = "INSERT INTO loan(Id, Name,


description, Price) VALUES ('"+(no)+"','"+(name)+"','"+(code)+"',"+
(price)+")";

JOptionPane.showMessageDialog(this, "Record successfully


inserted");

int rowsEffected = stmt.executeUpdate(strSQL);

System.out.println(rowsEffected + " rows effected");

else{JOptionPane.showMessageDialog(this," ID should be 4
character.");}

con.close();

} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage());

e.printStackTrace();

BACK TO MENU

this.setVisible(false);

new UserMenu().setVisible(true);
CLEAR

private void ClearActionPerformed(java.awt.event.ActionEvent evt) {

ID.setText("");

Name.setText("");

Desc.setText("");

Price.setText("");

}
CODING
CLICK HERE TO PROCCED

this.setVisible(false);

new MainMenu().setVisible(true);
CODING
PRESS TO ENTER

private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new PreMenu().setVisible(true);
CODING
SAVE

private void SaveActionPerformed(java.awt.event.ActionEvent evt) {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = null;

ResultSet rs = null;

String SQL = "SELECT * FROM MEM";

stmt = con.createStatement();

rs = stmt.executeQuery(SQL);

String memno = MemID.getText().trim();

String memname = MemName.getText();

String memadd = MemAdd.getText();


String memcity = MemCity.getText();

double memphone =
Double.parseDouble(MemPhone.getText());

if (memno.length() == 4) {

String strSQL = "INSERT INTO MEM(memid, Name,


Address, City, Phone) VALUES ('"+(memno)+"','"+(memname)+"','"+
(memadd)+"','"+(memcity)+"',"+(memphone)+")";

JOptionPane.showMessageDialog(this, "Record
successfully inserted");

int rowsEffected = stmt.executeUpdate(strSQL);

System.out.println(rowsEffected + " rows effected");

else {

JOptionPane.showMessageDialog(this, "Members ID
should be 4 character.");

con.close();

} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage());

e.printStackTrace();

CLEAR
private void ClearActionPerformed(java.awt.event.ActionEvent
evt) {

MemID.setText("");

MemAge.setText("");

MemQualification.setText("");

MemName.setText("");

MemAdd.setText("");

MemCity.setText("");

MemPhone.setText("");

BACK

private void
BackToMainActionPerformed(java.awt.event.ActionEvent evt) {

this.setVisible(false);

new UserMenu().setVisible(true);
CODING
DISPLAY

private void QueryActionPerformed(java.awt.event.ActionEvent evt)


{

DefaultTableModel model = (DefaultTableModel)


jTable1.getModel();

int rows = model.getRowCount();

if (rows > 0) {

for (int i = 0; i < rows; i++) {

model.removeRow(0);

String query = "SELECT * FROM Mem";

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

String Mid = rs.getString("Memid");

String MName = rs.getString("Name");

String MAddress = rs.getString("Address");

String MCity = rs.getString("City");

String MPhone = rs.getString("Phone");

System.out.println(Mid + "|" + MName + "|" + MAddress +


"|" + MCity + "|" + MPhone);

model.addRow(new Object[] {Mid, MName, MAddress,


MCity, MPhone});

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

}
}

BACK

private void
BackToMenuActionPerformed(java.awt.event.ActionEvent evt) {

this.setVisible(false);

new UserMenu().setVisible(true);
CODING
LOAN LIST

private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new loanList().setVisible(true);

PREVIOUS RECORD

this.setVisible(false);

new RegsRec().setVisible(true);

BACK

this.setVisible(false);

new PreMenu().setVisible(true);
CODING
MEMBER

private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new MemMenu().setVisible(true);

USER

private void jButton2ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new UserMenu().setVisible(true); // TODO add your handling


code here:

BACK

private void jButton4ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new MainMenu().setVisible(true); // TODO add your handling


code here:
CODING
BACK

private void btnBackActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new UserMenu().setVisible(true);

SAVE

private void btnSaveActionPerformed(java.awt.event.ActionEvent


evt) {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

String SQL = "SELECT * FROM registration";

Statement stmt = null;

ResultSet rs = null;

stmt = con.createStatement();
rs = stmt.executeQuery(SQL);

String RegnNo = txtOrdno.getText();

String RegnDate = txtOrdDate.getText();

String ID = txtItemID.getText();

String MemID = txtSID.getText();

double iPrice = Double.parseDouble(txtItemPrice.getText());

String strSQL = "INSERT INTO registration(regnno,


regnDate, Id, memId ) VALUES ('"+(RegnNo)+"','"+(RegnDate)+"','"+
(ID)+"','"+(MemID)+")";

JOptionPane.showMessageDialog(this, "Order successfully


placed");

int rowsEffected = stmt.executeUpdate(strSQL);

System.out.println(rowsEffected + " rows effected");

con.close();

} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage());

e.printStackTrace();

}
}

private void
formWindowGainedFocus(java.awt.event.WindowEvent evt) {

DefaultListModel MModel = (DefaultListModel)


jList1.getModel();

DefaultListModel BModel = (DefaultListModel)


jList2.getModel();

MModel.clear();

BModel.clear();

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = null;

ResultSet rs = null;

ResultSet rs1 = null;


String SQL = "SELECT * FROM mem";

String SQL1 = "SELECT * FROM loan";

stmt = con.createStatement();

rs = stmt.executeQuery(SQL);

while (rs.next()) {

String MID = rs.getString("memid");

String MName = rs.getString("Name");

MModel.addElement(MID + " - " + MName);

jList1.setModel(MModel);

rs1 = stmt.executeQuery(SQL1);

while (rs1.next()) {

String BID = rs1.getString("Id");

String BName = rs1.getString("Name");

BModel.addElement(BID + " - " + BName);

}
jList2.setModel(BModel);

con.close();

} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage());

e.printStackTrace();

private void jList1MouseClicked(java.awt.event.MouseEvent evt) {

String SidName = (String) jList1.getSelectedValue();

String Sid = SidName.substring(0,4);

String Sname= SidName.substring(7);

txtSID.setText(Sid);

txtSName.setText(Sname);

}
private void jList2MouseClicked(java.awt.event.MouseEvent evt) {

try {

Class.forName("com.mysql.jdbc.Driver");

Connection con = (Connection)

DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = null;

ResultSet rs = null;

String IDName = (String) jList2.getSelectedValue();

String ID = IDName.substring(0, 4);

txtItemID.setText(ID);

String SQL = "SELECT * FROM loan where Id = '"+(ID)+"'";

stmt = con.createStatement();

rs = stmt.executeQuery(SQL);

while (rs.next()) {

double iprice = rs.getDouble("Price");

txtItemPrice.setText(Double.toString(iprice));

}
con.close();

} catch (Exception e) {

JOptionPane.showMessageDialog(this,e.getMessage());

e.printStackTrace();

CLEAR

private void btnClearActionPerformed(java.awt.event.ActionEvent


evt) {

txtOrdno.setText("");

txtOrdDate.setText("");

txtSID.setText("");

txtItemID.setText("");

txtSName.setText("");

txtItemPrice.setText("");
CODING
BACK

private void jButton2ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new MemMenu().setVisible(true);

DISPLAY

private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {

DefaultTableModel model = (DefaultTableModel)


jTable1.getModel();

int rows = model.getRowCount();

if (rows > 0) {

for (int i = 0; i < rows; i++) {

model.removeRow(0);

}
}

String query = "SELECT * FROM registration";

try {

Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

String RegnNo = rs.getString("regnno");

String RegnD = rs.getString("regnDate");

String id = rs.getString("Id");

String Memid = rs.getString("MemId");

System.out.println(RegnNo + "|" + RegnD + "|" +id + "|" +


Memid);
model.addRow(new Object[] {RegnNo, RegnD, id, Memid});

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new RegsRec().setVisible(true);

});

}
CODING
ENTRY

private void jButton1ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new Inp().setVisible(true); // TODO add your handling


code here:

MEMBERS INPUT

private void jButton2ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new MemInp().setVisible(true); // TODO add your handling


code here:

REGISTRATION

private void jButton3ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);
new REGISTRATION().setVisible(true); // TODO add your
handling code here:

BACK

private void jButton6ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new PreMenu().setVisible(true); // TODO add your


handling code here:

EXIT

private void jButton7ActionPerformed(java.awt.event.ActionEvent


evt) {

JOptionPane.showMessageDialog(this,"thank You");

System.exit(0); // TODO add your handling code here:

MEMBERS LIST

private void jButton4ActionPerformed(java.awt.event.ActionEvent


evt) {

this.setVisible(false);

new MemList().setVisible(true);// TODO add your handling code


here:
CODING
DISPLAY

private void QueryActionPerformed(java.awt.event.ActionEvent evt)


{

DefaultTableModel model = (DefaultTableModel)


jTable1.getModel();

int rows = model.getRowCount();

if (rows > 0) {

for (int i = 0; i < rows; i++) {

model.removeRow(0);

String query = "SELECT * FROM loan";

try {
Class.forName("com.mysql.jdbc.Driver").newInstance();

Connection con = (Connection)


DriverManager.getConnection("jdbc:mysql://localhost:3306/netbank
ing","root","jns");

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(query);

while (rs.next()) {

String Bid = rs.getString("id");

String BName = rs.getString("Name");

String BCode = rs.getString("description");

String BPrice = rs.getString("Price");

System.out.println(Bid + "|" + BName + "|" + BCode + "|" +


BPrice);

model.addRow(new Object[] {Bid, BName, BCode, BPrice});

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e.getMessage());

}
BACK

private void
BackToMenuActionPerformed(java.awt.event.ActionEvent evt) {

this.setVisible(false);

new MemMenu().setVisible(true);

Anda mungkin juga menyukai