protected void btnBook_Click(object sender, EventArgs e) { try { int CardExpiryYear = Convert.ToInt16(ddlccExpirationYear.SelectedItem.Value); int CardExpiryMonth = Convert.ToInt16(ddlccExpirationMonth.SelectedItem.Value); TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; Card _card = new Card() { CardNo = txtCard_no.Text, Cvv2No = txtCvv.Text, Name = txtcard_holder.Text, ExpiryYear = CardExpiryYear, ExpiryMonth = CardExpiryMonth }; IBookingManager _bookingManager = BookingManagerFactory.GetInstance().Create(); TravelBooking travelbookingresult = new TravelBooking(); travelbookingresult = _bookingManager.ProcessAirTravelBooking(travelbooking, _card); Session["travelbooking"] = travelbookingresult; Response.Redirect("~/booking/Payment_Success.aspx"); } catch (Exception ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } }
protected void btnBook_Click(object sender, EventArgs e) { try { int CardExpiryYear = Convert.ToInt16(ddlccExpirationYear.SelectedItem.Value); int CardExpiryMonth = Convert.ToInt16(ddlccExpirationMonth.SelectedItem.Value); TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; //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.03 Card _card = new Card(txtCard_no.Text, txtcard_holder.Text, CardExpiryMonth, CardExpiryYear, txtCvv.Text); IBookingManager _bookingManager = BookingManagerFactory.GetInstance().Create(); TravelBooking travelbookingresult = new TravelBooking(); travelbookingresult = _bookingManager.ProcessAirTravelBooking(travelbooking, _card); Session["travelbooking"] = travelbookingresult; Response.Redirect("~/booking/Payment_Success.aspx"); } catch (Exception ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } }
protected void btnCancel_Click(object sender, EventArgs e) { try { IBookingManager bookingManager = BookingManagerFactory.GetInstance().Create(); Cancelation cancelation = new Cancelation(); cancelation.BookingID = int.Parse(lblBookingID.Text); cancelation.CancelationDate = DateTime.Parse(lblDate.Text); int noOfSeats = int.Parse(lblSeats.Text); decimal ticketCost = decimal.Parse(lblCost.Text); decimal totalCost = noOfSeats * ticketCost; cancelation.RefundAmount = totalCost; cancelation.NoOfSeats = noOfSeats; cancelation.CostPerTicket = ticketCost; cancelation.UserName = User.Identity.Name; cancelation.Miles = GetHappyMiles(lblRefNo.Text); cancelation.BookingReferenceNo = lblRefNo.Text; DateTime dateOfJourney = DateTime.Parse(lblDate.Text); TimeSpan timeOfJourney = TimeSpan.Parse(lblDeptTime.Text); if (bookingManager.CancelAirTravelBooking(cancelation, dateOfJourney, timeOfJourney)) { lblSuccessMessage.Text = "Cancelation done successfully"; btnCancel.Enabled = false; PlaceHolder2.Visible = true; Page.MaintainScrollPositionOnPostBack = true; lblCancelationDate.Text = DateTime.Now.ToLongDateString(); lblRefundAmount.Text = cancelation.RefundAmount.ToString(); } } catch (CancelationException cex) { lblErrMsg.Text = cex.Message; PlaceHolder2.Visible = false; } catch (Exception) { lblErrMsg.Text = "Sorry !!! Unable to cancel the booking. Please Try Again"; PlaceHolder2.Visible = false; } }
protected void btnProcedeForCancel_Click(object sender, EventArgs e) { try { IBookingManager bookingManager = BookingManagerFactory.GetInstance().Create(); DataSet booking = bookingManager.GetFlightBooking(txtRefNo.Text.ToUpper(), (Guid)System.Web.Security.Membership.GetUser().ProviderUserKey); DataRow row = booking.Tables[0].Rows[0]; PlaceHolder1.Visible = true; PlaceHolder2.Visible = false; lblBookingID.Text = row["BookingId"].ToString(); lblRefNo.Text = row["BookingReferenceNo"].ToString(); lblSeats.Text = row["NoOfSeats"].ToString(); lblCost.Text = row["CostPerTicket"].ToString(); lblDate.Text = DateTime.Parse(row["DateOfJourney"].ToString()).Date.ToLongDateString(); lblDeptTime.Text = DateTime.Parse(row["DepartureTime"].ToString()).TimeOfDay.ToString(); lblArrivalTime.Text = DateTime.Parse(row["ArrivalTime"].ToString()).TimeOfDay.ToString(); lblAirlineName.Text = row["AirlineName"].ToString(); lblFlightName.Text = row["FlightName"].ToString(); lblFromCity.Text = row["FromCityName"].ToString(); lblToCity.Text = row["ToCityName"].ToString(); lblClassType.Text = row["ClassType"].ToString(); lblHappyMiles.Text = GetHappyMiles(lblRefNo.Text).ToString(); btnCancel.Enabled = true; } catch (BookingNotAvailableException bnex) { lblErrMsg.Text = bnex.Message; PlaceHolder1.Visible = false; } catch (IndexOutOfRangeException) { lblErrMsg.Text = "Either booking is already canceled or the the reference number is invalid"; PlaceHolder1.Visible = false; } catch (Exception ex) { lblErrMsg.Text = "Sorry !!! Unable to cancel the booking. Please Try Again"; PlaceHolder1.Visible = false; } }
protected void btnBook_Click(object sender, EventArgs e) { int happyMiles = 0; MembershipUser mUser = Membership.GetUser(); decimal travelCost = 0; string userName = ""; try { int CardExpiryYear = Convert.ToInt16(ddlccExpirationYear.SelectedItem.Value); int CardExpiryMonth = Convert.ToInt16(ddlccExpirationMonth.SelectedItem.Value); int cardType = Convert.ToInt16(ddlccCardType.SelectedItem.Value); if (ValidatePaymentDetails(CardExpiryMonth, CardExpiryYear)) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; Card _card = new Card() { CardNo = txtCard_no.Text, Cvv2No = txtCvv.Text, Name = txtcard_holder.Text, ExpiryYear = CardExpiryYear, ExpiryMonth = CardExpiryMonth, CardType = (CardTypes)cardType }; IBookingManager _bookingManager = BookingManagerFactory.GetInstance().Create(); TravelBooking travelbookingresult = null; travelbookingresult = _bookingManager.ProcessAirTravelBooking(travelbooking, _card); if (Request.IsAuthenticated) { //Added by Anand for updated travel miles IHappyMiles travelMiles = new HappyMilesManager(); List <int> theAirlines = new List <int>(); //AirlineIDs for the onwared flights FlightBooking flightBookingOnward = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); if (flightBookingOnward != null) { theAirlines.Clear(); List <Schedule> theSchedules = flightBookingOnward.TravelScheduleInfo.GetSchedules(); if (theSchedules != null) { foreach (Schedule schedule in theSchedules) { theAirlines.Add(schedule.FlightInfo.AirlineForFlight.Id); } if (mUser != null) { userName = mUser.UserName; decimal insurance = 0; if (flightBookingOnward.Insurance != null) { insurance = flightBookingOnward.Insurance.Amount; } travelCost = travelbooking.GetBookingForTravel(TravelDirection.OneWay).TotalCost - insurance; happyMiles += travelMiles.UpdateHappyMilesForUser(userName, theAirlines, (double)travelCost, flightBookingOnward.ReferenceNo); } } } if (travelbooking.IsReturnAvailable()) { //AirlineIDs for the return flights theAirlines.Clear(); FlightBooking flightBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); List <Schedule> theSchedules = flightBookingReturn.TravelScheduleInfo.GetSchedules(); if (theSchedules != null) { foreach (Schedule schedule in theSchedules) { theAirlines.Add(schedule.FlightInfo.AirlineForFlight.Id); } if (mUser != null) { userName = mUser.UserName; decimal insurance = 0; if (flightBookingOnward.Insurance != null) { insurance = flightBookingOnward.Insurance.Amount; } travelCost = travelbooking.GetBookingForTravel(TravelDirection.Return).TotalCost - insurance; happyMiles += travelMiles.UpdateHappyMilesForUser(userName, theAirlines, (double)travelCost, flightBookingReturn.ReferenceNo); } } } ((SiteMaster)Master).ShowHappyMilesForUser(); Session["happymiles"] = happyMiles; } Session["travelbooking"] = travelbookingresult; Response.Redirect("~/booking/Payment_Success.aspx"); } } catch (HappyTrip.Model.BusinessLayer.Search.FlightSeatsAvailabilityException ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } catch (PaymentProcessException ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } catch (InvalidBookingTypeException ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } catch (BookingException ex) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = ex.Message; } catch (Exception) { lblUnSuccessful.Visible = true; lblUnSuccessful.Text = "Unable to Book Tickets"; } }