예제 #1
0
        protected void rptFlights_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            // Retrieve the row index for the item that fired the ItemCommand event
            int rowIndex = e.Item.ItemIndex;

            // Retrieve a value from a control in the Repeater's Items collection
            Label flightID = (Label)rptFlights.Items[rowIndex].FindControl("lblflightID");
            Label carrierName = (Label)rptFlights.Items[rowIndex].FindControl("lblCarrierName");
            Label flightPrice = (Label)rptFlights.Items[rowIndex].FindControl("lblFlightPrice");

            Flight currFlight = new Flight();
            currFlight.price = Convert.ToDouble(flightPrice.Text);
            currFlight.flightID = Convert.ToInt32(flightID.Text);

            VacationPackage vacationPackage;
            if (Session["VacationPackage"] != null)
            {
                vacationPackage = (VacationPackage)Session["VacationPackage"];
            }
            else
            {
                vacationPackage = new VacationPackage();
            }

            vacationPackage.flights.Add(currFlight);
            vacationPackage.flightsQuantity.Add(1);
            incrementCartNumber();
            Session["VacationPackage"] = vacationPackage;
        }
예제 #2
0
        private void displayCartCount()
        {
            cartCountDisplay.InnerHtml = "0";

            VacationPackage vacation = (VacationPackage)Session["VacationPackage"];

            for (int i = 0; i < vacation.cars.Count; i++)
            {
                updateCartCount(vacation.carsQuantity[i]);
            }

            for (int i = 0; i < vacation.events.Count; i++)
            {
                updateCartCount(vacation.eventsQuantity[i]);
            }

            for (int i = 0; i < vacation.rooms.Count; i++)
            {
                updateCartCount(vacation.roomsQuantity[i]);
            }

            for (int i = 0; i < vacation.flights.Count; i++)
            {
                updateCartCount(vacation.flightsQuantity[i]);
            }
        }
예제 #3
0
        protected void rptHotels_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            // Retrieve the row index for the item that fired the ItemCommand event
            int rowIndex = e.Item.ItemIndex;

            // Retrieve a value from a control in the Repeater's Items collection
            Label roomID = (Label)rptHotelResults.Items[rowIndex].FindControl("lblRoomID");
            Label hotelName = (Label)rptHotelResults.Items[rowIndex].FindControl("lblHotelName");
            Label roomPrice = (Label)rptHotelResults.Items[rowIndex].FindControl("lblHotelPrice");

            HotelServiceRef.Room currRoom = new HotelServiceRef.Room();
            currRoom.Price = Convert.ToInt32(roomPrice.Text);
            currRoom.RoomID = Convert.ToInt32(roomID.Text);

            VacationPackage vacationPackage;
            if (Session["VacationPackage"] != null)
            {
                vacationPackage = (VacationPackage)Session["VacationPackage"];
            }
            else
            {
                vacationPackage = new VacationPackage();
            }

            vacationPackage.rooms.Add(currRoom);
            vacationPackage.roomsQuantity.Add(1);
            incrementCartNumber();
            Session["VacationPackage"] = vacationPackage;
        }
예제 #4
0
 protected void Session_End(object sender, EventArgs e)
 {
     if (Session["VacationPackage"] != null)
     {
         VacationPackage vacation     = (VacationPackage)Session["VacationPackage"];
         Serialize       objSerialize = new Serialize();
         objSerialize.WriteCartToDB(vacation, Session["UserName"]);
     }
 }
