public void ChooseSeat(int seatNumber) { ucSeatMap.SetEmpty(seatNumber); if (_selectedSeatNumbers.Remove(seatNumber) == false) { _selectedSeatNumbers.Add(seatNumber); ucSeatMap.SetSelected(seatNumber); } lblSeatNo.Text = _seatClass.ToString(); foreach (int seatNo in _selectedSeatNumbers.OrderBy(i => i)) { lblSeatNo.Text += seatNo.ToString() + ","; } lblSeatNo.Text = lblSeatNo.Text.Remove(lblSeatNo.Text.Length - 1); }
private void LoadSeatMapData() { ClearTicketInfo(); _seatClass = rbtnUpperSeat.Checked ? Constants.SeatClass.B : rbtnLowerSeat.Checked ? Constants.SeatClass.A : Constants.SeatClass.S; _busId = cboBusName.SelectedValue.ToString(); _tourId = cboTour.SelectedValue.ToString(); _departureTime = dtDepartureTime.Value; ucSeatMap.InitSeatMap(_seatClass); var reservedTickets = new TicketBusiness().GetAll(_busId, _tourId, _seatClass.ToString(), _departureTime).ToList(); ucSeatMap.LoadTicket(reservedTickets); lblPrice.Text = CurrencyUtil.ToString(GetPriceBySeatClass(_seatClass.ToString())); _isEmptySeat = false; }
public void InitSeatMap(Constants.SeatClass seatClass) { InitLayoutContainer(); _seatMap = new List <Button>(); _seatClass = seatClass; bool isSeat = false; int seatIndex = 1; int gridIndex = 0; int maxSeat = seatClass == Constants.SeatClass.S ? MAX_FLOOR_SEAT_COUNT : MAX_NORMAL_SEAT_COUNT; for (int rowIndex = 0; rowIndex < MAX_ROWS_COUNT; rowIndex++) { for (int columnIndex = 0; columnIndex < MAX_COLUMNS_COUNT; columnIndex++) { isSeat = seatClass != Constants.SeatClass.S ? (gridIndex + rowIndex % 2) % 2 == 0 || seatIndex > maxSeat - 5 : (gridIndex + rowIndex % 2) % 2 == 1; int tempColumnIndex = columnIndex; if (rowIndex % 2 != 0) { tempColumnIndex = MAX_COLUMNS_COUNT - columnIndex - 1; } if (isSeat == false) { gridIndex++; continue; } Button seat = new Button(); seat.BackColor = EMPTY_SEAT_COLOR; seat.Dock = DockStyle.Fill; seat.Text = seatClass.ToString() + seatIndex.ToString(); seat.Name = seatIndex.ToString(); seat.Font = new System.Drawing.Font("Arial", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); seat.Click += new EventHandler(btnSeat_Click); _seatMap.Add(seat); _panelLayout.Controls.Add(seat, tempColumnIndex, rowIndex); seatIndex++; gridIndex++; } } }