private void frmProductSale_Load(object sender, EventArgs e) { RoomBO rbo = new RoomBO(); var roomList = rbo.GetList(); foreach (var item in roomList) { cmbRoomNumber.Items.Add(item.RoomNumber); } }
public RoomUpdateV(RoomBO selectedRoom) { InitializeComponent(); this.selectedRoom = selectedRoom; //fill the page with information of selected room. lblRoomName.Content = selectedRoom.Name.ToUpper(); txtSeats.Text = selectedRoom.Seats.ToString(); if (selectedRoom.Active == true) { active.IsChecked = true; } else { inactive.IsChecked = true; } }
/// <remarks> /// on Room selection prepare CustomerBO object by chosen customer name. /// </remarks> private void RoomSelectionChanged(object sender, SelectionChangedEventArgs e) { String selectedRoomName = (String)cboxRooms.SelectedItem; RoomService roomSrv = new RoomService(); _selectedRoom = (RoomBO)roomSrv.getRoomByName(selectedRoomName); }
/// <remarks> /// checks room-date pair. If there is a booking for this pair already, displays warning. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void txtDate_selectionChanged(object sender, SelectionChangedEventArgs e) { if ((DateTime)txtDate.SelectedDate == null) { lblWarningBook.Text = "Palun vali kuupäev"; return; } _selectedDate = (DateTime)txtDate.SelectedDate; if (cboxRoom.SelectedItem != null) { _selectedRoom = (RoomBO)cboxRoom.SelectedItem; List<BookingBO> allBookings = _bookingSrv.getAllFromTable(); foreach (BookingBO booking in allBookings) { if (DateTime.Compare(booking.Date, _selectedDate) == 0 && booking.Room.ToString().Equals(_selectedRoom.Name.ToString())) { if (_selectedBooking == null || _selectedBooking.BookingID != booking.BookingID) { lblWarning.Text = string.Format("Selleks kuupäevaks ruum {0} on juba broneeritud. Vali muu kuupäev/ruum", _selectedRoom.Name.ToString()); return; } else { lblWarning.Text = ""; } } else { lblWarning.Text = ""; } } } }
/// <remarks> /// checks room seats - participants pair. If participants value exeeds room seats, displays warning. /// checks room-date pair. If there is a booking for this pair already, displays warning. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void cboxRuum_selectionChanged(object sender, SelectionChangedEventArgs e) { _selectedRoom = (RoomBO)(sender as ComboBox).SelectedItem; // checks if any participants info is stores, that exeeds room seats value, if true, display warning if (_participants > 0 && _selectedRoom != null && _participants > _selectedRoom.Seats) { lblWarning2.Text = String.Format("Osalejate arv ületab valitud ruumi mahutavust ({0} kohta).",_selectedRoom.Seats.ToString()); } else { lblWarning2.Text = ""; } // checks, if there are already bookings for this date-room pair if true, display warning if (txtDate.SelectedDate != null) { List<BookingBO> allBookings = _bookingSrv.getAllFromTable(); if (allBookings != null) { foreach (BookingBO booking in allBookings) { if (DateTime.Compare(booking.Date, (DateTime)txtDate.SelectedDate) == 0 && booking.Room.ToString().Equals(_selectedRoom.Name.ToString())) { if (_selectedBooking != null && _selectedBooking.BookingID != booking.BookingID || _selectedBooking == null) { lblWarning.Text = string.Format("Selleks kuupäevaks ruum {0} on juba broneeritud. Vali muu kuupäev/ruum", _selectedRoom.Name.ToString()); return; } else { lblWarning.Text = ""; } } else { lblWarning.Text = ""; } } } } }
/// <remarks> /// Saves validates and saves the data in fields as new BookingBO and returns to previous page. /// </remarks> /// <param name="sender"></param> /// <param name="e"></param> private void btnBook_Click(object sender, RoutedEventArgs e) { lblWarningBook.Text = ""; //check if date is selected, if not, display warning if (txtDate.SelectedDate == null) lblWarningBook.Text = "Palun vali kuupäev"; else { //check, if date isn't in the past if (DateTime.Compare((DateTime)txtDate.SelectedDate,DateTime.Today)<0) { lblWarningBook.Text = "Valitud kuupäev on minevikus"; } //if date is selected, convert to DateTime and assing _selectedDate = (DateTime)txtDate.SelectedDate; //check if Room is selected, of not, display warning if (cboxRoom.SelectedItem == null) lblWarningBook.Text = "Palun vali ruum"; else { //if Room is selected, assign _selectedRoom = (RoomBO)cboxRoom.SelectedItem; //check if customer is selected, if not, display warning if ((CustomerBO)listCustomers.SelectedItem == null) { lblWarningBook.Text = "Palun vali klient"; } else { //if customer is selected, assign. Clear warning lable _selectedCustomer = (CustomerBO)listCustomers.SelectedItem; if (int.TryParse(txtParticipants.Text, out _participants) == false) { lblWarningBook.Text = "Palun sisesta osalejate arv"; return; } _participants = int.Parse(txtParticipants.Text); // if number is negative or 0, display warning if (_participants <= 0) { lblWarningBook.Text = "Palun sisesta osalejate arv"; return; } if (lblWarning.Text.Equals("") && lblWarning2.Text.Equals("") && lblWarningBook.Text.Equals("")) { //if all conditions filfilled and values assigned, assign optional values if ((_participants > 0) && (_selectedRoom != null) && (_selectedDate != null) && (_selectedCustomer != null)) { _additionalInfo = txtAdditionalInfo.Text; // if user created new booking, add new booking to DB if (_selectedBooking == null) { _bookingSrv.addNew(_selectedDate, _selectedRoom.RoomID, _selectedCustomer.CustomerID, _participants, DateTime.Now, _admin.AdminID, _additionalInfo); } // if user updates existing booking, update booking by Id else { _bookingSrv.UpdateById(_selectedBooking.BookingID, _selectedDate, _selectedRoom.RoomID, _selectedCustomer.CustomerID, _participants, _additionalInfo); } //return to previous page // Find the frame. Frame pageFrame = null; DependencyObject currParent = VisualTreeHelper.GetParent(this); while (currParent != null && pageFrame == null) { pageFrame = currParent as Frame; currParent = VisualTreeHelper.GetParent(currParent); } // gets us back to View we came from pageFrame.NavigationService.GoBack(); } } } } } }
public RoomReportBO(DateTime start, DateTime end, RoomBO room) : base(start, end) { this._room = room; }