Exemple #1
0
 //on button click, it will reserve a room thats picked, if you allready is a customer
 protected void Unnamed1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!reception.CheckEmailExists(tb_emailExist.Text))
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "VeiwBox", "VeiwBox(0, 'NotNewCustomerBox', 'NewCustomerBox')", true);
             lb_error.Text = "Emailen eksitere ikke i systemet!";
             return;
         }
         if (reception.CheckAvailableRoom(
                 int.Parse(Request["Room"]),
                 Convert.ToDateTime(Request["SDate"]),
                 Convert.ToDateTime(Request["LDate"])
                 ))
         {
             Customer    customer    = reception.GetCustomer(tb_emailExist.Text);
             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");
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "VeiwBox", "VeiwBox(0, 'NotNewCustomerBox', 'NewCustomerBox')", true);
             lb_error.Text = "Værelset er allerede optaget, prøv et andet værelse";
             Response.Redirect(@"..\Booking\?e=1");
         }
     }
     catch (Exception exception)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "VeiwBox", "VeiwBox(0, 'NotNewCustomerBox', 'NewCustomerBox')", true);
         lb_error.Text = exception.Message;
     }
 }