예제 #5
0
        protected void rptCars_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            // Retrieve the row index for the item that fired the ItemCommand event
            int rowIndex = e.Item.ItemIndex;

            // Retrieve a value from a control in the Repeater's Items collection
            Label carID = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnID");
            Label make = (Label)rptCars.Items[rowIndex].FindControl("lblCarMake");
            Label model = (Label)rptCars.Items[rowIndex].FindControl("lblCarModel");
            Label year = (Label)rptCars.Items[rowIndex].FindControl("lblCarYear");
            Label city = (Label)rptCars.Items[rowIndex].FindControl("lblCarCity");
            Label state = (Label)rptCars.Items[rowIndex].FindControl("lblCarState");
            Label price = (Label)rptCars.Items[rowIndex].FindControl("lblCarPrice");
            Label gps = (Label)rptCars.Items[rowIndex].FindControl("lblCarGps");
            Label type = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnType");
            Label carClass = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnClass");
            Label electric = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnElectric");
            Label passengers = (Label)rptCars.Items[rowIndex].FindControl("lblCarPassengers");
            Label luggage = (Label)rptCars.Items[rowIndex].FindControl("lblCarLuggage");
            Label doors = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnDoors");
            Label mileage = (Label)rptCars.Items[rowIndex].FindControl("lblCarMileage");
            Label agencyID = (Label)rptCars.Items[rowIndex].FindControl("lblCarHdnAgency");

            CarServiceRef.Car currCar = new CarServiceRef.Car();
            currCar.carID = int.Parse(carID.Text);
            currCar.make = make.Text;
            currCar.model = model.Text;
            currCar.year = year.Text;
            currCar.price = float.Parse(price.Text);
            currCar.gps = gps.Text;
            currCar.type = type.Text;
            currCar.carClass = carClass.Text;
            currCar.electric = electric.Text;
            currCar.passengers = int.Parse(passengers.Text);
            currCar.luggage = int.Parse(luggage.Text);
            currCar.doors = int.Parse(doors.Text);
            currCar.mileage = int.Parse(mileage.Text);

            VacationPackage vacationPackage;
            if (Session["VacationPackage"] != null)
            {
                vacationPackage = (VacationPackage)Session["VacationPackage"];
            }
            else
            {
                vacationPackage = new VacationPackage();
            }

            vacationPackage.cars.Add(currCar);
            vacationPackage.carsQuantity.Add(1);
            incrementCartNumber();
            Session["VacationPackage"] = vacationPackage;
        }
예제 #6
0
        protected void btnUpdateCart_Click(object sender, EventArgs e)
        {
            cartCountDisplay.InnerHtml = "0";

            VacationPackage vacation = (VacationPackage)Session["VacationPackage"];

            for (int i = 0; i < vacation.cars.Count; i++)
            {
                CarServiceRef.Car currCar = vacation.cars[i];
                int currCarQuantity = int.Parse(Request["cartCar" + currCar.carID]);
                vacation.carsQuantity[i] = currCarQuantity;

                updateCartCount(currCarQuantity);
            }

            for (int i = 0; i < vacation.events.Count; i++)
            {
                EventServiceRef.Event currEvent = vacation.events[i];
                int currEventQuantity = int.Parse(Request["cartEvent" + currEvent.ID]);
                vacation.eventsQuantity[i] = currEventQuantity;

                updateCartCount(currEventQuantity);
            }

            for (int i = 0; i < vacation.rooms.Count; i++)
            {
                HotelServiceRef.Room currRoom = vacation.rooms[i];
                int currRoomQuantity = int.Parse(Request["cartRooms" + currRoom.RoomID]);
                vacation.roomsQuantity[i] = currRoomQuantity;

                updateCartCount(currRoomQuantity);
            }

            for (int i = 0; i < vacation.flights.Count; i++)
            {
                Flight flight = vacation.flights[i];
                int currFlightQuantity = int.Parse(Request["cartFlights" + flight.flightID]);
                vacation.flightsQuantity[i] = currFlightQuantity;

                updateCartCount(currFlightQuantity);
            }

            displayCart();
        }
예제 #7
0
        protected void rptEvents_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            // Retrieve the row index for the item that fired the ItemCommand event
            int rowIndex = e.Item.ItemIndex;

            // Retrieve a value from a control in the Repeater's Items collection
            Label eventID = (Label)rptEvents.Items[rowIndex].FindControl("lblEventHdnID");
            Label eventName = (Label)rptEvents.Items[rowIndex].FindControl("lblEventName");
            Label eventType = (Label)rptEvents.Items[rowIndex].FindControl("lblEventType");
            Label eventDay = (Label)rptEvents.Items[rowIndex].FindControl("lblEventDay");
            Label eventTime = (Label)rptEvents.Items[rowIndex].FindControl("lblEventTime");
            Label eventCity = (Label)rptEvents.Items[rowIndex].FindControl("lblEventCity");
            Label eventState = (Label)rptEvents.Items[rowIndex].FindControl("lblEventState");
            Label eventPrice = (Label)rptEvents.Items[rowIndex].FindControl("lblEventPrice");
            Label agencyID = (Label)rptEvents.Items[rowIndex].FindControl("lblEventHdnAgency");

            EventServiceRef.Event currEvent = new EventServiceRef.Event();
            currEvent.ID = int.Parse(eventID.Text);
            currEvent.Name = eventName.Text;
            currEvent.Type = eventType.Text;
            currEvent.Day = eventDay.Text;
            currEvent.Time = eventTime.Text;
            currEvent.City = eventCity.Text;
            currEvent.State = eventState.Text;
            currEvent.Price = double.Parse(eventPrice.Text);
            currEvent.AgencyID = int.Parse(agencyID.Text);

            VacationPackage vacationPackage;
            if (Session["VacationPackage"] != null)
            {
                vacationPackage = (VacationPackage)Session["VacationPackage"];
            }
            else
            {
                vacationPackage = new VacationPackage();
            }

            vacationPackage.events.Add(currEvent);
            vacationPackage.eventsQuantity.Add(1);
            incrementCartNumber();
            Session["VacationPackage"] = vacationPackage;
        }
