Ejemplo n.º 1
0
        private List <Voorstelling> GetVoorstellingen()
        {
            List <Voorstelling> voorstellingen = new List <Voorstelling>();

            using (MySqlConnection conn = new MySqlConnection(connectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from voorstelling", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Voorstelling v = new Voorstelling
                        {
                            Id           = Convert.ToInt32(reader["Id"]),
                            Naam         = reader["Naam"].ToString(),
                            Beschrijving = reader["Beschrijving"].ToString(),
                            Datum        = DateTime.Parse(reader["Datum"].ToString()),
                        };
                        voorstellingen.Add(v);
                    }
                }
            }

            return(voorstellingen);
        }
        public ActionResult VoorstellingInfo(int id)
        {
            Handler.GetPrijzen();
            Voorstelling temp = null;

            foreach (Bioscoop b in Handler.Bioscopen)
            {
                foreach (Zaal z in b.Zalen)
                {
                    foreach (Voorstelling v in z.Voorstellingen)
                    {
                        if (v.Id == id)
                        {
                            temp = v;
                        }
                    }
                }
            }
            if (temp != null)
            {
                Session["Voorstelling"] = temp;
                return(View(temp));
            }
            return(HttpNotFound());
        }
Ejemplo n.º 3
0
        public void MaakBestelling(List <Event> events, string payment, string name, string email, string pickup)
        {
            //Add Klant
            Klant k = new Klant(email, name);

            ctx.KLANTEN.Add(k);
            ctx.SaveChanges();
            //Add Bestelling
            Bestelling b = new Bestelling(pickup, payment);

            b.KlantID = k.KlantID;
            ctx.BESTELLINGEN.Add(b);
            ctx.SaveChanges();
            //Add Events
            foreach (Event ev in events)
            {
                ev.BestellingID = b.BestellingID; //Vullen bestellingID in de event
                ctx.EVENTS.Add(ev);               //Adden van events
                if (ev.VoorstellingID != null)    //Update voorstelling plaatsen
                {
                    Voorstelling v = ctx.VOORSTELLINGEN.SingleOrDefault(m => m.VoorstellingID == ev.VoorstellingID.Value);
                    v.GereserveerdePlaatsen = v.GereserveerdePlaatsen + ev.Aantal;
                }
                if (ev.MaaltijdID != null) //Update Maaltijd plaatsen
                {
                    Maaltijd m = ctx.MAALTIJD.SingleOrDefault(c => c.MaaltijdID == ev.MaaltijdID.Value);
                    m.GereserveerdePlaatsen = m.GereserveerdePlaatsen + ev.Aantal;
                }
            }
            ctx.SaveChanges(); //Sla de bestelling, plus events en klant op en update plaatsen
        }
        public PartialViewResult MandjeItemsLijst()
        {
            string[] formKeys = Request.Form.AllKeys;
            if (formKeys != null)
            {
                foreach (var item in formKeys)
                {
                    if (Session[item] != null)
                    {
                        Session.Remove(item);
                    }
                }
            }
            decimal           teBetalen   = 0;
            List <MandjeItem> mandjeItems = new List <MandjeItem>();

            foreach (string nummer in Session)
            {
                int voorstellingsnummer;
                if (int.TryParse(nummer, out voorstellingsnummer))
                {
                    Voorstelling voorstelling = db.GetVoorstelling(voorstellingsnummer);
                    if (voorstelling != null)
                    {
                        MandjeItem mandjeItem = new MandjeItem(voorstellingsnummer, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, Convert.ToInt16(Session[nummer]));
                        teBetalen += (mandjeItem.Plaatsen * mandjeItem.Prijs);
                        mandjeItems.Add(mandjeItem);
                    }
                }
            }
            ViewBag.teBetalen = teBetalen;
            return(PartialView(mandjeItems));
        }
