Ejemplo n.º 1
0
 public Scooter(DateTime registerDate, ScooterState state) : this()
 {
     RegisterDate = registerDate;
     State        = state;
     Rentals      = new List <Rental>();
     PlanningWork = new List <PlanningWork>();
 }
Ejemplo n.º 2
0
 public bool IsStateAvailable(ScooterState state)
 {
     if (state == ScooterState.available)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
        public Scooter(DateTime RegisterDate, ScooterState State)
        {
            this.RegisterDate = RegisterDate;
            this.State        = State;

            planningWorks = new List <PlanningWork>();
            rentals       = new List <Rental>();
        }
Ejemplo n.º 4
0
        public void AddScooter(DateTime registerDate, ScooterState state, Station station)
        {
            Scooter scooter = new Scooter(registerDate, state);

            Scooters.Add(scooter);
            if (scooter.IsStateAvailable(state))
            {
                station.AddScooter(scooter);
                scooter.SetStation(station);
            }
        }
Ejemplo n.º 5
0
        public static bool ValidState(ScooterState state)
        {
            if (state != null)
            {
                return(true);
            }

            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
        private void cmdRegistrarScooter_Click(object sender, EventArgs e)
        {
            try
            {
                string station_id = "";

                if (rbtnUso.Checked || rbtnMantenimiento.Checked || rbtnDisponible.Checked)
                {
                    if (rbtnDisponible.Checked)
                    {
                        state = ScooterState.available;
                        cboxEstacion.Show();
                        if (cboxEstacion.SelectedItem == null)
                        {
                            station_id = "";
                        }
                        else
                        {
                            station_id = cboxEstacion.SelectedItem.ToString();
                        }
                    }
                    else if (rbtnMantenimiento.Checked)
                    {
                        state = ScooterState.inMaintenance;
                    }
                    else
                    {
                        state = ScooterState.inUse;
                    }

                    service.RegisterScooter(registerDate.Value, state, station_id);
                    MessageBox.Show(this, "Scooter registrado con exito", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    rbtnDisponible.Checked    = false;
                    rbtnMantenimiento.Checked = false;
                    rbtnUso.Checked           = false;
                    cboxEstacion.Text         = "";
                }
                else
                {
                    MessageBox.Show(this, "Debe seleccionar el estado del scooter", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (ServiceException serviceException)
            {
                MessageBox.Show(this, serviceException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 7
0
        public void RegisterScooter(DateTime registerDate, ScooterState state, string stationId)
        {
            Station station = ecoScooter.GetStation(stationId);

            if (loggedEmployee == null)
            {
                throw new ServiceException("Debe haber iniciado sesion como empleado para regisstrar un scooter");
            }

            else if (!Scooter.ValidRegisterDate(registerDate)) //futuro error
            {
                throw new ServiceException("Debe introducir una fecha valida");
            }

            else if (state == ScooterState.available && ecoScooter.GetStation(stationId) == null)
            {
                throw new ServiceException("Debes introducir un id valido para colocar el scooter");
            }
            else
            {
                ecoScooter.AddScooter(registerDate, state, station);
                saveChanges();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Boolean err  = false;
            string  mens = "";
            string  est  = "";

            try
            {
                if (txt_estacion.TextLength == 0)
                {
                    err   = true;
                    mens += "El campo Estación es obligatorio \n";
                }
                else
                {
                    est = txt_estacion.Text;
                }
                if (btn_disponible.Checked == true)
                {
                    estado = ScooterState.available;
                }
                if (btn_mantenimiento.Checked == true)
                {
                    estado = ScooterState.inMaintenance;
                }
                if (btn_disponible.Checked == false & btn_mantenimiento.Checked == false)
                {
                    err   = true;
                    mens += "Elige una de las opciones en la sección del Estado \n";
                }
                if (!err)
                {
                    DialogResult answer = MessageBox.Show(this,
                                                          "Patinete agregado \n",
                                                          "Well done",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Information);
                    if (answer == DialogResult.OK)
                    {
                        Scooter sc = new Scooter(txt_fecha.Value.Date, estado);
                        service.registerScooter(sc);
                        Station st = service.findStationById(est);
                        st.assignScooter(sc);
                        service.saveChanges();
                        this.Close();
                    }
                }
                else
                {
                    DialogResult answer = MessageBox.Show(this,
                                                          "Revise los datos introducidos \n" + mens,
                                                          "Error",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Error);
                }
            }
            catch (ServiceException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 9
0
 public void RegisterScooter(DateTime registerDate, ScooterState state, string stationId)
 {
     throw new NotImplementedException();
 }