private void btnCreateAccount_Click(object sender, RoutedEventArgs e)
        {
            Animations.AddSound(1);

            if (id_eleve.Text == "" || nom.Text == "" || prenom.Text == "" || password.Text == "")
            {
                InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox("عليك بملئ جميع الخانات");
                interfaceMessageBox.Show();
            }
            else
            {
                //Instancier un nouveau eleve et on le sauvegarde
                Eleve eleve = new Eleve();
                eleve.CreerCompte(id_eleve.Text.Trim(), password.Text.Trim(), nom.Text.Trim(), prenom.Text.Trim());
                this.Close();
            }
        }
Example #2
0
        /*------------------------------------------------------------------------------------*/
        public void changePassWord(string id_eleve, string passWord)
        {
            Eleve    eleve    = new Eleve();
            Securite securite = new Securite();
            string   password = securite.EncryptPassword(passWord.ToUpper());
            string   nom      = "ADMIN";
            string   prenom   = "ADMIN";

            eleve.Supprimer_Ligne_Eleve(id_eleve);
            try
            {
                /*
                 * il faut d'abord définir les éléments qu'on va insérer
                 * dans notre cas; nom,prenom,id_eleve,password
                 * (definir la requete d'insetion avec les paramete)
                 */
                string insertStmt = "INSERT INTO Eleve (id_eleve,password,nom,prenom)" +
                                    "VALUES(@id_eleve, @password, @nom, @prenom)";

                /*
                 * definir la connexion et la commande
                 */
                string path = System.IO.Directory.GetCurrentDirectory();
                string lien = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + path + "\\Etudiant.mdf;Integrated Security=True";
                using (SqlConnection conn = new SqlConnection(lien))
                    using (SqlCommand cmd = new SqlCommand(insertStmt, conn))
                    {
                        //definir les parametres et mettre leurs valeurs
                        cmd.Parameters.Add("@id_eleve", SqlDbType.NVarChar, 50).Value = id_eleve;
                        cmd.Parameters.Add("@password", SqlDbType.NVarChar, 50).Value = password;
                        cmd.Parameters.Add("@nom", SqlDbType.NVarChar, 50).Value      = nom;
                        cmd.Parameters.Add("@prenom", SqlDbType.NVarChar, 50).Value   = prenom;

                        // open connection, execute query, close connection
                        conn.Open();                              //ouvrir la connexion
                        int rowsInserted = cmd.ExecuteNonQuery(); //execution de la commande de l'instruction
                        conn.Close();                             //fermer la connexion
                    }
            }
            catch (Exception)
            {
                MessageBox.Show("            اوووووبس تاكد من معلوماتك \n\n\nلمزيد من المعلومات اضغط على زر المساعدة");
            }
        }
Example #3
0
 private void btnConnexion_Click(object sender, RoutedEventArgs e)
 //lorsque on clique sur le bouton pour se connecter
 {
     Animations.AddSound(1);
     if (txtUserName.Text.ToUpper() == "ADMIN")
     //Dans le cas ou l'administrateur se connecte on affiche l'interface d'administartion
     {
         Eleve ctd = new Eleve();
         int   c   = ctd.Connecter(txtUserName.Text.ToUpper(), txtPassword.Password.ToUpper());
         if (c == 1)
         {
             InterfaceAdministrateur interfaceadmin = new InterfaceAdministrateur();
             interfaceadmin.Show();
         }
         else
         {
             if (c == -1)
             {
                 InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox(" كلمة السر خاطئ");
                 interfaceMessageBox.Show();
                 errorImage.Visibility = System.Windows.Visibility.Visible;
             }
             else if (c == 0)
             {
                 InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox("اسم المستخدم خاطئ" + "\n" + " قم بفتح حساب جديد");
                 interfaceMessageBox.Show();
             }
         }
     }
     else
     {
         if ((txtUserName.Text == "") || (txtPassword.Password == ""))
         {
             InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox("عليك ملء كل الخانات");
             interfaceMessageBox.Show();
         }
         else
         {
             Eleve ctd = new Eleve();
             int   c   = ctd.Connecter(txtUserName.Text, txtPassword.Password);
             if (c == 1)
             //  si le nom d'utilisateur et le mot de passe sont justes
             {
                 this.NavigationService.Navigate(new InterfaceHomePage());
             }
             else
             {
                 if (c == -1)
                 // si le mot de passe est erroné
                 {
                     InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox(" كلمة السر خاطئ");
                     interfaceMessageBox.Show();
                     errorImage.Visibility = System.Windows.Visibility.Visible;
                 }
                 else if (c == 0)
                 //si le compte est inexistant
                 {
                     InterfaceMessageBox interfaceMessageBox = new InterfaceMessageBox("اسم المستخدم خاطئ" + "\n" + " قم بفتح حساب جديد");
                     interfaceMessageBox.Show();
                 }
             }
         }
     }
 }