private void LoginActionPerformed(java.awt.event.ActionEvent evt) {                                      
    	String name = userName.getText();
        //String psw ;
        //psw = new String(password.getPassword());
        Long count = 0L;
        Long count1 = 0L;
        String psw = new String(password.getPassword());
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("PersistenceUnit");
		EntityManager manager = emf.createEntityManager();
		EntityTransaction transaction = manager.getTransaction();
		TypedQuery<Long> query = manager.createQuery("Select count(c) from Audience c where c.userName='" + name + "' and c.password='" + psw + "'", Long.class);
		TypedQuery<Long> query1 = manager.createQuery("Select count(c) from Audience c where c.userName='" + name + "' and c.password='" + psw + "' and c.role='admin'", Long.class);
		transaction.begin();
		List<Long> result = query.getResultList();
		List<Long> result1 = query1.getResultList();
		transaction.commit();
		for(Long data: result){
		
		count = data;
			
		}
		
		//transaction.commit();
		for(Long data: result1){
			//if(result.get(0).toString().equals(1))
				count1 = data;
				
			}
			if(count1 == 1L){
				JOptionPane.showMessageDialog(window,"ADMIN Login Successful","Admin",JOptionPane.PLAIN_MESSAGE );
				this.setVisible(false);
				NewAdminGUI.main(null);
			}
			else if(count == 1L){
				JOptionPane.showMessageDialog(window,"LOGIN Successful","LOGIN SignUP",JOptionPane.PLAIN_MESSAGE );
				this.setVisible(false);
				SearchesGUI.main(null);
			}
			else
				JOptionPane.showMessageDialog(window,"User Name and Password are not found","Login Failed",JOptionPane.PLAIN_MESSAGE );
			//transaction.commit();
		

    }