/// <summary> /// Pat Banks /// Created: 2015/03/19 /// Gathers form data to submit to database for changes /// </summary> /// <returns>booking of the new information</returns> private Booking GatherFormInformation() { //gets quantity from the up/down quantity field int qty = (int)(UdAddBookingQuantity.Value); //get discount from form decimal discount = (decimal)(UdDiscount.Value); //calculate values for the tickets decimal extendedPrice = _bookingManager.CalcExtendedPrice(CurrentBookingDetails.TicketPrice, qty); decimal totalPrice = _bookingManager.CalcTotalCharge(discount, extendedPrice); Booking editedBooking = new Booking(CurrentBookingDetails.BookingID, CurrentBookingDetails.GuestID, _eId, CurrentBookingDetails.ItemListID, qty, DateTime.Now, discount, CurrentBookingDetails.Active, CurrentBookingDetails.TicketPrice, extendedPrice, totalPrice); return(editedBooking); }
/// <summary> /// Pat Banks /// Created 2015/04/11 /// Gathers form data to send to business logic /// </summary> private void gatherFormInformation() { try { ticketQty = Int32.Parse(txtGuestTickets.Text); //calculate values for the tickets extendedPrice = myManager.CalcExtendedPrice(selectedItemListing.Price, ticketQty); totalPrice = myManager.CalcTotalCharge(discount, extendedPrice); guestName = foundGuest.GetFullName; eventName = selectedItemListing.EventName; date = selectedItemListing.StartDate; Session["foundGuest"] = foundGuest; Session["ticketQty"] = ticketQty; Session["selectedItemListing"] = selectedItemListing; Session["extendedPrice"] = extendedPrice; Session["totalPrice"] = totalPrice; Session["discount"] = discount; //Need confirmation from guest before can officially submit //hide the submit panel and show the confirmation panel confirmDetails.Style.Add("display", "block"); ticketRequest.Style.Add("display", "none"); } catch (Exception ax) { showError("Error: " + ax.Message); return; } }
/// <summary> /// Tony Noel /// Created: 2015/02/11 /// a method to collect all information from the form /// Then after taking each variable and testing them in their specific validation method, parses them /// into the correct variable needed to be stored as a ItemListingDetails /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/03/11 /// Added up/down controls to allow for easier user data entry /// </remarks> private Booking GatherFormInformation() { ItemListingDetails selectedItemListing = GetSelectedItem(); //gets quantity from the up/down quantity field int qty = (int)(UdAddBookingQuantity.Value); //get discount from form decimal discount = (decimal)(UdDiscount.Value); //calculate values for the tickets decimal extendedPrice = _bookingManager.CalcExtendedPrice(selectedItemListing.Price, qty); decimal totalPrice = _bookingManager.CalcTotalCharge(discount, extendedPrice); Booking bookingToAdd = new Booking(CurrentInvoice.HotelGuestID, _eId, selectedItemListing.ItemListID, qty, DateTime.Now, selectedItemListing.Price, extendedPrice, discount, totalPrice); return(bookingToAdd); }
public void TestBookingCalcExtendedPrice() { //Creates a decimal and an int to be calculated decimal numA = 2.0m; int numB = 2; decimal expected = 4.0m; decimal result = myBook.CalcExtendedPrice(numA, numB); //Asserts that the expected and the result will be .5M Assert.AreEqual(expected, result); }