Ejemplo n.º 1
0
        private void btnCountinue_Click(object sender, EventArgs e)
        {
            //Declaring the Variables
            int    mobileNumber;
            string email    = txtEmail.Text;
            string name     = txtName.Text;
            string surname  = txtSurname.Text;
            string address  = txtAddress.Text;
            string idNumber = txtId.Text;
            string bdId     = txtBdId.Text;
            int    telephone;

            double bookingDays;
            double roomPrice;
            double bookingPrice;

            Email userEmail = new Email();                                                                                           // intializing a new email

            if (ValidateControls() && int.TryParse(txtMobile.Text, out mobileNumber) && int.TryParse(txtMobile.Text, out telephone)) // the form is validated and the inputs taken
            {
                DateTime dateFrom = new DateTime();                                                                                  // intilizing a new date (From)
                DateTime dateTo   = new DateTime();                                                                                  // intilizing a new date (to)
                dateFrom = dateFromPick.Value.Date;                                                                                  // Getting the value from
                dateTo   = dateToPick.Value.Date;                                                                                    // Getting the value to

                TimeSpan t = dateTo.Date - dateFrom.Date;                                                                            //setting the time span to get the days
                bookingDays = t.TotalDays;                                                                                           // getting total days

                RoomNo   roomNo = (RoomNo)Enum.Parse(typeof(RoomNo), cbxRoomNo.SelectedItem.ToString());                             // Get roomNo from enums of the cbx
                RoomType type   = (RoomType)Enum.Parse(typeof(RoomType), cbxTyp.SelectedItem.ToString());                            // Get type from enums of the cbx

                cust = new Customer(mobileNumber, email, name, surname, address, idNumber, telephone);                               // Intilizing a new customer with all the details


                roomPrice    = room.GetRoomPrice(type); // getting the room price and inputing the type
                bookingPrice = bookingDays * roomPrice; // Getting the price of the booking



                room = new Rooms(roomNo, type, roomPrice, bdlst);                               // Creating a room and settinf it's properties
                bd   = new Booking_Date(emp, cust, dateFrom, dateTo, room, bookingPrice, bdId); // creating a booking date and giving it its properties
                bill = new Bill(cust, emp, bd);                                                 // crearing a new bill


                tblCustomerTableAdapter.InsertQuery(mobileNumber, email, name, surname, address, idNumber, telephone);                                    //inserting the date to the database
                tblBookingDateTableAdapter1.Insert(bd.Emp.ToString(), emp.ToString(), dateFrom, dateTo, room.ToString(), bookingPrice.ToString(), bdId);; //inserting the date to the database

                this.tblCustomerTableAdapter.Fill(this.customerDS.tblCustomer);                                                                           // filling the tables
                this.tblBookingDateTableAdapter1.Fill(this.customerDS.tblBookingDate);
                MessageBox.Show("Booking" + "\nInfo:" + cust.GetInfo() + "\n" + bd.GetInfo() + "\n" + "Type: " + type);                                   // messages box al the booking info


                userEmail.SendEmail(txtEmail.Text, "*****@*****.**", "DETAILS OF YOUR BOOKING", "\nEnjoy Your Stay" + bd.GetInfo()); // sending the email

                Menu m1 = new Menu(emp);                                                                                                       // Sets the user back to the menu
                this.Hide();
                m1.ShowDialog();
            }
        }
Ejemplo n.º 2
0
 public Bill(Customer cust, Employee emp, Booking_Date bd) // This is the overloaded constractor of the bill with the values below.
 {
     this.cust = cust;
     this.emp  = emp;
     this.bd   = bd;
 }