Beispiel #1
0
 public Reservation CreateReservation(int id, Guest guest, List <Room> rooms)
 {
     reservation = new Reservation(id, rooms, guest);
     Console.WriteLine(reservation.ToString());
     return(reservation);
 }
Beispiel #2
0
 internal void SetGuest(Guest g)
 {
     _guest = g;
 }
Beispiel #3
0
 public void ReturnResult(Guest guest, Hotel hotel)
 {
     Console.WriteLine($"{guest.Search(hotel)}");
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            AVL       avl                 = new AVL();
            Hashtable hashtable           = new Hashtable();
            CircularDoublyLinkedList list = new CircularDoublyLinkedList();
            const int size                = 10;

            table = new Guest[size];
            for (int i = 0; i < size; i++)
            {
                table[i] = null;
            }

            int n = -1;

            while (n != 0)
            {
                Console.WriteLine("\n***Регистрация постояльцев в гостинице***");
                Console.WriteLine("\n     ************ Меню ************\n");
                Console.WriteLine("1 - Добавить гостиничный номер");
                Console.WriteLine("2 - Вывести список всех номеров");
                Console.WriteLine("3 - Зарегистрировать постояльца в гостинице");
                Console.WriteLine("4 - Вывести всех постояльцев");
                Console.WriteLine("5 - Удалить гостиничный номер");
                Console.WriteLine("6 - Удалить запись о постояльце");
                Console.WriteLine("7 - Поиск постояльца по № паспорта");
                Console.WriteLine("8 - Поиск постояльца по ФИО");
                Console.WriteLine("9 - Поиск гостиничного номера по №");
                Console.WriteLine("10 - Поиск гостиничного номера по наличию оборудования");
                Console.WriteLine("11 - Регистрация вселения постояльца");
                Console.WriteLine("12 - Регистрация выселения постояльца");
                Console.WriteLine("0 - Выход");
                Console.WriteLine("Выберите нужный пункт меню: ");

                while (true)
                {
                    if (Int32.TryParse(Console.ReadLine(), out n))
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Неверный ввод");
                    }
                }

                switch (n)
                {
                case 1:     //Добавление гостиничного номера
                {
                    avl.Add(avl.InputData());
                    break;
                }

                case 2:     //Вывод списка номеров
                {
                    if (avl.IsEmpty())
                    {
                        Console.WriteLine("Список номеров пуст!");
                    }
                    else
                    {
                        Console.WriteLine("Список номеров: ");
                        avl.PostOrderTraversal();
                    }
                    Console.ReadLine();
                    break;
                }

                case 3:     //Регистрация постояльца в гостинице
                {
                    Guest newGuest = new Guest();
                    hashtable.Insert(newGuest.Input(newGuest, hashtable));
                    break;
                }

                case 4:     // Вывод списка постояльцев
                {
                    if (hashtable.IsEmpty)
                    {
                        Console.WriteLine("База пуста. Заполните ее!");
                    }
                    else
                    {
                        hashtable.Print();
                    }
                    Console.ReadLine();
                    break;
                }

                case 5:     // Удаление гостиничного номера
                {
                    if (avl.IsEmpty())
                    {
                        Console.WriteLine("Список номеров пуст!");
                    }
                    else
                    {
                        Console.WriteLine("Введите гостиничный номер для удаления (в формате ANNN: где A – буква (Л – люкс, П – полулюкс, О – одноместный, М – многоместный), NNN – цифры): ");
                        string word = avl.InputRoomNumber();
                        if (list.ContainsRoom(word))
                        {
                            Console.WriteLine("\nНельзя удалять гостиничный номер с вселенными постояльцами!");
                        }
                        else
                        {
                            avl.Delete(word);
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 6:     // Удаление записи о постояльце
                {
                    Guest        current = new Guest();
                    Registration reg     = new Registration();
                    if (hashtable.IsEmpty)
                    {
                        Console.WriteLine("База пуста. Заполните ее!");
                    }
                    else
                    {
                        Console.WriteLine("Введите № паспорта постояльца для удаления: ");
                        current.passport_number = current.InputPassportNumber();
                        if (!list.IsEmpty)
                        {
                            reg = list.FindPassport(current.passport_number);
                            if (reg != null && reg.chekOut == null)
                            {
                                Console.WriteLine("Нельзя удалять вселенных постояльцев!");
                            }
                        }
                        else
                        {
                            bool isPresent = hashtable.Remove(current.GetKey());
                            Console.WriteLine(isPresent == true ? "\nЗапись успешно удалена!" : "\nПостоялец с таким номером паспорта не зарегистрирован в гостинице!");
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 7:     // Поиск постояльца по номеру паспорта
                {
                    Guest current = new Guest();
                    if (hashtable.IsEmpty)
                    {
                        Console.WriteLine("База пуста. Заполните ее!");
                    }
                    else
                    {
                        Console.WriteLine("Введите № паспорта постояльца для поиска: ");
                        current.passport_number = current.InputPassportNumber();
                        current = hashtable.FindGuest(current.GetKey());
                        if (current == null)
                        {
                            Console.WriteLine("Постоялец с таким номером паспорта не зарегистрирован в гостинице!");
                        }
                        else
                        {
                            if (list.ContainsResident(current.passport_number))
                            {
                                Console.WriteLine("\nНайден паспорт: {0}", current.passport_number);
                                Console.WriteLine("ФИО постояльца: {0}", current.FIO);
                                Console.WriteLine("Год рождения: {0}", current.birth_year);
                                Console.WriteLine("Адрес проживания: {0}", current.adress);
                                Console.WriteLine("Цель визита: {0}", current.purpose_of_visit);
                                Console.WriteLine("Постоялец живет в номере {0}.", list.FindPassport(current.passport_number).room_num);
                            }
                            else
                            {
                                Console.WriteLine("\nНайден паспорт: {0}", current.passport_number);
                                Console.WriteLine("ФИО постояльца: {0}", current.FIO);
                                Console.WriteLine("Год рождения: {0}", current.birth_year);
                                Console.WriteLine("Адрес проживания: {0}", current.adress);
                                Console.WriteLine("Цель визита: {0}", current.purpose_of_visit);
                                Console.WriteLine("Постоялец не проживает в гостинице!");
                            }
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 8:     // Поиск постояльца по ФИО
                {
                    string FIO;
                    if (hashtable.IsEmpty)
                    {
                        Console.WriteLine("База пуста. Заполните ее!");
                    }
                    else
                    {
                        Console.WriteLine("Введите ФИО для поиска: ");
                        FIO = Console.ReadLine();
                        hashtable.SearchString(FIO);

                        Console.WriteLine("\nНайденные постояльцы: ");
                        foreach (var item in guests)
                        {
                            Console.Write("\nФИО постояльца: {0}", item.FIO);
                            Console.Write("\nПаспорт постояльца: {0}\n", item.passport_number);
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 9:     // Поиск гостиничного номера по его №
                {
                    AVL.Hotel_room hm = new AVL.Hotel_room();
                    guests.Clear();
                    if (avl.IsEmpty())
                    {
                        Console.WriteLine("Список номеров пуст!");
                    }
                    else
                    {
                        Console.WriteLine("Введите гостиничный номер для поиска: ");
                        string str = avl.InputRoomNumber();
                        hm = avl.Find(str);
                        if (hm == null)
                        {
                            Console.WriteLine("\nИскомый номер не обнаружен!");
                        }
                        else
                        {
                            Console.WriteLine("\nНомер найден:");
                            Console.WriteLine("\nГостиничный номер: {0}", hm.room_number);
                            Console.WriteLine("Количество комнат: {0}", hm.rooms);
                            Console.WriteLine("Количество мест: {0}", hm.places);
                            Console.WriteLine("Оборудование: {0}", hm.equipment);
                            Console.WriteLine("Санузел: {0}", hm.toilet);

                            if (list.IsEmpty)
                            {
                                Console.WriteLine("В номере никто не проживает.");
                            }
                            else
                            {
                                list.FindRooms(hm.room_number);
                                if (rooms.Count > 0)
                                {
                                    foreach (var item in rooms)
                                    {
                                        guests.Add(hashtable.FindGuest(Convert(item)));
                                    }
                                    Console.WriteLine("\nВ номере проживают: ");
                                    foreach (var item in guests)
                                    {
                                        Console.Write("ФИО постояльца: {0}", item.FIO);
                                        Console.Write("\nПаспорт постояльца: {0}\n", item.passport_number);
                                    }
                                }
                            }
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 10:     // Поиск гостиничных номеров по оборудованию
                {
                    if (avl.IsEmpty())
                    {
                        Console.WriteLine("Список номеров пуст!");
                    }
                    else
                    {
                        Console.WriteLine("Введите оборудование для поиска: ");
                        avl.SearchString(Console.ReadLine());
                        if (AVL.h_rooms.Count != 0)
                        {
                            Console.WriteLine("\nНайденные номера: ");
                            foreach (var item in AVL.h_rooms)
                            {
                                Console.WriteLine("\nГостиничный номер: {0}", item.room_number);
                                Console.WriteLine("Количество комнат: {0}", item.rooms);
                                Console.WriteLine("Количество мест: {0}", item.places);
                                Console.WriteLine("Оборудование: {0}", item.equipment);
                                Console.WriteLine("Санузел: {0}", item.toilet);
                            }
                        }
                        else
                        {
                            Console.WriteLine("\nИскомое оборудование не встречается в номерах!");
                        }
                    }
                    Console.ReadLine();
                    break;
                }

                case 11:     // Регистрация вселения
                {
                    Registration reg      = new Registration();
                    Guest        newGuest = new Guest();
                    string       date;
                    DateTime     dateChekIn = new DateTime();
                    dateChekIn = DateTime.Now;
                    Console.WriteLine("Введите № паспорта постояльца: ");
                    newGuest.passport_number = newGuest.InputPassportNumber();
                    bool isPresent = hashtable.Find(newGuest.GetKey());
                    bool flag      = false;
                    bool freeBeds  = false;
                    if (!isPresent)
                    {
                        Console.WriteLine("\nПостоялец с таким номером паспорта не зарегистрирован в гостинице! Необходимо пройти регистрацию!");
                    }
                    else if (list.ContainsResident(newGuest.passport_number) && !list.IsEmpty)
                    {
                        Console.WriteLine("\nПостоялец уже живет в гостинице!");
                    }
                    else
                    {
                        reg.pass_num = newGuest.passport_number;
                        Console.WriteLine("Введите гостиничный номер для регистрации(в формате ANNN: где A – буква (Л – люкс, П – полулюкс, О – одноместный, М – многоместный), NNN – цифры): ");
                        reg.room_num = reg.InputRoomNumber();
                        flag         = avl.Contains(reg.room_num);
                        if (avl.IsEmpty())
                        {
                            Console.WriteLine("\nСписок номеров пуст! Сначала заполните его.");
                        }
                        else if (flag)
                        {
                            if (avl.Find(reg.room_num).places > 0)
                            {
                                freeBeds = avl.ChangeFreePlaces(reg.room_num);
                                Console.WriteLine("\nВселить постояльца? (y/n)");
                                date = InputLetter();
                                if (date.Equals("y"))
                                {
                                    reg.chekIn = dateChekIn.ToString();
                                    Console.WriteLine("Дата: " + reg.chekIn);
                                    Console.WriteLine("Успешно!");
                                    list.Add(reg);
                                }
                                else
                                {
                                    Console.WriteLine("Отмена.");
                                }
                            }
                            else
                            {
                                Console.WriteLine("\nВ номере нет свободных мест!");
                            }
                        }
                        else
                        {
                            Console.WriteLine("\nНет такого номера!");
                        }
                    }

                    /*Console.WriteLine("Введите № паспорта постояльца: ");
                     * newGuest.passport_number = newGuest.InputPassportNumber();
                     * reg.pass_num = newGuest.passport_number;
                     * Console.WriteLine("Введите гостиничный номер для регистрации(в формате ANNN: где A – буква (Л – люкс, П – полулюкс, О – одноместный, М – многоместный), NNN – цифры): ");
                     * reg.room_num = reg.InputRoomNumber();
                     * list.Add(reg);*/
                    Console.ReadLine();
                    break;
                }

                case 12:     // Регистрация выселения
                {
                    AVL.Hotel_room hm           = new AVL.Hotel_room();
                    DateTime       checkOutDate = new DateTime();
                    checkOutDate = DateTime.Now;
                    Registration reg      = new Registration();
                    Guest        newGuest = new Guest();
                    string       date;
                    Console.WriteLine("Введите № паспорта постояльца: ");
                    newGuest.passport_number = newGuest.InputPassportNumber();
                    if (list.IsEmpty)
                    {
                        Console.WriteLine("\nВ гостинице никто не проживает.");
                    }
                    else
                    {
                        reg = list.FindPassport(newGuest.passport_number);
                        if (reg != null)
                        {
                            Console.WriteLine("\nВыселить постояльца? (y/n)");
                            date = InputLetter();
                            if (date.Equals("y"))
                            {
                                hm = avl.Find(reg.room_num);
                                hm.places++;
                                reg.chekOut = checkOutDate.ToString();
                                Console.WriteLine("Дата: " + reg.chekOut);
                                Console.WriteLine("Успешно!");
                            }
                            else
                            {
                                Console.WriteLine("Отмена.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Постоялец с таким номером паспорта не проживает в гостинице!");
                        }
                    }
                    Console.ReadLine();
                    break;
                }
                }
            }
        }
Beispiel #5
0
 public void SetNextNode(Guest obj)
 {
     next = obj;
 }
Beispiel #6
0
        public Form3(Guest guestItem)
        {
            InitializeComponent();

            _guestItem = guestItem;
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            HotelDbEntities context     = new HotelDbEntities();
            Reservation     reservation = new Reservation(context);
            Menu            menu        = new Menu(context, reservation);

            SqlConnection con = new SqlConnection(conString);

            Service service = new Service(con);
            //service.DeleteAmenity(context.Rooms.Take(1).FirstOrDefault(), "Breakfast");


            var guests = new List <Person>();

            //reservation.ReserveRoom(guests, context.Rooms.FirstOrDefault(), DateTime.Now, DateTime.Now.AddDays(1));
            int      input;
            Room     room         = new Room();
            DateTime CheckInDate  = DateTime.MinValue;
            DateTime CheckOutDate = DateTime.MinValue;

            do
            {
                menu.DisplayCurrentSetup(room, guests, CheckInDate, CheckOutDate);
                menu.DisplayAvailableRooms();

                menu.DisplayOptions();

                int.TryParse(Console.ReadLine(), out input);

                int roomNumber = 0;

                switch (input)
                {
                case 1:
                    Console.WriteLine("Select available room");

                    int.TryParse(Console.ReadLine(), out roomNumber);
                    if (roomNumber != 0)
                    {
                        room = context.Rooms.Where(x => x.Nr == roomNumber).Select(x => x).FirstOrDefault();
                    }
                    break;

                case 2:
                    Console.Clear();
                    Console.WriteLine("Enter first name:");
                    string firstName = Console.ReadLine();
                    Console.WriteLine("Enter last name:");
                    string lastName = Console.ReadLine();
                    Console.WriteLine("Enter personal code:");
                    string personalCode = Console.ReadLine();
                    guests.Add(new Person()
                    {
                        FirstName = firstName, LastName = lastName, PersonalCode = personalCode
                    });
                    break;

                case 3:
                    menu.DisplayAmenitiesOptions();
                    int select;
                    int.TryParse(Console.ReadLine(), out select);
                    switch (select)
                    {
                    case 1:
                        Console.WriteLine("Enter name of amenity");
                        var name = Console.ReadLine();
                        Console.WriteLine("Enter price");
                        var price = double.Parse(Console.ReadLine());
                        Console.WriteLine("Select room number");
                        var num = int.Parse(Console.ReadLine());


                        service.AddAmenity(context.Rooms.Where(x => x.Nr == num).Select(x => x).FirstOrDefault(), name, price);
                        break;

                    case 2:
                        Console.WriteLine("Select room number");
                        var num2 = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter name of amenity");
                        var name2 = Console.ReadLine();
                        service.DeleteAmenity(context.Rooms.Where(x => x.Nr == num2).Select(x => x).FirstOrDefault(), name2);
                        break;

                    case 3:
                        Console.WriteLine("Select room number");
                        var num3 = int.Parse(Console.ReadLine());
                        Console.WriteLine("Enter name of amenity");
                        var name3 = Console.ReadLine();
                        Console.WriteLine("Enter new room number");
                        var roomId = int.Parse(Console.ReadLine());
                        service.UpdateAmenity(context.Rooms.Where(x => x.Nr == num3).Select(x => x).FirstOrDefault(), name3, context.Rooms.Where(x => x.Nr == roomId).Select(x => x).FirstOrDefault());
                        break;

                    default:
                        break;
                    }

                    break;

                case 4:
                    Console.WriteLine("Check in date: ");
                    DateTime.TryParse(Console.ReadLine(), out CheckInDate);
                    Console.WriteLine("Check out date: ");
                    DateTime.TryParse(Console.ReadLine(), out CheckOutDate);
                    break;


                case 5:
                    Console.Clear();
                    if (CheckInDate != DateTime.MinValue && guests.Capacity != 0)
                    {
                        var reservationConfirmed = reservation.ReserveRoom(guests, room, CheckInDate, CheckOutDate);
                        if (reservationConfirmed)
                        {
                            Console.Clear();
                            Console.WriteLine("reservation successful");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Failed to register. Make sure to fill all fields.");
                    }
                    break;

                case 6:
                    Console.WriteLine("Select room number to free up");
                    int roomNum = int.Parse(Console.ReadLine());
                    reservation.RemoveGuests(roomNum);
                    break;

                case 7:
                    break;

                default:
                    break;

                case 8:
                    Console.Clear();
                    menu.DisplayAllRooms();
                    break;

                case 9:
                    Console.Clear();
                    menu.ViewAllGuests();
                    break;

                case 10:
                    Console.WriteLine("Select room nr to change price");
                    int rNr = int.Parse(Console.ReadLine());
                    Console.WriteLine("Enter new price");
                    double newPrice = double.Parse(Console.ReadLine());
                    reservation.UpdateRoom(rNr, newPrice);
                    break;

                case 11:
                    menu.DisplayMostUsedRooms();

                    break;

                case 12:
                    Console.WriteLine("Enter guests first or second name");
                    var   searchKey  = Console.ReadLine();
                    Guest guestFound = reservation.SearchGuest(searchKey);
                    if (guestFound != null)
                    {
                        Console.WriteLine($"Guest {guestFound.FirstName} {guestFound.LastName} was found in {context.Rooms.Where(x => x.Id == guestFound.RoomId).FirstOrDefault().Nr} room");
                    }
                    else
                    {
                        Console.WriteLine("Guest not found");
                    }
                    break;

                case 13:
                    menu.DisplayMostExpensiveAmenities();
                    break;
                }
            } while (input != 22);
        }
Beispiel #8
0
 internal void SetGuest(Guest guest)
 {
     this.guest = guest;
 }
Beispiel #9
0
        public static void ToRentARoom(Hotel hotel, Guest guest)
        {
            int[] rooms = null;
            foreach (KeyValuePair <int, Guest> Pair in Hotel.Booked)
            {
                if (Pair.Value.Name == guest.Name)
                {
                    DateTime time = DateTime.Now;
                    Console.WriteLine($"You have rented a room #{Pair.Key + 1}.");
                    guest = Pair.Value;
                    Console.WriteLine("How many days would you like to rent a room for?");
                    int      days2  = Convert.ToInt32(Console.ReadLine());
                    DateTime date1  = time.AddDays(days2);
                    decimal  topay1 = days2 * hotel[Pair.Key].Price;
                    Console.WriteLine($"To pay: {topay1}.");
                    Console.ReadKey();
                    Console.WriteLine("*money*");
                    Console.ReadKey();
                    //int paid1;
                    guest.ToRent(days2, hotel[Pair.Key]);
                    Hotel.Booked.Remove(Pair.Key);
                    break;
                }
            }
            if (guest != null)
            {
                //Console.WriteLine("Your age:");
                //int age = Convert.ToInt32(Console.ReadLine());
                //guest = new Guest(guest.Name, age);
                //tourist.Notify += DisplayMessage;
                string category;
                while (true)
                {
                    Console.WriteLine("What type of room would you like to book?");
                    Console.WriteLine("1 Standart");
                    Console.WriteLine("2 Medium");
                    Console.WriteLine("3 Lux");
                    category = Console.ReadLine();
                    switch (category)
                    {
                    case null:
                        Console.WriteLine("Sorry you did something wrong.");
                        break;

                    case "1":
                        rooms = Hotel.Standart;
                        break;

                    case "2":
                        rooms = Hotel.Medium;
                        break;

                    case "3":
                        rooms = Hotel.Lux;
                        break;

                    default:
                        throw new Exception();
                    }

                    DateTime time = DateTime.Now;
                    Console.WriteLine("How many days?");

                    int days1 = Convert.ToInt32(Console.ReadLine());
                    if (days1 <= 0)
                    {
                        throw new Exception();
                    }
                    DateTime date  = time.AddDays(days1);
                    decimal  topay = days1 * hotel[rooms[0]].Price;
                    Console.WriteLine($"To pay: {topay}.");
                    Console.ReadKey();
                    Console.WriteLine("*money*");
                    Console.ReadKey();
                    foreach (int r in rooms)
                    {
                        if (guest.ToRent(days1, hotel[r]))
                        {
                            Hotel.Booked.Add(r, guest);
                            break;
                        }
                    }
                }
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            try
            {
                Hotel hotel = new Hotel(Hotel.Rooms);

                string choice = "";

                Console.WriteLine("Please, enter guest's name: ");
                string name = Console.ReadLine();
                if (name == null)
                {
                    throw new Exception("The name input is not correct.");
                }
                Console.WriteLine("Please, enter guest's age");
                int age = Convert.ToInt32(Console.ReadLine());
                if (name == null)
                {
                    throw new Exception("The age input is not correct.");
                }
                Guest guest = new Guest(name, age);


                while (true)
                {
                    Console.WriteLine("Please, choose a number according to your purpose:");
                    Console.WriteLine("1. To book a room.");
                    Console.WriteLine("2. To rent a room now.");
                    Console.WriteLine("3. To display the information about hotel room.");
                    Console.WriteLine("4. To display guest's card");
                    Console.WriteLine("0. Exit");



                    choice = Console.ReadLine();

                    switch (choice)
                    {
                    case "1":
                        ToBookARoom(hotel, guest);
                        break;

                    case "2":
                        ToRentARoom(hotel, guest);
                        break;

                    case "3":
                        RoomInfo(hotel);
                        break;

                    case "4":
                        GetCard();
                        break;

                    case "0":
                        return;

                    default:
                        throw new Exception();
                    }
                }
            }
            catch (Exception)
            {
                throw new Exception("Error");
            }
        }