protected void btnRegister_Click(object sender, EventArgs e) { // Open SQL connection SQLConnector con = new SQLConnector(); string EncryptedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1"); ResourceDTO NewResource = new ResourceDTO { LoginName = txtUserName.Text, LoginPassword = EncryptedPassword, FirstName = Firstname.Text, LastName = Lastname.Text, Email = Email.Text }; // Insert User into table List <ResourceDTO> ExistingUser = new List <ResourceDTO>(); ExistingUser = con.GetAll("Resource", "LoginName", NewResource.LoginName, typeof(string)).Cast <ResourceDTO>().ToList(); if (ExistingUser.Count == 0) { NewResource = (ResourceDTO)(con.CreateObject(NewResource)); string strMessage = string.Format("Hej {0},\r\n\r\nDin bruger \"{1}\" er hermed oprettet i vores system! Vi håber du får set mange film hos os!\r\n\r\nMvh.\r\nTEC BioBooking!", NewResource.FirstName, NewResource.LoginName); string strSubject = string.Format("Bruger {0} oprettet!", NewResource.LoginName); Mailor mailor = new Mailor(); mailor.SendMail(NewResource.Email, strSubject, strMessage); Response.Redirect("default.aspx"); } else { lblMessage.Text = "Brugernavn er optaget - prøv igen."; } }
protected void Page_Load(object sender, EventArgs e) { ValidateEmployee val = new ValidateEmployee(); if (!val.IsEmployee(Context.User.Identity.Name)) { Response.Redirect("default.aspx"); } //Create Dynamic drop down lists for Movie and Screening SQLConnector con = new SQLConnector(); if (!Page.IsPostBack) { List <MovieDTO> lisMovies = new List <MovieDTO>(); lisMovies = con.GetAll("Movie").Cast <MovieDTO>().ToList(); MovieDropDownList.DataTextField = "Title"; MovieDropDownList.DataValueField = "Id"; MovieDropDownList.DataSource = lisMovies; MovieDropDownList.DataBind(); List <TheaterDTO> lisTheaters = new List <TheaterDTO>(); lisTheaters = con.GetAll("Theater").Cast <TheaterDTO>().ToList(); TheaterDropDownList.DataTextField = "Name"; TheaterDropDownList.DataValueField = "Id"; TheaterDropDownList.DataSource = lisTheaters; TheaterDropDownList.DataBind(); TheaterDropDownList.SelectedIndex = 0; //Give Number Of Seats textbox value from DB matching the Theater selected in drop down. string SeatsTemp = string.Empty; SQLConnector sqlCon = new SQLConnector(); object obj = sqlCon.Get("Theater", Convert.ToInt32(TheaterDropDownList.Text)); foreach (PropertyInfo pi in obj.GetType().GetProperties()) { if (pi.Name == "NumberOfSeats") { SeatsTemp = Convert.ToString(pi.GetValue(obj)); InputSeats.Value = SeatsTemp; } } } }
protected void Page_Load(object sender, EventArgs e) { ValidateEmployee val = new ValidateEmployee(); if (!val.IsEmployee(Context.User.Identity.Name)) { Response.Redirect("default.aspx"); } SQLConnector con = new SQLConnector(); List <ResourceScreeningDTO> lisResScre = new List <ResourceScreeningDTO>(); lisResScre = con.GetAll("ResourceScreening").Cast <ResourceScreeningDTO>().ToList(); //Lav table HtmlGenericControl table = new HtmlGenericControl("TABLE"); table.Attributes["class"] = "table table-hover"; BodyDiv.Controls.Add(table); //Lav header ResourceScreeningDTO dummy = new ResourceScreeningDTO(); TableRow HeaderRow = new TableRow(); foreach (PropertyInfo pi in dummy.GetType().GetProperties()) { TableCell HeaderCell = new TableCell { Text = pi.Name }; HeaderRow.Cells.Add(HeaderCell); } Reservation.Rows.Add(HeaderRow); foreach (ResourceScreeningDTO lisRow in lisResScre) { TableRow CurrentRow = new TableRow(); TableCell FirstCell = new TableCell { Text = lisRow.FirstName }; CurrentRow.Cells.Add(FirstCell); foreach (PropertyInfo pi in lisRow.GetType().GetProperties()) { if (pi.Name != "FirstName") { TableCell CurrentCell = new TableCell { Text = Convert.ToString(pi.GetValue(lisRow)) }; CurrentRow.Cells.Add(CurrentCell); } } Reservation.Rows.Add(CurrentRow); } }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["Done"] == "1") { RaiseAlert("Tak for din bestilling - Bekræftelse er sendt til din mail"); } int ScreeningId = Convert.ToInt32(Request.QueryString["Id"]); SQLConnector con = new SQLConnector(); List <MovieScreeningDTO> MovieScreening = new List <MovieScreeningDTO>(); MovieScreening = con.GetAll("MovieScreening", "ScreeningId", ScreeningId.ToString(), typeof(int)).Cast <MovieScreeningDTO>().ToList(); MovieScreeningDTO MovieScreeningSingle = new MovieScreeningDTO(); try { MovieScreeningSingle = MovieScreening[1]; } catch (Exception) { RaiseAlert("Filmen kunne ikke findes - prøv igen"); return; } // Initialize page with content from requested movie InitPageContent(MovieScreeningSingle); // Draw dynamic html for reservation foreach (var SeatRow in MovieScreening.Select(x => x.SeatRow).Distinct()) { TableRow tr = new TableRow(); tr.ID = "TableRow" + SeatRow.ToString(); foreach (var item in MovieScreening.Where(x => x.SeatRow == SeatRow)) { // Afhængig af item.AvailableStatusID Indsæt <td> som read-only med en klasse der farver elementet rødt TableCell td = new TableCell() { }; td.ID = item.SeatId.ToString(); if (true) { } td.Text = String.Format("<a href=\"#\"><span Id=" + "SeatMainContent_" + item.SeatId.ToString() + " class=\"glyphicon glyphicon-print TableSeat " + ((item.AvailableStatusId != 0) ? "BookedSeat" : "") + "\"></span></a>"); tr.Cells.Add(td); } Reservation.Rows.Add(tr); } }
protected void Page_Load(object sender, EventArgs e) { if (Context.User.Identity.IsAuthenticated) { List <ResourceDTO> Resource = new List <ResourceDTO>(); ResourceDTO resourceSingle = new ResourceDTO(); SQLConnector con = new SQLConnector(); Resource = con.GetAll("Resource", "LoginName", Context.User.Identity.Name, typeof(string)).Cast <ResourceDTO>().ToList(); try { resourceSingle = Resource[0]; } catch (Exception) { throw; } if (resourceSingle.Employee) { //CreateMovie HtmlGenericControl liCreateMovie = new HtmlGenericControl("LI"); navLogin.Controls.Add(liCreateMovie); HtmlGenericControl aCreateMovie = new HtmlGenericControl("A"); aCreateMovie.Attributes["href"] = "createmovie"; aCreateMovie.InnerText = "Opret film"; liCreateMovie.Controls.Add(aCreateMovie); //CreateScreening HtmlGenericControl liCreateScreening = new HtmlGenericControl("LI"); navLogin.Controls.Add(liCreateScreening); HtmlGenericControl aCreateScreening = new HtmlGenericControl("A"); aCreateScreening.Attributes["href"] = "createscreening"; aCreateScreening.InnerText = "Opret filmvisning"; liCreateScreening.Controls.Add(aCreateScreening); //ViewScreening HtmlGenericControl liViewScreening = new HtmlGenericControl("LI"); navLogin.Controls.Add(liViewScreening); HtmlGenericControl aViewScreening = new HtmlGenericControl("A"); aViewScreening.Attributes["href"] = "ViewReservations"; aViewScreening.InnerText = "Se reservationer"; liViewScreening.Controls.Add(aViewScreening); } } }
public bool IsEmployee(string LoginName) { bool Employee = false; List <ResourceDTO> Resource = new List <ResourceDTO>(); ResourceDTO resourceSingle = new ResourceDTO(); SQLConnector con = new SQLConnector(); Resource = con.GetAll("Resource", "LoginName", LoginName, typeof(string)).Cast <ResourceDTO>().ToList(); try { resourceSingle = Resource[0]; } catch (Exception) { throw; } Employee = resourceSingle.Employee; return(Employee); }
protected void SeedButton_Click(object sender, EventArgs e) { SQLConnector con = new SQLConnector(); //Henter alt ud fra respektive tabeller List <MovieDTO> lisMovies = new List <MovieDTO>(); lisMovies = con.GetAll("Movie").Cast <MovieDTO>().ToList(); List <ResourceDTO> lisResource = new List <ResourceDTO>(); lisResource = con.GetAll("Resource").Cast <ResourceDTO>().ToList(); List <TheaterDTO> lisTheater = new List <TheaterDTO>(); lisTheater = con.GetAll("Theater").Cast <TheaterDTO>().ToList(); List <ScreeningDTO> lisScreening = new List <ScreeningDTO>(); lisScreening = con.GetAll("Screening").Cast <ScreeningDTO>().ToList(); //Skaber objekter i respektive elementer MovieDTO movie2 = new MovieDTO() { Title = "Title Only", Description = "Description Only", PosterFileName = "PosterFileName Only", Price = 13.37M }; ResourceDTO resource = new ResourceDTO() { LoginName = "BoNi", LoginPassword = "******", FirstName = "Bo", LastName = "Nielsen", Employee = false, Email = "*****@*****.**" }; TheaterDTO theater = new TheaterDTO() { Name = "Sal 1", NumberOfSeats = 40 }; ScreeningDTO screening = new ScreeningDTO() { MovieId = 1, TheaterId = 1, StartDate = DateTime.Now, EndDate = DateTime.Now.AddHours(3), AvailableSeats = 40 }; movie2 = (MovieDTO)con.CreateObject(movie2); resource = (ResourceDTO)con.CreateObject(resource); theater = (TheaterDTO)con.CreateObject(theater); screening = (ScreeningDTO)con.CreateObject(screening); //Eksempel på hente alle screenings med MovieId = 3 List <ScreeningDTO> lisTestScreening = new List <ScreeningDTO>(); lisTestScreening = con.GetAll("Screening", "MovieId", "3", typeof(int)).Cast <ScreeningDTO>().ToList(); //Henter alle resources (brugere) med Employee = 1, dvs ansatte/admins List <ResourceDTO> lisTestResource = new List <ResourceDTO>(); lisTestResource = con.GetAll("Resource", "Employee", "true", typeof(bool)).Cast <ResourceDTO>().ToList(); //Eksempel på updating af et objekt MovieDTO movie3 = new MovieDTO() { Id = 1, Title = "UPDATED Title Only", Description = "UPDATED Description Only", PosterFileName = "UPDATED PosterFileName Only", Price = 1113.37M }; movie3 = (MovieDTO)con.UpdateObject(movie3); string tempString = string.Empty; foreach (var item in lisMovies) { foreach (var pi in item.GetType().GetProperties()) { tempString += pi.Name + ": " + Convert.ToString(pi.GetValue(item)) + "<br />"; } } //Anden test TestLabel.Text = tempString; }
protected void Page_Load(object sender, EventArgs e) { string MovieId = Request.QueryString["Id"]; if (!string.IsNullOrEmpty(MovieId)) { SQLConnector con = new SQLConnector(); List <MovieDTO> listMovies = new List <MovieDTO>(); listMovies = con.GetAll("Movie").Cast <MovieDTO>().ToList(); List <ScreeningDTO> listScreening = new List <ScreeningDTO>(); listScreening = con.GetAll("Screening", "MovieId", MovieId, typeof(int)).Cast <ScreeningDTO>().ToList(); if (listMovies.Count > 0) { foreach (MovieDTO Movie in listMovies) { if (Movie.Id == Convert.ToInt32(MovieId)) { //wrapper div for movie HtmlGenericControl MovieWrapperDiv = new HtmlGenericControl("DIV"); MovieWrapperDiv.Attributes["class"] = "row"; ScreeningBody.Controls.Add(MovieWrapperDiv); //adding div for movie HtmlGenericControl MovieDiv = new HtmlGenericControl("DIV"); MovieDiv.Attributes["class"] = "col-md-12"; string StringDivId = "div-mov-" + Movie.Id; MovieDiv.Attributes["Id"] = StringDivId; MovieWrapperDiv.Controls.Add(MovieDiv); //Adding div for poster HtmlGenericControl PosterDiv = new HtmlGenericControl("DIV"); PosterDiv.Attributes["class"] = "col-md-4 class"; string StringPosterDivId = "div-poster-" + Movie.Id; PosterDiv.Attributes["Id"] = StringPosterDivId; MovieDiv.Controls.Add(PosterDiv); //Adding poster img to poster div HtmlGenericControl MoviePosterImg = new HtmlGenericControl("IMG"); MoviePosterImg.Attributes["src"] = "/content/images/" + Movie.PosterFileName; MoviePosterImg.Attributes["height"] = "450px"; MoviePosterImg.Attributes["width"] = "300px"; string StringPosterImgId = "img-poster-" + Movie.Id; MoviePosterImg.Attributes["Id"] = StringPosterImgId; PosterDiv.Controls.Add(MoviePosterImg); //Adding div for movie details HtmlGenericControl DetailDiv = new HtmlGenericControl("DIV"); DetailDiv.Attributes["class"] = "col-md-8"; string StringDetailDivId = "div-detail-" + Movie.Id; DetailDiv.Attributes["Id"] = StringDetailDivId; MovieDiv.Controls.Add(DetailDiv); //Adding Label for movie in movie detail div HtmlGenericControl MovieH1Title = new HtmlGenericControl("H1"); MovieH1Title.InnerHtml = Movie.Title; DetailDiv.Controls.Add(MovieH1Title); //Adding description for movie in movie detail div HtmlGenericControl Description = new HtmlGenericControl("P"); Description.InnerText = Movie.Description; DetailDiv.Controls.Add(Description); HtmlGenericControl LineBreak = new HtmlGenericControl("BR"); ScreeningBody.Controls.Add(LineBreak); } } } //Wrapper div for Screenings HtmlGenericControl ScreeningWrapperDiv = new HtmlGenericControl("DIV"); ScreeningWrapperDiv.Attributes["class"] = "row"; ScreeningBody.Controls.Add(ScreeningWrapperDiv); if (listScreening.Count > 0) { //adding div for screenings HtmlGenericControl ScreeningDiv = new HtmlGenericControl("DIV"); ScreeningDiv.Attributes["class"] = "col-md-12"; string StringDivSId = "div-scr-" + 0; ScreeningDiv.Attributes["Id"] = StringDivSId; ScreeningWrapperDiv.Controls.Add(ScreeningDiv); //Adding div for column 1 HtmlGenericControl ScreeningColumn1 = new HtmlGenericControl("DIV"); ScreeningColumn1.Attributes["class"] = "col-md-4 class"; string StringScreeningsDivId1 = "div-scr-" + 1; ScreeningColumn1.Attributes["Id"] = StringScreeningsDivId1; ScreeningDiv.Controls.Add(ScreeningColumn1); //Adding div for column 2 HtmlGenericControl ScreeningColumn2 = new HtmlGenericControl("DIV"); ScreeningColumn2.Attributes["class"] = "col-md-4 class"; string StringScreeningsDivId2 = "div-scr-" + 2; ScreeningColumn2.Attributes["Id"] = StringScreeningsDivId2; ScreeningDiv.Controls.Add(ScreeningColumn2); //Adding div for column 3 HtmlGenericControl ScreeningColumn3 = new HtmlGenericControl("DIV"); ScreeningColumn3.Attributes["class"] = "col-md-4 class"; string StringScreeningsDivId3 = "div-scr-" + 3; ScreeningColumn3.Attributes["Id"] = StringScreeningsDivId3; ScreeningDiv.Controls.Add(ScreeningColumn3); int intCount = -1; foreach (ScreeningDTO Screening in listScreening) { //Adding start date to columns HtmlGenericControl ScreeningStart = new HtmlGenericControl("A"); ScreeningStart.Attributes["href"] = "/moviereservation.aspx?Id=" + Screening.Id; ScreeningStart.InnerHtml = Convert.ToString(Screening.StartDate); HtmlGenericControl LineBreak = new HtmlGenericControl("BR"); if (intCount < listScreening.Count / 3) { ScreeningColumn1.Controls.Add(ScreeningStart); ScreeningColumn1.Controls.Add(LineBreak); } else if (intCount < (2 * listScreening.Count) / 3) { ScreeningColumn2.Controls.Add(ScreeningStart); ScreeningColumn2.Controls.Add(LineBreak); } else { ScreeningColumn3.Controls.Add(ScreeningStart); ScreeningColumn3.Controls.Add(LineBreak); } intCount++; } } else { HtmlGenericControl ParagraphForNoScreenings = new HtmlGenericControl("P"); ParagraphForNoScreenings.InnerText = "No screenings found."; ScreeningBody.Controls.Add(ParagraphForNoScreenings); } } }
protected void ReservationConfirm_Click(object sender, EventArgs e) { // Input checks if (String.IsNullOrEmpty(ChosenSeatString.Value)) { RaiseAlert("Minimum et sæde skal vælges."); return; } // Initialize variables int ScreeningId = Convert.ToInt32(Request.QueryString["Id"]); int UserId = 0; List <ResourceDTO> Resource = new List <ResourceDTO>(); ResourceDTO resourceSingle = new ResourceDTO(); SQLConnector con = new SQLConnector(); Resource = con.GetAll("Resource", "LoginName", Context.User.Identity.Name, typeof(string)).Cast <ResourceDTO>().ToList(); try { resourceSingle = Resource[0]; } catch (Exception) { throw; } UserId = resourceSingle.Id; MovieScreeningDTO MovieScreeningSingle = new MovieScreeningDTO(); List <MovieScreeningDTO> MovieScreening = new List <MovieScreeningDTO>(); MovieScreening = con.GetAll("MovieScreening", "ScreeningId", ScreeningId.ToString(), typeof(int)).Cast <MovieScreeningDTO>().ToList(); try { MovieScreeningSingle = MovieScreening[0]; } catch (Exception) { return; } List <String> ConfirmedSeats; ConfirmedSeats = ChosenSeatString.Value.Split(',').ToList(); ReservationDTO Reservation = new ReservationDTO() { ResourceId = UserId, ScreeningId = ScreeningId }; // Ensure that other users haven't reserved we're about to insert. // Get existing reservations List <ReservationDTO> ExistingReservation = new List <ReservationDTO>(); ExistingReservation = con.GetAll("Reservation", "ScreeningId", ScreeningId.ToString(), typeof(int)).Cast <ReservationDTO>().ToList(); // Only check against ConfirmedSeats if there are existing reservations if (ExistingReservation.Count() > 0) { foreach (var item in ConfirmedSeats) { if (ExistingReservation.Where(x => x.SeatId == Convert.ToInt32(item.Substring(12))).Count() > 0) { Response.Redirect("~/MovieReservation?ScreeningId=" + ScreeningId.ToString() + "\""); RaiseAlert("Sæderne er ikke længere ledige - prøv igen"); return; } } } // Opret nye reservationer foreach (var item in ConfirmedSeats) { Reservation.SeatId = Convert.ToInt32(item.Substring(12)); // Create screening con.CreateObject(Reservation); } // Redirect to same page string strMessage = string.Format("Hej {0}, tak for din bestilling!\r\n\r\nDu har reserveret {1} {3} til filmen {2}\r\n\r\nMvh.\r\nTEC BioBooking!", resourceSingle.FirstName, ConfirmedSeats.Count().ToString(), MovieScreeningSingle.MovieTitle, (ConfirmedSeats.Count() == 1 ? "billet" : "billetter")); string strSubject = string.Format("Tak for din bestilling"); Mailor mailor = new Mailor(); mailor.SendMail(resourceSingle.Email, strSubject, strMessage); Response.Redirect("/MovieReservation?Id=" + ScreeningId.ToString() + "&Done=1"); }
protected void Page_Load(object sender, EventArgs e) { SQLConnector Connector = new SQLConnector(); List <MovieDTO> ListMovies = new List <MovieDTO>(); ListMovies = Connector.GetAll("Movie").Cast <MovieDTO>().ToList(); if (ListMovies.Count > 0) { foreach (MovieDTO movie in ListMovies) { //Wrapper div HtmlGenericControl tempWrapperDiv = new HtmlGenericControl("DIV"); tempWrapperDiv.Attributes["class"] = "row"; BodyDiv.Controls.Add(tempWrapperDiv); //Adding div for movie HtmlGenericControl tempMovieDiv = new HtmlGenericControl("DIV"); tempMovieDiv.Attributes["class"] = "col-md-12"; string tempStringDivId = "div-mov-" + movie.Id; tempMovieDiv.Attributes["Id"] = tempStringDivId; tempWrapperDiv.Controls.Add(tempMovieDiv); //Adding div for poster HtmlGenericControl tempPosterDiv = new HtmlGenericControl("DIV"); tempPosterDiv.Attributes["class"] = "col-md-4 class"; string tempStringPosterDivId = "div-poster-" + movie.Id; tempPosterDiv.Attributes["Id"] = tempStringPosterDivId; tempMovieDiv.Controls.Add(tempPosterDiv); //Adding poster img to poster div HtmlGenericControl tempMoviePosterImg = new HtmlGenericControl("IMG"); tempMoviePosterImg.Attributes["src"] = "/content/images/" + movie.PosterFileName; tempMoviePosterImg.Attributes["height"] = "450px"; tempMoviePosterImg.Attributes["width"] = "300px"; string tempStringPosterImgId = "img-poster-" + movie.Id; tempMoviePosterImg.Attributes["Id"] = tempStringPosterImgId; tempPosterDiv.Controls.Add(tempMoviePosterImg); //Adding div for movie details HtmlGenericControl tempDetailDiv = new HtmlGenericControl("DIV"); tempDetailDiv.Attributes["class"] = "col-md-8"; string tempStringDetailDivId = "div-detail-" + movie.Id; tempDetailDiv.Attributes["Id"] = tempStringDetailDivId; tempMovieDiv.Controls.Add(tempDetailDiv); //Adding label for movie in movie detail div HtmlGenericControl tempH1Title = new HtmlGenericControl("H1"); tempH1Title.InnerHtml = movie.Title; tempDetailDiv.Controls.Add(tempH1Title); //Adding description for movie in movie detail div HtmlGenericControl tempDescription = new HtmlGenericControl("P"); tempDescription.InnerText = movie.Description; tempDetailDiv.Controls.Add(tempDescription); //Adding link to screenings for movie HtmlGenericControl tempLink = new HtmlGenericControl("A"); tempLink.Attributes["href"] = "/showscreenings.aspx?Id=" + movie.Id; tempLink.InnerHtml = "Visninger."; tempDetailDiv.Controls.Add(tempLink); HtmlGenericControl tempLineBreak = new HtmlGenericControl("BR"); BodyDiv.Controls.Add(tempLineBreak); } } //string strTemp = ""; //foreach (PropertyInfo pi in Context.User.Identity.GetType().GetProperties()) //{ // strTemp += pi.Name + ": " + pi.PropertyType + ": " + pi.GetValue(Context.User.Identity) + "<br/>"; //} //testLabel.Text = strTemp; }