Example #1
0
        //Een nieuwe stage toevoegen in database
        public static int AddStage(Stage stage)
        {
            try
            {
                String sSQL = "INSERT INTO Stage(Name) VALUES(@Name)";

                DbParameter par1 = Database.AddParameter("@Name", stage.Name);
                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; }
        }
Example #2
0
 //Een nieuwe line up creeren
 private static LineUp Create(IDataRecord record, Band band, Stage stage)
 {
     return new LineUp()
     {
         Id = record["Id"].ToString(),
         Date = Convert.ToDateTime(record["Date"].ToString()),
         From = record["From"].ToString(),
         Until = record["Until"].ToString(),
         Band = band,
         Stage = stage
     };
 }
Example #3
0
        //Een lineup ophalen dmv stage en dag
        public static ObservableCollection<LineUp> GetLineUpByStageAndDay(Stage stage, DateTime? dag)
        {
            try
            {
                ObservableCollection<LineUp> LineUp = new ObservableCollection<LineUp>();
                ObservableCollection<Band> lB = Band.GetBands();

                String sql = "SELECT * FROM LineUp WHERE Stage=@StageId AND Date=@Date ORDER BY [FROM] asc";

                DbParameter par1 = Database.AddParameter("@StageId", stage.Id);
                if (par1.Value == null) par1.Value = DBNull.Value;

                DbParameter par2 = Database.AddParameter("@Date", dag);
                if (par2.Value == null) par2.Value = DBNull.Value;

                DbParameter[] pars = new DbParameter[] { par1, par2 };
                DbDataReader reader = Database.GetData(sql, pars);

                while (reader.Read())
                {
                    int IdBand = int.Parse(reader["Band"].ToString());
                    Band band = Band.GetBandById(lB, IdBand);
                    LineUp lineup = CreateLineUpFromStage(reader, band);
                    LineUp.Add(lineup);
                }
                reader.Close();
                return LineUp;
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); return null; }
        }
Example #4
0
        //Een bestaande stage bewerken
        public static int EditStage(Stage stage)
        {
            try
            {
                String sSQL = "Update Stage Set Name=@Name WHERE ID=@ID";

                DbParameter par1 = Database.AddParameter("@Name", stage.Name);
                if (par1.Value == null) par1.Value = DBNull.Value;

                DbParameter par2 = Database.AddParameter("@ID", stage.Id);
                if (par2.Value == null) par2.Value = DBNull.Value;

                DbParameter[] pars = new DbParameter[] { par1, par2 };
                int affected = Database.ModifyData(sSQL, pars);

                return affected;
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); return 0; }
        }