private RoomDTO GetAvailableRoomByRoomType(string roomTypeTitle, DateTime startDate, DateTime endDate) { IQueryable <Entity <Guid> > allEntities = _repository.GetAll(); foreach (var entity in allEntities) { RoomDTO roomDTO = entity as RoomDTO; if (roomDTO == null) { continue; } if (roomDTO.IsFree) { RoomTypeDTO roomTypeDTO = GetRoomType(roomDTO); if (!roomTypeDTO.Title.Equals(roomTypeTitle)) { continue; } return(roomDTO); } } return(null); }
public static bool InsertRoomType(RoomTypeDTO roomType) { try { if (connection.State != ConnectionState.Open) { connection.Open(); } var query = "INSERT INTO LoaiPhong(MaLoaiPhong, DonGia)\n" + $"VALUES ('{roomType.RoomTypeID}', {roomType.RoomTypePrice})"; var command = new SqlCommand(query, connection); command.ExecuteNonQuery(); return(true); } catch (Exception) { return(false); } finally { connection.Close(); } }
public bool Delete(RoomTypeDTO oRoomTypeData) { string sProcName; DatabaseManager oDB; try { oDB = new DatabaseManager(); sProcName = "up_Del_RoomTypeMaster"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iRoomtypeId", DbType.Int32, oRoomTypeData.RoomTypeId); oDB.ExecuteNonQuery(oDB.DbCmd); } catch (Exception exp) { oDB = null; oRoomTypeData = null; GF.LogError("clsRoomtypeMaster.Delete", exp.Message); return(false); } finally { oDB = null; } return(true); }
public static bool UpdateRoomType(RoomTypeDTO roomType) { try { if (connection.State != ConnectionState.Open) { connection.Open(); } var query = "UPDATE LoaiPhong\n" + $"SET DonGia = {roomType.RoomTypePrice}\n" + $"WHERE MaLoaiPhong = '{roomType.RoomTypeID}'"; var command = new SqlCommand(query, connection); command.ExecuteNonQuery(); return(true); } catch (Exception) { return(false); } finally { connection.Close(); } }
public bool Insert(RoomTypeDTO oRoomTypeData) { string sProcName; DatabaseManager oDB; try { oDB = new DatabaseManager(); sProcName = "up_Ins_RoomTypeMaster"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@sRoomType", DbType.String, oRoomTypeData.RoomType.Trim()); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iDefaultNoOfBeds", DbType.Int32, oRoomTypeData.DefaultNoOfBeds); oDB.ExecuteNonQuery(oDB.DbCmd); } catch (Exception exp) { oDB = null; oRoomTypeData = null; GF.LogError("clsRoomtypeMaster.Insert", exp.Message); return(false); } finally { oDB = null; oRoomTypeData = null; } return(true); }
public RoomTypeDTO[] GetData(int RoomTypeId) { DataSet ds; RoomTypeDTO[] oRoomTypeData; oRoomTypeData = null; ds = null; string query = "select RoomTypeId, RoomType, DefaultNoOfBeds from tblRoomTypeMaster where 1=1"; if (RoomTypeId != 0) { query += " and RoomTypeId=" + RoomTypeId; } query += " order by RoomType"; ds = GetDataFromDB(query); if (ds != null && ds.Tables[0].Rows.Count > 0) { oRoomTypeData = new RoomTypeDTO[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { oRoomTypeData[i] = new RoomTypeDTO(); oRoomTypeData[i].RoomTypeId = Convert.ToInt32(ds.Tables[0].Rows[i][0]); oRoomTypeData[i].RoomType = Convert.ToString(ds.Tables[0].Rows[i][1]).Trim(); oRoomTypeData[i].DefaultNoOfBeds = Convert.ToInt32(ds.Tables[0].Rows[i][2]); } } return(oRoomTypeData); }
public ActionResult PostRoomType(RoomTypeDTO roomType) { string value = roomType.NameRoomType; string valuePrice = roomType.PriceRoom.ToString(); var list = _roomTypeService.GetAll(); // //Check Validate // if (value == "") // return NotFound (new { success = false, message = "Vui lòng nhập tên loại phòng" }); // if (valuePrice == "") // return NotFound (new { success = false, message = "Vui lòng nhập giá tiền" }); // else if (!int.TryParse(valuePrice, out int n)) // return NotFound (new { success = false, message = "Giá tiền không được chứa chữ" }); foreach (var rt in list) { string temp = rt.NameRoomType; if (temp.Equals(value, StringComparison.InvariantCultureIgnoreCase)) { return(NotFound(new { success = false, message = "Tên loại phòng đã tồn tại" })); } } _roomTypeService.Add(roomType); return(Ok(new { success = true, message = "Thêm thành công" })); }
private void Delete() { if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete)) { return; } if (ValidateValues() == false) { return; } bool bActionCompleted = false; int Id = 0; int.TryParse(hfId.Value, out Id); if (Id == 0) { lblStatus.Text = "Please click on edit button again."; return; } RoomTypeDTO oRoomTypeData = new RoomTypeDTO(); //oRoomTypeData.RoomTypeId = Convert.ToInt32(SessionHandler"RoomTypeId"]); oRoomTypeData.RoomTypeId = Id; RoomTypeMaster oRoomTypeMaster = new RoomTypeMaster(); /* * ADDED BY VIJAY * CHECK IF THE ROOM TYPE WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT * */ string sMessage = ""; GF.HasRecords(Convert.ToString(Id), "roomtype", out sMessage); if (sMessage != "") { base.DisplayAlert(sMessage); btnDelete.Enabled = true; } else { bActionCompleted = oRoomTypeMaster.Delete(oRoomTypeData); if (bActionCompleted == true) { base.DisplayAlert("The record has been deleted successfully."); txtRoomType.Text = ""; ddlDefaultNoOfBeds.SelectedIndex = 0; lblStatus.Text = "Deleted"; RefreshGrid(); } else { base.DisplayAlert("Error Occured while deletion: Please refer to the error log."); } } oRoomTypeData = null; oRoomTypeMaster = null; }
public JsonResult Delete(RoomTypeDTO dto) { var manager = this.GetManagerFor <IRoomTypeManager>(); var result = manager.Delete(dto.Id); var resultDTO = new RoomTypeDTO(result); return(Json(resultDTO)); }
public JsonResult Update(RoomTypeDTO dto) { var manager = this.GetManagerFor<IRoomTypeManager>(); var result = manager.Update(dto); var resultDTO = new RoomTypeDTO(result); return Json(resultDTO); }
public static bool InsertRoomType(RoomTypeDTO roomType) { if (RoomTypeDAO.CheckRoomTypeID(roomType.RoomTypeID)) { return(false); } return(RoomTypeDAO.InsertRoomType(roomType)); }
public void Add(RoomTypeDTO roomtypeDto) { var roomtype = _mapper.Map <RoomTypeDTO, RoomType>(roomtypeDto); _unitOfWork.RoomTypes.Add(roomtype); _unitOfWork.Complete(); }
public RoomTypeDTO GetSelectedRoomType() { var row = this.dgvRoomType.CurrentRow; var roomType = new RoomTypeDTO(); roomType.RoomTypeID = row.Cells["EditRoomTypeID"].Value.ToString(); roomType.RoomTypePrice = Convert.ToInt64(row.Cells["EditRoomTypePrice"].Value.ToString().Replace(",", "")); return(roomType); }
public static RoomTypeDTO Instance(this RoomTypeDTO roomType, string format) { switch (format) { case "Name (MaxOccupants)": roomType.Name = roomType.Name += " (" + roomType.MaxOccupants + ")"; break; } return(roomType); }
public NHResult <RoomType> Update(RoomTypeDTO dto) { var roomType = base.GetById(dto.Id); roomType.Name = dto.Name; roomType.Sort = dto.Sort; var result = base.SaveOrUpdate(roomType); return(result); }
private void Update() { if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Update)) { return; } if (ValidateValues() == false) { return; } bool bActionCompleted = false; int Id = 0; int.TryParse(hfId.Value, out Id); if (Id == 0) { lblStatus.Text = "Please click on edit button again."; return; } RoomTypeDTO oRoomTypeData = new RoomTypeDTO(); int DNOB = 0; oRoomTypeData.RoomTypeId = Id; oRoomTypeData.RoomType = txtRoomType.Text.ToString(); if (ddlDefaultNoOfBeds.Text != "Choose") { int.TryParse(ddlDefaultNoOfBeds.Text, out DNOB); oRoomTypeData.DefaultNoOfBeds = DNOB; } else { oRoomTypeData.DefaultNoOfBeds = 0; } RoomTypeMaster oRoomTypeMaster = new RoomTypeMaster(); bActionCompleted = oRoomTypeMaster.Update(oRoomTypeData); if (bActionCompleted == true) { base.DisplayAlert("The record has been updated successfully."); txtRoomType.Text = ""; ddlDefaultNoOfBeds.SelectedIndex = 0; lblStatus.Text = "Updated"; } else { lblStatus.Text = "Error Occured while updation: Please refer to the error log."; } oRoomTypeData = null; oRoomTypeMaster = null; }
public NHResult <RoomType> Create(RoomTypeDTO dto) { var roomType = new RoomType { Name = dto.Name, Sort = dto.Sort }; var result = base.SaveOrUpdate(roomType); return(result); }
public async Task <JsonResult> DeleteRoomType(RoomTypeDTO dto) { var result = await this.PostAsync <RoomTypeDTO>(this.GetAPIAddress("/api/console/RoomType/Delete"), new { dto = dto }); return(Json(new { success = result.Info.IsValid, error = result.Info.Errors })); }
public void Update(int id, RoomTypeDTO roomtypeDto) { var roomtype = _unitOfWork.RoomTypes.GetBy(id); if (roomtype == null) { return; } roomtype.NameRoomType = roomtypeDto.NameRoomType; roomtype.PriceRoom = roomtypeDto.PriceRoom; // _mapper.Map<RoomTypeDTO, RoomType>(roomtypeDto, roomtype); _unitOfWork.Complete(); }
public JsonResult GetRoomType(int id, IEnumerable<string> query) { var queries = new Query[] { }; if (query != null) { queries = query.Select(q => new Query { Name = q }).ToArray(); } var manager = this.GetManagerFor<IRoomTypeManager>(); var result = manager.GetById(id); var resultDTO = new RoomTypeDTO(queries, result); return Json(resultDTO); }
public JsonResult GetRoomType(int id, IEnumerable <string> query) { var queries = new Query[] { }; if (query != null) { queries = query.Select(q => new Query { Name = q }).ToArray(); } var manager = this.GetManagerFor <IRoomTypeManager>(); var result = manager.GetById(id); var resultDTO = new RoomTypeDTO(queries, result); return(Json(resultDTO)); }
private RoomTypeDTO GetRoomType(RoomDTO roomDTO) { IQueryable <Entity <Guid> > allEntities = _repository.GetAll(); foreach (var entity in allEntities) { RoomTypeDTO roomTypeDTO = entity as RoomTypeDTO; if (roomTypeDTO == null) { continue; } if (roomTypeDTO.Id == roomDTO.RoomTypeId) { return(roomTypeDTO); } } throw new Exception("No room type for this room?"); }
private void AddRoomTypes() { _singleRoomType = new RoomTypeDTO { Title = "Single", Price = 50 }; _doubleRoomType = new RoomTypeDTO { Title = "Double", Price = 100 }; _tripleRoomType = new RoomTypeDTO { Title = "Triple", Price = 150 }; _penthouseRoomType = new RoomTypeDTO { Title = "Penthouse", Price = 200 }; _repository.Add(_singleRoomType); _repository.Add(_doubleRoomType); _repository.Add(_tripleRoomType); _repository.Add(_penthouseRoomType); }
public ActionResult PutRoomType(int id, RoomTypeDTO values) { string value = values.NameRoomType; var list = _roomTypeService.GetAll(); foreach (var rt in list) { if (rt.RoomTypeId != id) { string temp = rt.NameRoomType; if (temp.Equals(value, StringComparison.InvariantCultureIgnoreCase)) { return(NotFound(new { success = false, message = "Tên loại phòng đã tồn tại" })); } } } _roomTypeService.Update(id, values); var roomType = _roomTypeService.GetBy(id); return(Ok(new { success = true, data = roomType })); }
private void Save() { if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Add)) { return; } bool bActionCompleted = false; RoomTypeDTO oRoomTypeData = new RoomTypeDTO(); int DNOB = 0; oRoomTypeData.RoomType = txtRoomType.Text.ToString(); if (ddlDefaultNoOfBeds.Text != "Choose") { int.TryParse(ddlDefaultNoOfBeds.Text, out DNOB); oRoomTypeData.DefaultNoOfBeds = DNOB; } else { oRoomTypeData.DefaultNoOfBeds = 0; } RoomTypeMaster oRoomTypeMaster = new RoomTypeMaster(); bActionCompleted = oRoomTypeMaster.Insert(oRoomTypeData); if (bActionCompleted == true) { base.DisplayAlert("The record has been inserted successfully."); txtRoomType.Text = ""; ddlDefaultNoOfBeds.SelectedIndex = 0; lblStatus.Text = "Saved"; } else { lblStatus.Text = "Error Occured while insertion: Please refer to the error log."; } oRoomTypeData = null; oRoomTypeMaster = null; }
public Accomodation GetReleasedRooms(int BookingId) { Accomodation accomodation; DataSet dsAccomodationData; DataRow dr; string sProcName; DatabaseManager oDB; dsAccomodationData = null; accomodation = null; try { oDB = new DatabaseManager(); sProcName = "up_Get_ReleasedRooms"; oDB.DbCmd = oDB.GetStoredProcCommand(sProcName); oDB.DbDatabase.AddInParameter(oDB.DbCmd, "@iBookingId", DbType.Int32, BookingId); dsAccomodationData = oDB.ExecuteDataSet(oDB.DbCmd); oDB = null; } catch (Exception exp) { oDB = null; dsAccomodationData = null; GF.LogError("clsBookingRoomReleaseHandler.GetReleasedRooms", exp.Message); } #region Populate the Object if (dsAccomodationData != null && dsAccomodationData.Tables[0].Rows.Count > 0) { accomodation = new Accomodation(); List <AccomodationRoomType> accomodationRoomTypes = null; List <AccomodationRoom> accomodationRooms = null; for (int i = 0; i < dsAccomodationData.Tables[0].Rows.Count; i++) { dr = dsAccomodationData.Tables[0].Rows[i]; int AccomodationId = Convert.ToInt32(dr.ItemArray.GetValue(3)); int bId = Convert.ToInt32(dr.ItemArray.GetValue(1)); int CategoryId = Convert.ToInt32(dr.ItemArray.GetValue(11)); int TypeId = Convert.ToInt32(dr.ItemArray.GetValue(12)); string RoomCategoryName = Convert.ToString(dr.ItemArray.GetValue(13)); string RoomTypeName = Convert.ToString(dr.ItemArray.GetValue(14)); string RoomNo = Convert.ToString(dr.ItemArray.GetValue(4)); if (accomodation.AccomodationDetail == null) { AccomodationDTO accomodationDetail = new AccomodationDTO(); accomodationDetail.AccomodationId = AccomodationId; accomodation.AccomodationDetail = accomodationDetail; } AccomodationRoomCategory Category = null; if (accomodation.Categories != null) { Category = accomodation.Categories.Find(delegate(AccomodationRoomCategory CategoryTypes) { return(CategoryTypes.RoomCategory.RoomCategoryId == CategoryId); }); if (Category != null && Category.RoomTypes != null) { accomodationRoomTypes = Category.RoomTypes; } else { accomodationRoomTypes = null; } } if (Category == null) { RoomCategoryDTO newRoomCategory = new RoomCategoryDTO(); newRoomCategory.RoomCategoryId = CategoryId; newRoomCategory.RoomCategory = RoomCategoryName; Category = new AccomodationRoomCategory(); Category.RoomCategory = newRoomCategory; accomodationRoomTypes = null; accomodationRooms = null; } AccomodationRoomType AccomodationRoomType = null; if (Category.RoomTypes != null) { AccomodationRoomType = Category.RoomTypes.Find(delegate(AccomodationRoomType type) { return(type.RoomType.RoomTypeId == TypeId); }); if (AccomodationRoomType != null && AccomodationRoomType.Rooms != null) { accomodationRooms = AccomodationRoomType.Rooms; } else { accomodationRooms = null; } } if (AccomodationRoomType == null) { RoomTypeDTO newRoomType = new RoomTypeDTO(); newRoomType.RoomTypeId = TypeId; newRoomType.RoomType = RoomTypeName; AccomodationRoomType = new AccomodationRoomType(); AccomodationRoomType.RoomType = newRoomType; if (accomodationRoomTypes == null) { accomodationRoomTypes = new List <AccomodationRoomType>(); } accomodationRoomTypes.Add(AccomodationRoomType); Category.RoomTypes = accomodationRoomTypes; accomodationRooms = null; } AccomodationRoom AccomodationRoom = null; if (AccomodationRoomType.Rooms != null) { AccomodationRoom = AccomodationRoomType.Rooms.Find(delegate(AccomodationRoom room) { return(room.RoomDetail.RoomNo == RoomNo); }); } if (AccomodationRoom == null) { RoomDTO newRoom = new RoomDTO(); newRoom.RoomNo = RoomNo; AccomodationRoom = new AccomodationRoom(); AccomodationRoom.RoomDetail = newRoom; if (accomodationRooms == null) { accomodationRooms = new List <AccomodationRoom>(); } accomodationRooms.Add(AccomodationRoom); AccomodationRoomType.Rooms = accomodationRooms; } if (accomodation.Categories == null) { List <AccomodationRoomCategory> categories = new List <AccomodationRoomCategory>(); categories.Add(Category); accomodation.Categories = categories; } else { if (!accomodation.Categories.Exists(delegate(AccomodationRoomCategory CategoryTypes) { return(CategoryTypes.RoomCategory.RoomCategoryId == CategoryId); })) { accomodation.Categories.Add(Category); } } } } #endregion return(accomodation); }
public static bool UpdateRoomType(RoomTypeDTO roomType) { return(RoomTypeDAO.UpdateRoomType(roomType)); }
public void Delete(RoomTypeDTO obj) { roomTypeRepository.Delete(Mapper.Map <RoomTypeDTO, RoomType>(obj)); }
private void BtnConfirm_Click(object sender, EventArgs e) { switch (this.Tag) { case "AddForm": { if (string.IsNullOrEmpty(this.tbRoomTypePrice.Text) || string.IsNullOrEmpty(this.tbRoomType.Text)) { MessageBox.Show("Các thông tin không được để trống", "THÊM LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var roomType = new RoomTypeDTO(); roomType.RoomTypeID = this.tbRoomType.Text; roomType.RoomTypePrice = Convert.ToInt64(this.tbRoomTypePrice.Text.Replace(",", "")); if (RoomTypeBUS.InsertRoomType(roomType)) { MessageBox.Show( "Thêm loại phòng " + roomType.RoomTypeID + " thành công!", "THÊM LOẠI PHÒNG THÀNH CÔNG!", MessageBoxButtons.OK, MessageBoxIcon.Information); var mainForm = (MainForm)Owner; mainForm.ReLoadRoomTypeList(); mainForm.ReLoadFindRoom(); this.Close(); } else { MessageBox.Show( "Loại phòng " + roomType.RoomTypeID + " đã tồn tại!", "THÊM LOẠI PHÒNG THẤT BẠI!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } case "EditForm": { if (string.IsNullOrEmpty(this.tbRoomType.Text)) { MessageBox.Show("Các thông tin không được để trống", "THÊM LOẠI PHÒNG THẤT BẠI", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { var roomType = new RoomTypeDTO(); roomType.RoomTypeID = this.tbRoomType.Text; roomType.RoomTypePrice = Convert.ToInt64(this.tbRoomTypePrice.Text.Replace(",", "")); if (RoomTypeBUS.UpdateRoomType(roomType)) { MessageBox.Show( "Sửa loại phòng " + roomType.RoomTypeID + " thành công!", "SỬA LOẠI PHÒNG THÀNH CÔNG!", MessageBoxButtons.OK, MessageBoxIcon.Information); var mainForm = (MainForm)Owner; mainForm.ReLoadRoomTypeList(); mainForm.ReLoadRoomData(); mainForm.ReLoadAvailableRoom(); mainForm.ReLoadFindRoom(); this.Close(); } else { MessageBox.Show( "Sửa loại phòng " + roomType.RoomTypeID + " thất bại!", "THÊM LOẠI PHÒNG THẤT BẠI!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } break; } } }
public void Save(RoomTypeDTO obj) { roomTypeRepository.Save(Mapper.Map <RoomTypeDTO, RoomType>(obj)); }
public decimal CalculatePrice(RoomDTO roomDTO, int daysNumber) { RoomTypeDTO roomTypeDTO = GetRoomType(roomDTO); return(roomTypeDTO.Price * daysNumber); }