J Kasthu

J Kasthu

  • NA
  • 7
  • 1.1k

How to control another jframe buttons from login jframe..

Jan 5 2018 11:12 PM
try{ String sql = "SELECT * from tbluserlogin WHERE Name = '"+ txtusername.getText().toString()+"' AND Password= '"+txtpassword.getText()+"' AND Branch = '"+ CboDepartment.getSelectedItem().toString()+"' "; pst = conn.prepareStatement(sql); rs=pst.executeQuery(sql); rs.next(); String name = rs.getString("Branch"); if (name.equals("Admin")) { Main ah = new Main(); ah.setVisible(true); this.dispose(); } else if(name.equals("Minor Offense")){ new Main().setVisible(true); this.dispose(); } else if(name.equals("Traffic Branch")){ new Main().setVisible(true); this.dispose(); } else if(name.equals("Child @ Women Branch")){ new Main().setVisible(true); this.dispose(); } else if(name.equals("Crime Branch")){ new Main().setVisible(true); this.dispose(); } else { JOptionPane.showMessageDialog(null, "Connot Login"); txtusername.setText(""); txtpassword.setText(""); CboDepartment.setSelectedIndex(-1); } } catch (Exception e){ JOptionPane.showMessageDialog(null, e); }