예제 #8
0
        protected void btnClearCart_Click(object sender, EventArgs e)
        {
            if (Session["VacationPackage"] != null)
            {
                VacationPackage vacation = (VacationPackage)Session["VacationPackage"];
                vacation.cars.Clear();
                vacation.carsQuantity.Clear();
                vacation.events.Clear();
                vacation.eventsQuantity.Clear();
                vacation.rooms.Clear();
                vacation.roomsQuantity.Clear();
                vacation.flights.Clear();
                vacation.flightsQuantity.Clear();

                clearCartCount();

                Session["VacationPackage"] = vacation;
                Serialize objSerialize = new Serialize();
                objSerialize.WriteCartToDB(vacation, Session["UserName"]);

                displayCart();
            }
        }
예제 #9
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string email    = txtUserName.Text;
            string password = txtPassword.Text;

            UserServiceRef.UserService pxy = new UserServiceRef.UserService();
            if (pxy.ValidateLogin(email, password))
            {
                if (chkRememberMe.Checked)
                {
                    HttpCookie emailCookie = new HttpCookie("UserEmail");
                    emailCookie.Value   = email;
                    emailCookie.Expires = new DateTime(2024, 1, 1);
                    Response.Cookies.Add(emailCookie);
                }
                else
                {
                    Response.Cookies.Remove("UserEmail");
                }

                Session.Remove("LoginCount");
                Session["UserName"] = email;

                Serialize       objSerialize = new Serialize();
                VacationPackage vacation     = (VacationPackage)objSerialize.ReadCartFromDB(email);
                if (vacation != null)
                {
                    Session["VacationPackage"] = vacation;
                }
                else
                {
                    Session["VacationPackage"] = new VacationPackage();
                }

                Response.Redirect("Home.aspx");
            }
            else
            {
                txtUserName.Text = "";
                txtPassword.Text = "";

                int loginCount = 0;
                if (Session["LoginCount"] != null)
                {
                    loginCount = (int)Session["LoginCount"];
                }
                Session["LoginCount"] = loginCount + 1;

                if (loginCount > 2)
                {
                    loginAlert.InnerHtml = "Too many tries, you are not allowed to login again for a while.";
                    txtUserName.Enabled  = false;
                    txtPassword.Enabled  = false;
                }
                else
                {
                    loginAlert.InnerHtml = "Invalid credentials, please try again!";
                }

                loginAlert.Visible = true;
            }
        }
