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;
        }
Exemplo n.º 3
0
        public static Traveller Login(string UserName, string Password)
        {
            OracleConnection conn = new OracleConnection(String.Format("Data Source=Neptune; User Id={0}; Password={1};", UserName, Password));

            conn.Open(); // Try to connect using given username/password - if can't connect, an exception is thrown
            conn.Close();
            TravellerDAO travellerDao = new TravellerDAO(UserName, Password);

            return(travellerDao.FindById());
        }
Exemplo 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");
            }
        }
Exemplo 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");
            }
        }
Exemplo n.º 6
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";
        }