Ejemplo n.º 1
0
        public async Task <List <ScheData> > ReadData()
        {
            List <ScheData> entries = new List <ScheData>();

            string dbpath = Path.Combine(ApplicationData.Current.LocalFolder.Path, DB_FILE);

            using (SqliteConnection db = new SqliteConnection($"Filename={dbpath}"))
            {
                db.Open();
                SqliteCommand    selectCommand = new SqliteCommand("SELECT * FROM sche", db);
                SqliteDataReader query         = await selectCommand.ExecuteReaderAsync();

                while (await query.ReadAsync())
                {
                    Debug.WriteLine(query["Date"].ToString());
                    ScheData Lobj = new ScheData()
                    {
                        ID       = (long)query["ID"],
                        Content  = query["Content"].ToString(),
                        Complete = (long)query["Complete"] == 1,
                        Time     = DateTimeOffset.ParseExact(query["Date"].ToString(), "yyyy/MM/dd", new CultureInfo("ko-KR"))
                    };
                    entries.Add(Lobj);
                }
            }
            return(entries);
        }
Ejemplo n.º 2
0
        public async Task Insert(ScheData data, SqliteConnection db, SqliteTransaction trans)
        {
            SqliteCommand insert = new SqliteCommand(
                "INSERT INTO sche (Content, Complete, Date) VALUES (@Cont, @Comp, @Date)", db, trans);

            insert.Parameters.AddWithValue("@Cont", data.Content);
            insert.Parameters.AddWithValue("@Comp", (data.Complete ? 1 : 0));
            insert.Parameters.AddWithValue("@Date", data.Time.ToString("yyyy/MM/dd"));
            await insert.ExecuteNonQueryAsync();
        }
Ejemplo n.º 3
0
        public async Task Insert(ScheData data)
        {
            string dbpath = Path.Combine(ApplicationData.Current.LocalFolder.Path, DB_FILE);

            using (SqliteConnection db = new SqliteConnection($"Filename={dbpath}"))
            {
                await db.OpenAsync();

                SqliteCommand insert = new SqliteCommand(
                    "INSERT INTO sche (Content, Complete, Date) VALUES (@Cont, @Comp, @Date)", db);
                insert.Parameters.AddWithValue("@Cont", data.Content);
                insert.Parameters.AddWithValue("@Comp", (data.Complete ? 1 : 0));
                insert.Parameters.AddWithValue("@Date", data.Time.ToString("yyyy/MM/dd"));
                await insert.ExecuteNonQueryAsync();
            }
        }