/// <summary>
        /// Action lors de la sélection d'une liste
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ListBoxItem_Selected_1(object sender, RoutedEventArgs e)
        {
            //récupère les infos de la liste séléctionner
            ListBoxItem itemSelected = e.Source as ListBoxItem;

            selectedList = (ListOfTasks)itemSelected.DataContext;
            //change le titre de l'affichage des tâches
            txtBox_TitleList.Text = selectedList.Name;

            if (Tasks != null && cmbBoxSortTask.SelectedIndex == 0)
            {
                UpdateTasksIndex();
            }

            //ajoute les tâches affilié à la liste  depuis la base de données dans la liste
            Tasks = MyGlobals.databaseHandler.TaskDAO.GetAllTaskByListID(selectedList.ID, MyGlobals.databaseHandler.PriorityDAO.GetAllPriority());
            SortingTask();
            TotalTasksUpdate();
            DataContext = this;

            //active et désactive des contrôles
            Button_AddTask.IsEnabled            = true;
            menuItem_addTask.IsEnabled          = true;
            menuItem_DeleteListOfTask.IsEnabled = true;
            menuItem_UpdateListOfTask.IsEnabled = true;
            menuItem_EdiTask.IsEnabled          = false;
            menuItem_DeleteTask.IsEnabled       = false;
            BorderComment.Visibility            = Visibility.Hidden;
        }
Ejemplo n.º 2
0
 public RenameListAction(DatabaseHandler databaseHandler, ListOfTasks list, string newName)
 {
     this.databaseHandler = databaseHandler;
     this.listUpdated     = list;
     this.oldName         = this.listUpdated.Name;
     this.newName         = newName;
 }
        /// <summary>
        /// Ajoute une nouvelle liste et rentre en mode edition de son titre
        /// </summary>
        private void AddList()
        {
            ListOfTasks list = new ListOfTasks("NewList", lists.Count);

            /*AddListAction addListAction = new AddListAction(list,MyGlobals.databaseHandler,lists);
             * actionManager.RecordAction(addListAction);*/
            //isListAdded = true;

            //ajoute la liste dans la base de donnée et récupère l'id attribué par la base de donnée à la liste ajouté
            MyGlobals.databaseHandler.ListDAO.Add(list);
            list.ID = MyGlobals.databaseHandler.ListDAO.getLastAddedListID();
            lists.Add(list);

            //selectionne le listboxitem ajouté et focus la vue dessus
            listBox_listOfTasks.SelectedItem = listBox_listOfTasks.Items[listBox_listOfTasks.Items.Count - 1];
            listBox_listOfTasks.ScrollIntoView(listBox_listOfTasks.SelectedItem);
            listBox_listOfTasks.UpdateLayout();

            ListBoxItem listBoxItem = (ListBoxItem)listBox_listOfTasks.ItemContainerGenerator.ContainerFromIndex(listBox_listOfTasks.Items.Count - 1);
            //affiche la textbox pour éditer le titre de la liste
            TextBox target = getTextBoxFromLisboxItem("txtBoxNameList", listBoxItem);

            target.Visibility = Visibility.Visible;
            target.Focus();
            target.SelectAll();
        }
Ejemplo n.º 4
0
        public DeleteListAction(ObservableCollection <ListOfTasks> lists, int indexList, DatabaseHandler databaseHandler)
        {
            this.lists     = lists;
            this.indexList = indexList;
            deletedList    = lists[indexList];

            this.databaseHandler = databaseHandler;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Supprime la liste de la base de données
        /// </summary>
        /// <param name="list"> liste à supprimer</param>
        public void DeleteList(ListOfTasks list)
        {
            string        query     = String.Format("DELETE FROM {0}  WHERE {1} = @listID ", DatabaseBuild.LIST_TABLE_NAME, DatabaseBuild.LIST_KEY);
            SQLiteCommand myCommand = new SQLiteCommand(query, database.myConnection);

            database.OpenConnection();
            myCommand.Parameters.AddWithValue("@listID", list.ID);
            myCommand.ExecuteNonQuery();
            database.CloseConnection();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Met à jour le nom de la lite sur la base de données
        /// </summary>
        /// <param name="list">liste à modifier</param>
        public void UpdateListName(ListOfTasks list)
        {
            string        query     = String.Format("UPDATE {0} SET {1} = @nameList WHERE {2} = @listID ", DatabaseBuild.LIST_TABLE_NAME, DatabaseBuild.LIST_NAME, DatabaseBuild.LIST_KEY);
            SQLiteCommand myCommand = new SQLiteCommand(query, database.myConnection);

            database.OpenConnection();
            myCommand.Parameters.AddWithValue("@nameList", list.Name);
            myCommand.Parameters.AddWithValue("@listID", list.ID);

            myCommand.ExecuteNonQuery();
            database.CloseConnection();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Ajout d'une liste sur la base de donnée
        /// </summary>
        /// <param name="list">liste à ajouté</param>
        public void Add(ListOfTasks list)
        {
            string query = String.Format("INSERT INTO {0} ( {1} , {2} ) VALUES (@name , @index)", DatabaseBuild.LIST_TABLE_NAME, DatabaseBuild.LIST_NAME, DatabaseBuild.LIST_INDEX);

            SQLiteCommand myCommand = new SQLiteCommand(query, database.myConnection);

            database.OpenConnection();
            myCommand.Parameters.AddWithValue("@name", list.Name);
            myCommand.Parameters.AddWithValue("@index", list.IndexArray);
            myCommand.ExecuteNonQuery();
            database.CloseConnection();
        }
Ejemplo n.º 8
0
 public AddListAction(ListOfTasks listAdded, DatabaseHandler databaseHandler, ObservableCollection <ListOfTasks> lists)
 {
     this.listAdded       = listAdded;
     this.databaseHandler = databaseHandler;
     this.lists           = lists;
 }