| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 
 | package java2015;
 
import java.awt.Color;
 
public class AuthentificationClient extends JFrame {
 
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField textField;
	private JPasswordField passwordField;
	static String s3;
	static String s6;
	private JTextField textField_1;
	private JPasswordField passwordField_1;
	Boolean exist;
 
	/**
         * Launch the application.
         */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					AuthentificationClient frame = new AuthentificationClient();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
 
	/**
         * Create the frame.
         */
	public AuthentificationClient() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 786, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
 
		textField = new JTextField();
		textField.setColumns(10);
 
		JButton btnNewButton = new JButton("Continuer");
		btnNewButton.addActionListener(new ActionListener() {
			@SuppressWarnings("null")
			public void actionPerformed(ActionEvent e) {
 
				String s1=textField_1.getText();
				@SuppressWarnings("deprecation")
				String s2=passwordField_1.getText();
 
				String s4=textField.getText();
				@SuppressWarnings("deprecation")
				String s5=passwordField.getText();
 
				s3=s1+s2;
 
				Connexion c=new Connexion();
				Connection conn=null;
				Statement stat1=null;
				ResultSet res=null;
 
     try {
					if (!(s4.isEmpty()) &&  !(s5.isEmpty())){
						c.Connexion();
		                conn=c.getConnect();
    				String  sql1="SELECT Password FROM gestion_aeroport.utilisateurs WHERE Login='"+s4+"'";
                    stat1= (Statement) conn.createStatement();
                    res = stat1.executeQuery(sql1);
 
            			if(res.next())
            			 {
            			 String motDePasse = res.getString(1);
            			 if(motDePasse.equals(s5))
            			 {
            				 JOptionPane.showMessageDialog(null,"Connexion réussie ! ","Success",JOptionPane.PLAIN_MESSAGE);
             				EspaceClient espClient = new EspaceClient();
            				espClient.setVisible(true);	 
            			 }
 
 
            				 else {
            				 JOptionPane.showMessageDialog(null,"Mot de passe incorrect ! ","Error",1);}
            			 }
 
            				 else {
            				 JOptionPane.showMessageDialog(null,"Login incorrect ! ","Error",1);
            				 }
 
					}
 
 
            			else if (!(s1.isEmpty()) && !(s2.isEmpty()))
 
            			{
 
            				c.Connexion();
                            conn=c.getConnect();
            				Statement statX=null;
            				ResultSet resX=null;
            				PreparedStatement stX=null;
 
            				String  sqlX="SELECT Password FROM gestion_aeroport.utilisateurs WHERE Login='"+s1+"'";
                            statX= (Statement) conn.createStatement();
                            resX = statX.executeQuery(sqlX);
                			if(resX.next())
                			 {
                			 String motDePasseX = resX.getString(1);
                			 if(motDePasseX.equals(s2))
                			 {
                				 JOptionPane.showMessageDialog(null,"Login existant! ","Error",JOptionPane.PLAIN_MESSAGE);
 
                			 }
                			else {
                				 JOptionPane.showMessageDialog(null,"Compte crée ! ","Success",1);
                                 stX.setString(1, s1);
                                 stX.setString(2, s2);
                                 stX.setString(3, s3);
                                 stX.setString(4,"client");
                                 stX.executeUpdate();
                   				EspaceClient espClient = new EspaceClient();
                 				espClient.setVisible(true);	
                 				 }
 
                			 }   
 
 
                    }
 
			}
            catch (Exception e1) {
        	e1.printStackTrace();
            }
			}
 
		});
 
		JLabel lblNewLabel = new JLabel("Login:");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
 
		JLabel lblNewLabel_1 = new JLabel("Mot de passe :");
		lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
 
		passwordField = new JPasswordField();
 
		JLabel lblNewLabel_2 = new JLabel("Acc\u00E8s membre");
		lblNewLabel_2.setForeground(new Color(255, 0, 0));
		lblNewLabel_2.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 14));
 
		textField_1 = new JTextField();
		textField_1.setColumns(10);
 
		JLabel label = new JLabel("Login:");
		label.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
 
		JLabel label_1 = new JLabel("Mot de passe:");
		label_1.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 11));
 
		JLabel lblNouveauMembre = new JLabel("Nouveau membre");
		lblNouveauMembre.setForeground(Color.RED);
		lblNouveauMembre.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 14));
		contentPane.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
				ColumnSpec.decode("81px"),
				FormFactory.UNRELATED_GAP_COLSPEC,
				ColumnSpec.decode("223px"),
				ColumnSpec.decode("32px"),
				ColumnSpec.decode("79px"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("78px"),
				ColumnSpec.decode("18px"),
				ColumnSpec.decode("221px:grow"),},
			new RowSpec[] {
				FormFactory.PARAGRAPH_GAP_ROWSPEC,
				RowSpec.decode("25px"),
				FormFactory.PARAGRAPH_GAP_ROWSPEC,
				RowSpec.decode("23px"),
				RowSpec.decode("32px"),
				RowSpec.decode("20px"),
				RowSpec.decode("80px"),
				RowSpec.decode("23px"),}));
		contentPane.add(label_1, "8, 6, left, center");
		contentPane.add(lblNouveauMembre, "10, 2, center, fill");
		contentPane.add(lblNewLabel, "2, 4, fill, center");
		contentPane.add(textField, "4, 4, fill, bottom");
		contentPane.add(label, "8, 4, fill, center");
		contentPane.add(textField_1, "10, 4, fill, top");
		contentPane.add(lblNewLabel_1, "2, 6, left, center");
		contentPane.add(passwordField, "4, 6, fill, top");
 
		passwordField_1 = new JPasswordField();
		contentPane.add(passwordField_1, "10, 6, fill, default");
		contentPane.add(btnNewButton, "6, 8, left, top");
		contentPane.add(lblNewLabel_2, "4, 2, center, fill");
	}
  public static String	idActuel(){
	return s3;
}
} | 
Partager