예제 #10
0
        private void displayCart()
        {
            divReservationsBody.Visible = false;
            divCartBody.Visible = true;
            divCart.InnerHtml = "";
            double totalVacationPrice = 0;
            lblTotalPrice.Text = "";
            if (Session["VacationPackage"] != null)
            {
                VacationPackage vacation = (VacationPackage)Session["VacationPackage"];

                divCart.InnerHtml += "<div class='page-header'><h3>Cars</h3></div><div class='row' style='text-align: center;'>";
                for (int i = 0; i < vacation.cars.Count; i++)
                {
                    CarServiceRef.Car currCar = vacation.cars[i];
                    totalVacationPrice += (Convert.ToDouble(currCar.price) * vacation.carsQuantity[i]);
                    divCart.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                    divCart.InnerHtml += currCar.year + " ";
                    divCart.InnerHtml += currCar.make + " ";
                    divCart.InnerHtml += currCar.model + "</h4><p>";
                    divCart.InnerHtml += "Seats: " + currCar.passengers + "<br />";
                    divCart.InnerHtml += "GPS available: " + currCar.gps + "<br />";
                    divCart.InnerHtml += "Bags: " + currCar.luggage + "<br />";
                    divCart.InnerHtml += "Price: $" + currCar.price + "<br />";
                    divCart.InnerHtml += "Mileage: " + currCar.mileage + "</p>";
                    divCart.InnerHtml += "<br />Quantity: <input type='number' class='form-control' id='cartCar" + currCar.carID + "' name='cartCar" + currCar.carID + "' value='" + vacation.carsQuantity[i] + "'></div></div></div>";
                }

                divCart.InnerHtml += "</div><div class='page-header'><h3>Vacations</h3></div><div class='row' style='text-align: center;'>";
                for (int i = 0; i < vacation.events.Count; i++)
                {
                    EventServiceRef.Event currEvent = vacation.events[i];
                    totalVacationPrice += (currEvent.Price * vacation.eventsQuantity[i]);
                    divCart.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                    divCart.InnerHtml += currEvent.Name + " <small>";
                    divCart.InnerHtml += currEvent.City + ", " + currEvent.State + "</small></h4><p>";
                    divCart.InnerHtml += currEvent.Time + ", " + currEvent.Day + "<br />";
                    divCart.InnerHtml += "Type: " + currEvent.Type + "<br />";
                    divCart.InnerHtml += "Price: $" + currEvent.Price + "</p>";
                    divCart.InnerHtml += "<br />Quantity: <input type='number' class='form-control' id='cartEvent" + currEvent.ID + "' name='cartEvent" + currEvent.ID + "' value='" + vacation.eventsQuantity[i] + "'></div></div></div>";
                }

                divCart.InnerHtml += "</div><div class='page-header'><h3>Rooms</h3></div><div class='row' style='text-align: center;'>";
                for (int i = 0; i < vacation.rooms.Count; i++)
                {
                    HotelServiceRef.Room currRooms = vacation.rooms[i];
                    totalVacationPrice += (currRooms.Price * vacation.roomsQuantity[i]);
                    divCart.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                    divCart.InnerHtml += txtHotelCity.Text + ", " + ddlHotelState.SelectedItem.Text + "</small></h4><p>";
                    divCart.InnerHtml += "Price: $" + currRooms.Price + "</p>";
                    divCart.InnerHtml += "<br />Quantity: <input type='number' class='form-control' id='cartRooms" + currRooms.RoomID + "' name='cartRooms" + currRooms.RoomID + "' value='" + vacation.roomsQuantity[i] + "'></div></div></div>";
                }

                divCart.InnerHtml += "</div><div class='page-header'><h3>Flights</h3></div><div class='row' style='text-align: center;'>";
                for (int i = 0; i < vacation.flights.Count; i++)
                {
                    Flight currFlight = vacation.flights[i];
                    totalVacationPrice += (currFlight.price * vacation.flightsQuantity[i]);
                    divCart.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                    divCart.InnerHtml += txtFlightDepCity.Text + ", " + ddlFlightDepState.SelectedItem.Text + "</small></h4><p>";
                    divCart.InnerHtml += "Price: $" + currFlight.price + "</p>";
                    divCart.InnerHtml += "<br />Quantity: <input type='number' class='form-control' id='cartFlights" + currFlight.carrierID + "' name='cartFlights" + currFlight.flightID + "' value='" + vacation.flightsQuantity[i] + "'></div></div></div>";
                }

                divCart.InnerHtml += "</div>";

                lblTotalPrice.Text += "Total Price: $" + totalVacationPrice.ToString();

            }
        }
예제 #11
0
        protected void btnCheckout_Click(object sender, EventArgs e)
        {
            if (Session["VacationPackage"] != null)
            {
                VacationPackage vacation = (VacationPackage)Session["VacationPackage"];

                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "GetUser";
                objCommand.Parameters.AddWithValue("@email", Session["UserName"]);
                DBConnect objDB = new DBConnect();
                DataSet myDS = objDB.GetDataSetUsingCmdObj(objCommand);
                DataRow user = myDS.Tables[0].Rows[0];

                CarServiceRef.Customer carCustomer = new CarServiceRef.Customer();
                carCustomer.customerID = (int)user["UserID"];
                carCustomer.firstName = (string)user["firstName"];
                carCustomer.lastName = (string)user["lastName"];
                carCustomer.email = (string)user["email"];
                carCustomer.address = "";
                carCustomer.age = 0;
                carCustomer.phoneNumber = "";

                EventServiceRef.Customer eventCustomer = new EventServiceRef.Customer();
                eventCustomer.ID = (int)user["UserID"];
                eventCustomer.CustomerFirstName = (string)user["firstName"];
                eventCustomer.CustomerLastName = (string)user["lastName"];
                eventCustomer.CustomerEmail = (string)user["email"];
                eventCustomer.CustomerPhone = "";

                HotelServiceRef.Customer hotelCustomer = new HotelServiceRef.Customer();
                hotelCustomer.CustID = (int)user["UserID"];
                hotelCustomer.FirstName = (string)user["firstName"];
                hotelCustomer.LastName = (string)user["lastName"];
                hotelCustomer.Address = (string)user["email"];

                CarServiceRef.CarService carService = new CarServiceRef.CarService();
                EventServiceRef.EventService eventService = new EventServiceRef.EventService();
                HotelServiceRef.HotelService hotelService = new HotelServiceRef.HotelService();
                AirServiceRef.AirService airService = new AirServiceRef.AirService();
                string emailBody = "<h1>You have reserved</h1>";
                emailBody += "<h2>Cars</h2>";
                bool reservedCars = true;
                for (int i = 0; i < vacation.cars.Count; i++)
                {
                    CarServiceRef.Car currCar = vacation.cars[i];
                    if (!carService.Reserve(carCustomer, currCar))
                    {
                        reservedCars = false;
                    }
                    else
                    {
                        emailBody += "<p>" + currCar.year + " " + currCar.make + " " + currCar.model + " ($" + currCar.price + ")</p>";
                    }
                }

                emailBody += "<h2>Events</h2>";
                bool reservedEvents = true;
                for (int i = 0; i < vacation.events.Count; i++)
                {
                    EventServiceRef.Event currEvent = vacation.events[i];
                    if (!eventService.Reserve(currEvent, eventCustomer))
                    {
                        reservedEvents = false;
                    }
                    else
                    {
                        emailBody += "<p>" + currEvent.Name + " ($" + currEvent.Price + ")</p>";
                    }
                }

                emailBody += "<h2>Hotels</h2>";
                bool reservedHotels = true;
                for (int i = 0; i < vacation.rooms.Count; i++)
                {
                    HotelServiceRef.Room currRoom = vacation.rooms[i];
                    if (!hotelService.Reserve(currRoom, hotelCustomer))
                    {
                        reservedHotels = false;
                    }
                    else
                    {
                        emailBody += "<p>" + currRoom.RoomNumber + " ($" + currRoom.Price + ")</p>";
                    }
                }

                emailBody += "<h2>Flights</h2>";
                bool reservedFlights = true;
                for (int i = 0; i < vacation.flights.Count; i++)
                {
                    Flight currFlight = vacation.flights[i];

                    emailBody += "<p>" + currFlight.carrierName + " ($" + currFlight.price + ") could not be reserved because the AirService does not accept reservations</p>";
                }

                emailBody += "<br><br><p>Thank you,<br>Vacation-O-City Team</p>";

                if (reservedCars)
                {
                    vacation.cars.Clear();
                    vacation.carsQuantity.Clear();
                }

                if (reservedEvents)
                {
                    vacation.events.Clear();
                    vacation.eventsQuantity.Clear();
                }

                if (reservedHotels)
                {
                    vacation.events.Clear();
                    vacation.roomsQuantity.Clear();
                }

                if (reservedFlights)
                {
                    vacation.flights.Clear();
                    vacation.flightsQuantity.Clear();
                }

                Email emailSender = new Email();
                emailSender.SendMail((string)Session["UserName"], "*****@*****.**", "Reservation Confirmation", emailBody, "*****@*****.**");

                clearCartCount();

                Session["VacationPackage"] = vacation;
                vacation = (VacationPackage)Session["VacationPackage"];
                Serialize objSerialize = new Serialize();
                objSerialize.WriteCartToDB(vacation, Session["UserName"]);
            }

            displayCart();
        }