mardi 23 mai 2017

JAVA - not display else message

i am a new guy for JAVA.this is my mysql customer table structure...

create table Customer(
CID  VARCHAR (10) primary key,
Name VARCHAR (30) not null,
LicenseID VARCHAR (10) not null,
NIC VARCHAR (10) not null,
DOB date not null,
Address VARCHAR (25) not null,
Tp int (10) ,
Email VARCHAR (30) not null 

);

this is my customerController function...

private void addCustomerBtnActionPerformed(java.awt.event.ActionEvent evt) {                                               
    CustomerDTO customer = new CustomerDTO(
            idTxt.getText(),
            nameText.getText(),
            licenseText.getText(),
            NICText.getText(),
            DOBText.getText(),
            addressText.getText(),
            Integer.parseInt(tpText.getText()),
            emailText.getText());
    try { 
        boolean result = custController.add(customer);
        if (result){
            JOptionPane.showMessageDialog(this, "Customer has been successfully added...");
        }else{
            JOptionPane.showMessageDialog(this, "Customer has not been added...");
        }
    } catch (Exception ex) {
        Logger.getLogger(addCustomer.class.getName()).log(Level.SEVERE, null, ex);
    }
}

when i add the new customer, it is added to database and also show this message.."Customer has been successfully added..." .but when i try to add existing CID or Tp as a string , i can't see "Customer has not been added..." this message...please anyone can help me solve this problem ?

Aucun commentaire:

Enregistrer un commentaire