private void OK_Click(object sender, RoutedEventArgs e) { var res = db.Passengers.Select(PK => PK).ToList().Last(); var fio = FIO.Text.Split(' '); Passengers passengers = new Passengers { PK_Passenger = res.PK_Passenger + 1, Surname = fio[0], Name = fio[1], FatherName = fio[2], E_mail = Mail.Text, PasAddress = Address.Text, Telephone = Telephone.Text }; var tic = db.Tickets.Select(PK => PK).ToList().Last(); Tickets tickets = new Tickets { FK_Flight = fk_flight, FK_Route = fk_route, FK_Passenger = passengers.PK_Passenger, PK_Ticket = tic.PK_Ticket + 1, Passengers = passengers }; db.Passengers.Add(passengers); db.Tickets.Add(tickets); db.SaveChanges(); Close(); }
//To Update the records of a particluar employee public int UpdatePassengers(Passengers passengers) { try { using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); string sqlQuery = "dbo.UpdatePassengers"; SqlCommand cmd = new SqlCommand(sqlQuery, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID_departure", passengers.IdDeparture); cmd.Parameters.AddWithValue("@ID_passenger", passengers.IdPassenger); cmd.Parameters.AddWithValue("@Service_class", passengers.ServiceClass); cmd.Parameters.AddWithValue("@Passenger_lastname", passengers.PassengerLastname); cmd.Parameters.AddWithValue("@Passenger_name", passengers.PassengerName); cmd.ExecuteNonQuery(); con.Close(); } return(1); } catch { throw; } }
/// <summary> /// board passengers /// </summary> /// <param name="addingAmount">count of peoples in generating queue</param> public override List <Passenger.Passenger> BoardPassengers(int addingAmount) { List <Passenger.Passenger> busQueue = new BusQueue(addingAmount).GeneratePassengers(new BusPassengersBuilder()); Passengers.AddRange(BoardBus.Instance().BoardPassenger(Passengers.Count, ref busQueue)); return(busQueue); }
public void AddPassenger(Passenger pass) { if (IsSeatsExist) { Passengers.Add(pass); } }
public static bool Insert(Passengers passanger) { bool status; try { using (var mySqlConnection = new MySqlConnection(connectionString)) { mySqlConnection.Open(); string query = "INSERT passengers (passengerId,firstName,lastName,mobileNo,adharNo) " + "VALUES (@passengerId,@firstName,@lastName,,@mobileNo,@adharNo)"; var sqlCommand = new MySqlCommand(query, mySqlConnection); sqlCommand.Parameters.Add(new MySqlParameter("@passengerId", passanger.PassengerId)); sqlCommand.Parameters.Add(new MySqlParameter("@firstName", passanger.FirstName)); sqlCommand.Parameters.Add(new MySqlParameter("@lastName", passanger.LastName)); sqlCommand.Parameters.Add(new MySqlParameter("@mobileNo", passanger.MobileNo)); sqlCommand.Parameters.Add(new MySqlParameter("@adharNo", passanger.AdharNo)); sqlCommand.ExecuteNonQuery(); status = true; } } catch (Exception ex) { Logger.LogException(ex); throw new Exception("Error while connecting with database, please contact site admin for more detail."); } finally { } return(status); }
public static bool Update(Passengers passanger) { bool status; try { using (var con = new MySqlConnection(connectionString)) { string query = "UPDATE passengers SET passengerId=@passengerId,firstName=@firstName,lastName=@lastName,mobileNo=@mobileNo " + "WHERE adharNo=@adharNo"; MySqlCommand cmd = new MySqlCommand(query, con); cmd.Parameters.Add(new MySqlParameter("@passangerId", passanger.PassengerId)); cmd.Parameters.Add(new MySqlParameter("@firstName", passanger.FirstName)); cmd.Parameters.Add(new MySqlParameter("@lastName", passanger.LastName)); cmd.Parameters.Add(new MySqlParameter("@mobileNo", passanger.MobileNo)); cmd.Parameters.Add(new MySqlParameter("@adharNo", passanger.AdharNo)); cmd.ExecuteNonQuery(); status = true; } } catch (Exception ex) { throw ex; } return(status); }
public Form1() { InitializeComponent(); Calendar.MinDate = DateTime.Today.Date; List <string> lines = File.ReadAllLines(filePath).ToList(); foreach (string line in lines) { string[] entries = line.Split(','); Passenger newPassenger = new Passenger(Convert.ToInt16(entries[0]), entries[1], entries[2], entries[3], entries[4], entries[5]); Passengers.Add(newPassenger); cmbList.Items.Add(newPassenger.PassengerName); flightNumber++; } clnTakeOff.MinDate = DateTime.Today.Date; List <string> lines2 = File.ReadAllLines(filePath2).ToList(); txtAllFlights.Text = "Time".PadRight(8) + "Date".PadRight(22) + "From".PadRight(16) + "To".PadRight(12) + "Flight\n"; foreach (string line in lines2) { string[] entries = line.Split(','); Flight newFlight = new Flight(Convert.ToString(entries[0]), entries[1], entries[2], entries[3], entries[4], Convert.ToString(entries[5]), Convert.ToInt16(entries[6]), Convert.ToInt16(entries[7]), Convert.ToString(entries[8]), Convert.ToInt16(entries[9]), entries[10]); Flights.Add(newFlight); if (newFlight.NumberOfWays == 2) { cmbInToolStripFlights.Items.Add($"{newFlight.TakeOffPlace}-{newFlight.Destination}"); } else { cmbOneWay.Items.Add($"{newFlight.TakeOffPlace}-{newFlight.Destination}"); } txtAllFlights.Text += newFlight.FlightTime.PadRight(8) + newFlight.TakeOffDate.PadRight(18) + newFlight.TakeOffPlace.PadRight(16) + newFlight.Destination.PadRight(12) + newFlight.FlightID + "\n"; } }
public void AddPassengers(IEnumerable <Passenger> pass) { foreach (var p in pass) { Passengers.Enqueue(p); } }
public static void bookFlight(List <Flights> flights) { Booking.availableFlights(flights); int flightNumber = Convert.ToInt32(Console.ReadLine()); Passengers passenger = Booking.addPassenger(); Console.WriteLine(("Passenger id = " + (passenger.PassengerId + " added successfully"))); if (!string.ReferenceEquals(flights, null)) { foreach (Flights flight in flights) { if ((flight.FlightNumber == flightNumber)) { flightNumber = flight.FlightNumber; if ((Booking.freePlace(flight) == true)) { flight.addPassengers(flight.Passengers, passenger); Console.WriteLine("flight booked successfully :) "); int places = flight.Passengers.Count; flight.OccupiedPlaces = places; passenger.FlightNum = flight.FlightNumber; } else { Console.WriteLine("flight book failed, there is no available place :( "); passenger = null; } break; } } } }
private void searchTextBox_TextChanged(object sender, EventArgs e) { PassengerList aux; if (searchTextBox.Text == "") { aux = Passengers; } else { if (firstNameRadioButton.Checked) { aux = Passengers.multipleSearch(1, searchTextBox.Text); } else if (lastNameRadioButton.Checked) { aux = Passengers.multipleSearch(2, searchTextBox.Text); } else if (flightRadioButton.Checked) { aux = Passengers.multipleSearch(3, searchTextBox.Text); } else { aux = Passengers.multipleSearch(4, searchTextBox.Text); } } loadPassengerList(aux); }
public static Passengers defaultPassengers() { var passengers = new Passengers(); foreach (var path in new List <string>() { "Images/Bee", "Images/Monkey", "Images/Mouse" }) { var texture = Resources.Load <Texture2D>(path); passengers.Add(texture); passengers.Select(texture); } foreach (var path in new List <string>() { "Images/businessman", "Images/doctor", "Images/girl", "Images/girl2", "Images/girl3", "Images/man2", "Images/student", "Images/woman", }) { var texture = Resources.Load <Texture2D>(path); passengers.Add(texture); } return(passengers); }
// for existing request public RequestViewModel(Request request) : base(request) { InitializeCommands(); Vehicle = new VehicleViewModel(Model.getVehicle()); VinNumber = Vehicle.VinNumber; Requestor = new UserViewModel(Model.getRequestor()); if (Model.isApproved()) { Approver = new UserViewModel(Model.getApprover()); } Driver = new UserViewModel(Model.getDriver()); DriverLicense = Requestor.DriverLicense; var start = Model.getPlannedTripStart(); var end = Model.getPlannedTripEnd(); this.plannedStartDate = start.ToString("MM/dd/yyyy"); this.plannedEndDate = end.ToString("MM/dd/yyyy"); PlannedStartHour = start.Hour; PlannedEndHour = end.Hour; PlannedStartDateMask = new DateMask(); PlannedEndDateMask = new DateMask(); foreach (var passenger in Model.getPassengers()) { Passengers.Add(new Tuple <string, Person>(passenger.getFullName(), passenger)); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,SeatPreference,RewardNumber,DiscountPercentage")] Passengers passengers) { if (id != passengers.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(passengers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PassengersExists(passengers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(passengers)); }
public override void Embus(Passenger passenger) { if (Passengers.Count == Capacity) { Console.WriteLine($"{GetType().Name} maximum capacity reached. Consider start now."); return; } switch (passenger.GetType().Name) { case "AdultPassenger": if (passenger.Pay(Price) > 0) { Passengers.Add(passenger); } break; case "ChildPassenger": if (ChildChair) { if (passenger.Pay(Price) > 0) { Passengers.Add(passenger); ChildChair = false; } } else { Console.WriteLine("No more child chair left."); } break; } }
public void AddBus(int n) { List <SimpleMan> newPassengers = new List <SimpleMan>(); for (int i = 0; i < n; i++) { newPassengers.Add(new SimpleMan()); } Random rnd = new Random(); Bus bus = new Bus(BusStops[rnd.Next(0, 2)].X, BusStops[rnd.Next(0, 2)].Y + 76, X, 100, firstLevel, secondLevel, newPassengers); if (Passengers == null) { Passengers = new List <SimpleMan>(); } Passengers.AddRange(newPassengers); Buses.Add(bus); TimeEvent += bus.Time; //List<SimpleMan> newPassengers = new List<SimpleMan>(); //for (int i = 0; i < n; i++) //{ // newPassengers.Add(new SimpleMan()); //} //Bus bus = new Bus(newPassengers); //if (Passengers == null) // Passengers = new List<SimpleMan>(); //Passengers.AddRange(newPassengers); //Buses.Add(bus); //TimeTickEvent += bus.TimeTick; }
public void LiftMove(int targetFloor, string direction) { if (direction == "down") { for (int floor = CurrentFloor; floor >= targetFloor; floor--) { Console.WriteLine($"Lift on {floor} floor"); } CurrentFloor = targetFloor; } else { for (int floor = 1; floor <= targetFloor; floor++) { Console.WriteLine($"Lift on {floor} floor"); var outgoingPassengers = Passengers.Where(p => p.SelectedFloor == floor).ToList(); if (outgoingPassengers != null) { foreach (var passenger in outgoingPassengers) { Console.WriteLine($"Passenger {passenger.Name} out in {floor} floor"); } } } } }
public override bool Equals(Object o) { if (this == o) { return(true); } if (!(o is KondutoTravel)) { return(false); } KondutoTravel that = o as KondutoTravel; if (!Passengers.SequenceEqual <KondutoPassenger>(that.Passengers)) { return(false); } if (!object.Equals(Departure, that.Departure)) { return(false); } if (!object.Equals(Return, that.Return)) { return(false); } return(true); }
/// <summary> /// 导入 /// </summary> /// <param name="passengers">The passengers.</param> /// <returns></returns> public bool ImportQueryPassengers(List <PassengerInTicket> passengers) { if (passengers?.Any() != true || Session.UserProfile.Passengers == null) { return(false); } var pas = passengers.Select(s => { var p = Session.UserProfile.Passengers?.FindMatch(s); if (p == null || p.Type == s.TicketType) { return(p); } return(p.CreateChild()); }). ExceptNull(). ToArray(); if (pas.Length != passengers.Count) { AppContext.HostForm.ShowWarningToastMini("联系人数据不正确,请关闭当前查询并重新查询后再试。"); return(false); } Passengers.Clear(); pas.Take(3).ForEach(Passengers.Add); if (pas.Length > 3) { AppContext.HostForm.ShowInfoToastMini("候补订单最多3个联系人,多出来的乘客已经忽略。"); } return(true); }
public bool Register(string passengerId, int cargoCount) { lock (Passengers) { if (IsRegistrationOpened == false) { return(false); } if (Passengers.Any(x => x.Equals(passengerId))) { return(false); } if (Passengers.Count < PassengerCapacity) { Passengers.Add(passengerId); CargoCount += cargoCount; return(true); } else { IsRegistrationOpened = false; return(false); } } }
/// <summary> /// board passengers /// </summary> /// <param name="addingAmount">count of peoples in generating queue</param> public override List <Passenger.Passenger> BoardPassengers(int addingAmount) { List <Passenger.Passenger> tmp = new List <Passenger.Passenger>(); List <Passenger.Passenger> taxiQueue = new TaxiQueue(addingAmount).GeneratePassengers(new TaxiPassengersBuilder()); foreach (var pretender in BoardTaxi.Instance().BoardPassenger(Passengers.Count, ref taxiQueue)) { if (pretender is Adult) { tmp.Add(pretender); continue; } if (pretender is Child) { if (ChildChairsExisting) { tmp.Add(pretender); continue; } else { throw new Exception("Sorry, I have no childchairs"); } } if (pretender is Preferential) { throw new Exception("Sorry, we don't transport preferentials"); } } Passengers.AddRange(tmp); return(taxiQueue); }
public override void Embus(Passenger passenger) { if (Passengers.Count == Capacity) { Console.WriteLine($"{GetType().Name} maximum capacity reached. Consider start now."); return; } switch (passenger.GetType().Name) { case "AdultPassenger": if (passenger.Pay(Price) > 0) { Passengers.Add(passenger); } break; case "ChildPassenger": if (passenger.Pay(Price * 0.5f) > 0) { Passengers.Add(passenger); } break; case "PrivilegedPassenger": Passengers.Add(passenger); break; } }
public async Task <IActionResult> Login(Passengers p) { try { var data = await ApiClientFactory.Instance.GetPassengers(); var GetID = from passenger in data where passenger.Surname.Equals(p.Surname) select passenger.PersonId; var PassengerID = GetID.ToArray(); if (GetID != null) { HttpContext.Session.SetInt32("idpassenger", PassengerID[0]); HttpContext.Session.SetInt32("ispassengerconnected", 1); //Someone is connected return(RedirectToAction("Index", "Home", new { id = PassengerID[0] })); } else { return(View()); } } catch (Exception) { return(View()); } }
public void CheckUserApplied(Guid userId) { if (Driver.Id.Equals(userId) || Passengers.Select(x => x.PassengerId.Equals(userId)).Any()) { UserApplied = true; } }
public override List <Car> GetResult() { List <Car> lst = new List <Car>(); int i = 0; int capacity = new Taxi().Capacity; while (i < Drivers.Count && i < Passengers.Count / ((double)capacity)) { Car car = new Taxi(); car.DriverInstance(Drivers[i]); car.Passengers.AddRange(Passengers.GetRange(i * capacity, Passengers.Count - i * capacity < capacity ? Passengers.Count - i * capacity : capacity)); lst.Add(car); i++; if (car.Passengers.Last() is Child) { (car as Taxi).ChildChairsExisting = true; } } Drivers.RemoveRange(0, i); foreach (var car in lst) { Passengers.RemoveRange(0, car.Passengers.Count); } return(lst); }
private void SaveFlight() { if (SelectedTrip != null && SelectedDate != null && Passengers.Count != 0) { List <PassengersInFlightModel> passList = new List <PassengersInFlightModel>(Passengers); Passengers.Clear(); foreach (var p in passList) { p.Date = SelectedDate.ToShortDateString(); PassengersInFlightModel pass = PassengersViewModel.AddNewPassenger(p); Passengers.Add(pass); } FlightsViewModel.NewFlight = new TripModel(SelectedTrip.TripNumber, SelectedDate.ToShortDateString(), SelectedTrip.AirwayCompany, SelectedTrip.Plane, SelectedTrip.TownFrom, SelectedTrip.TownTo, SelectedTrip.DepTime, SelectedTrip.ArrTime, null, Passengers); } else if (SelectedTrip == null) { MessageBox.Show("Trip is not selected!"); } else if (SelectedDate == null) { MessageBox.Show("Date for trip is not selected!"); } else if (Passengers.Count == 0) { MessageBox.Show("Passengers list is empty! Please,add passengers."); } else { MessageBox.Show("Check entered data! Something is wrong."); } }
/// <summary> /// Picks passengers from the given floor. /// </summary> /// <param name="floorNumber">The number of the floor.</param> private void PickPassengers(int floorNumber) { var floor = GetFloor(floorNumber); bool hasFloorsWithWaitingMechanics = HasFloorsWithWaitingMechanics(); if (floor.IsEmpty() || (hasFloorsWithWaitingMechanics && !floor.HasWaitingMechanics())) { return; } var pickedUpPassangers = new List <Person>(); var passengersToPick = floor.Passengers.Where(p => p.CurrentFloor != p.Destination).OrderBy(p => p.IsMechanic).ToList(); foreach (var passenger in passengersToPick) { if (passenger.Destination != floorNumber && !IsFull()) { Passengers.Add(passenger); pickedUpPassangers.Add(passenger); } } if (pickedUpPassangers.Any()) { floor.LeaveFloor(pickedUpPassangers); AddHistoryRecord(floorNumber); } }
/// <summary> /// ConfimAddTaxi_Click функція, що створює дані про новий автомобіль таксі,попередньо перевіряючи валідність заповлення полів. /// </summary> /// <param name="sender">Об'єкт.</param> /// <param name="e">Маршрутизована подія</param> private void ConfimAddTaxi_Click(object sender, RoutedEventArgs e) { if (AddTAXIXID.Text != "" && AddTaxiName.Text != "" && Passengers.Text != "" && BusinessClass.Text != "" && EconomClass.Text != "") { try { string connectionString = ConfigurationManager.ConnectionStrings["MainConnection"].ConnectionString; string query = $"INSERT INTO Taxi (Id,Model,Passengers,Business,Econom) " + $"VALUES ('{AddTAXIXID.Text}', '{AddTaxiName.Text}', '{Passengers.Text}', '{BusinessClass.Text}', '{EconomClass.Text}');"; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(query, connection); command.ExecuteNonQuery(); connection.Close(); } AddTAXIXID.Clear(); AddTaxiName.Clear(); Passengers.Clear(); BusinessClass.Clear(); EconomClass.Clear(); } catch (Exception ee) { MessageBox.Show(ee.Message); } } else { MessageBox.Show("Something wrong"); } }
public void Apply(IReadModelContext context, IDomainEvent <Domain.Booking.Booking, BookingId, PassengerNameUpdatedEvent> domainEvent) { var passenger = Passengers.Single(x => x.PassengerKey == domainEvent.AggregateEvent.PassengerKey); passenger.Name = domainEvent.AggregateEvent.Name; }
public void SearchPassengerToMove(int pas) { try { if (pas == 1) { Passenger1 = Passengers.FirstOrDefault(p => p.Seat == Seat1); if (Passenger1 == null) { ErrorMessage = "There is no passenger on this seat!"; } else { ErrorMessage = null; } } else if (pas == 2) { Model.Passenger ps = Passengers.FirstOrDefault(p => p.Seat == Seat2); if (ps != null) { Passenger2 = ps; ErrorMessage2 = null; } else { ErrorMessage2 = "There is no passenger on this seat! You can move the passenger to this seat."; } } } catch (Exception) { ErrorMessage = "Something went wrong! Please try again later."; } }
private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (firstNameSortRadioButton.Checked == true) { Passengers.quickSort(0, Passengers.Count - 1, 1); } loadPassengerList(Passengers); }