private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPasswordActionPerformed
        String username,stringPass="";
        char[] pass;
        String passHash="";
        username=this.txtUsername.getText();
        pass=this.txtPassword.getPassword();
        
        for(int i=0;i<pass.length;i++){
            stringPass+=pass[i];
        }
        
        try{
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(stringPass.getBytes());

            byte byteData[] = md.digest();

            //convert the byte to hex format
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < byteData.length; i++) {
             sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
            }

            passHash=sb.toString();
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
        
        String tempUserId,tempUserType,tempPassword;
        try{
            String query="SELECT userid,password,usertype FROM users WHERE username='"+username+"'";
            Statement st=con.createStatement();
            ResultSet rs=st.executeQuery(query);
            
            if(rs.next()==false){
                JOptionPane.showMessageDialog(null, "Username not found!", "Login failed!", JOptionPane.ERROR_MESSAGE);
            }
            else{
                tempUserId=Integer.toString(rs.getInt(1));
                tempPassword=rs.getString(2);
                tempUserType=rs.getString(3);
                
                if(tempPassword.equals(passHash)){
                    this.lblSignedIn.setVisible(true);
                    this.lblName.setText(this.txtUsername.getText());
                    this.btnEmployees.setEnabled(true);
                    this.lblEmployees.setEnabled(true);
                    this.lblProjects.setEnabled(true);
                    this.btnProjects.setEnabled(true);
                    
                    if(tempUserType.equals("administrator")){
                        this.lblDepartments.setEnabled(true);
                        this.btnDepartments.setEnabled(true);
                        this.lblDepartments.setText("Add/Remove/Change department details");
                        this.lblRegisterUser.setVisible(true);
                    }
                    else{
                        this.lblDepartments.setEnabled(false);
                        this.btnDepartments.setEnabled(false);
                        this.lblRegisterUser.setVisible(false);
                        this.lblDepartments.setText("This Option is only for Database administrators");
                    }
                    this.btnLogout.setEnabled(true);
                    this.txtPassword.setEnabled(false);
                    this.txtUsername.setEnabled(false);
                    this.btnLogin.setEnabled(false);
                    
                }
                else{
                    JOptionPane.showMessageDialog(null, "Password not valid!", "Login failed!", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
        catch(Exception ex){
            ex.printStackTrace();
        }
    }//GEN-LAST:event_txtPasswordActionPerformed