コード例 #1
0
        private UserVacation DeserializeCart()
        {
            int userID = (int)Session["Login"];

            DBConnect    sqlDB = new DBConnect();
            UserVacation cart  = new UserVacation();

            SqlCommand obj = new SqlCommand();

            obj.CommandType = CommandType.StoredProcedure;
            obj.CommandText = "TheDeserializeCart";
            obj.Parameters.AddWithValue("@userID", userID);

            byte[]  byteArray;
            DataSet cartDS = sqlDB.GetDataSetUsingCmdObj(obj);
            DataRow record = cartDS.Tables[0].Rows[0];

            if (record[0] != DBNull.Value)
            {
                byteArray = (byte[])record[0];
                BinaryFormatter deserializer = new BinaryFormatter();
                MemoryStream    memStream    = new MemoryStream(byteArray);
                cart = (UserVacation)deserializer.Deserialize(memStream);
            }

            return(cart);
        }
コード例 #2
0
        protected void Session_End(object sender, EventArgs e)
        {
            UserVacation    cart   = (UserVacation)Session["Cart"];
            BinaryFormatter serial = new BinaryFormatter();
            MemoryStream    memory = new MemoryStream();

            try
            {
                serial.Serialize(memory, cart);

                byte[] byteArray = memory.ToArray();

                int userID = (int)Session["Login"];

                DBConnect  objDB      = new DBConnect();
                SqlCommand objCommand = new SqlCommand();
                objCommand.CommandType = CommandType.StoredProcedure;
                objCommand.CommandText = "TheSerializeCart";

                objCommand.Parameters.AddWithValue("@userID", userID);
                objCommand.Parameters.AddWithValue("@cartArray", byteArray);


                int i = objDB.DoUpdateUsingCmdObj(objCommand);
            }
            catch (Exception ex)
            {
                //Then do nothing
            }
        }
コード例 #3
0
        protected void rptActivities_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int index = e.Item.ItemIndex;

            Label activityType = (Label)rptActivities.Items[index].FindControl("lblActivityType");
            Label price        = (Label)rptActivities.Items[index].FindControl("lblPrice");

            Experiences.Activities activity = new Experiences.Activities();
            activity.Activity_type = activityType.Text;
            activity.Activity_cost = decimal.Parse(price.Text);

            UserVacation userVacation;

            if (Session["UserVacation"] != null)
            {
                userVacation = (UserVacation)Session["UserVacation"];
            }
            else
            {
                userVacation = new UserVacation();
            }

            userVacation.activity.Add(activity);
            userVacation.activityQuan.Add(1);
            Session["UserVacation"]     = userVacation;
            lblMessage.Visible          = true;
            lblMessage.Text             = "The activity has been added to your cart!";
            divActivities.Visible       = false;
            divSearchActivities.Visible = false;
        }
コード例 #4
0
        //protected void btnSearchforRooms_Click(object sender, EventArgs e)
        //{
        //    gvHotelResults.Visible = false;
        //    gvRoomResults.Visible = true;
        //    int hotelID = 0;
        //    Hotel thehotel ;

        //    for (int i = 0; i < gvHotelResults.Rows.Count; i++)
        //    {
        //        if (gvHotelResults.Rows[i].FindControl("btnSearchforRooms") == sender)
        //        {
        //            hotelID = int.Parse(gvHotelResults.Rows[i].Cells[0].Text);
        //        }
        //        else
        //        {
        //            DataSet myDS = proxy.FindRoomsByHotel();
        //        }
        //    }
        //    gvRoomResults.DataBind();
        //}

        protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < gvRoomResults.Rows.Count; i++)
            {
                if (gvRoomResults.Rows[i].FindControl("btnAddToCart") == sender)
                {
                    UserVacation userVacation = new UserVacation();
                    Hotels.Room  room         = new Hotels.Room();
                    room.City     = txtCity.Text;
                    room.State    = ddlState.SelectedValue;
                    room.RoomDesc = gvRoomResults.Rows[i].Cells[1].Text;
                    room.Price    = float.Parse(gvRoomResults.Rows[i].Cells[9].Text);

                    if (Session["UserVacation"] != null)
                    {
                        userVacation = (UserVacation)Session["UserVacation"];
                    }
                    else
                    {
                        userVacation = new UserVacation();
                    }

                    userVacation.room.Add(room);
                    userVacation.roomQuan.Add(1);
                    Session["UserVacation"] = userVacation;

                    gvRoomResults.Visible = false;
                    lblMessage.Text       = "Your room has been booked!";
                }
            }
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["UserVacation"] != null)
                {
                    double       carPrice      = 0;
                    double       activityPrice = 0;
                    double       flightPrice   = 0;
                    double       hotelPrice    = 0;
                    UserVacation vacation      = (UserVacation)Session["UserVacation"];
                    for (int i = 0; i < vacation.car.Count; i++)
                    {
                        Cars.Car car = vacation.car[i];
                        divCar.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                        divCar.InnerHtml += car.make + "&nbsp";
                        divCar.InnerHtml += car.model + "</h4><p>";
                        divCar.InnerHtml += "Price: $" + car.price + "<br/>";
                        divCar.InnerHtml += "Number of Doors: " + car.numDoors + "<br/>";
                        divCar.InnerHtml += "Eco-Friendly: " + car.eco + "<br/>";
                        divCar.InnerHtml += "Number of Passengers: " + car.numPassenger + "</p></div></div></div>";
                        carPrice          = carPrice + car.price;
                    }
                    for (int y = 0; y < vacation.flight.Count; y++)
                    {
                        Flights.FlightClass flight = vacation.flight[y];
                        divFlight.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                        divFlight.InnerHtml += "To: " + flight.ArrivalCity + "</br>From: " + flight.DepartureCity + "</h4>";
                        divFlight.InnerHtml += "<p>Depart: " + flight.DepartureDate + " at " + flight.DepartureTime + "</br>";
                        divFlight.InnerHtml += "Arrive: " + flight.ArrivalDate + " at " + flight.ArrivalTime + "</br>";
                        divFlight.InnerHtml += "Stops: " + flight.Stops + "</br> Class: " + flight.Class + "</br>";
                        divFlight.InnerHtml += "Price: " + flight.Price + "</p></div></div></div>";
                        flightPrice          = flightPrice + (double)flight.Price;
                    }
                    for (int x = 0; x < vacation.room.Count; x++)
                    {
                        Hotels.Room room = vacation.room[x];
                        divHotel.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                        divHotel.InnerHtml += "Location: " + room.City + ", " + room.State + "</h4>";
                        divHotel.InnerHtml += "<p>Description: " + room.RoomDesc + "</br>Price: $" + room.Price;
                        divHotel.InnerHtml += "</p></div></div></div>";
                        hotelPrice          = hotelPrice + room.Price;
                    }
                    for (int j = 0; j < vacation.activity.Count; j++)
                    {
                        Experiences.Activities activity = vacation.activity[j];
                        divActivity.InnerHtml += "<div class='col-md-3'><div class='panel panel-default'><div class='panel-body'><h4>";
                        divActivity.InnerHtml += activity.Activity_type + "</h4><p>";
                        divActivity.InnerHtml += "Price: $" + activity.Activity_cost + "</p></div></div></div>";
                        activityPrice          = activityPrice + (double)activity.Activity_cost;
                    }
                    total          = activityPrice + carPrice + flightPrice + hotelPrice;
                    lblTotal.Text  = total.ToString();
                    lblTotal2.Text = total.ToString();
                }
            }

            //this.UpdateSubtotals();
        }
