private void Btn_Connecter_Click(object sender, RoutedEventArgs e)
        {
            //UtilisateurConnecte utilisateurConnecte2 = UtilisateurConnecte.Instance;
            //utilisateurConnecte2.Identifiant = "login";
            //utilisateurConnecte2.Role = "role";
            //RC otherWindow2 = new RC();
            //otherWindow2.Show();
            //this.Close();
            //return;

            // on cherche si c'est un client
            IClientMapper lClientMapper = (IClientMapper)DataMapperFactory.GetDataMapperFactory().GetClientMapper();
            DataTable     clients       = lClientMapper.FindAll();

            foreach (DataRow row in clients.Rows)
            {
                if (TextBox_Identifiant.Text == row["pseudo"].ToString() &&
                    TextBox_Motdepasse.Password == row["mot_de_passe"].ToString())
                {
                    // un client s'est connecté
                    UtilisateurConnecte utilisateurConnecte = UtilisateurConnecte.Instance;
                    utilisateurConnecte.Identifiant = TextBox_Identifiant.Text;
                    utilisateurConnecte.Role        = "Client";
                    FenetreClient otherWindow = new FenetreClient();
                    otherWindow.Show();
                    this.Close();
                    return;
                }
            }

            // on cherche si c'est un employé
            IEmployeMapper lEmployeMapper = (IEmployeMapper)DataMapperFactory.GetDataMapperFactory().GetEmployeMapper();
            DataTable      employes       = lEmployeMapper.FindAll();

            foreach (DataRow row in employes.Rows)
            {
                if (TextBox_Identifiant.Text == row["pseudo"].ToString() &&
                    TextBox_Motdepasse.Password == row["mot_de_passe"].ToString())
                {
                    // un employé RC s'est connecté
                    UtilisateurConnecte utilisateurConnecte = UtilisateurConnecte.Instance;
                    utilisateurConnecte.Identifiant = TextBox_Identifiant.Text;
                    utilisateurConnecte.Role        = row["fonction"].ToString();
                    RC otherWindow = new RC();
                    otherWindow.Show();
                    this.Close();
                    return;
                }
            }

            MessageBox.Show("Identifiant ou mot de passe incorrect.");
        }
Beispiel #2
0
        public SelectionnerClientContext()
        {
            IClientMapper lClientMapper = (IClientMapper)DataMapperFactory.GetDataMapperFactory().GetClientMapper();
            DataTable     clients       = lClientMapper.FindAll();

            foreach (DataRow row in clients.Rows)
            {
                Guid guidClient;
                if (Guid.TryParse(row["iD"].ToString(), out guidClient))
                {
                    listeClient.Add(new ClientSelection {
                        NomRaison  = row["nom"].ToString() + " " + row["prenom"].ToString() + " " + row["raison_sociale"].ToString(),
                        GuidClient = guidClient
                    });
                }
                else
                {
                    Debug.WriteLine("Client non trouvé");
                }
            }
        }