Exemple #1
0
 private void BtnSupprimer_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Utilisateur T = TabUtilisateur.SelectedItem as Utilisateur;
         T.Supprime = true;
         T.Update();
         ListUtilisateur.Remove(T);
         TabUtilisateur.Items.Refresh();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #2
0
        private void OnSignupCommand(object obj)
        {
            Signup = new SignupWindow(this);
            ButtonPressedEvent.GetEvent().Handler += CloseSignupWindow;
            Signup.ShowDialog();

            if (Signup.SignupVM.ClickOnSignup)
            {
                ListUtilisateur.Add(Signup.SignupVM.NewUtilisateur);
                XmlSerializer xs = new XmlSerializer(typeof(List <Utilisateur>));

                StreamWriter wr = new StreamWriter("Xml/listeUtilisateur.xml");

                xs.Serialize(wr, ListUtilisateur);
            }
        }
Exemple #3
0
        private void BtnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtPseudo.Text) ||
                    string.IsNullOrWhiteSpace(txtNomUtilisateur.Text) ||
                    string.IsNullOrWhiteSpace(txtPrenomsUtilisateur.Text) ||
                    string.IsNullOrWhiteSpace(txtBp.Text) ||
                    string.IsNullOrWhiteSpace(txtEmail.Text) ||
                    string.IsNullOrWhiteSpace(txtPassword.Password) ||
                    string.IsNullOrWhiteSpace(txtDateExpiration.Text) ||
                    string.IsNullOrWhiteSpace(txtTelephone.Text))
                {
                    Outils.BoxMessage("C");
                }
                else
                {
                    if (txtPassword.Password != txtPasswordComfirmed.Password)
                    {
                        MessageBox.Show("Veuillez saisir des mots de passe identique", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }


                    Utilisateur M = new Utilisateur();
                    M.Pseudo            = txtPseudo.Text;
                    M.NomUtilisateur    = txtNomUtilisateur.Text;
                    M.PrenomUtilisateur = txtPrenomsUtilisateur.Text;
                    M.BP        = txtBp.Text;
                    M.Telephone = txtTelephone.Text;
                    M.Email     = txtEmail.Text;
                    M.DateExpirationPassword = txtDateExpiration.SelectedDate;
                    M.EstSuperutilisateur    = chkSuperUser.IsChecked.Value;
                    M.Estactif = chkActif.IsChecked.Value;
                    if (txtPhoto.Source == null)
                    {
                        M.photo = null;
                    }
                    else
                    {
                        M.photo = Hex.ToHexString(ImageConverter.ToArray(ImageConverter.FromImage((BitmapSource)txtPhoto.Source)));
                    }

                    if (Id > 0)
                    {
                        M.Id = Id;
                        if (chkmdp.IsChecked.Value)
                        {
                            byte[]  B              = Encoding.UTF8.GetBytes(txtPassword.Password);
                            SHA1Cng sha1           = new SHA1Cng();
                            byte[]  result         = sha1.ComputeHash(B);
                            var     toStringResult = Hex.ToHexString(result);
                            M.MotDePasse = toStringResult;
                        }
                        M.Update();
                        Outils.BoxMessage("M");
                        LoadTabUtilisateur();
                        GriserChamps();
                        Id = 0;
                    }
                    else
                    {
                        if (Utilisateur.userExist(txtPseudo.Text))
                        {
                            MessageBox.Show("Veuillez saisir un autre pseudo, celui-ci existe déjà!!!", "mTransport", MessageBoxButton.OK, MessageBoxImage.Information);
                            return;
                        }
                        byte[]  B              = Encoding.UTF8.GetBytes(txtPassword.Password);
                        SHA1Cng sha1           = new SHA1Cng();
                        byte[]  result         = sha1.ComputeHash(B);
                        var     toStringResult = Hex.ToHexString(result);
                        M.MotDePasse = toStringResult;

                        M.Insert();
                        ListUtilisateur.Add(M);
                        TabUtilisateur.Items.Refresh();
                        Outils.BoxMessage("A");
                        GriserChamps();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }