Exemplo n.º 1
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;
            }
        }