private void Button_Click(object sender, RoutedEventArgs e)
 {
     //makes a resevation and changes the page to resevations 
     Customer customer = new Customer(firstname.Text,lastname.Text,adresse.Text,city.Text,postal.Text,country.Text,email.Text,phoneNumber.Text);
     Reservation reservation = new Reservation(customer,Room,DateTime.Now, (DateTime)datePicker.SelectedDate);
     Reception.CreateCustomer(customer);
     Reception.CreateReservation(reservation);
     Resevations resevations = new Resevations(ContentControl,Reception);
     ContentControl.Content = resevations;
 }
Exemple #2
0
        //on Button click, it will reserve a room thats picked.
        protected void bn_reserve_Click(object sender, EventArgs e)
        {
            if (CheckEmptyTextBox(tb_firstName, "Fornavnet"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_lastName, "Efternavnet"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_phoneNumber, "Telefonnummeret"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_email, "Emailen"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_address, "Adressen"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_postal, "Postnummeret"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_country, "Landet"))
            {
                return;
            }
            if (CheckEmptyTextBox(tb_city, "Byen"))
            {
                return;
            }

            try
            {
                if (CheckEmail())
                {
                    return;
                }

                Customer customer = new Customer(
                    tb_firstName.Text,
                    tb_lastName.Text,
                    tb_address.Text,
                    tb_city.Text,
                    tb_postal.Text,
                    tb_country.Text,
                    tb_email.Text,
                    tb_phoneNumber.Text
                    );
                reception.CreateCustomer(customer);

                Reservation reservation = new Reservation(
                    customer,
                    reception.GetRoom(int.Parse(Request["Room"])),
                    Convert.ToDateTime(Request["SDate"]),
                    Convert.ToDateTime(Request["LDate"])
                    );
                reception.CreateReservation(reservation);
                Response.Redirect(@"..\Confirmed.aspx");
            }
            catch (Exception exception)
            {
                lb_error.Text = exception.Message;
            }
        }