Ejemplo n.º 5
0
        public Voorstelling GetById(int id)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                FilmRepository FRep = new FilmRepository(new MssqlFilmContext());
                ZaalRepository ZRep = new ZaalRepository(new MssqlZaalContext());
                conn.Open();
                string query = "SELECT * FROM dbo.voorstelling WHERE ID = @id";

                SqlCommand cmd = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("ID", id);
                SqlDataReader reader = cmd.ExecuteReader();
                Voorstelling  voor   = new Voorstelling();
                while (reader.Read())
                {
                    voor.Id        = reader.GetInt32(reader.GetOrdinal("ID"));
                    voor.Starttijd = reader.GetDateTime(reader.GetOrdinal("begintijd"));
                    voor.Eindtijd  = reader.GetDateTime(reader.GetOrdinal("eindtijd"));
                    voor.Zl        = ZRep.GetById(reader.GetInt32(reader.GetOrdinal("Zaal_ID")));
                    voor.Fl        = FRep.GetById(reader.GetInt32(reader.GetOrdinal("Film_ID")));
                }
                conn.Close();
                return(voor);
            }
        }
        public ActionResult Mandje()
        {
            decimal           teBetalen   = 0;
            List <MandjeItem> mandjeItems = new List <MandjeItem>();

            if (Session.Keys.Count != 0)
            {
                foreach (string nummer in Session)
                {
                    int voorstellingnummer;
                    if (int.TryParse(nummer, out voorstellingnummer))
                    {
                        Voorstelling voorstelling = _voorstellingRepository.GetVoorstelling(voorstellingnummer);
                        if (voorstelling != null)
                        {
                            MandjeItem mandjeItem = new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, Convert.ToInt16(Session[nummer]));
                            teBetalen += (mandjeItem.Plaatsen * mandjeItem.Prijs);
                            mandjeItems.Add(mandjeItem);
                        }
                    }
                }
                ViewBag.TeBetalen = teBetalen;
                return(View(mandjeItems));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Mandje()
        {
            decimal           teBetalen   = 0;
            List <MandjeItem> mandjeItems = new List <MandjeItem>();

            foreach (string nummer in Session)
            {
                int voorstellingsNr;
                if (int.TryParse(nummer, out voorstellingsNr))
                {
                    Voorstelling voorstelling = service.GetVoorStelling(voorstellingsNr);
                    if (voorstelling != null)
                    {
                        MandjeItem mandjeItem = new MandjeItem
                                                (
                            voorstellingsNr,
                            voorstelling.Datum, voorstelling.Titel,
                            voorstelling.Uitvoerders,
                            voorstelling.Prijs, Convert.ToInt16(Session[nummer])
                                                );

                        teBetalen += (mandjeItem.Plaatsen * mandjeItem.Prijs);

                        mandjeItems.Add(mandjeItem);
                    }
                }
            }
            ViewBag.teBetalen = teBetalen;
            return(View(mandjeItems));
        }
        public static void ReserveerTickets(Voorstelling voorstelling)
        {
            var stop = false;

            while (!stop)
            {
                Console.WriteLine();
                Console.WriteLine("===================================");
                Console.WriteLine("R E S E R V E R E N T I C K E T S");
                Console.WriteLine("===================================");

                var result        = LeesAantalTickets(voorstelling);
                var aantalTickets = result.Item1;
                stop = result.Item2;
                while ((aantalTickets < 1) & !stop)
                {
                    result        = LeesAantalTickets(voorstelling);
                    aantalTickets = result.Item1;
                    stop          = result.Item2;
                }
                if (!stop)
                {
                    if (Bevestig("Bevestiging Reserveren (Y/N) : "))
                    {
                        VoegReserveringToeInWinkelmandje(voorstelling, aantalTickets);
                        ToonMandje();
                    }
                    stop = true;
                }
            }
            return;
        }
        public ActionResult Mandje()
        {
            decimal           teBetalen    = 0;
            List <MandjeItem> winkelMandje = new List <MandjeItem>();

            foreach (string number in Session)
            {
                int voorstellingnummer;
                if (int.TryParse(number, out voorstellingnummer))
                {
                    Voorstelling voorstelling = service.GetGekozenVoorstelling(voorstellingnummer);
                    if (voorstelling != null)
                    {
                        MandjeItem mandjeItem = new MandjeItem(voorstellingnummer, voorstelling.Datum
                                                               , voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Prijs,
                                                               Convert.ToInt16(Session[number]));
                        teBetalen += (mandjeItem.Prijs * mandjeItem.Plaatsen);
                        winkelMandje.Add(mandjeItem);
                    }
                }
            }
            ViewBag.Mandje    = winkelMandje;
            ViewBag.teBetalen = teBetalen;
            return(View(winkelMandje));
        }
        public ActionResult SelectStoel(FormCollection formCollection)
        {
            int    id     = Convert.ToInt32(formCollection["stoel"]);
            Ticket ticket = null;

            foreach (Stoel s in Handler.GetAllStoelen())
            {
                if (id == s.Id)
                {
                    ticket = new Ticket(Ticket.Highestid, s, Session["ticketPrijs"] as Prijs);
                }
            }
            Session["Ticket"] = ticket;
            Voorstelling voorstelling = Session["Voorstelling"] as Voorstelling;

            foreach (Voorstelling v in Handler.GetAllVoorstellingen())
            {
                if (v.Id == voorstelling.Id)
                {
                    voorstelling.AddTicket(ticket);
                }
            }
            Handler.AddTicketToVoorstelling(ticket, voorstelling);
            return(RedirectToAction("TicketInfo"));
        }
Ejemplo n.º 11
0
        public ActionResult Reserveren(int voorstellingsNr)
        {
            Voorstelling gekozenVoorstelling = new Voorstelling();

            gekozenVoorstelling = service.GetGekozenVoorstelling(voorstellingsNr);
            return(View(gekozenVoorstelling));
        }
Ejemplo n.º 12
0
        public ActionResult Bevestig()
        {
            //als je op de knop zoek me op gedrukt hebt
            if (Request["zoek"] != null)
            {
                var naam     = Request["naam"];
                var paswoord = Request["paswoord"];

                Klant klant = service.GetKlant(naam, paswoord);
                if (klant != null)
                {
                    Session["klant"] = klant;
                }
                else
                {
                    ViewBag.errorMessage = "Verkeerde gebruikersnaam of wachtwoord";
                }
                return(View());
            }
            //als je op de knop ik ben nieuw gedrukt heb
            if (Request["nieuw"] != null)
            {
                return(RedirectToAction("Nieuw", "Home"));
            }
            //als je op de knop bevestigen gedrukt hebt
            if (Request["bevestig"] != null)
            {
                var klant = (Klant)Session["Klant"];
                Session.Remove("klant");
                var geluktereservering  = new List <MandjeItem>();
                var mislukteReservering = new List <MandjeItem>();

                foreach (string number in Session)
                {
                    var nieuweReservatie = new Reservatie();
                    nieuweReservatie.VoorstellingsNr = int.Parse(number);
                    nieuweReservatie.Plaatsen        = Convert.ToInt16(Session[number]);
                    nieuweReservatie.KlantNr         = klant.KlantNr;
                    Voorstelling voorstelling = service.GetVoorstelling(nieuweReservatie.VoorstellingsNr);

                    if (nieuweReservatie.Plaatsen < voorstelling.VrijePlaatsen)
                    {
                        service.BewaarReservatie(nieuweReservatie);
                        geluktereservering.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Datum,
                                                              voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Prijs, nieuweReservatie.Plaatsen));
                    }
                    else
                    {
                        mislukteReservering.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Datum,
                                                               voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Prijs, nieuweReservatie.Plaatsen));
                    }
                }
                Session.RemoveAll();
                Session["gelukt"]  = geluktereservering;
                Session["mislukt"] = mislukteReservering;
                return(RedirectToAction("Overzicht", "Home"));
            }
            return(View());
        }
