Im creating a little patients management software to my wife. The program is fully functional but Im having a problem once I update patient data or exclude any register. I have a search form to bring all patients (using date period, name...) then I select desired patient (from last visit) and all patient's data are shown into another form. I can update data, exclude this visit but, once I save it, this form (secundary) is closed (dispose). But the main form (search form) is holding previous values. How can I do to refresh main form after closing secundary form??? thx a lot
Edited: Forgot to say its Java - sry ;)
Edited2: this is the method Im using to call secundary form. I used Netbeans to create the project.
private void btn_selecionaActionPerformed(java.awt.event.ActionEvent evt) {
try{
int sel = tabela.getSelectedRow();
if (sel != -1){
String sql = "select * from agendados "
+ "where numag = " + modelo.getValueAt(sel, 5);
con_mnt.executaSQL(sql);
func = new Funcoes();
func.carregaDados(dados, con_mnt.rs);
new CarregarAgendamento(func.getDados()).setVisible(true);
} else{
JOptionPane.showMessageDialog(null, "Selecione algum paciente antes.", " Atenção!!!", JOptionPane.ERROR_MESSAGE);
}
}
catch(SQLException | NumberFormatException e){
JOptionPane.showMessageDialog(null, "Nao existe dados ainda", " Atenção!!!", JOptionPane.ERROR_MESSAGE);
}
}
Edited 3: Save, Delete and salvarAgendamento methods:
private void btn_salvaActionPerformed(java.awt.event.ActionEvent evt) {
salvarAgendamento();
dispose();
}
private void btn_deleteActionPerformed(java.awt.event.ActionEvent evt) {
if(javax.swing.JOptionPane.showConfirmDialog(null,"Deseja realmente Excluir este Agendamento?","ATENÇÃO ",javax.swing.JOptionPane.YES_NO_OPTION )==0)
{
con_ag = new Firebird(func.fullPath("/db/manutencao.fdb"));
con_ag.removeFDB("agendados", "numag", jt_cod.getText());
Agendados.refresh = 1;
this.dispose();
}
}
public void salvarAgendamento(){
ArrayList<Object> colunas = new ArrayList<>();
ArrayList<Object> valores = new ArrayList<>();
calendario = new Calendario();
if (jcb_motivo.getSelectedIndex() == -1)
{
JOptionPane.showMessageDialog(null, "Faltou o Motivo do Agendamento!");
jcb_motivo.requestFocus();
}
else if (jt_dataAg.getText().equals(""))
{
JOptionPane.showMessageDialog(null, "Faltou a Data do Agendamento!");
jt_dataAg.requestFocus();
}
else if (dados.getStatusAg() == 0)
{
JOptionPane.showMessageDialog(null, "Faltou selecionar o Status do Agendamento!");
jcb_status.requestFocus();
}
else
{
calendario.dataFormatada("dd/mm/yyyy", "yyyy-mm-dd", jt_dataAg.getText());
dados.setDataAg(calendario.getDataFormatada() + " 00:00:00");
colunas.add("statusag");
colunas.add("obs");
valores.add(jt_tel1.getText());
valores.add(jt_tel2.getText());
valores.add(jt_cel.getText());
valores.add(dados.getConvenioNum()); //convnum
valores.add(dados.getDentistaNum()); //dentnum
valores.add(jcb_motivo.getSelectedItem());
valores.add(dados.getDataAg()); //dataag
valores.add(dados.getStatusAg()); //statusag
valores.add(area_obs.getText());
valores.add(jt_cod.getText());
grava(valores);
JOptionPane.showMessageDialog(null, "Agendamento alterado com sucesso!");
dispose();
}
}