public bool Delete(Room room) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_RoomDelete"); db.AddInParameter(command, "@CompanyId", DbType.Int32, room.CompanyId); db.AddInParameter(command, "@RoomId", DbType.Int32, room.RoomId); db.ExecuteNonQuery(command); return true; }
public bool Insert(Room room) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_RoomInsert"); db.AddInParameter(command, "@CompanyId", DbType.Int32, room.CompanyId); db.AddInParameter(command, "@RoomName", DbType.String, room.RoomName); db.AddInParameter(command, "@RoomNumber", DbType.String, room.RoomNumber); db.AddInParameter(command, "@BedTypeId", DbType.Int32, room.BedTypeId); db.AddInParameter(command, "@MaxAdult", DbType.Int32, room.MaxAdult); db.AddInParameter(command, "@MaxChildren", DbType.Int32, room.MaxChildren); db.AddInParameter(command, "@MaxInfant", DbType.Int32, room.MaxInfant); db.AddInParameter(command, "@SmokingAllow", DbType.Boolean, room.SmokingAllow); db.AddInParameter(command, "@CreatedBy", DbType.Int32, room.CreatedUser); db.AddInParameter(command, "@CreatedDate", DbType.DateTime, room.CreatedDate); db.AddInParameter(command, "@UpdatedBy", DbType.Int32, room.UpdatedUser); db.AddInParameter(command, "@UpdatedDate", DbType.DateTime, room.UpdatedDate); db.AddInParameter(command, "@StatusId", DbType.Int32, room.StatusId); db.ExecuteNonQuery(command); return true; }
public bool UpdateRoomAsDirty(Room room, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_RoomMarkDirty"); db.AddInParameter(command, "@RoomId", DbType.Int32, room.RoomId); db.AddInParameter(command, "@UpdatedUser", DbType.Int32, room.UpdatedUser); db.ExecuteNonQuery(command, transaction); return true; }
public bool UpdateRoomAsDirty(Room room) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_RoomMarkDirty"); db.AddInParameter(command, "@RoomId", DbType.Int32, room.RoomId); db.AddInParameter(command, "@UpdatedUser", DbType.Int32, room.UpdatedUser); db.ExecuteNonQuery(command); return true; }
public DataSet SelectAll(Room room) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_RoomSelectAll"); db.AddInParameter(dbCommand, "@CompanyId", DbType.Int32, room.CompanyId); return db.ExecuteDataSet(dbCommand); }
public bool IsDuplicateTypeName(Room room) { bool result = false; Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_RoomIsDuplicateTypeName"); db.AddInParameter(dbCommand, "@CompanyId", DbType.Int32, room.CompanyId); db.AddInParameter(dbCommand, "@RoomId", DbType.Int32, room.RoomId); db.AddInParameter(dbCommand, "@RoomCode", DbType.String, room.RoomCode); db.AddOutParameter(dbCommand, "@IsExist", DbType.Boolean, 1); db.ExecuteNonQuery(dbCommand); result = Convert.ToBoolean(db.GetParameterValue(dbCommand, "@IsExist").ToString()); return result; }
private bool SaveData(Int64 reservationId) { bool result = false; DbConnection connection = null; DbTransaction transaction = null; try { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); connection = db.CreateConnection(); connection.Open(); transaction = connection.BeginTransaction(); ResMan.Reservation reservation = new GenRes.Reservation(); reservation.ReservationId = reservationId; reservation.CompanyId = Master.CurrentCompany.CompanyId; reservation.CustomerId = Convert.ToInt32(cmbCustomer.Value); reservation.SourceId = Convert.ToInt32(cmbSource.Value); reservation.CheckInDate = Convert.ToDateTime(dtCheckingDate.Text); reservation.CheckOutDate = Convert.ToDateTime(dtCheckOutDate.Text); reservation.StatusId = Convert.ToInt32(cmbResStatus.SelectedItem.Value.ToString()); reservation.RoomTotal = Convert.ToDecimal(txtRoomTotal.Text.Trim()); reservation.ServiceTotal = Convert.ToDecimal(txtServiceTotal.Text.Trim()); reservation.NetTotal = Convert.ToDecimal(txtNetTotal.Text.Trim()); reservation.Discount = Convert.ToDecimal(txtDiscount.Text.Trim()); reservation.TaxTypeId = Convert.ToInt32(cmbTax.Value); reservation.TaxAmount = Convert.ToDecimal(txtTaxTotal.Text.Trim()); reservation.Total = Convert.ToDecimal(txtTotal.Text.Trim()); reservation.PaidAmount = Convert.ToDecimal(txtPaidAmount.Text.Trim()); reservation.Balance = Convert.ToDecimal(txtBalance.Text.Trim()); reservation.TaxPercentage = Convert.ToDecimal(hdnTaxPercent.Value == string.Empty ? "0" : hdnTaxPercent.Value); reservation.CreatedUser = Master.LoggedUser.UsersId; reservation.UpdatedUser = Master.LoggedUser.UsersId; if (Session[Constants.SESSION_RESERVATION_ROOMINFORMATION] != null) { reservation.ReservationRoomDataSet = (DataSet)Session[Constants.SESSION_RESERVATION_ROOMINFORMATION]; } else { reservationRoom.ReservationId = reservationId; reservation.ReservationRoomDataSet = reservationRoom.SelectAllDataSetByReseervationId(); } if (Session[Constants.SESSION_RESERVATION_ADDTIONALSERVICE] != null) { reservation.ReservationAdditionalServiceDataSet = (DataSet)Session[Constants.SESSION_RESERVATION_ADDTIONALSERVICE]; } else { reservationAdditionalService.ReservationId = reservationId; reservation.ReservationAdditionalServiceDataSet = reservationAdditionalService.SelectAllDataSetByReservationID(); } if (Session[Constants.SESSION_RESERVATION_PAYMENTINFORMATION] != null) { reservation.ReservationPaymentDataSet = (DataSet)Session[Constants.SESSION_RESERVATION_PAYMENTINFORMATION]; } else { reservationPayments.ReservationId = reservationId; reservation.ReservationPaymentDataSet = reservationPayments.SelectAllDataSetByReservationID(); } reservation.Save(db, transaction); if (reservation.StatusId == (int)HBM.Common.Enums.HBMStatus.CheckOut) { if (Session[Constants.SESSION_RESERVATION_ROOMINFORMATION] != null) { DataSet roomsToMakeDrity = (DataSet)Session[Constants.SESSION_RESERVATION_ROOMINFORMATION]; if (roomsToMakeDrity != null && roomsToMakeDrity.Tables.Count > 0 && roomsToMakeDrity.Tables[0] != null && roomsToMakeDrity.Tables[0].Rows.Count > 0) { for (int i = 0; i <= roomsToMakeDrity.Tables[0].Rows.Count - 1; i++) { Room dirtyroom = new Room(); dirtyroom.RoomId = Convert.ToInt32(roomsToMakeDrity.Tables[0].Rows[i]["RoomId"].ToString()); dirtyroom.UpdatedUser = Master.LoggedUser.UsersId; dirtyroom.UpdateRoomAsDirty(db, transaction); } } } } transaction.Commit(); this.hdnReservationId.Value = reservation.ReservationId.ToString(); result = true; } catch (System.Exception) { transaction.Rollback(); } return result; }