Example #1
0
 public static void EditGenre(Genre genre, String naam)
 {
     String sql = "UPDATE Genre Set Name=@naam WHERE ID=@Genre";
     DbParameter par1 = Database.AddParameter("@Genre", genre._ID);
     DbParameter par2 = Database.AddParameter("@naam", naam);
     if (par2.Value == null) par2.Value = DBNull.Value;
     Database.ModifyData(sql, par1, par2);
 }
Example #2
0
 public static void DeleteGenre(Genre genre) {
     String sql = "DELETE FROM Genre WHERE ID = @Genre";
     DbParameter par1 = Database.AddParameter("@Genre", genre._ID);
     if (par1.Value == null) par1.Value = DBNull.Value;
     Database.ModifyData(sql, par1);
 }
Example #3
0
        public static Genre getById(string GenreID)
        {
            Genre genre = new Genre();

            String sSQL = "SELECT * FROM Genre WHERE ID = @ID";
            DbParameter par1 = Database.AddParameter("@ID", GenreID);
            if (par1.Value == null) par1.Value = DBNull.Value;
            DbDataReader reader = Database.GetData(sSQL, par1);
            while (reader.Read())
            {
                genre.ID = reader["ID"].ToString();
                genre.Name = reader["Name"].ToString();
            }

            return genre;
        }
Example #4
0
        //string IDataErrorInfo.Error
        //{
        //    get { return "Model not valid"; }
        //}

        //string IDataErrorInfo.this[string columnName]
        //{
        //    get
        //    {
        //        try
        //        {
        //            object value = this.GetType().GetProperty(columnName).GetValue(this);
        //            Validator.ValidateProperty(value, new ValidationContext(this, null, null)
        //            {
        //                MemberName = columnName
        //            });
        //        }
        //        catch (ValidationException ex)
        //        {
        //            return ex.Message;
        //        }
        //        return String.Empty;
        //    }
        //}

        #endregion


        public static ObservableCollection<Genre> getAll()
        {
            ObservableCollection<Genre> lijst = new ObservableCollection<Genre>();

            String sSQL = "SELECT * FROM Genre";
            DbDataReader reader = Database.GetData(sSQL);
            while (reader.Read())
            {
                Genre aNew = new Genre();
                aNew.ID = reader["ID"].ToString();
                aNew.Name = reader["Name"].ToString();
                
                lijst.Add(aNew);
            }


            return lijst;
        }
Example #5
0
 public static void DeleteBandGenre(Band band, Genre genre)
 {
     String sql = "DELETE FROM BandGenre WHERE BandId = @Band AND GenreId = @Genre";
     DbParameter par1 = Database.AddParameter("@Band", band.ID);
     DbParameter par2 = Database.AddParameter("@Genre", genre.ID);
     if (par1.Value == null) par1.Value = DBNull.Value;
     Database.ModifyData(sql, par1, par2);
 }
Example #6
0
 public static void NewBandGenre(Band band, Genre genre)
 {
     String sql = "INSERT INTO BandGenre (BandId, GenreId) VALUES(@Band, @Genre)";
     DbParameter par1 = Database.AddParameter("@Band", band.ID);
     DbParameter par2 = Database.AddParameter("@Genre", genre.ID);
     if (par1.Value == null) par1.Value = DBNull.Value;
     Database.ModifyData(sql, par1, par2);
 }