public override ValidationResult Validate() { //Enregistrer if (TachesProdAjoutees.Count == 0) { return(new ValidationResult(true)); } else { DALTache.EnregistrerTachesProd(TachesProdAjoutees.ToList()); return(new ValidationResult(true)); } }
private void SupprimerTache(object o) { TacheApercu tache = (TacheApercu)CollectionViewSource.GetDefaultView(TachesProdAjoutees).CurrentItem; TachesProdAjoutees.Remove(tache); }
//private ICommand _cmdEnregistrer; //public ICommand CmdEnregistrer //{ // get // { // if (_cmdEnregistrer == null) // _cmdEnregistrer = new RelayCommand(ValiderSaisie, TesterConsultation); // return _cmdEnregistrer; // } //} #endregion #region Méthodes privées private void AjouterTache(object o) { //Gestion de la validation des saisies string pattern = @"^\d{1,4}[\.]?\d?$"; Regex rgx = new Regex(pattern); if (string.IsNullOrEmpty(Libelle)) { MessageBox.Show("Le libellé de la tâche est obligatoire!", "Attention", MessageBoxButton.OK); } else if (string.IsNullOrEmpty(DureePrevue)) { MessageBox.Show("La durée prévue est obligatoire!", "Attention", MessageBoxButton.OK); } else if (!rgx.IsMatch(DureePrevue)) { MessageBox.Show("La durée prévue doit être saisie __._!", "Attention", MessageBoxButton.OK); } else if (!string.IsNullOrEmpty(DureeRestante) && !rgx.IsMatch(DureeRestante)) { MessageBox.Show("La durée restante doit être saisie __._!", "Attention", MessageBoxButton.OK); } else { _moduleCourant = (Module)CollectionViewSource.GetDefaultView(Modules).CurrentItem; _personneCourante = (Personne)CollectionViewSource.GetDefaultView(Personnes).CurrentItem; _activiteCourante = (Activite)CollectionViewSource.GetDefaultView(_personneCourante.Activites).CurrentItem; TacheApercu tache = new TacheApercu(); tache.Login = _personneCourante.CodePersonne; tache.IdTache = new Guid(); tache.NomTache = Libelle; tache.Annexe = false; tache.CodeActivite = _activiteCourante.CodeActivite; tache.Description = NouvelleTache.Description; tache.CodeModule = _moduleCourant.CodeModule; tache.CodeLogiciel = _logicielCourant.CodeLogiciel; tache.CodeVersion = _versionCourante.NumVersion; DureePrevue = DureePrevue.Replace(".", ","); float i; if (float.TryParse(DureePrevue, out i)) { tache.DureePrevue = i; } if (string.IsNullOrEmpty(DureeRestante)) { tache.DureeRestante = i; } else { DureeRestante = DureeRestante.Replace(".", ","); float j; if (float.TryParse(DureeRestante, out j)) { tache.DureeRestante = j; } } TachesProdAjoutees.Add(tache); } NouvelleTache = new TacheApercu(); Libelle = null; DureePrevue = null; DureeRestante = null; }