2
Good afternoon, can anyone help me create a procedure in the SQL database ? To make a reservation for a room, I have to select a room and declare the Date Entry and Date.
What I want, is to make a reservation in the room 1 between the days 13/06/2018 and 14/06/2018, and then if someone wants to make another reservation in that same room between the days 13/06/2018 and 14/06/2018, given that this room already has a reservation that day, I want a busy message to appear. Someone can help me?
Reserve table
public partial class Reserva
{
public int ID_Reserva { get; set; }
public int ID_Cliente { get; set; }
public int ID_Quarto { get; set; }
public System.DateTime DataEntrada { get; set; }
public Nullable<System.DateTime> DataSaida { get; set; }
public int NumeroPessoas { get; set; }
public Nullable<int> NumeroNoites { get; set; }
public Nullable<decimal> Preço { get; set; }
public string Observaçoes { get; set; }
public virtual Cliente Cliente { get; set; }
public virtual Quarto Quarto { get; set; }
}
Quarto Table
public partial class Quarto
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Quarto()
{
this.Reserva = new HashSet<Reserva>();
}
public int ID_Quarto { get; set; }
public string TipoQuarto { get; set; }
public string EstadoQuarto { get; set; }
public Nullable<decimal> PreçoQuarto { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Reserva> Reserva { get; set; }
}
You need to provide some more information so that we can help. The first is what the
SGBD
that you are using.SQL Server
? The second is to inform which tables are involved in this reservation.– Sorack
You need to use the BETWEEN clause and inform the date of exit and entry, assuming you are using SQL. There are already questions answered about this.
– Mauro Alexandre
@Sorack thanks for the answer. I am using SQL Server. I edited the question and can see the tables, compliments.
– John
Was any of the answer helpful? Don’t forget to choose one and mark it so it can be used if someone has a similar question!
– Sorack