コード例 #6
0
        protected void rptCars_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int index = e.Item.ItemIndex;

            Label carID    = (Label)rptCars.Items[index].FindControl("lblCarID");
            Label carMake  = (Label)rptCars.Items[index].FindControl("lblMake");
            Label carModel = (Label)rptCars.Items[index].FindControl("lblModel");
            Label price    = (Label)rptCars.Items[index].FindControl("lblPriceCar");
            Label numDoor  = (Label)rptCars.Items[index].FindControl("lblNumDoors");
            Label eco      = (Label)rptCars.Items[index].FindControl("lblEcoFriendly");
            Label numPass  = (Label)rptCars.Items[index].FindControl("lblNumberPass");
            Label agencyID = (Label)rptCars.Items[index].FindControl("lblAgencyID");

            Cars.Car rental = new Cars.Car();
            rental.carID        = int.Parse(carID.Text);
            rental.make         = carMake.Text;
            rental.model        = carModel.Text;
            rental.price        = int.Parse(price.Text);
            rental.numDoors     = int.Parse(numDoor.Text);
            rental.eco          = eco.Text;
            rental.numPassenger = int.Parse(numPass.Text);
            rental.agencyID     = int.Parse(agencyID.Text);

            UserVacation userVacation;

            if (Session["UserVacation"] != null)
            {
                userVacation = (UserVacation)Session["UserVacation"];
            }
            else
            {
                userVacation = new UserVacation();
            }

            userVacation.car.Add(rental);
            userVacation.carQuan.Add(1);
            Session["UserVacation"] = userVacation;
            divCars.Visible         = false;
            divSearchCars.Visible   = false;
            lblMessage.Visible      = true;
            lblMessage.Text         = "The car has been added to your trip!";
        }
コード例 #7
0
        protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < gvFlightResults.Rows.Count; i++)
            {
                if (gvFlightResults.Rows[i].FindControl("btnAddToCart") == sender)
                {
                    UserVacation        userVacation = new UserVacation();
                    Flights.FlightClass flight       = new Flights.FlightClass();
                    flight.ArrivalCity   = txtArrivalCity.Text;
                    flight.DepartureCity = txtDepartureCity.Text;
                    flight.DepartureDate = gvFlightResults.Rows[i].Cells[1].Text;
                    flight.DepartureTime = gvFlightResults.Rows[i].Cells[2].Text;
                    flight.ArrivalDate   = gvFlightResults.Rows[i].Cells[3].Text;
                    flight.ArrivalTime   = gvFlightResults.Rows[i].Cells[4].Text;
                    flight.Stops         = Convert.ToInt16(ddlStops.SelectedValue);
                    flight.Class         = ddlFlightOption.SelectedValue;
                    string price = gvFlightResults.Rows[i].Cells[5].Text;
                    flight.Price = decimal.Parse(gvFlightResults.Rows[i].Cells[5].Text);

                    if (Session["UserVacation"] != null)
                    {
                        userVacation = (UserVacation)Session["UserVacation"];
                    }
                    else
                    {
                        userVacation = new UserVacation();
                    }

                    userVacation.flight.Add(flight);
                    userVacation.flightQuan.Add(1);
                    Session["UserVacation"] = userVacation;

                    gvFlightResults.Visible = false;
                    lblMessage.Text         = "Your flight has successfully been added to cart";
                }
            }
        }