//overloaded constructor. in this case the admin add a services public AdminServiceEdit(string Email, string PassHash, string CarPlate) { InitializeComponent(); this.Email = Email; this.PassHash = PassHash; this.ServicedCar = new Service.Car(); this.newService = true; TotalUpDown.Value = 0; KilometersUpDown.Value = 0; DeleteButton.Visible = false; try { CarManagerClient carManager = new CarManagerClient(); Car.Car FetchedCar = carManager.GetCarByPlate(CarPlate, this.Email, this.PassHash); ServicedCar.PlateNumber = FetchedCar.PlateNumber; ServicedCar.Make = FetchedCar.Make; ServicedCar.Model = FetchedCar.Model; ServicedCar.Year = FetchedCar.Year; ServicedCar.Kilometers = FetchedCar.Kilometers; ServicedCar.BurnedLiters = FetchedCar.BurnedLiters; this.serviceManager = new ServiceManagerClient(); } catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); } }
//overloaded constructor. in this case the admin is adding a car public AdminCarEdit(string Email, string PassHash) { InitializeComponent(); this.Email = Email; this.PassHash = PassHash; this.newCar = true; MakerTextBox.Text = ""; ModelTextBox.Text = ""; PlateNumberTextBox.Text = ""; PlateNumberTextBox.ReadOnly = false; PlateNumberTextBox.BackColor = Color.White; PlateNumberTextBox.ForeColor = Color.Black; deleteButton.Visible = false; for (int i = 1980; i <= DateTime.Now.Year; i++) { YearComboBox.Items.Add(i); } LitersUpDown.Value = 0; KilometersUpDown.Value = 0; try { this.carManager = new CarManagerClient(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); } }
//constructor public AdminCarEdit(Car.Car EditingCar, string Email, string PassHash) { InitializeComponent(); this.EditingCar = EditingCar; this.Email = Email; this.PassHash = PassHash; this.newCar = false; MakerTextBox.Text = EditingCar.Make; ModelTextBox.Text = EditingCar.Model; PlateNumberTextBox.Text = EditingCar.PlateNumber; PlateNumberTextBox.ReadOnly = true; for (int i = 1980; i <= DateTime.Now.Year; i++) { YearComboBox.Items.Add(i); } if (EditingCar.Year != 0) { YearComboBox.SelectedIndex = EditingCar.Year - 1980; } LitersUpDown.Value = EditingCar.BurnedLiters; KilometersUpDown.Value = EditingCar.Kilometers; try { this.carManager = new CarManagerClient(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); } }
//on Click function. this show a new child form which allow the admin to modify the car of the booking private void EditCar(object sender, EventArgs e) { try { CarManagerClient carManager = new CarManagerClient(); var selectedCar = bookingManager.GetBookingByID(Convert.ToInt32(bookingsListView.SelectedItems[0].Text), this.Email, this.PassHash).BookedCar; AdminCarEdit bookingFormChild = new AdminCarEdit(carManager.GetCarByPlate(selectedCar.PlateNumber, this.Email, this.PassHash), this.Email, this.PassHash); bookingFormChild.MdiParent = this.ParentForm; bookingFormChild.FormBorderStyle = FormBorderStyle.None; bookingFormChild.Dock = DockStyle.Fill; bookingFormChild.Show(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco a mostrare la macchina della prenotazione.", MessageBoxButtons.OK); } }
//constuctor public UserCarBooker(string Email, string PassHash) //this page if accesible only for logged users so it requested the datas of the //logged users { InitializeComponent(); try { //initialize connection with the server this.bookingManager = new BookingManagerClient(); this.carManager = new CarManagerClient(); this.Email = Email; this.PassHash = PassHash; this.UpdateAvailableCars(); bookingBox.DropDownStyle = ComboBoxStyle.DropDownList; carBox.DropDownStyle = ComboBoxStyle.DropDownList; } catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", exc.ToString(), MessageBoxButtons.OK); this.StopEditing(); } }
//constructor public AdminServiceList(string Email, string PassHash, string CarPlate) { this.Email = Email; this.PassHash = PassHash; this.CarPlate = CarPlate; this.serviceManager = new ServiceManagerClient(); this.carManager = new CarManagerClient(); InitializeComponent(); servicesListView.View = View.Details; servicesListView.Columns.Add("ID", -2, HorizontalAlignment.Left); servicesListView.Columns.Add("Kilometri", -2, HorizontalAlignment.Left); servicesListView.Columns.Add("Spesa totale", -2, HorizontalAlignment.Left); try { this.serviceManager = new ServiceManagerClient(); this.carManager = new CarManagerClient(); this.UpdateServices(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); } }
//contrusctor public AdminReportList(string Email, string PassHash, int BookingID) { this.Email = Email; this.PassHash = PassHash; InitializeComponent(); this.BookingID = BookingID; reportListView.View = View.Details; reportListView.Columns.Add("ID", -2, HorizontalAlignment.Left); reportListView.Columns.Add("Oggetto", -2, HorizontalAlignment.Left); reportListView.Columns.Add("Messaggio", -2, HorizontalAlignment.Left); try { this.reportManager = new ReportManagerClient(); this.carManager = new CarManagerClient(); this.UpdateReports(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco.", MessageBoxButtons.OK); } }
//constructor public AdminCarList(string Email, string PassHash) { this.Email = Email; this.PassHash = PassHash; InitializeComponent(); carListView.Clear(); carListView.View = View.Details; carListView.Columns.Add("Targa", 230, HorizontalAlignment.Left); carListView.Columns.Add("Marca", 200, HorizontalAlignment.Left); carListView.Columns.Add("Modello", 150, HorizontalAlignment.Left); carListView.Columns.Add("Anno", 50, HorizontalAlignment.Left); carListView.Columns.Add("Kilometri", 50, HorizontalAlignment.Left); try { carManager = new CarManagerClient(); this.UpdateList(); }catch (Exception exc) { MessageBox.Show("Errore nella connessione al server.", exc.ToString(), MessageBoxButtons.OK); } }