Exemplo n.º 1
0
        public void InsertTaken(TaakRecord record)
        {
            Database db    = new Database(context);
            var      check = db.CheckRecord(record.id.ToString(), "taak");

            var conn = new SqliteConnection(connectionString);

            conn.Open();

            var cmd = conn.CreateCommand();

            if (check)
            {
                cmd.CommandText = "UPDATE taak " +
                                  $"SET zorgmoment_id = {record.zorgmoment_id}, stap = {record.stap}, omschrijving = '{record.omschrijving}', stap = {record.stap} " +
                                  $"WHERE id = {record.id}";
            }
            else
            {
                cmd.CommandText = "INSERT INTO taak (id, zorgmoment_id, stap, omschrijving, voltooid) " +
                                  $"VALUES ({record.id}, {record.zorgmoment_id}, {record.stap}, '{record.omschrijving}', {record.voltooid})";
            }
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();

            conn.Close();
        }
Exemplo n.º 2
0
        public void DownloadData(string id)
        {
            var webClient = new WebClient()
            {
                Encoding = Encoding.UTF8
            };

            string personalisedUrl = url + id;

            try
            {
                byte[] myDataBuffer = webClient.DownloadData(personalisedUrl);

                string    download = Encoding.ASCII.GetString(myDataBuffer);
                JsonValue value    = JsonValue.Parse(download);

                foreach (JsonObject result in value)
                {
                    DatabaseClient dbc          = new DatabaseClient(context);
                    ClientRecord   clientRecord = new ClientRecord(result);
                    dbc.InsertClientData(clientRecord);

                    DatabaseZorgmoment dbz          = new DatabaseZorgmoment(context);
                    ZorgmomentRecord   momentRecord = new ZorgmomentRecord(result);
                    dbz.InsertZorgmomenten(momentRecord);

                    DatabaseTaak dbt = new DatabaseTaak(context);
                    foreach (JsonObject taak in result["taken"])
                    {
                        TaakRecord taakRecord = new TaakRecord(taak);
                        dbt.InsertTaken(taakRecord);
                    }
                }
            }
            catch (WebException e)
            {
                Console.WriteLine("exception: " + e.Message);
            }
        }
Exemplo n.º 3
0
        public ArrayList GetTakenByZorgmoment(string moment_id)
        {
            var conn = new SqliteConnection(connectionString);

            conn.Open();

            var cmd = conn.CreateCommand();

            cmd.CommandText = $"SELECT * FROM taak WHERE zorgmoment_id = {moment_id}";
            cmd.CommandType = CommandType.Text;
            SqliteDataReader reader = cmd.ExecuteReader();

            ArrayList taakRecords = new ArrayList();

            while (reader.Read())
            {
                TaakRecord row = new TaakRecord(reader);
                taakRecords.Add(row);
            }

            conn.Close();

            return(taakRecords);
        }