private void btn_devolver_Click(object sender, EventArgs e)
        {
            Entities.User user = service.userLogged();
            Rental        r    = user.lastRental();
            bool          err  = false;
            string        id   = "";

            try
            {
                if (txt_estacion.TextLength == 0)
                {
                    err = true;
                    MessageBox.Show("Por favor, indique una estación");
                }
                else
                {
                    if (r == null)
                    {
                        MessageBox.Show("No dispone de ningun alquiler");
                        throw new ServiceException("Ha-ha");
                    }
                    id = txt_estacion.Text;
                    if (btn_si.Checked == true)
                    {
                        Station st = service.findStationById(id);
                        service.returnScooter(r, st);
                        MessageBox.Show("Patinete devuelto, se procede a registrar incidente" + "\nPrecio del recorrido: " + r.Price);
                        registrarIncidente RegistrarIncidente = new registrarIncidente(service);
                        RegistrarIncidente.ShowDialog();
                        this.Hide();
                    }
                    else
                    {
                        if (btn_no.Checked == true)
                        {
                            Station st = service.findStationById(id);
                            service.returnScooter(r, st);
                            MessageBox.Show("Patinete devuelto sin incidentes" + "\nPrecio del recorrido: " + r.Price);
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Por favor, seleccione si desea registrar un incidente");
                        }
                    }
                }
            }
            catch (ServiceException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void btn_registrar_Click(object sender, EventArgs e)
 {
     try
     {
         User   user = service.userLogged();
         Rental r    = user.lastRental();
         bool   err  = false;
         string inc  = "";
         if (txt_incidente.TextLength == 0)
         {
             err = true;
             MessageBox.Show("Por favor, indique el incidente");
         }
         else
         {
             inc = txt_incidente.Text;
             Incident i = new Incident(inc, DateTime.Now);
             r.addIncident(i);
             MessageBox.Show("Incidente registrado");
             this.Hide();
         }
     }
     catch (ServiceException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btn_alquilar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_idEstacion.TextLength == 0)
         {
             MessageBox.Show("Introduce el id de la estación!");
         }
         else
         {
             Station st = service.findStationById(txt_idEstacion.Text);
             Scooter sc = st.chooseScooterToRent();
             User    u  = service.userLogged();
             Rental  r  = new Rental(DateTime.Now, st, sc, u);
             service.rentScooter(r);
         }
     }
     catch (ServiceException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 public ventanaIniciado(IEcoScooterService service)
 {
     InitializeComponent();
     this.service = service;
     label3.Text  = service.userLogged().Name;
 }
Ejemplo n.º 5
0
        void testLogin2()
        {
            Console.WriteLine();
            Console.WriteLine("TESTING MORE ABOUT LOGIN...");

            try
            {
                if (service.loggedAsUser())
                {
                    Console.WriteLine("   User " + service.userLogged().Name + " logged in");
                }
                else if (service.loggedAsEmployee())
                {
                    Console.WriteLine("   Employee " + service.employeeLogged().Name + " logged in");
                }
                else
                {
                    Console.WriteLine("   Nobody logged in");
                }

                service.logout();

                if (service.loggedAsUser())
                {
                    Console.WriteLine("   User " + service.userLogged().Name + " logged in");
                }
                else if (service.loggedAsEmployee())
                {
                    Console.WriteLine("   Employee " + service.employeeLogged().Name + " logged in");
                }
                else
                {
                    Console.WriteLine("   Nobody logged in");
                }

                service.login("user1", "user1");
                if (service.loggedAsUser())
                {
                    Console.WriteLine("   User " + service.userLogged().Name + " logged in");
                }
                else if (service.loggedAsEmployee())
                {
                    Console.WriteLine("   Employee " + service.employeeLogged().Name + " logged in");
                }
                else
                {
                    Console.WriteLine("   Nobody logged in");
                }
            }
            catch (Exception e)
            {
                printError(e);
            }
        }