protected void btnBook_Click(object sender, EventArgs e) { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); //Calling the Parameterized Constructor //This is done once the class variables are set to private set //and a paramterized constructor is introduced //Using VS - Effectively - CR - STYCBG09.02 Passenger passenger = new Passenger(Name.Text, Gender.SelectedItem.Value.ToCharArray()[0], Convert.ToDateTime(DOB.Text)); travelbookingoneway.AddPassenger(passenger); } BookingContact bookingcontact = new BookingContact(); bookingcontact.Address = txtAddress.Text; bookingcontact.City = txtCity.Text; bookingcontact.ContactName = txtName.Text; bookingcontact.Email = txtEmailId.Text; bookingcontact.MobileNo = txtMobile.Text; bookingcontact.PhoneNo = txtPhoneNumber.Text; bookingcontact.State = txtState.Text; travelbookingoneway.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.OneWay, travelbookingoneway); if (travelbooking.IsReturnAvailable()) { FlightBooking TravelBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); foreach (var passenger in travelbookingoneway.GetPassengers()) { TravelBookingReturn.AddPassenger(passenger); } TravelBookingReturn.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.Return, TravelBookingReturn); } Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); }
protected void btnBook_Click(object sender, EventArgs e) { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); Passenger passenger = new Passenger { Name = Name.Text, DateOfBirth = Convert.ToDateTime(DOB.Text), Gender = Gender.SelectedItem.Value.ToCharArray()[0] }; travelbookingoneway.AddPassenger(passenger); } BookingContact bookingcontact = new BookingContact(); bookingcontact.Address = txtAddress.Text; bookingcontact.City = txtCity.Text; bookingcontact.ContactName = txtName.Text; bookingcontact.Email = txtEmailId.Text; bookingcontact.MobileNo = txtMobile.Text; bookingcontact.PhoneNo = txtPhoneNumber.Text; bookingcontact.State = txtState.Text; travelbookingoneway.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.OneWay, travelbookingoneway); if (travelbooking.IsReturnAvailable()) { FlightBooking TravelBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); foreach (var passenger in travelbookingoneway.GetPassengers()) { TravelBookingReturn.AddPassenger(passenger); } TravelBookingReturn.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.Return, TravelBookingReturn); } Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); }
protected void btnBook_Click(object sender, EventArgs e) { try { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); travelbookingoneway.AddPassenger(new Passenger { Name = Name.Text, DateOfBirth = Convert.ToDateTime(DOB.Text), Gender = Gender.SelectedItem.Value.ToCharArray()[0] }); } BookingContact bookingcontact = new BookingContact(); bookingcontact.Address = txtAddress.Text; bookingcontact.City = txtCity.Text; bookingcontact.ContactName = txtName.Text; bookingcontact.Email = txtEmailId.Text; bookingcontact.MobileNo = txtMobile.Text; bookingcontact.PhoneNo = txtPhoneNumber.Text; bookingcontact.State = txtState.Text; travelbookingoneway.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.OneWay, travelbookingoneway); Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); } catch (Exception) { lblHeaderDepart.Text = "Please check the information entered"; } }
protected void btnBook_Click(object sender, EventArgs e) { int adults = Convert.ToInt32(Request.QueryString["adults"].ToString()); int td = Convert.ToInt16(Request.QueryString["td"].ToString()); TravelDirection traveldirection = (TravelDirection)td; List <string> onwardids = new List <string>(); for (int i = 0; i < hdnScheduleOnwardSelectedId.Value.Split('|').Length; i++) { onwardids.Add(hdnScheduleOnwardSelectedId.Value.Split('|')[i].ToString()); } List <TravelSchedule> lstTravelSchedule = (List <TravelSchedule>)Session["flightbookingonwardresults"]; List <Schedule> resultonward = (from t in lstTravelSchedule.SelectMany(schedule => schedule.GetSchedules()) where onwardids.Contains(t.ID.ToString()) select t).ToList(); TravelSchedule objOnwardSchedule = new TravelSchedule(); decimal OnwardCostPerTicket = 0; decimal OnwardTotalCost = 0; foreach (Schedule schedule in resultonward) { objOnwardSchedule.AddSchedule(schedule); OnwardCostPerTicket = OnwardCostPerTicket + schedule.GetFlightCosts().FirstOrDefault().CostPerTicket; } OnwardTotalCost = OnwardCostPerTicket * adults; FlightBooking flightbookingonward = new FlightBooking(); flightbookingonward.NoOfSeats = adults; flightbookingonward.BookingType = BookingTypes.Flight; FlightClass Class = new FlightClass(); Class.ClassInfo = (TravelClass)Enum.Parse(typeof(TravelClass), Request.QueryString["class"]); flightbookingonward.Class = Class; flightbookingonward.TravelScheduleInfo = objOnwardSchedule; flightbookingonward.DateOfJourney = Convert.ToDateTime(Request.QueryString["depart_date"]); flightbookingonward.TotalCost = OnwardTotalCost; if (Membership.GetUser() != null) { flightbookingonward.UserName = Membership.GetUser().UserName; } else { flightbookingonward.UserName = "******"; } TravelBooking travelbooking = new TravelBooking(); travelbooking.AddBookingForTravel(TravelDirection.OneWay, flightbookingonward); if (traveldirection == TravelDirection.Return) { List <string> retunrids = new List <string>(); for (int i = 0; i < hdnScheduleReturnSelectedId.Value.Split('|').Length; i++) { retunrids.Add(hdnScheduleReturnSelectedId.Value.Split('|')[i].ToString()); } List <TravelSchedule> lstTravelScheduleReturn = (List <TravelSchedule>)Session["flightbookingreturnresults"]; List <Schedule> resultreturn = (from t in lstTravelScheduleReturn.SelectMany(schedule => schedule.GetSchedules()) where retunrids.Contains(t.ID.ToString()) select t).ToList(); TravelSchedule objReturnSchedule = new TravelSchedule(); decimal ReturnTotalCost = 0; decimal ReturnCostPerTicket = 0; foreach (Schedule schedule in resultreturn) { objReturnSchedule.AddSchedule(schedule); ReturnCostPerTicket = ReturnCostPerTicket + schedule.GetFlightCosts().FirstOrDefault().CostPerTicket; } ReturnTotalCost = ReturnCostPerTicket * adults; FlightBooking flightbookingreturn = new FlightBooking(); flightbookingreturn.NoOfSeats = adults; flightbookingreturn.TravelScheduleInfo = objReturnSchedule; flightbookingreturn.DateOfJourney = Convert.ToDateTime(Request.QueryString["return_date"]); flightbookingreturn.TotalCost = ReturnTotalCost; if (Membership.GetUser() != null) { flightbookingreturn.UserName = Membership.GetUser().UserName; } else { flightbookingreturn.UserName = "******"; } travelbooking.AddBookingForTravel(TravelDirection.Return, flightbookingreturn); } Session["travelbooking"] = travelbooking; Response.Redirect("~/booking/passengers.aspx"); }
protected void btnBook_Click(object sender, EventArgs e) { try { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); travelbookingoneway.GetPassengers().Clear(); FlightBooking travelbookingReturn = null; bool isReturnAvailable = false; if (travelbooking.IsReturnAvailable()) { isReturnAvailable = true; travelbookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); travelbookingReturn.GetPassengers().Clear(); } foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); DateTime dtDOB; if (DateTime.TryParse(DOB.Text, out dtDOB) == false) { lblError.Text = "Invalid Date of Birth"; return; } else { if (dtDOB > DateTime.Now) { lblError.Text = "Birthday is in the future."; return; } lblError.Text = ""; } travelbookingoneway.AddPassenger(new Passenger { Name = Name.Text, DateOfBirth = dtDOB, Gender = Gender.SelectedItem.Value.ToCharArray()[0] }); if (isReturnAvailable) { travelbookingReturn.AddPassenger(new Passenger { Name = Name.Text, DateOfBirth = dtDOB, Gender = Gender.SelectedItem.Value.ToCharArray()[0] }); } } //Insurance captured if user has selected insurance if (InsuranceOption.Checked) { FlightBooking bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); TravelInsurance insurance = new TravelInsurance(); insurance.Amount = Convert.ToDecimal(lblOnwardInsuranceValue.Text) * bookingoneway.NoOfSeats; travelbookingoneway.Insurance = insurance; if (isReturnAvailable) { FlightBooking bookingReturh = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); TravelInsurance insuranceReturn = new TravelInsurance(); insuranceReturn.Amount = Convert.ToDecimal(lblReturnInsuranceValue.Text) * bookingReturh.NoOfSeats; travelbookingReturn.Insurance = insuranceReturn; } } //------------------------------------------------- BookingContact bookingcontact = new BookingContact(); bookingcontact.Address = txtAddress.Text; bookingcontact.City = txtCity.Text; bookingcontact.ContactName = txtName.Text; bookingcontact.Email = txtEmailId.Text; bookingcontact.MobileNo = txtMobile.Text; bookingcontact.PhoneNo = txtPhoneNumber.Text; bookingcontact.State = txtState.Text; travelbookingoneway.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.OneWay, travelbookingoneway); if (isReturnAvailable) { travelbookingReturn.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.Return, travelbookingReturn); } Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); } catch (Exception) { lblError.Text = "Please check the information entered"; } }