//constructor public UserAddReport(string Email, string PasswordHash) //this page if accesible only for logged users so it requested the datas of the //logged users { try { this.Email = Email; this.PasswordHash = PasswordHash; InitializeComponent(); // Initializing Design BookingListComboBox.DropDownStyle = ComboBoxStyle.DropDownList; //initialize connection with the server this.bookingManager = new BookingManagerClient(); bookings = bookingManager.GetBookingsForUser(Email, Email, PasswordHash); //show all the bookings of the user so he can select the one to add the report foreach (Booking.Booking SingleBooking in bookings) { BookingListComboBox.Items.Add(SingleBooking.ID.ToString() + " - " + SingleBooking.BookedCar.Make + " " + SingleBooking.BookedCar.Model); } } catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); this.cancelReport(); } }
//this function reload the list of all cars private void UpdateBookings() { bookingsListView.Items.Clear(); try { var bookings = bookingManager.GetBookings(this.Email, this.PassHash); if (this.UserEmail != "") { bookings = bookingManager.GetBookingsForUser(this.UserEmail, this.Email, this.PassHash); labelUser.Text = "di " + this.UserEmail; labelUser.Left = (this.ClientSize.Width - labelUser.Width) / 2; } foreach (var SingleBooking in bookings) { bookingsListView.Items.Add(new ListViewItem(new string[] { SingleBooking.ID.ToString(), SingleBooking.BookedCar.PlateNumber, SingleBooking.Booker.Email, SingleBooking.Start.ToShortDateString(), SingleBooking.End.ToShortDateString() })); } }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco ad aggiornare la lista.", MessageBoxButtons.OK); } bookingsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); bookingsListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }