Exemplo n.º 1
0
            public static void UpdateTasksForDay(DailyTasks dailyTasks)
            {
                using (var con = new SQLiteConnection(Helper.connectionString))
                {
                    con.Open();
                    using (var cmd = new SQLiteCommand(con))
                    {
                        cmd.CommandText = @"UPDATE Tasks SET TasksForTheDay = @tasks WHERE Day = @day";
                        cmd.Parameters.AddWithValue("@tasks", dailyTasks.TasksForTheDay);
                        cmd.Parameters.AddWithValue("@day", dailyTasks.Day.ToString());

                        var a = cmd.ExecuteNonQuery();
                    }
                    con.Close();
                }
            }
Exemplo n.º 2
0
            public static List <DailyTasks> GetTasksForTheWeek()
            {
                List <DailyTasks> tasksForTheWeek = new List <DailyTasks>();

                foreach (var day in (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek)))
                {
                    if (day == DayOfWeek.Sunday || day == DayOfWeek.Saturday)
                    {
                        continue;
                    }

                    DailyTasks dailyTasks = new DailyTasks();
                    using (var con = new SQLiteConnection(Helper.connectionString))
                    {
                        con.Open();
                        using (var cmd = new SQLiteCommand(con))
                        {
                            cmd.CommandText = @"SELECT * FROM Tasks WHERE Day = @day";
                            cmd.Parameters.AddWithValue("@day", day.ToString());

                            using (var reader = cmd.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    Enum.TryParse(reader["Day"].ToString(), out DayOfWeek parsedDay);

                                    dailyTasks.Day            = parsedDay;
                                    dailyTasks.TasksForTheDay = reader["TasksForTheDay"].ToString();
                                }
                            }
                        }
                        con.Close();
                    }

                    tasksForTheWeek.Add(dailyTasks);
                }

                return(tasksForTheWeek);
            }
Exemplo n.º 3
0
            public static DailyTasks GetTasksForTheDay(DayOfWeek day)
            {
                DailyTasks dailyTasks = new DailyTasks();

                using (var con = new SQLiteConnection(Helper.connectionString))
                {
                    con.Open();
                    using (var cmd = new SQLiteCommand(con))
                    {
                        cmd.CommandText = @"SELECT * FROM Tasks WHERE Day = '" + day.ToString() + "'";

                        using (var reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                dailyTasks.Day            = day;
                                dailyTasks.TasksForTheDay = reader["TasksForTheDay"].ToString();
                            }
                        }
                    }
                    con.Close();
                }
                return(dailyTasks);
            }