private static void UpdateDb(Seat seat, string id) { using (var connection = new SqlConnection(connectionString)) { var query = (seat.BookingState == BookingState.Reserved || seat.BookingState == BookingState.Cancelled) ? $"INSERT INTO Ticket ([UniqueNumber], [Row], [Number], [BookingState]) VALUES (\'{id}\', {seat.Row}, {seat.Number}, {(int) seat.BookingState})" : $"DELETE FROM Ticket WHERE [Row] = {seat.Row} AND [Number] = {seat.Number}"; var command = new SqlCommand(query, connection); connection.Open(); command.ExecuteScalar(); connection.Close(); } }
private void btSubmit_Click(object sender, RoutedEventArgs e) { var queue = new MessageQueue(_queueName); var customer = new Customer { Name = tbName.Text, Surname = tbSurname.Text }; if (!_selectedSeats.Any()) { MessageBox.Show("reserve the seat"); return; } foreach (var selectedSeat in _selectedSeats) { var seat = new Seat { BookingState = selectedSeat.BookingState, Data = customer, Number = selectedSeat.Number, Row = selectedSeat.Row }; queue.Send(seat); } MessageBox.Show("Wait for approval"); _selectedSeats.Clear(); }
private void UI_InitSeats() { for (var i = 0; i < 30; i++) { for (var j = 0; j < 40; j++) { var uiSeat = DrawSeat(BookingState.Free); canvas.Children.Add(uiSeat); Canvas.SetTop(uiSeat, i * 10); Canvas.SetLeft(uiSeat, j * 10); _room[i, j] = new Seat { ViewModel = uiSeat }; } } }