public DataSet SelectByReservationID(ReservationPayments reservationPayments)
        {
            Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING);
            DbCommand dbCommand = db.GetStoredProcCommand("usp_ReservationPaymentSelectByReservationID");
            db.AddInParameter(dbCommand, "@ReservationId", DbType.Int64, reservationPayments.ReservationId);

            return db.ExecuteDataSet(dbCommand);
        }
        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(ReservationPayments reservationPayments, Database db, DbTransaction transaction)
        {
            DbCommand commandInsert = db.GetStoredProcCommand("usp_ReservationPaymentInsert");

            db.AddInParameter(commandInsert, "@ReservationId", DbType.Int64, reservationPayments.ReservationId);
            db.AddInParameter(commandInsert, "@PaymentDate", DbType.DateTime, "PaymentDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@ReferenceNumber", DbType.String, "ReferenceNumber", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Notes", DbType.String, "Notes", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@PaymentTypeId", DbType.Int32, "PaymentTypeId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CurrencyId", DbType.Int32, "CurrencyId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CreditCardTypeId", DbType.Int32, "CreditCardTypeId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CCNo", DbType.String, "CCNo", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CCExpirationDate", DbType.DateTime, "CCExpirationDate", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CCNameOnCard", DbType.String, "CCNameOnCard", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@CreatedUser", DbType.Int32, "CreatedUser", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);
            db.AddInParameter(commandInsert, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);

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

            db.AddInParameter(commandUpdate, "@ReservationPaymentId", DbType.Int64, "ReservationPaymentId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@PaymentDate", DbType.DateTime, "PaymentDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@ReferenceNumber", DbType.String, "ReferenceNumber", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Notes", DbType.String, "Notes", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@PaymentTypeId", DbType.Int32, "PaymentTypeId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CurrencyId", DbType.Int32, "CurrencyId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CreditCardTypeId", DbType.Int32, "CreditCardTypeId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CCNo", DbType.String, "CCNo", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CCExpirationDate", DbType.DateTime, "CCExpirationDate", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@CCNameOnCard", DbType.String, "CCNameOnCard", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@UpdatedUser", DbType.Int32, "UpdatedUser", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@StatusId", DbType.Int32, "StatusId", DataRowVersion.Current);
            db.AddInParameter(commandUpdate, "@Amount", DbType.Decimal, "Amount", DataRowVersion.Current);

            DbCommand commandDelete = db.GetStoredProcCommand("usp_ReservationPaymentDelete");
            db.AddInParameter(commandDelete, "@ReservationPaymentId", DbType.Int64, "ReservationPaymentId", DataRowVersion.Current);

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

            return true;
        }