Ejemplo n.º 13
0
        public ActionResult DeleteConfirmed(int id)
        {
            Voorstelling voorstelling = db.Voorstellingen.Find(id);

            db.Voorstellingen.Remove(voorstelling);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Bevestiging(string naam, string paswoord)
        {
            if (Request["zoek"] != null)
            {
                var klant = _cultuurhuisRepository.GetKlant(naam, paswoord);
                if (klant != null)
                {
                    Session["Klant"] = klant;
                    return(View());
                }
                else
                {
                    ViewBag.ErrorMessage = "de ingegeven gebruikersnaam of wachtwoord waren niet correct";
                    return(View());
                }
            }
            if (Request["nieuw"] != null)
            {
                return(RedirectToAction("NieuweKlant", "Voorstelling"));
            }

            if (Request["bevestig"] != null)
            {
                //verwerking klantgegevens via Session["Klant"]
                var klant = (Klant)Session["klant"];
                Session.Remove("klant");

                List <MandjeItem> gelukteReservaties  = new List <MandjeItem>();
                List <MandjeItem> mislukteReservaties = new List <MandjeItem>();

                //haal alle reservaties uit de session
                foreach (string nummer in Session)
                {
                    Reservatie nieuweReservatie = new Reservatie();
                    nieuweReservatie.VoorstellingsNr = int.Parse(nummer);
                    nieuweReservatie.Plaatsen        = Convert.ToInt16(Session[nummer]);
                    nieuweReservatie.KlantNr         = klant.KlantNr;

                    Voorstelling voorstelling = _voorstellingRepository.GetVoorstelling(nieuweReservatie.VoorstellingsNr);

                    if (voorstelling.VrijePlaatsen >= nieuweReservatie.Plaatsen)
                    {
                        //opslaan in database
                        _voorstellingRepository.BewaarReservatie(nieuweReservatie);
                        gelukteReservaties.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, nieuweReservatie.Plaatsen));
                    }
                    else
                    {
                        mislukteReservaties.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, nieuweReservatie.Plaatsen));
                    }
                }
                Session.RemoveAll();
                Session["gelukt"]  = gelukteReservaties;
                Session["mislukt"] = mislukteReservaties;
                return(RedirectToAction("Overzicht", "Voorstelling"));
            }
            return(View());
        }
        public Voorstelling GetVoorstelling(int itemId, DateTime DatumTijd)
        {
            Voorstelling voorstelling = (from v in ctx.VOORSTELLINGEN
                                         where v.ItemID == itemId && v.BeginTijd == DatumTijd
                                         select v).SingleOrDefault();

            //voorstelling.VoorstellingItem = ctx.ITEMS.SingleOrDefault(i => i.ItemID == voorstelling.ItemID);
            return(voorstelling);
        }
