コード例 #1
0
        //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);
            }
        }
コード例 #2
0
 //on Click function. take the data of the selected car and initialize a new booking sending data to the server
 private void confirmBooking(object sender, EventArgs e)
 {
     if (carBox.SelectedItem.ToString() != "" && startPicker.Value < endPicker.Value)
     {
         var car      = new Booking.Car();
         var CarPlate = carBox.SelectedItem.ToString();
         CarPlate = CarPlate.Substring(0, CarPlate.IndexOf(" "));
         var fetchedCar = carManager.GetCarByPlate(CarPlate, this.Email, this.PassHash);
         car.PlateNumber  = fetchedCar.PlateNumber;
         car.Make         = fetchedCar.Make;
         car.Model        = fetchedCar.Model;
         car.Year         = fetchedCar.Year;
         car.Kilometers   = fetchedCar.Kilometers;
         car.BurnedLiters = fetchedCar.BurnedLiters;
         try
         {
             bookingManager.BookCar(car, startPicker.Value, endPicker.Value, this.Email, this.PassHash);
             MessageBox.Show("Auto prenotata!", "Puoi dormire sonni tranquilli.", MessageBoxButtons.OK);
             this.StopEditing();
         }
         catch (Exception exc)
         {
             MessageBox.Show("Errore nella connessione al server.", "Proprio non riesco a confermare la richiesta.", MessageBoxButtons.OK);
         }
     }
     else
     {
         MessageBox.Show("Controlla di aver inserito tutti i dati.", "Proprio non riesco così.", MessageBoxButtons.OK);
     }
 }
コード例 #3
0
 //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);
     }
 }