public int Add(DTORoom dtoRoom) { Room entityRoom = RoomMapper.GetEntityRoom(dtoRoom); UnitOfWork.RoomRepository.Add(entityRoom); UnitOfWork.Commit(); return(entityRoom.Id); }
private void SaveDataToDatabase() { if (!checkData()) { return; } try { if (m_IsAdd) { String roomName = Utils.standardNamePerson(txtRoomName.Text); String roomType = lkRoomType.EditValue.ToString(); int numberOfBeds = Int32.Parse(spNumberOfBeds.Value.ToString()); String Description = rtxtDecription.Text; String status = lkStatus.EditValue.ToString(); roomObject = new DTORoom("PH00000000", roomName, roomType, numberOfBeds, Description, status); if (roomBUS.InsertRoom(roomObject)) { XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4); } } else { String roomName = Utils.standardNamePerson(txtRoomName.Text); String roomType = lkRoomType.EditValue.ToString(); int numberOfBeds = Int32.Parse(spNumberOfBeds.Value.ToString()); String Description = rtxtDecription.Text; String status = lkStatus.EditValue.ToString(); roomObject = new DTORoom(txtRoomId.Text, roomName, roomType, numberOfBeds, Description, status); if (roomBUS.UpdateRoom(roomObject)) { XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1); } else { XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4); } } } catch (System.Exception ex) { XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3); } finally { updateEnableButtonAndResetValueOfControl(ref btnSave); } }
/// <summary> /// Phương thức thêm mới một Room vào csdl /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool InsertRoom(DTORoom Room) { try { return(roomDAO.InsertRoom(Room)); } catch (SqlException) { throw; } }
/// <summary> /// Phương thức cập nhật một Room xuống csdl theo id /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool UpdateRoom(DTORoom Room) { try { return(roomDAO.UpdateRoom(Room)); } catch (SqlException) { throw; } }
public static Room GetEntityRoom(DTORoom dtoRoom) { Room entityRoom = new Room() { Bookable = dtoRoom.Bookable, Id = dtoRoom.Id, Name = dtoRoom.Name, Places = dtoRoom.Places, RoomNumber = dtoRoom.RoomNumber }; return(entityRoom); }
public static DTORoom GetDTORoom(Room entityRoom) { DTORoom dtoRoom = new DTORoom() { Bookable = entityRoom.Bookable, Id = entityRoom.Id, Name = entityRoom.Name, Places = entityRoom.Places, RoomNumber = entityRoom.RoomNumber }; return(dtoRoom); }
/// <summary> /// Phương thức thêm mới một Room vào csdl /// </summary> /// <returns>true: thêm mới thành công, false: thêm mới thất bại</returns> public bool InsertRoom(DTORoom Room) { try { DataExecute.Instance.createSqlCmd("sp_AddNewRoomInsert" /*Truyen vao storeprocedure*/, new object[6] { Room.RoomID, Room.RoomName, Room.RoomTypeID, Room.NumberOfBeds, Room.Description, Room.RoomStatusID }); return(DataExecute.Instance.updateData(DataConnection.Instance.m_cmd) > 0); } catch (SqlException) { throw; } }
public IActionResult Add([FromBody] DTORoom dtoRoom) { try { _logger.LogInformation("Request Rooms/Add"); return(Ok(roomsManager.Add(dtoRoom))); } catch (Exception ex) { roomsManager.Dispose(); _logger.LogError("Error during Rooms/Add", ex.Message); return(StatusCode(500, ex.Message)); } }
private void btnDelete_Click(object sender, EventArgs e) { if (roomMulitiSelect.Selection.Count == 0) { XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1); return; } try { System.Collections.ArrayList _listroomObjectInDelibility = new System.Collections.ArrayList(); foreach (object _rowObjectItem in roomMulitiSelect.Selection) { grdvListRoom.FocusedRowHandle -= 1; DataRowView _rowObjectDetail = _rowObjectItem as DataRowView; roomObject = new DTORoom(_rowObjectDetail.Row["RoomID"].ToString(), _rowObjectDetail.Row["RoomName"].ToString(), _rowObjectDetail.Row["RoomTypeID"].ToString(), Int32.Parse(_rowObjectDetail.Row["NumberOfBeds"].ToString()), _rowObjectDetail.Row["Description"].ToString(), _rowObjectDetail.Row["StatusID"].ToString()); if (!roomBUS.DeleteRoom(roomObject.RoomID)) { _listroomObjectInDelibility.Add(_rowObjectDetail.Row["RoomID"]); } } String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n"; if (_listroomObjectInDelibility.Count != 0) { foreach (var item in _listroomObjectInDelibility) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4); } else { XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1); } } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }