/// <summary> /// Puts the information onto the page to display. /// </summary> private void DisplayInformation() { VehicleManager vehicle = null; DateTime hireStart = DateTime.Now, hireEnd = DateTime.Now; string manufacturer, model; double totalDays = 0, totalCost = 0; SIPPCode sizeOfVehicleSIPPCode, noOfDoorsSIPPCode, transmissionAndDriveSIPPCode, fuelAndACSIPPCode; AddressManager address = null; CustomerManager customer = null; LocationManager location = null; LoadInformation(ref vehicle, ref totalDays, ref totalCost, ref hireStart, ref hireEnd, ref address, ref customer, ref location); priceLbl.Text = "Total Price: £" + totalCost.ToString() + " for " + totalDays * 24 + " hours"; addressLbl.Text = "Pick up from address: <br />" + address.GetAddressStr() + "<br />Location Contact: " + location.PhoneNo; vehicleImg.ImageUrl = vehicle.ImageLoc; vehicleImg.AlternateText = vehicle.Manufacturer + " " + vehicle.Model; //make standard size of car images 270x150 vehicleImg.Width = Variables.STANDARDWIDTH; vehicleImg.Height = Variables.STANDARDHEIGHT; manufacturer = vehicle.Manufacturer; model = vehicle.Model; //Gets SIPP Code descriptions for all letters of SIPP code for this car sizeOfVehicleSIPPCode = SIPPCode.GetSIPPCodeDesc(Variables.SIZEOFVEHICLE, vehicle.SIPPCode[0].ToString()); noOfDoorsSIPPCode = SIPPCode.GetSIPPCodeDesc(Variables.NOOFDOORS, vehicle.SIPPCode[1].ToString()); transmissionAndDriveSIPPCode = SIPPCode.GetSIPPCodeDesc(Variables.TRANSMISSIONANDDRIVE, vehicle.SIPPCode[2].ToString()); fuelAndACSIPPCode = SIPPCode.GetSIPPCodeDesc(Variables.FUELANDAC, vehicle.SIPPCode[3].ToString()); carInfoLbl.Text = "<br /><b>" + manufacturer + " " + model + "</b><br />" + sizeOfVehicleSIPPCode.Description + "<br />" + noOfDoorsSIPPCode.Description + "<br />" + transmissionAndDriveSIPPCode.Description + "<br />" + fuelAndACSIPPCode.Description + "<br />"; dateTimeLbl.Text = "<br /><b>Hire Start: " + hireStart.ToString("dd/MM/yyyy HH:mm tt") + "<br />" + "Hire End: " + hireEnd.ToString("dd/MM/yyyy HH:mm tt") + "</b>"; }
/// <summary> /// Saves the order to the database and emails the appropriate accounts. /// </summary> private void SaveOrder() { VehicleManager vehicle = null; DateTime hireStart = DateTime.Now, hireEnd = DateTime.Now; string payerID = "", customerEmailAddress, locationEmailAddress, companyEmailAddress, subject = "", managerBody, body, orderInfo; double totalDays = 0, totalCost = 0; AddressManager address = null; CustomerManager customer = null; LocationManager location = null; LoadInformation(ref vehicle, ref totalDays, ref totalCost, ref hireStart, ref hireEnd, ref address, ref customer, ref location); bool useLocation = (bool)Session["UseLocation"]; //Gets the customer, location and company email addresses to send the confirmation of the order to. customerEmailAddress = customer.EmailAddress; locationEmailAddress = location.EmailAddress; companyEmailAddress = CompanyManager.GetCompanyByLocation(location.LocationID); if (CompletePayment(totalCost, vehicle.Currency, ref payerID) == true) { //String that will be placed in email to summarise order. orderInfo = "<br /><br /><b>Vehicle:</b> " + vehicle.Manufacturer + " " + vehicle.Model + "<br /><b>SIPP Code:</b> " + vehicle.SIPPCode + "<br /><b>Total Cost:</b> " + vehicle.Currency + " " + totalCost + ". For " + totalDays + " days." + "<br /><b>Start:</b> " + hireStart.ToString() + ". <b>End:</b> " + hireEnd.ToString() + "<br /><b>Address:</b> " + address.GetAddressStr() + "<br /><br /><b>PayPal Payer ID:</b> " + payerID; body = "<a href=" + Variables.URL + "Account/ViewOrders>Your Account </a>" + orderInfo; managerBody = "Complete this order by going to the <a href=" + Variables.URL + "Account/ViewCustomerOrders>customer orders page</a>" + orderInfo; if (useLocation == false) { //If address is similar to address already on the system use that one if (AddressManager.GetAddresses().Any(x => x.AddressID == address.AddressID)) { OrderManager.InsertNewOrder(customer.CustomerID, address.AddressID, hireStart, hireEnd, vehicle.VehicleAvailableID, payerID); confirmOrderNotify(customerEmailAddress, subject, body); confirmOrderNotify(locationEmailAddress, subject, managerBody); confirmOrderNotify(companyEmailAddress, subject, managerBody); } else { AddressManager.AddNewAddress(1, address.AddressLine1, address.AddressLine2, address.City , address.ZipOrPostcode, address.CountyStateProvince, address.Country); OrderManager.InsertNewOrder(customer.CustomerID, address.AddressID, hireStart, hireEnd, vehicle.VehicleAvailableID, payerID); confirmOrderNotify(customerEmailAddress, subject, body); confirmOrderNotify(locationEmailAddress, subject, managerBody); confirmOrderNotify(companyEmailAddress, subject, managerBody); } } else { //Don't insert address ID as location address is used OrderManager.InsertNewOrder(customer.CustomerID, 0, hireStart, hireEnd, vehicle.VehicleAvailableID, payerID); confirmOrderNotify(customerEmailAddress, subject, body); confirmOrderNotify(locationEmailAddress, subject, managerBody); confirmOrderNotify(companyEmailAddress, subject, managerBody); } } else { Response.Redirect("~/Account/InformUser.aspx?InfoString=A+problem+has+occured+in+the+PayPal+payment.+Please+try+again.", false); } }