//Validation des données private void BtnValider_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txtMatricule.Text) || string.IsNullOrWhiteSpace(txtMarque.Text) || string.IsNullOrWhiteSpace(txtModele.Text) || string.IsNullOrWhiteSpace(txtNbrePlace.Text) || string.IsNullOrWhiteSpace(txtAnneeAchat.Text) || string.IsNullOrWhiteSpace(txtNoChassis.Text)) { Outils.BoxMessage("C"); } else { TeteEngin T = new TeteEngin(); T.Matricule = txtMatricule.Text; T.NbrePlaces = int.Parse(txtNbrePlace.Text); T.Marque = txtMarque.Text; T.AnneeAchat = int.Parse(txtAnneeAchat.Text); T.Modele = txtModele.Text; T.NoChassis = txtNoChassis.Text; if (Id > 0) { T.Id = Id; T.Update(); Outils.BoxMessage("M"); LoadTabTeteEngin(); GriserChamps(); Id = 0; } else { if (Outils.VerifNoChassis(txtNoChassis.Text)) { MessageBox.Show("Le No de chassis: " + txtNoChassis.Text + " existe déjà !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error); txtNoChassis.Focus(); return; } //T.Matricule = Outils.GenMatricule(); T.Insert(); ListTeteEngin.Add(T); TabTeteEngin.Items.Refresh(); Outils.BoxMessage("A"); GriserChamps(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
private void BtnValider_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txtDesignation.Text) || string.IsNullOrWhiteSpace(txtDescription.Text) || string.IsNullOrWhiteSpace(txtDestination.Text) || string.IsNullOrWhiteSpace(txtDateArriveePrevue.Text) || string.IsNullOrWhiteSpace(txtDateDepartPrevue.Text) || string.IsNullOrWhiteSpace(txtDepart.Text) || cmbVehicule.SelectedIndex == -1) { Outils.BoxMessage("C"); } else { if (Outils.VerifDate((DateTime)txtDateDepartPrevue.SelectedDate, (DateTime)txtDateArriveePrevue.SelectedDate, "date départ prévue", "date")) { return; } Voyage T = new Voyage(); T.Designation = txtDesignation.Text; T.Depart = txtDepart.Text; T.Destination = txtDestination.Text; T.DateDepartPrevue = (DateTime)txtDateDepartPrevue.SelectedDate; T.DateArriveePrevue = (DateTime)txtDateArriveePrevue.SelectedDate; T.Description = txtDescription.Text; var c = cmbVehicule.SelectedItem as LoadCombo; T.IdVehicule = c.Id; if (FenVoyage.checkTravelDateOfVehicleSelected((DateTime)txtDateDepartPrevue.SelectedDate, (DateTime)txtDateArriveePrevue.SelectedDate, c.Id)) { MessageBox.Show("Le véhicule sélectionné est déjà enregistrer sur un voyage pour les dates du " + txtDateDepartPrevue.SelectedDate + " au " + txtDateArriveePrevue.SelectedDate + " !!!", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (Id > 0) { T.Id = Id; T.Update(); Outils.BoxMessage("M"); LoadTabVoyage(); GriserChamps(); Id = 0; } else { T.Insert(); var b = Vehicule.getVehicule(c.Id); T.Vehicule = b; ListVoyage.Add(T); TabVoyage.Items.Refresh(); Outils.BoxMessage("A"); GriserChamps(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnValider_Click(object sender, RoutedEventArgs e) { try { if (string.IsNullOrWhiteSpace(txtNomSociete.Text) || string.IsNullOrWhiteSpace(txtAdresse.Text) || string.IsNullOrWhiteSpace(txtBP.Text) || string.IsNullOrWhiteSpace(txtQuartier.Text) || string.IsNullOrWhiteSpace(txtVille.Text) || string.IsNullOrWhiteSpace(txtPays.Text) || string.IsNullOrWhiteSpace(txtTelephone1.Text) || string.IsNullOrWhiteSpace(txtEmail.Text) || string.IsNullOrWhiteSpace(txtSiteWeb.Text) || string.IsNullOrWhiteSpace(txtNomDirecteur.Text) || string.IsNullOrWhiteSpace(txtPrenomDirecteur.Text)) { Outils.BoxMessage("C"); } else { RaisonSociale M = new RaisonSociale(); M.NomSociete = txtNomSociete.Text; M.Adresse = txtAdresse.Text; M.BoitePostale = txtBP.Text; M.Quartier = txtQuartier.Text; M.Ville = txtVille.Text; M.Pays = txtPays.Text; M.Telephone1 = txtTelephone1.Text; M.Telephone2 = txtTelephone2.Text; M.Email = txtEmail.Text; M.Fax = txtFax.Text; M.Siteweb = txtSiteWeb.Text; M.NomDirecteur = txtNomDirecteur.Text; M.PrenomDirecteur = txtPrenomDirecteur.Text; if (txtLogo.Source == null) { M.Logo = null; } else { M.Logo = Hex.ToHexString(ImageConverter.ToArray(ImageConverter.FromImage((BitmapSource)txtLogo.Source))); } if (txtSignature.Source == null) { M.SignatureDirecteur = null; } else { M.SignatureDirecteur = Hex.ToHexString(ImageConverter.ToArray(ImageConverter.FromImage((BitmapSource)txtSignature.Source))); } if (Id > 0) { M.Id = Id; M.Update(); Outils.BoxMessage("M"); GriserChamps(); Id = 0; } else { M.Insert(); Outils.BoxMessage("A"); GriserChamps(); } getRs(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }