/// <summary>
        /// Save la nouvelle task en bdd si besoin
        /// Incrémente le nombre d'exécution de cette task et ferme cette fenêtre
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SaveTask(object sender, RoutedEventArgs e)
        {
            Task newTask = new Task();
            var  name    = "";

            // On récupère le nom
            if (txtBox.Text.Trim() == "")
            {
                name            = comboTask.Text;
                newTask.Libelle = name;
            }
            else
            {
                name = txtBox.Text;

                // Insertion de la task en BDD si elle n'existe pas
                newTask.Libelle = name;
                try
                {
                    SqliteDbAccess.SaveTasks(newTask);
                } catch (Exception) { }
            }
            SqliteDbAccess.UpdateCountTask(newTask);
            // On change la variable name de la dont on hérite
            MainWindow mainWindow = Owner as MainWindow;

            mainWindow.monTimerName = name;

            this.Close();
        }
        public TimerName()
        {
            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            // Récupération des tasks en BDD
            comboTask.Items.Clear();
            foreach (Task task in SqliteDbAccess.LoadTask())
            {
                comboTask.Items.Add(task);
            }
        }
Example #3
0
        /// <summary>
        /// Charge l'historique des pomodoro
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadHistorique(object sender, RoutedEventArgs e)
        {
            viewHistorique.Items.Clear();
            var taskList = SqliteDbAccess.LoadTask();

            foreach (Task task in taskList)
            {
                viewHistorique.Items.Add($"{task.Libelle} {task.Count}");
            }
            if (taskList.Count == 0)
            {
                viewHistorique.Items.Add($"No task found");
            }
        }