protected void btn_confirm_Click(object sender, EventArgs e) { //load sessiion queue List <Queue> sessionQueue = DBconnection.viewSessionQueue(session.Id, type); if (sessionQueue.Count != 0) //check if queue contains any members { //check if reservation is same as capacity if (session.Reservations == session.Capacity) { //load the top queue member in to a Reservation object Reservation nextInQ = new Reservation(sessionQueue[0].SessionID, DateTime.Now, sessionQueue[0].UserID, sessionQueue[0].SessionTitle, sessionQueue[0].ReservationDate); DBconnection.reserveSession(nextInQ, type); //add above reservation to a database DBconnection.removeQueue(sessionQueue[0].Id, "ID"); //remove queue member that has been added to a reservation } } else { //if queue does not exists, remove one reservation and update number of session's reservation int reservationsNumber = session.Reservations - 1; DBconnection.updateSessionReservation(type, reservationsNumber, reservation); } DBconnection.deleteRecord("Reservation", reservation.ReservationID, "ID"); Session["message"] = "Your reservation has been cancelled. Thank you"; Response.Redirect("Message.aspx"); }
protected void btn_deleteRecord_Click(object sender, EventArgs e) { //check if a session has been selected before proceeding if (Session["selectedRow"] == null) { HttpContext.Current.Response.Write("<script>alert('Please select a session to be deleted first!')</script>"); } else { //delete a record from a database based on the session type (class, workshop") and sessionID DBconnection.deleteRecord(DropDownList1.SelectedValue, Int32.Parse(Session["selectedRow"].ToString()), "ID"); //remove all queues assosiated with this session DBconnection.removeQueue(Int32.Parse(Session["selectedRow"].ToString()), "SessionID"); //delete all reservations assosiated with this session DBconnection.deleteRecord("Reservation", Int32.Parse(Session["selectedRow"].ToString()), DropDownList1.SelectedValue + "ID"); GridView1.SelectedIndex = -1; //clear grid view selection Session["selectedRow"] = null; // clear selectedRow session's data refreshTable(); HttpContext.Current.Response.Write("<script>alert('Session has been deleted.')</script>"); //show javascript confirmation window } }