예제 #1
0
        public static void Registration_Booking()
        {
            string startDate = "";
            string endDate   = "";
            string hotelID   = "";
            string guestID   = "";
            string roomNo    = "";

            Console.Clear();
            System.Console.WriteLine("Please enter following information:");
            System.Console.Write("Hotel ID: ");
            hotelID = System.Console.ReadLine();
            System.Console.Write("Room Number: ");
            roomNo = System.Console.ReadLine();
            System.Console.Write("Guest ID: ");
            guestID = System.Console.ReadLine();
            System.Console.Write("Start Date: ");
            startDate = System.Console.ReadLine();
            System.Console.Write("End Date: ");
            endDate = System.Console.ReadLine();

            if (startDate.CompareTo("") == 0 && endDate.CompareTo("") == 0 && hotelID.CompareTo("") == 0 && roomNo.CompareTo("") == 0 && guestID.CompareTo("") == 0)
            {
                Console.Clear();
                MessageBox.Show("Error: All Input Cannot Empty!", "Error");
                return;
            }
            try
            {
                if (startDate.CompareTo("") != 0 && endDate.CompareTo("") != 0 && hotelID.CompareTo("") != 0 && roomNo.CompareTo("") != 0 && guestID.CompareTo("") != 0)
                {
                    string sql = "insert into Booking values('" + hotelID + "','" + roomNo + "','" + guestID + "','" + startDate + "','" + endDate + "')";
                    string booking_reference_num = GenerateRandomNumber();
                    Loading.Searching_Loading();
                    if (DataOperation.execSQL(sql))
                    {
                        System.Console.WriteLine("Data executing successful!");
                        System.Console.WriteLine("Please waiting...");
                        Thread.Sleep(2000);
                        System.Console.WriteLine("Thank you!");
                        System.Console.WriteLine("Your Booking Reference Number is :" + booking_reference_num);
                        System.Console.WriteLine("Press any button to quit!");
                        System.Console.ReadKey();
                        Console.Clear();
                    }
                    else
                    {
                        MessageBox.Show("There is no available room in hotel:\t" + hotelID + "\n time between:\t" + startDate + "\t and \t" + endDate, "Notice");
                        Console.Clear();
                    }
                    return;
                }
                else
                {
                    Console.Clear();
                    MessageBox.Show("Error: All Input Cannot Empty!", "Error");
                    return;
                }
            }
            catch (Exception e)
            {
                Console.Clear();
                MessageBox.Show("Error: Wrong!", "Notice");
            }
        }