//Een bestaande line up verwijderen public static int DeleteLineUp(LineUp lineUp) { try { String sSQL = "DELETE FROM LineUp WHERE Id=@Id"; DbParameter par1 = Database.AddParameter("@Id", lineUp.Id); if (par1.Value == null) par1.Value = DBNull.Value; DbParameter[] pars = new DbParameter[] { par1 }; int affected = Database.ModifyData(sSQL, pars); return affected; } catch (Exception ex) { Console.WriteLine(ex.Message); return 0; } }
//Een bestaande line up bewerken public static int EditLineUp(LineUp lineUp) { try { String sSQL = "Update LineUp SET Date=@Date, [From]=@From, Until=@Until, Stage=@Stage, Band=@Band WHERE ID=@ID"; DbParameter par1 = Database.AddParameter("@Date", lineUp.Date); if (par1.Value == null) par1.Value = DBNull.Value; DbParameter par2 = Database.AddParameter("@From", lineUp.From); if (par2.Value == null) par2.Value = DBNull.Value; DbParameter par3 = Database.AddParameter("@Until", lineUp.Until); if (par3.Value == null) par3.Value = DBNull.Value; DbParameter par4 = Database.AddParameter("@Stage", lineUp.Stage.Id); if (par4.Value == null) par4.Value = DBNull.Value; DbParameter par5 = Database.AddParameter("@Band", lineUp.Band.Id); if (par5.Value == null) par5.Value = DBNull.Value; DbParameter par6 = Database.AddParameter("@ID", lineUp.Id); if (par6.Value == null) par6.Value = DBNull.Value; DbParameter[] pars = new DbParameter[] { par1, par2, par3, par4, par5, par6 }; int affected = Database.ModifyData(sSQL, pars); return affected; } catch (Exception ex) { Console.WriteLine(ex.Message); return 0; } }
//Een nieuwe line up toevoegen in database public static int AddLineUp(LineUp lineUp) { try { String sSQL = "INSERT INTO LineUp(Date, [From], Until, Stage, Band) VALUES(@Date, @From, @Until, @Stage, @Band)"; DbParameter par1 = Database.AddParameter("@Date", lineUp.Date); if (par1.Value == null) par1.Value = DBNull.Value; DbParameter par2 = Database.AddParameter("@From", lineUp.From); if (par2.Value == null) par2.Value = DBNull.Value; DbParameter par3 = Database.AddParameter("@Until", lineUp.Until); if (par3.Value == null) par3.Value = DBNull.Value; DbParameter par4 = Database.AddParameter("@Stage", lineUp.Stage.Id); if (par4.Value == null) par4.Value = DBNull.Value; DbParameter par5 = Database.AddParameter("@Band", lineUp.Band.Id); if (par5.Value == null) par5.Value = DBNull.Value; DbParameter[] pars = new DbParameter[] { par1, par2, par3, par4, par5 }; int affected = Database.ModifyData(sSQL, pars); return affected; } catch (Exception ex) { Console.WriteLine(ex.Message); return 0; } }