public DataSet SelectByReseervationId(ReservationRoom reservationRoom)
        {
            Database  db        = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_ReservationRoomSelectByReservationId");

            db.AddInParameter(dbCommand, "@ReservationId", DbType.Int32, reservationRoom.ReservationId);

            return(db.ExecuteDataSet(dbCommand));
        }
Exemplo n.º 2
0
        public bool Insert(Reservation reservation, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_ReservationInsert");

            db.AddInParameter(command, "@CompanyId", DbType.Int32, reservation.CompanyId);
            db.AddInParameter(command, "@CustomerId", DbType.Int32, reservation.CustomerId);
            db.AddInParameter(command, "@StatusId", DbType.Int32, reservation.StatusId);
            db.AddInParameter(command, "@CheckInDate", DbType.DateTime, reservation.CheckInDate);
            db.AddInParameter(command, "@CheckOutDate", DbType.DateTime, reservation.CheckOutDate);
            db.AddInParameter(command, "@SourceId", DbType.Int32, reservation.SourceId);
            db.AddInParameter(command, "@RoomTotal", DbType.Decimal, reservation.RoomTotal);
            db.AddInParameter(command, "@ServiceTotal", DbType.Decimal, reservation.ServiceTotal);
            db.AddInParameter(command, "@NetTotal", DbType.Decimal, reservation.NetTotal);
            db.AddInParameter(command, "@Discount", DbType.Decimal, reservation.Discount);
            db.AddInParameter(command, "@TaxAmount", DbType.Decimal, reservation.TaxAmount);
            db.AddInParameter(command, "@PaidAmount", DbType.Decimal, reservation.PaidAmount);
            db.AddInParameter(command, "@Total", DbType.Decimal, reservation.Total);
            db.AddInParameter(command, "@Balance", DbType.Decimal, reservation.Balance);
            db.AddInParameter(command, "@CreatedUser", DbType.Int32, reservation.CreatedUser);
            db.AddInParameter(command, "@TaxTypeId", DbType.Int32, reservation.TaxTypeId);
            db.AddInParameter(command, "@TaxPercentage", DbType.Decimal, reservation.TaxPercentage);

            db.AddOutParameter(command, "@NewReservationId", DbType.Int32, 8);

            db.ExecuteNonQuery(command);

            //Int32 newReservationId = Convert.ToInt32(db.GetParameterValue(command, "@NewReservationId"));
            reservation.ReservationId = Convert.ToInt32(db.GetParameterValue(command, "@NewReservationId"));

            ReservationRoom reservationRoom = new ReservationRoom();

            reservationRoom.ReservationId       = reservation.ReservationId;
            reservationRoom.ReservationRoomList = reservation.ReservationRoomDataSet;
            reservationRoom.Save(db, transaction);

            ReservationAdditionalService reservationAddtionalService = new ReservationAdditionalService();

            reservationAddtionalService.ReservationId = reservation.ReservationId;
            reservationAddtionalService.ReservationAdditionalServiceList = reservation.ReservationAdditionalServiceDataSet;
            reservationAddtionalService.Save(db, transaction);

            ReservationPayments reservationPayments = new ReservationPayments();

            reservationPayments.ReservationId          = reservation.ReservationId;
            reservationPayments.ReservationPaymentList = reservation.ReservationPaymentDataSet;
            reservationPayments.Save(db, transaction);

            return(true);
        }
        public bool Insert(Reservation reservation, Database db, DbTransaction transaction)
        {
            DbCommand command = db.GetStoredProcCommand("usp_ReservationInsert");

            db.AddInParameter(command, "@CompanyId", DbType.Int32, reservation.CompanyId);
            db.AddInParameter(command, "@CustomerId", DbType.Int32, reservation.CustomerId);
            db.AddInParameter(command, "@StatusId", DbType.Int32, reservation.StatusId);
            db.AddInParameter(command, "@CheckInDate", DbType.DateTime, reservation.CheckInDate);
            db.AddInParameter(command, "@CheckOutDate", DbType.DateTime, reservation.CheckOutDate);
            db.AddInParameter(command, "@SourceId", DbType.Int32, reservation.SourceId);
            db.AddInParameter(command, "@RoomTotal", DbType.Decimal, reservation.RoomTotal);
            db.AddInParameter(command, "@ServiceTotal", DbType.Decimal, reservation.ServiceTotal);
            db.AddInParameter(command, "@NetTotal", DbType.Decimal, reservation.NetTotal);
            db.AddInParameter(command, "@Discount", DbType.Decimal, reservation.Discount);
            db.AddInParameter(command, "@TaxAmount", DbType.Decimal, reservation.TaxAmount);
            db.AddInParameter(command, "@PaidAmount", DbType.Decimal, reservation.PaidAmount);
            db.AddInParameter(command, "@Total", DbType.Decimal, reservation.Total);
            db.AddInParameter(command, "@Balance", DbType.Decimal, reservation.Balance);
            db.AddInParameter(command, "@CreatedUser", DbType.Int32, reservation.CreatedUser);
            db.AddInParameter(command, "@TaxTypeId", DbType.Int32, reservation.TaxTypeId);
            db.AddInParameter(command, "@TaxPercentage", DbType.Decimal, reservation.TaxPercentage);

            db.AddOutParameter(command, "@NewReservationId", DbType.Int32,8);

            db.ExecuteNonQuery(command);

            //Int32 newReservationId = Convert.ToInt32(db.GetParameterValue(command, "@NewReservationId"));
            reservation.ReservationId = Convert.ToInt32(db.GetParameterValue(command, "@NewReservationId"));

            ReservationRoom reservationRoom = new ReservationRoom();
            reservationRoom.ReservationId = reservation.ReservationId;
            reservationRoom.ReservationRoomList = reservation.ReservationRoomDataSet;
            reservationRoom.Save(db, transaction);

            ReservationAdditionalService reservationAddtionalService = new ReservationAdditionalService();
            reservationAddtionalService.ReservationId = reservation.ReservationId;
            reservationAddtionalService.ReservationAdditionalServiceList = reservation.ReservationAdditionalServiceDataSet;
            reservationAddtionalService.Save(db, transaction);

            ReservationPayments reservationPayments = new ReservationPayments();
            reservationPayments.ReservationId = reservation.ReservationId;
            reservationPayments.ReservationPaymentList = reservation.ReservationPaymentDataSet;
            reservationPayments.Save(db, transaction);

            return true;
        }
        public bool InsertUpdateDelete(ReservationRoom reservationRoom, Database db, DbTransaction transaction)
        {
            DbCommand commandInsert = db.GetStoredProcCommand("usp_ReservationRoomInsert");

            db.AddInParameter(commandInsert, "@ReservationId", DbType.Int64, reservationRoom.ReservationId);
            db.AddInParameter(commandInsert, "@RoomId", DbType.Int32, "RoomId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@RatePlanId", DbType.Int32, "RatePlanId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Sharers", DbType.String, "Sharers", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CheckInDate", DbType.DateTime, "CheckInDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CheckOutDate", DbType.DateTime, "CheckOutDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfAdults", DbType.Int32, "NumberOfAdults", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfChildren", DbType.Int32, "NumberOfChildren", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfInfant", DbType.Int32, "NumberOfInfant", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Days", DbType.Decimal, "Days", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Rate", DbType.Decimal, "Rate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CreatedUser", DbType.Decimal, "CreatedUser", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandUpdate = db.GetStoredProcCommand("usp_ReservationRoomUpdate");

            db.AddInParameter(commandUpdate, "@ReservationReservationId", DbType.Int32, "ReservationReservationId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@RoomId", DbType.Int32, "RoomId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@RatePlanId", DbType.Int32, "RatePlanId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Sharers", DbType.String, "Sharers", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CheckInDate", DbType.DateTime, "CheckInDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CheckOutDate", DbType.DateTime, "CheckOutDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfAdults", DbType.Int32, "NumberOfAdults", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfChildren", DbType.Int32, "NumberOfChildren", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfInfant", DbType.Int32, "NumberOfInfant", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Days", DbType.Decimal, "Days", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Rate", DbType.Decimal, "Rate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@UpdatedUser", DbType.Int32, "UpdatedUser", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandDelete = db.GetStoredProcCommand("usp_ReservationRoomDelete");

            db.AddInParameter(commandDelete, "@ReservationRoomId", DbType.Int32, "ReservationRoomId", DataRowVersion.Current);

            db.UpdateDataSet(reservationRoom.ReservationRoomList, reservationRoom.ReservationRoomList.Tables[0].TableName, commandInsert, commandUpdate, commandDelete, transaction);

            return(true);
        }
        public DataSet SelectByReseervationId(ReservationRoom reservationRoom)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_ReservationRoomSelectByReservationId");
            db.AddInParameter(dbCommand, "@ReservationId", DbType.Int32, reservationRoom.ReservationId);

            return db.ExecuteDataSet(dbCommand);
        }
        public bool InsertUpdateDelete(ReservationRoom reservationRoom, Database db, DbTransaction transaction)
        {
            DbCommand commandInsert = db.GetStoredProcCommand("usp_ReservationRoomInsert");

            db.AddInParameter(commandInsert, "@ReservationId", DbType.Int64, reservationRoom.ReservationId);
            db.AddInParameter(commandInsert, "@RoomId", DbType.Int32, "RoomId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@RatePlanId", DbType.Int32, "RatePlanId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Sharers", DbType.String, "Sharers", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CheckInDate", DbType.DateTime, "CheckInDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CheckOutDate", DbType.DateTime, "CheckOutDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfAdults", DbType.Int32, "NumberOfAdults", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfChildren", DbType.Int32, "NumberOfChildren", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@NumberOfInfant", DbType.Int32, "NumberOfInfant", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Days", DbType.Decimal, "Days", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Rate", DbType.Decimal, "Rate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CreatedUser", DbType.Decimal, "CreatedUser", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandUpdate = db.GetStoredProcCommand("usp_ReservationRoomUpdate");

            db.AddInParameter(commandUpdate, "@ReservationReservationId", DbType.Int32, "ReservationReservationId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@RoomId", DbType.Int32, "RoomId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@RatePlanId", DbType.Int32, "RatePlanId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Sharers", DbType.String, "Sharers", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CheckInDate", DbType.DateTime, "CheckInDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CheckOutDate", DbType.DateTime, "CheckOutDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfAdults", DbType.Int32, "NumberOfAdults", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfChildren", DbType.Int32, "NumberOfChildren", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@NumberOfInfant", DbType.Int32, "NumberOfInfant", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Days", DbType.Decimal, "Days", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Rate", DbType.Decimal, "Rate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@UpdatedUser", DbType.Int32, "UpdatedUser", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);

            DbCommand commandDelete = db.GetStoredProcCommand("usp_ReservationRoomDelete");
            db.AddInParameter(commandDelete, "@ReservationRoomId", DbType.Int32, "ReservationRoomId", DataRowVersion.Current);

            db.UpdateDataSet(reservationRoom.ReservationRoomList, reservationRoom.ReservationRoomList.Tables[0].TableName, commandInsert, commandUpdate, commandDelete, transaction);

            return true;
        }