// BaseData class will be parent of BookData public void InsertReservation(SiCAP_GrupoCARARA.App_Domain.Reservation reservation) { SqlConnection connection = ManageDatabaseConnection("Open"); try { using (SqlCommand sqlCommand = new SqlCommand("insert_reservation", connection)) { sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.Add("@Date", SqlDbType.Date).Value = reservation.Date; sqlCommand.Parameters.Add("@IdTimeForReservation", SqlDbType.Int).Value = reservation.IdTimeForReservation; sqlCommand.Parameters.Add("@IdUser", SqlDbType.Int).Value = reservation.IdUser; sqlCommand.Parameters.Add("@IdParkingSpace", SqlDbType.Int).Value = reservation.IdParkingSpace; sqlCommand.Parameters.Add("@IdVehicle", SqlDbType.Int).Value = reservation.IdVehicle; sqlCommand.Parameters.Add("@HasBeenCanceled", SqlDbType.Bit).Value = reservation.HasBeenCanceled; //connection.Open(); sqlCommand.ExecuteNonQuery(); connection = ManageDatabaseConnection("Close"); } } catch (SqlException sqlException) { throw sqlException; } }
public void InsertReservationInGivenPeriod() { ReservationTransaction transaction = new ReservationTransaction(); int checkInTime = int.Parse(DropDownListCheckIn.SelectedItem.Value); int checkOutTime = int.Parse(DropDownListCheckOut.SelectedItem.Value); while (checkInTime <= checkOutTime) { SiCAP_GrupoCARARA.App_Domain.Reservation myReservation = FillReservation(checkInTime); transaction.InsertReservation(myReservation); checkInTime++; } }
public SiCAP_GrupoCARARA.App_Domain.Reservation FillReservation(int idTimeForReservation) { int id = 0; UserData userData = new UserData(); DateTime thisDay = DateTime.Today; string date = thisDay.ToString("dd/MM/yyyy"); User userInSession = userData.getUserInSession((string)Session["user"]); int idUser = userInSession.Id; int idParkingSpace = 3; // Aquí hay que meter lo que viene de los botones...!!!!!!!!!!!!!!!!!!!!!!!!!! int idVehicle = int.Parse(DropDownListVehiclesOfOneUser.SelectedItem.Value); bool hasBeenCanceled = false; SiCAP_GrupoCARARA.App_Domain.Reservation myReservation = new SiCAP_GrupoCARARA.App_Domain.Reservation(id, thisDay, idTimeForReservation, idUser, idParkingSpace, idVehicle, hasBeenCanceled); return myReservation; }
public SiCAP_GrupoCARARA.App_Domain.Reservation FillReservation(int idTimeForReservation) { int id = 0; UserData userData = new UserData(); DateTime thisDay = DateTime.Today; string date = thisDay.ToString("dd/MM/yyyy"); User userInSession = userData.getUserInSession((string)Session["user"]); int idUser = userInSession.Id; int idParkingSpace = 3; // Aquí hay que meter lo que viene de los botones...!!!!!!!!!!!!!!!!!!!!!!!!!! int idVehicle = int.Parse(DropDownListVehiclesOfOneUser.SelectedItem.Value); bool hasBeenCanceled = false; SiCAP_GrupoCARARA.App_Domain.Reservation myReservation = new SiCAP_GrupoCARARA.App_Domain.Reservation(id, thisDay, idTimeForReservation, idUser, idParkingSpace, idVehicle, hasBeenCanceled); return(myReservation); }
public void InsertReservation(SiCAP_GrupoCARARA.App_Domain.Reservation reservation) { reservationData.InsertReservation(reservation); }