public Flight(int id) //creates flight using a reservation ID { try { this.resId = id; this.planeName = DBPlanes.getName(DBReservations.getPlane(resId)); this.capacity = DBPlanes.getCapacity(DBReservations.getPlane(resId)); this.departureTime = DBReservations.getDate(resId); this.destination = DBDestinations.getLocation(DBReservations.getDestination(resId)); this.travelDistance = DBDestinations.getDistanceFromLR(this.destination); this.flightSpeed = DBPlanes.getSpeed(DBPlanes.getID(this.planeName)); this.passengerCount = 0; this.travelTime = ((this.travelDistance * 2) / this.flightSpeed) + 1; //Travel time to and from destination with 1 extra hour for refuling and acceleration/deceleration; List <string> flightResList = DBReservations.getReservationsByPlane(DBPlanes.getID(this.planeName)); foreach (String s in flightResList) // "Out of all the reservations made for the plane that this Flight belongs to..." -ksm { int resNum = Convert.ToInt32(s); if (this.departureTime == DBReservations.getDate(resNum) && this.destination == DBDestinations.getLocation(DBReservations.getDestination(resNum))) { this.passengerCount++; //"... Add 1 passenger for each reservation that matches this flight." -ksm } } this.seatsAvailable = this.capacity - this.passengerCount; this.returnTime = this.departureTime; TimeSpan time = TimeSpan.FromHours(travelTime); this.returnTime = this.returnTime + time; } catch (Exception ex) { throw ex; } }
/// <summary> Updates this instance. </summary> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> private bool Update() { LastModUtc = DateTime.UtcNow; var result = DBReservations.UpdateReservation( ItemId, ItemGuid, ModuleId, ModuleGuid, Title, Description, ImageName, StartDate, EndDate, Location, Latitude, Longitude, LastModUserId, LastModUserGuid, LastModUtc); if (result) { OnContentChanged(new ContentChangedEventArgs()); } return(result); }
/// <summary> Deletes this instance. </summary> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> public bool Delete() { var result = DBReservations.DeleteReservation(ItemId); if (result) { OnContentChanged(new ContentChangedEventArgs { IsDeleted = true }); } return(result); }
/// <summary> Gets the reservation event. </summary> /// <param name="itemId"> The item identifier. </param> private void GetReservationEvent(int itemId) { using (var reader = DBReservations.GetReservation(itemId)) if (reader.Read()) { ItemId = Convert.ToInt32(reader["ItemID"], CultureInfo.InvariantCulture); ModuleId = Convert.ToInt32(reader["ModuleID"], CultureInfo.InvariantCulture); Title = reader["Title"].ToString(); Description = reader["Description"].ToString(); ImageName = reader["ImageName"].ToString(); StartDate = Convert.ToDateTime(reader["StartDate"], CultureInfo.CurrentCulture); EndDate = Convert.ToDateTime(reader["StartDate"], CultureInfo.CurrentCulture); CreatedDate = Convert.ToDateTime(reader["CreatedDate"], CultureInfo.CurrentCulture); UserId = Convert.ToInt32(reader["UserID"], CultureInfo.InvariantCulture); UserGuid = new Guid(reader["UserGuid"].ToString()); Location = reader["Location"].ToString(); Latitude = reader["Latitude"].ToString(); Longitude = reader["Longitude"].ToString(); LastModUserId = Convert.ToInt32(reader["LastModUserId"], CultureInfo.InvariantCulture); var u = reader["ItemGuid"].ToString(); if (u.Length == 36) { ItemGuid = new Guid(u); } u = reader["UserGuid"].ToString(); if (u.Length == 36) { UserGuid = new Guid(u); } u = reader["LastModUserGuid"].ToString(); if (u.Length == 36) { LastModUserGuid = new Guid(u); } u = reader["ModuleGuid"].ToString(); if (u.Length == 36) { ModuleGuid = new Guid(u); } if (reader["LastModUtc"] != DBNull.Value) { LastModUtc = Convert.ToDateTime(reader["LastModUtc"], CultureInfo.CurrentCulture); } } }
/// <summary> Gets the events by page. </summary> /// <param name="siteId"> The site identifier. </param> /// <param name="pageId"> The page identifier. </param> /// <returns> DataTable. </returns> public static DataTable GetEventsByPage(int siteId, int pageId) { var dataTable = new DataTable(); dataTable.Columns.Add("ItemID", typeof(int)); dataTable.Columns.Add("ItemGuid", typeof(Guid)); dataTable.Columns.Add("ModuleID", typeof(int)); dataTable.Columns.Add("ModuleGuid", typeof(Guid)); dataTable.Columns.Add("ModuleTitle", typeof(string)); dataTable.Columns.Add("Title", typeof(string)); dataTable.Columns.Add("Description", typeof(string)); dataTable.Columns.Add("ViewRoles", typeof(string)); dataTable.Columns.Add("CreatedDate", typeof(DateTime)); dataTable.Columns.Add("LastModUtc", typeof(DateTime)); dataTable.Columns.Add("Location", typeof(string)); dataTable.Columns.Add("Latitude", typeof(string)); dataTable.Columns.Add("Longitude", typeof(string)); using (var reader = DBReservations.GetReservationsByPage(siteId, pageId)) { while (reader.Read()) { var row = dataTable.NewRow(); row["ItemID"] = reader["ItemID"]; row["ItemGuid"] = reader["ItemGuid"]; row["ModuleID"] = reader["ModuleID"]; row["ModuleGuid"] = reader["ModuleGuid"]; row["ModuleTitle"] = reader["ModuleTitle"]; row["Title"] = reader["Title"]; row["Description"] = reader["Description"]; row["ViewRoles"] = reader["ViewRoles"]; row["CreatedDate"] = Convert.ToDateTime(reader["CreatedDate"]); row["LastModUtc"] = Convert.ToDateTime(reader["LastModUtc"]); row["Location"] = reader["Location"]; row["Latitude"] = reader["Latitude"]; row["Longitude"] = reader["Longitude"]; dataTable.Rows.Add(row); } } return(dataTable); }
protected void Button1_Click(object sender, EventArgs e) { String jet = jetsDropDownList.SelectedValue; String dest = destinationDropDownList.SelectedValue; DateTime date = Calendar1.SelectedDate; if (ampmDropDownList.SelectedValue == "PM") { int hours; if (hourBox.Text == "12") { hours = Convert.ToInt32(hourBox.Text); } else { hours = Convert.ToInt32(hourBox.Text) + 12; } TimeSpan time = new TimeSpan(hours, Convert.ToInt32(minuteBox.Text), 0); date = date.Date + time; } else { int hours; if (hourBox.Text == "12") { hours = Convert.ToInt32(hourBox.Text) - 12; } else { hours = Convert.ToInt32(hourBox.Text); } TimeSpan time = new TimeSpan(hours, Convert.ToInt32(minuteBox.Text), 0); date = date.Date + time; } DBReservations.RegisterReservation(DBPlanes.getID(jet), CookieHandler.getID(), DBDestinations.getID(dest), date); //sets cookies for use in results page CookieHandler.setCookie("jet", DBPlanes.getName(DBPlanes.getID(jet))); CookieHandler.setCookie("dest", destinationDropDownList.SelectedValue); CookieHandler.setCookie("date", date.ToString()); //change page to results HttpContext.Current.Response.Redirect("Results.aspx"); }
public Plane(int id) { try { this.id = id; this.name = DBPlanes.getName(id); this.mileRange = DBPlanes.getRange(id); this.location = DBPlanes.getLocation(id); this.cruiseSpeed = DBPlanes.getSpeed(id); List <string> resList = DBReservations.getReservationsByPlane(id); int count = 0; foreach (String res in resList) // "For each reservation that this plane has create a flight based on reservation IDs" - ksm { flights[count] = new Flight(Convert.ToInt32(res)); count++; } HashSet <Flight> knownValues = new HashSet <Flight>(); Dictionary <int, Flight> uniqueValues = new Dictionary <int, Flight>(); foreach (var pair in flights) // "Remove duplicate flights" -ksm { if (knownValues.Add(pair.Value)) { uniqueValues.Add(pair.Key, pair.Value); } } flights = uniqueValues; } catch (Exception ex) { throw ex; } }
/// <summary> Creates this instance. </summary> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> private bool Create() { ItemGuid = Guid.NewGuid(); CreatedDate = DateTime.UtcNow; var newId = DBReservations.AddReservation( ItemGuid, ModuleGuid, ModuleId, Title, Description, ImageName, StartDate, EndDate, UserId, UserGuid, Location, Latitude, Longitude, CreatedDate, LastModUserId, LastModUserGuid, LastModUtc); ItemId = newId; var result = newId > -1; if (result) { var e = new ContentChangedEventArgs(); OnContentChanged(e); } return(result); }
protected void btnAdmin_Click(object sender, EventArgs e) { DBReservations.clearDB(); }
/// <summary> Gets the events table. </summary> /// <param name="moduleId"> The module identifier. </param> /// <param name="startDate"> The start date. </param> /// <param name="endDate"> The end date. </param> /// <returns> DataTable. </returns> public static DataTable GetEventsTable(int moduleId, DateTime startDate, DateTime endDate) { return(DBReservations.GetReservationTable(moduleId, startDate, endDate)); }
/// <summary> Gets the events. </summary> /// <param name="moduleId"> The module identifier. </param> /// <param name="startDate"> The start date. </param> /// <param name="endDate"> The end date. </param> /// <returns> DataSet. </returns> public static DataSet GetEvents(int moduleId, DateTime startDate, DateTime endDate) { return(DBReservations.GetReservations(moduleId, startDate, endDate)); }
/// <summary> Deletes the by site. </summary> /// <param name="siteId"> The site identifier. </param> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> public static bool DeleteBySite(int siteId) { return(DBReservations.DeleteBySite(siteId)); }
/// <summary> Deletes the by module. </summary> /// <param name="moduleId"> The module identifier. </param> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> public static bool DeleteByModule(int moduleId) { return(DBReservations.DeleteByModule(moduleId)); }
/// <summary> Deletes the by item identifier. </summary> /// <param name="itemID"> The item identifier. </param> /// <returns> <c>true</c> if XXXX, <c>false</c> otherwise. </returns> public static bool DeleteByItemID(int itemID) { return(DBReservations.DeleteReservation(itemID)); }