protected void btnReserve_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                try
                {
                    Traveller      traveller      = (Traveller)Session["traveller"];
                    ReservationDAO reservationDAO = new ReservationDAO(traveller.Id, traveller.Password);
                    int            shipId         = Convert.ToInt32(ddlCruise.SelectedValue);
                    int            cabinNo        = Convert.ToInt32(txtCabinNo.Text);

                    bool success = reservationDAO.CreateReservation(shipId, cabinNo);
                    if (success)
                    {
                        Response.Redirect("~/Reservations.aspx");
                    }
                    else
                    {
                        lblError.Text    = "The specified cabin is not available.";
                        lblError.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Traveller         traveller    = (Traveller)Session["traveller"];
                TravellerDAO      travellerDAO = new TravellerDAO(traveller.Id, traveller.Password);
                List <CruiseShip> cruises      = travellerDAO.GetShips();

                if (0 == cruises.Count)
                {
                    lblDestinations.Text = "There are no destinations available for the chosen cruise.";
                    lblDestTitle.Visible = false;
                    btnReserve.Enabled   = false;
                }
                else
                {
                    ddlCruise.DataSource     = cruises;
                    ddlCruise.DataTextField  = "ShipName";
                    ddlCruise.DataValueField = "ShipId";
                    ddlCruise.DataBind();
                    lblDestTitle.Visible = true;
                    ddlCruise_SelectedIndexChanged(null, null);
                }
            }
        }
        protected void ddlCruise_SelectedIndexChanged(object sender, EventArgs e)
        {
            Traveller          traveller        = (Traveller)Session["traveller"];
            TravellerDAO       travellerDAO     = new TravellerDAO(traveller.Id, traveller.Password);
            int                shipId           = Convert.ToInt32(ddlCruise.SelectedValue);
            List <Destination> destinationsList = travellerDAO.GetDestinations(shipId);
            string             destinations     = string.Join(",", destinationsList);

            lblDestinations.Text = destinations;
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Traveller    traveller    = (Traveller)Session["traveller"];
            TravellerDAO travellerDAO = new TravellerDAO(traveller.Id, traveller.Password);
            Traveller    t            = travellerDAO.FindById();

            if (traveller.IsAdmin)
            {
                lblAdmin.Text = t.ToString();
            }

            else
            {
                Response.Redirect("~/Reservations.aspx");
            }
        }
Esempio n. 5
0
        protected void btnReservation_Click(object sender, EventArgs e)
        {
            Traveller    traveller    = (Traveller)Session["traveller"];
            TravellerDAO travellerDAO = new TravellerDAO(traveller.Id, traveller.Password);
            Traveller    t            = travellerDAO.FindById();

            List <Reservation> reservations = travellerDAO.GetReservations();

            if (0 == reservations.Count)
            {
                Response.Redirect("~/ReserveCruise.aspx");
            }
            else
            {
                Response.Redirect("~/Reservations.aspx");
            }
        }
Esempio n. 6
0
 protected void btnLogin_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         try
         {
             Traveller traveller = DatabaseHelper.Login(txtUserName.Text, txtPassword.Text);
             Session.Add("traveller", traveller); // Save traveller information into session
             Response.Redirect("~/HomePage.aspx");
             // Response.Redirect("~/Reservations.aspx");
         }
         catch (Exception)
         {
             lblInvalid.Visible = true;
         }
     }
 }
Esempio n. 7
0
        protected void gvReservations_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Traveller      traveller      = (Traveller)Session["traveller"];
            ReservationDAO reservationDAO = new ReservationDAO(traveller.Id, traveller.Password);
            int            index          = Convert.ToInt32(e.CommandArgument);
            int            shipId         = Convert.ToInt32(gvReservations.Rows[index].Cells[0].Text);
            int            cabinNo        = Convert.ToInt32(gvReservations.Rows[index].Cells[2].Text);

            if (e.CommandName == "CANCEL")
            {
                try
                {
                    reservationDAO.CancelReservation(shipId, cabinNo);
                    FillPage();
                    hyperLinkHome_Click(sender, e);
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
Esempio n. 8
0
        private void FillPage()
        {
            Traveller          traveller    = (Traveller)Session["traveller"];
            TravellerDAO       travellerDAO = new TravellerDAO(traveller.Id, traveller.Password);
            List <Reservation> reservations = travellerDAO.GetReservations();

            gvReservations.DataSource         = reservations;
            gvReservations.Columns[0].Visible = true;
            gvReservations.DataBind();
            gvReservations.Columns[0].Visible = false;
            if (0 == reservations.Count)
            {
                lblNoReservations.Visible = true;
            }
            else
            {
                lblNoReservations.Visible = false;
            }
            Traveller t = travellerDAO.FindById();

            lblFullName.Text   = t.ToString();
            hyperLinkHome.Text = traveller.IsAdmin ? "Home" : "Log Out";
        }