Exemplo n.º 1
0
        void LoadLidmaatschappen(SqliteConnection conn, string PersoonID)
        {
            bool shouldClose = false;

            // Is the database already open?
            if (conn.State != ConnectionState.Open)
            {
                shouldClose = true;
                conn.Open();
            }

            // Execute query
            using (var command = conn.CreateCommand())
            {
                try
                {
                    // Create new command
                    command.CommandText = "SELECT DISTINCT ID FROM [Clublidmaatschap] WHERE PersoonID = '" + PersoonID + "'";

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var lidmaatschap = new ClublidmaatschapModel();
                            var id           = (string)reader["ID"];

                            lidmaatschap.Load(conn, id);

                            Lidmaatschappen.Add(lidmaatschap);
                        }
                    }
                }
                catch (Exception Exception)
                {
                    Debug.WriteLine(Exception.Message);
                }
            }

            if (shouldClose)
            {
                conn.Close();
            }
        }
Exemplo n.º 2
0
        public void Sort(string key, bool ascending)
        {
            // Take action based on key
            switch (key)
            {
            case "ClubNaam":
                if (ascending)
                {
                    Lidmaatschappen.Sort((x, y) => x.ClubNaam.CompareTo(y.ClubNaam));
                }
                else
                {
                    Lidmaatschappen.Sort((x, y) => - 1 * x.ClubNaam.CompareTo(y.ClubNaam));
                }
                break;

            case "IngeschrevenOp":
                if (ascending)
                {
                    Lidmaatschappen.Sort((x, y) => ((int)x.IngeschrevenOp.Compare(y.IngeschrevenOp)));
                }
                else
                {
                    Lidmaatschappen.Sort((x, y) => - 1 * ((int)x.IngeschrevenOp.Compare(y.IngeschrevenOp)));
                }
                break;

            case "UitgeschrevenOp":
                if (ascending)
                {
                    Lidmaatschappen.Sort((x, y) => ((int)x.UitgeschrevenOp.Compare(y.UitgeschrevenOp)));
                }
                else
                {
                    Lidmaatschappen.Sort((x, y) => - 1 * ((int)x.UitgeschrevenOp.Compare(y.UitgeschrevenOp)));
                }
                break;
            }
        }