When I open my AdminPanel
and it contains the JTable
with PatientRecords
and button to open the frame to Add Patient.. after filling up the form I click the ADD button and it will save to the database
int YesOrNo = JOptionPane.showConfirmDialog(null, "Do you want to save?", "Save",JOptionPane.YES_NO_OPTION);
if(YesOrNo == 0){
try{
String sql = "Insert into Patient_Records (First_Name,Last_Name,MI,Age,Birth_Date,Gender,Marital_Status,Street,City,[State/Province],Zip_Code,Country,Contact_No,Email_Address,Registered_Date,[In/Out]) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pst = conn.prepareStatement(sql);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String now = (sdf.format(new java.util.Date()));
pst.setString(1, ADDFIRSTNAME.getText());
pst.setString(2, ADDLASTNAME.getText());
pst.setString(3, ADDMIDDLEINITIAL.getText());
pst.setString(4, ADDAGE.getText());
pst.setString(5, ((JTextField)ADDDATE.getDateEditor().getUiComponent()).getText());
pst.setString(6, (String) ADDGENDERBOX.getSelectedItem());
pst.setString(7, (String)ADDSTATUS.getSelectedItem());
pst.setString(8, ADDADDRESS.getText());
pst.setString(9, ADDADDRESS1.getText());
pst.setString(10, ADDADDRESS2.getText());
pst.setString(11, jTextField3.getText());
pst.setString(12, (String)ADDCOUNTRY.getSelectedItem());
pst.setString(13, jTextField1.getText());
pst.setString(14, jTextField2.getText());
pst.setString(15, now);
pst.setString(16, "0");
String CN = jTextField1.getText();
String EA = jTextField2.getText();
String F = ADDFIRSTNAME.getText();
String M = ADDLASTNAME.getText();
String L = ADDMIDDLEINITIAL.getText();
if(!ConValid(CN)){
JOptionPane.showMessageDialog(null, "Contact Number is not valid","Invalid Input",JOptionPane.WARNING_MESSAGE);
}else if(!ConValid(CN)){
JOptionPane.showMessageDialog(null, "Contact Number must contain 11 number(s)","Invalid Input",JOptionPane.WARNING_MESSAGE);
}else if(!valEmail(EA)){
JOptionPane.showMessageDialog(null, "Invalid Email Address","Invalid Input",JOptionPane.WARNING_MESSAGE);
}else if(!OnLetter(F) || !OnLetter(M) || !OnLetter(L)){
JOptionPane.showMessageDialog(null, "Name must not contain number(s)","Invalid Input",JOptionPane.WARNING_MESSAGE);
}else{
JOptionPane.showMessageDialog(null, "Saved","Saved",JOptionPane.INFORMATION_MESSAGE);
pst.execute();
AdminPortal AP = new AdminPortal();
AP.PatientRec();
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}else{
}
after that I exit the Frame that I fill with Patient records and the AdminPanel
with JTable
that contains PatientRecords
did mot Refresh
I tried this code
AdminPortal AP = new AdminPortal();
AP.PatientRec();
what should I do?