Ejemplo n.º 16
0
        public static void VoegReserveringToeInWinkelmandje(Voorstelling voorstelling, int aantalTickets)
        {
            //In winkelmandje
            var winkelmandjeItem = new WinkelmandjeItem();

            winkelmandjeItem.Voorstelling   = voorstelling;
            winkelmandjeItem.AantalPlaatsen = aantalTickets;
            WinkelMandje.Add(winkelmandjeItem);
        }
        public Voorstelling GetVoorstelling(int?voorstellingId)
        {
            Voorstelling voorstelling = (from v in ctx.VOORSTELLINGEN
                                         where v.VoorstellingID == voorstellingId
                                         select v).SingleOrDefault();

            voorstelling.VoorstellingLocatie = ctx.LOCATIES.SingleOrDefault(m => m.LocatieID == voorstelling.LocatieId);
            voorstelling.VoorstellingZaal    = ctx.ZALEN.SingleOrDefault(m => m.ZaalID == voorstelling.ZaalID);
            return(voorstelling);
        }
Ejemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "VoorstellingsNr,Titel,Uitvoerders,Datum,GenreNr,Prijs,VrijePlaatsen")] Voorstelling voorstelling)
 {
     if (ModelState.IsValid)
     {
         db.Entry(voorstelling).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GenreNr = new SelectList(db.Genres, "GenreNr", "Naam", voorstelling.GenreNr);
     return(View(voorstelling));
 }
Ejemplo n.º 19
0
        public ActionResult Reservering(Voorstelling voor)
        {
            Voorstelling voorst = _voorstellingRepository.GetById(voor.Id);
            Account      acc    = new Account();
            TicketAuth   auth   = new TicketAuth();

            acc.Id = Convert.ToInt32(auth.Decrypt());
            Reservering res = new Reservering(voorst, acc);

            return(View("Reservering", "Reservering", res));
        }
        public ActionResult ComboDeal(string combo1, string combo2, string combo3, string amount, string button)
        {
            int Number1 = 0;
            int Number2 = 0;
            int Number3 = 0;
            int aantal  = 0;

            if (int.TryParse(combo1, out Number1) && int.TryParse(combo2, out Number2) && int.TryParse(combo3, out Number3) && int.TryParse(amount, out aantal))
            {
                Event event1 = new Event();
                event1.Aantal = aantal;
                Voorstelling v1 = dbVoorstelling.GetVoorstelling(Number1);
                Item         i1 = dbItem.GetItem(v1.ItemID);
                event1.DatumTijd         = v1.BeginTijd;
                event1.EventEindTijd     = v1.EindTijd;
                event1.Prijs             = decimal.Parse("8,75");
                event1.Titel             = i1.Titel;
                event1.EventVoorstelling = v1;

                Event event2 = new Event();
                event2.Aantal = aantal;
                Voorstelling v2 = dbVoorstelling.GetVoorstelling(Number2);
                Item         i2 = dbItem.GetItem(v2.ItemID);
                event2.DatumTijd         = v2.BeginTijd;
                event2.EventEindTijd     = v2.EindTijd;
                event2.Prijs             = decimal.Parse("8,75");
                event2.Titel             = i2.Titel;
                event2.EventVoorstelling = v2;

                Event event3 = new Event();
                event3.Aantal = aantal;
                Voorstelling v3 = dbVoorstelling.GetVoorstelling(Number3);
                Item         i3 = dbItem.GetItem(v3.ItemID);
                event3.DatumTijd         = v3.BeginTijd;
                event3.EventEindTijd     = v3.EindTijd;
                event3.Prijs             = 0;
                event3.Titel             = i3.Titel;
                event3.EventVoorstelling = v3;


                if (Session[button] == null)
                {
                    Session[button] = new List <Event>();
                }
                List <Event> events = (List <Event>)Session[button];
                events.Add(event1);
                events.Add(event2);
                events.Add(event3);

                Session[button] = events;
            }
            return(RedirectToAction("ComboDeal"));
        }
Ejemplo n.º 21
0
        public ActionResult Reserveren(int id)
        {
            uint         aantalPlaatsen      = uint.Parse(Request["aantalPlaatsen"]);
            Voorstelling gekozenVoorstelling = service.GetVoorstelling(id);

            if (gekozenVoorstelling.VrijePlaatsen >= aantalPlaatsen)
            {
                Session[gekozenVoorstelling.VoorstellingsNr.ToString()] = aantalPlaatsen;
                return(RedirectToAction("Mandje", "Home"));
            }
            return(RedirectToAction("Reserveer", "Home", new { id = id }));
        }
Ejemplo n.º 22
0
 public ActionResult Bevestiging(string naam, string paswoord)
 {
     //gebruiker opzoeken
     if (Request["zoek"] != null)
     {
         var klant = db.GetKlant(naam, paswoord);
         if (klant != null)
         {
             Session["klant"] = klant;
         }
         else
         {
             ViewBag.errorMessage = "Verkeerde gebruikersnaam of wachtwoord";
         }
         return(View());
     }
     //nieuwe gebruiker
     if (Request["nieuw"] != null)
     {
         return(RedirectToAction("Nieuw", "Home"));
     }
     //bevestig
     if (Request["bevestig"] != null)
     {
         var klant = (Klant)Session["klant"];
         Session.Remove("klant");
         List <MandjeItem> gelukteReservaties  = new List <MandjeItem>();
         List <MandjeItem> mislukteReservaties = new List <MandjeItem>();
         //haal alle reservaties uit de session
         foreach (string nummer in Session)
         {
             Reservatie nieuweReservatie = new Reservatie();
             nieuweReservatie.VoorstellingsNr = int.Parse(nummer);
             nieuweReservatie.Plaatsen        = Convert.ToInt16(Session[nummer]);
             nieuweReservatie.KlantNr         = klant.KlantNr;
             Voorstelling voorstelling = db.GetVoorstelling(nieuweReservatie.VoorstellingsNr);
             if (voorstelling.VrijePlaatsen >= nieuweReservatie.Plaatsen)
             { //opslaan in database
                 db.BewaarReservatie(nieuweReservatie);
                 gelukteReservaties.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, nieuweReservatie.Plaatsen));
             }
             else
             {
                 mislukteReservaties.Add(new MandjeItem(voorstelling.VoorstellingsNr, voorstelling.Titel, voorstelling.Uitvoerders, voorstelling.Datum, voorstelling.Prijs, nieuweReservatie.Plaatsen));
             }
         }
         Session.RemoveAll();
         Session["gelukt"]  = gelukteReservaties;
         Session["mislukt"] = mislukteReservaties;
         return(RedirectToAction("Overzicht", "Home"));
     }
     return(View());
 }
