示例#1
0
        public void removeItem(CustomTreeViewItem item)
        {
            try
            {
                int i     = 0;
                int index = -1;
                while (i < m_Tasks.Count && index < 0)
                {
                    index = m_Tasks[i].Items.IndexOf(item);
                    ++i;
                }

                if (item.parent != null && index >= 0)
                {
                    int parent_index = m_Tasks.IndexOf(item.parent);
                    m_Tasks[parent_index].Items.Remove(item);
                }
                else if (item.parent == null)
                {
                    m_Tasks.Remove(item);
                }
                taches t = req.getSTaches(bdd, item.Title.Text);
                req.supTaches(bdd, t);
            }
            catch (Exception)
            {
                MessageBox.Show("Une erreur est survenu lors de l'enregistrement des tâches en attente: " + "Veuillez réessayer ultérieurement et redémarrer l'application", "Media Task Manager", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#2
0
        public taches getSTaches(mediametrieEntities bdd, string label)
        {
            taches task = (from t in bdd.taches1
                           where (t.label_tache == label)
                           select t).FirstOrDefault();;

            return(task);
        }
示例#3
0
 public void change_container_Day(mediametrieEntities bdd, taches laTache)
 {
     if (laTache.label_tache_parent == null)
     {
         laTache.label_container = "Tâches de la journée";
         bdd.SaveChanges();
     }
 }
示例#4
0
 public void change_container_boite_rec(mediametrieEntities bdd, taches laTache)
 {
     if (laTache.label_tache_parent == null)
     {
         laTache.label_container = "Boite de réception";
         bdd.SaveChanges();
     }
 }
示例#5
0
        /**************************************************************/
        /*                      Requete Suppression                   */
        /**************************************************************/

        public void supTaches(mediametrieEntities bdd, taches laTaches)
        {
            taches s = getSTaches(bdd, laTaches.label_tache);

            if (s != null)
            {
                bdd.taches1.Remove(laTaches);
                bdd.SaveChanges();
            }
        }
示例#6
0
        /**************************************************************/
        /*                    Requete Modification                    */
        /**************************************************************/

        public void modifTaches(mediametrieEntities bdd, taches laTaches)
        {
            /* Ajouter le changement  */
            taches original = bdd.taches1.Find(laTaches.label_tache);

            if (original != null)
            {
                bdd.Entry(original).CurrentValues.SetValues(laTaches);
                original.label_container    = laTaches.label_container;
                original.label_tache        = laTaches.label_tache;
                original.label_tache_parent = laTaches.label_tache_parent;
                original.date_debut         = laTaches.date_debut;
                original.date_fin           = laTaches.date_fin;
                original.commentaire        = laTaches.commentaire;
                original.effectuer          = laTaches.effectuer;
                bdd.SaveChanges();
            }
        }
示例#7
0
        private void change_label(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount == 2)
            {
                TextBox textBox = new TextBox();
                textBox.Text = Title.Text;

                chkBox.Content   = textBox;
                textBox.KeyDown += (o, ev) =>
                {
                    if (ev.Key == Key.Enter || ev.Key == Key.Escape)
                    {
                        if (Title.Text != textBox.Text)
                        {
                            if (req.checkTaches(bdd, Title.Text) == true)
                            {
                                taches t = req.getSTaches(bdd, Title.Text);
                                req.supTaches(bdd, t);
                            }
                            if (req.checkTaches(bdd, textBox.Text) == true)
                            {
                                MessageBox.Show("Déjà une tache avec ce nom");
                                textBox.Text = Title.Text;
                                return;
                            }
                        }
                        Title.Text     = textBox.Text;
                        chkBox.Content = Title;
                        ev.Handled     = true;
                    }
                };
                textBox.LostFocus += (o, ev) =>
                {
                    Title.Text     = textBox.Text;
                    chkBox.Content = Title;
                    ev.Handled     = true;
                };
            }
            else
            {
                this.IsSelected = true;
            }
            e.Handled = true;
        }
示例#8
0
 /// <summary>
 /// Ajout une sous-tâches
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void newTask_OnSaveNewSubTask(object sender, RoutedEventArgs e)
 {
     try
     {
         CustomTreeViewItem selected = treeView.SelectedItem as CustomTreeViewItem;
         if (selected != null)
         {
             if (selected.parent != null)
             {
                 selected = selected.parent;
             }
             string content = new TextRange(newTask.comment.Document.ContentStart, newTask.comment.Document.ContentEnd).Text;
             string Name    = "Sous-Tache";
             int    i       = 0;
             while (selected.Contains(Name + i) != -1)
             {
                 ++i;
             }
             Name += i;
             m_containers[currentIndex].addItem(selected, Name, newTask.beginDatePicker.Text, newTask.endDatePicker.Text, content, false);
             taches newSubTask = new taches();
             newSubTask.label_tache        = Name;
             newSubTask.commentaire        = content;
             newSubTask.date_debut         = newTask.beginDatePicker.SelectedDate;
             newSubTask.date_fin           = newTask.endDatePicker.SelectedDate;
             newSubTask.label_tache_parent = selected.Title.Text;
             newSubTask.effectuer          = false;
             req.ajoutTaches(bdd, newSubTask);
             newTask.Close();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Une erreur est survenu lors de l'ajout d'une sous-tâches: " + "Veuillez réessayer ultérieurement et redémarrer l'application", "Media Task Manager", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#9
0
 private void saveTask_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         foreach (Container c in m_containers)
         {
             if (req.checkContainer(bdd, c.Name) == false)
             {
                 req.ajoutContainer(bdd, new container()
                 {
                     label = c.Name
                 });
             }
             foreach (CustomTreeViewItem i in c.m_Tasks)
             {
                 if (i != null)
                 {
                     string parent_task;
                     if (i.parent == null)
                     {
                         parent_task = null;
                     }
                     else
                     {
                         parent_task = i.parent.Name;
                     }
                     taches t = new taches()
                     {
                         label_container = c.Name, label_tache = i.Title.Text, label_tache_parent = parent_task, commentaire = i.comment, date_debut = DateTime.Parse(i.dateBegin), date_fin = DateTime.Parse(i.dateEnd), effectuer = i.chkBox.IsChecked
                     };
                     // taches b_t = req.getSTaches(bdd, i.Title.Text);
                     if (req.checkTaches(bdd, t.label_tache) != false)
                     {
                         req.modifTaches(bdd, t);
                     }
                     else
                     {
                         req.ajoutTaches(bdd, t);
                     }
                     foreach (CustomTreeViewItem i1 in i.Items)
                     {
                         taches t1 = new taches()
                         {
                             label_container = null, label_tache = i1.Title.Text, label_tache_parent = i.Title.Text, commentaire = i1.comment, date_debut = DateTime.Parse(i1.dateBegin), date_fin = DateTime.Parse(i1.dateEnd), effectuer = i1.chkBox.IsChecked
                         };
                         if (req.checkTaches(bdd, i1.Title.Text) != false)
                         {
                             req.modifTaches(bdd, t1);
                         }
                         else
                         {
                             req.ajoutTaches(bdd, t1);
                         }
                     }
                 }
             }
         }
         MessageBox.Show("Les modifications ont bien été ajoutée", "Media Task Manager", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception)
     {
         MessageBox.Show("Une erreur est survenu lors de l'ajout d'une tâche : " + "Veuillez réessayer ultérieurement et redémarrer l'application", "Media Task Manager", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#10
0
        /**************************************************************/
        /*                       Requete Ajout                        */
        /**************************************************************/

        public void ajoutTaches(mediametrieEntities bdd, taches laTaches)
        {
            bdd.taches1.Add(laTaches);
            bdd.SaveChanges();
        }