public VMSaisieTache(string logiciel, float numVersion) { Personnes = DALPersonne.RecupererToutesPersonneActivite(Properties.Settings.Default.CodeDernierUtilisateur); Modules = DALLogiciel.RecupererModules(logiciel); PersonnesTachesProdAjoutees = new ObservableCollection <Personne>(); _logicielCourant = new Entity.Logiciel(); _logicielCourant.CodeLogiciel = logiciel; _versionCourante = new Entity.Version(); _versionCourante.NumVersion = numVersion; TachesProdAjoutees = new ObservableCollection <TacheApercu>(); NouvelleTache = new TacheApercu(); }
/// <summary> /// Affichage des différentes taches déjà enregistrée sur la personne connectée (prod et annexe) /// </summary> /// <param name="obj">Paramètre de la commande</param> private void AfficherTaches(object obj) { var selecLog = (Logiciel)CollectionViewSource.GetDefaultView(Logiciels).CurrentItem; var selecVer = (Entity.Version)CollectionViewSource.GetDefaultView(selecLog.Versions).CurrentItem; TachesProd.Clear(); TachesAnnexe.Clear(); HeuresRestantes = 8; if (Utilisateur.TachesProd != null) { var triProd = Utilisateur.TachesProd. Where(tp => tp.CodeLogiciel == selecLog.CodeLogiciel && tp.CodeVersion == selecVer.NumVersion).ToList(); if (triProd != null) { foreach (var tp in triProd) { if (tp.TravauxProd != null) { foreach (var trP in tp.TravauxProd) { if (trP.Date == DateTime.Today) { HeuresRestantes -= trP.Heures; } var tach = new TacheApercu(); tach.Date = trP.Date; tach.DureePrevue = tp.DureePrevue; tach.DureeRestante = tp.DureeRestante; tach.NomTache = tp.NomTache; tach.IdTache = tp.IdTache; TachesProd.Add(tach); break; } } } } } if (Utilisateur.TachesAnnexes != null) { var triAnnex = Utilisateur.TachesAnnexes.ToList(); if (triAnnex != null) { foreach (var ta in triAnnex) { if (ta.TravauxAnnexes != null) { foreach (var trA in ta.TravauxAnnexes) { if (trA.Date == DateTime.Today) { HeuresRestantes -= trA.Heures; } var tach = new TacheApercu(); tach.NomTache = ta.NomTache; tach.IdTache = ta.IdTache; tach.CodeActivite = ta.CodeActivite; tach.Date = trA.Date; TachesAnnexe.Add(tach); break; } } } } } }
/// <summary> /// Lecture du dataread retourné pr la requête SQL de récupération des Taches /// </summary> /// <param name="listTache">Liste de TacheApercu</param> /// <param name="reader">donnée du reader</param> private static void RecupererTachesApercuFromDataReader(List <TacheApercu> listTache, SqlDataReader reader) { TacheApercu tache = new TacheApercu(); if (reader["IdTache"] != DBNull.Value) { tache.IdTache = (Guid)reader["IdTache"]; } if (reader["Libelle"] != DBNull.Value) { tache.NomTache = (string)reader["Libelle"]; } if (reader["Annexe"] != DBNull.Value) { tache.Annexe = (bool)reader["Annexe"]; } if (reader["CodeActivite"] != DBNull.Value) { tache.CodeActivite = (string)reader["CodeActivite"]; } if (reader["Login"] != DBNull.Value) { tache.Login = (string)reader["Login"]; } if (reader["Description"] != DBNull.Value) { tache.Description = (string)reader["Description"]; } if (reader["Numero"] != DBNull.Value) { tache.NumTache = (int)reader["Numero"]; } if (reader["DureePrevue"] != DBNull.Value) { tache.DureePrevue = (float)reader["DureePrevue"]; } if (reader["DureeRestanteEstimee"] != DBNull.Value) { tache.DureeRestante = (float)reader["DureeRestanteEstimee"]; } if (reader["CodeModule"] != DBNull.Value) { tache.CodeModule = (string)reader["CodeModule"]; } if (reader["NumeroVersion"] != DBNull.Value) { tache.CodeVersion = (float)reader["NumeroVersion"]; } if (reader["CodeLogicielVersion"] != DBNull.Value) { tache.CodeLogiciel = (string)reader["CodeLogicielVersion"]; } if (reader["DateTravail"] != DBNull.Value) { tache.Date = (DateTime)reader["DateTravail"]; } if (reader["Heures"] != DBNull.Value) { tache.Heures = (float)reader["Heures"]; } if (reader["TauxProductivite"] != DBNull.Value) { tache.TauxProductivite = (float)reader["TauxProductivite"]; } listTache.Add(tache); }
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; }