Ejemplo n.º 23
0
        public void Delete(Voorstelling voorstelling)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                string     query = "DELETE FROM dbo.voorstelling WHERE ID = (@id)";
                SqlCommand cmd   = new SqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@id", voorstelling.Id);
                cmd.ExecuteNonQuery();
                conn.Close();
            }
        }
Ejemplo n.º 24
0
        // GET: Voorstelling/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Voorstelling voorstelling = db.Voorstellingen.Find(id);

            if (voorstelling == null)
            {
                return(HttpNotFound());
            }
            return(View(voorstelling));
        }
Ejemplo n.º 25
0
        public ActionResult Reserveer(int id)
        {
            Voorstelling voorstelling   = service.GetGekozenVoorstelling(id);
            uint         aantalPlaatsen = uint.Parse(Request["aantalPlaatsen"]);

            if (aantalPlaatsen > voorstelling.VrijePlaatsen)
            {
                return(RedirectToAction("Reserveer", "Home", new { id = id }));
            }

            Session[id.ToString()] = aantalPlaatsen;


            return(RedirectToAction("Mandje", "Home"));
        }
Ejemplo n.º 26
0
        // GET: Voorstelling/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Voorstelling voorstelling = db.Voorstellingen.Find(id);

            if (voorstelling == null)
            {
                return(HttpNotFound());
            }
            ViewBag.GenreNr = new SelectList(db.Genres, "GenreNr", "Naam", voorstelling.GenreNr);
            return(View(voorstelling));
        }
        public ActionResult SelectTicket(FormCollection formCollection)
        {
            string ticketNaam = formCollection["ticket"];
            Prijs  prijs      = null;

            foreach (Prijs p in Handler.GetPrijzen())
            {
                if (p.Naam == ticketNaam)
                {
                    prijs = p;
                }
            }
            Session["ticketPrijs"] = prijs;
            Voorstelling voorstelling = Session["Voorstelling"] as Voorstelling;

            return(RedirectToAction("StoelKiezen"));
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Geeft de zaal terug van een voorstelling
 /// </summary>
 /// <param name="voorstelling"></param>
 /// <returns></returns>
 public static Zaal GetZaalFromVoorstelling(Voorstelling voorstelling)
 {
     foreach (Bioscoop b in Bioscopen)
     {
         foreach (Zaal z in b.Zalen)
         {
             foreach (Voorstelling v in z.Voorstellingen)
             {
                 if (voorstelling == v)
                 {
                     return(z);
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 29
0
        public List <Voorstelling> Select()
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    List <Voorstelling> voorstellingen = new List <Voorstelling>();
                    conn.Open();
                    string        query  = "SELECT * FROM dbo.voorstelling INNER JOIN dbo.zaal ON voorstelling.zaal_ID = zaal.ID INNER JOIN dbo.film ON voorstelling.film_ID = film.ID";
                    SqlCommand    cmd    = new SqlCommand(query, conn);
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        int      id        = reader.GetInt32(reader.GetOrdinal("ID"));
                        int      zaalId    = reader.GetInt32(reader.GetOrdinal("zaal_ID"));
                        int      filmId    = reader.GetInt32(reader.GetOrdinal("film_ID"));
                        DateTime starttijd = reader.GetDateTime(reader.GetOrdinal("begintijd"));
                        DateTime eindtijd  = reader.GetDateTime(reader.GetOrdinal("eindtijd"));

                        int nummer  = reader.GetInt32(reader.GetOrdinal("nummer"));
                        int grootte = reader.GetInt32(reader.GetOrdinal("grootte"));

                        string  naam         = reader.GetString(reader.GetOrdinal("naam"));
                        string  genres       = reader.GetString(reader.GetOrdinal("genre"));
                        string  beschrijving = reader.GetString(reader.GetOrdinal("beschrijving"));
                        int     lengte       = reader.GetInt32(reader.GetOrdinal("lengte"));
                        decimal rating       = reader.GetDecimal(reader.GetOrdinal("rating"));
                        int     jaar         = reader.GetInt32(reader.GetOrdinal("jaar"));

                        Zaal         z = new Zaal(zaalId, nummer, grootte);
                        Film         f = new Film(filmId, naam, beschrijving, genres, lengte, rating, jaar);
                        Voorstelling v = new Voorstelling(id, z, f, starttijd, eindtijd);

                        voorstellingen.Add(v);
                    }
                    conn.Close();
                    return(voorstellingen);
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                return(new List <Voorstelling>());
            }
        }
Ejemplo n.º 30
0
        //public static Regisseur GetRegisseurFromFilmId(int filmId)
        //{
        //    using (OracleConnection con = Connection)
        //    {
        //        Regisseur regisseur = null;
        //        try
        //        {

        //            OracleCommand cmd = CreateOracleCommand(con, "select REGISSEUR.NAAM, REGISSEUR.ID, REGISSEUR.GEBOORTEDATUM, REGISSEUR.WOONPLAATS, REGISSEUR.FOTOURL FROM Regisseur INNER JOIN FILM ON regisseur_id = REGISSEUR.ID WHERE FILM.ID = :filmId");
        //            cmd.Parameters.Add("filmId", filmId);
        //            con.Open();
        //            OracleDataReader reader = ExecuteQuery(cmd);
        //            Film newFilm = null;
        //            while (reader.Read())
        //            {
        //                int id = Convert.ToInt32(reader["Id"]);
        //                string naam = reader["Naam"].ToString();
        //                DateTime geboorteDatum = Convert.ToDateTime(reader["GeboorteDatum"]);
        //                string woonplaats = reader["Woonplaats"].ToString();
        //                string fotoUrl = reader["FotoUrl"].ToString();
        //                regisseur = new Regisseur(id, naam, geboorteDatum, woonplaats, fotoUrl);
        //            }
        //            return tempList;
        //        }
        //        catch (Exception e)
        //        {
        //            throw e;
        //        }
        //    }
        //}

        internal static bool AddTicket(Ticket ticket, Voorstelling voorstelling)
        {
            using (OracleConnection con = Connection)
            {
                try
                {
                    OracleCommand command = CreateOracleCommand(con, "INSERT INTO TICKET VALUES(:id, :voorstellingId, :stoelId, :prijsId");
                    command.Parameters.Add(":id", ticket.Id);
                    command.Parameters.Add(":voorstellingId", voorstelling.Id);
                    command.Parameters.Add(":stoelId", ticket.Stoel.Id);
                    command.Parameters.Add(":prijsId", ticket.Prijs.Id);
                    return(ExecuteNonQuery(command));
                }
                catch
                {
                    return(false);
                }
            }
        }