public void AddDriver(string VehicleRegistration, string Dni)
        {
            VehicleDrivers vd = new VehicleDrivers();

            vd.Dni = Dni;
            vd.VehicleRegistration = VehicleRegistration;

            if (Vehicles.Exist(vd.VehicleRegistration))
            {
                if (Drivers.Exist(vd.Dni))
                {
                    vd.Add();

                    System.Windows.Forms.MessageBox.Show("Registro grabado");

                    vd = null;
                }
                else
                {
                    throw new System.InvalidOperationException("No existe un conductor con ese DNI.");
                }
            }
            else
            {
                throw new System.InvalidOperationException("No existe un vehículo con esa matrícula.");
            }
        }
        public void AddVehicle(string vRegistration, string brand, string model, string dni)
        {
            Vehicles v = new Vehicles();

            v.VehicleRegistration = vRegistration;
            v.Brand = brand;
            v.Model = model;
            v.Dni   = dni;

            if (v.Exist())
            {
                throw new System.InvalidOperationException("Ya existe un vehículo con esa matrícula.");
            }
            else
            {
                if (!Drivers.Exist(v.Dni))
                {
                    throw new System.InvalidOperationException("El DNI del conductor introducido no existe.");
                }
                else
                {
                    if (Drivers.TotalVehicles(v.Dni) >= 10)
                    {
                        throw new System.InvalidOperationException("Este conductor ya es conductor habitual de 10 vehículos.");
                    }
                    else
                    {
                        v.Add();
                        System.Windows.Forms.MessageBox.Show("Registro grabado");
                    }
                }
            }

            v = null;
        }
示例#3
0
        //Getter drivers
        public static Drivers.DriversEnum drivers()
        {
            Drivers drivers = new Drivers(driversList);

            Drivers.DriversEnum driversEnum = drivers.GetEnumerator();
            return(driversEnum);
        }
        public void AddDriver(string dni, string name, string surname)
        {
            Drivers driver = new Drivers();

            driver.Dni      = dni;
            driver.Name     = name;
            driver.Surnames = surname;

            if (driver.Exist())
            {
                System.Windows.Forms.MessageBox.Show("Ya existe un cliente con este DNI.");
            }
            else
            {
                driver.Add();
                System.Windows.Forms.MessageBox.Show("Registro grabado");
            }

            driver = null;
        }
        public void AddInfringement(int NumberInfringement, string VehicleRegistration)
        {
            //We build the new infraction
            InfringementDrivers id = new InfringementDrivers();

            id.Date = DateTime.Now;
            id.NumberInfringement  = NumberInfringement;
            id.VehicleRegistration = VehicleRegistration;

            //We use the vehicle registration to rescue the data of the usual driver
            Vehicles v = new Vehicles(id.VehicleRegistration);

            if (!v.Exist())
            {
                throw new System.InvalidOperationException("El vehículo no existe.");
            }
            else
            {
                id.Dni = v.Dni;

                id.Add();

                //We build a driver class to execute the sanction
                Drivers d = new Drivers(id.Dni);

                //We use the type of infraction introduced to rescue the penalty points
                InfringementType it = new InfringementType(id.NumberInfringement);

                //We call the function that subtracts the points of that type of infraction
                d.Sanction(it.Points);

                System.Windows.Forms.MessageBox.Show("Infracción introducida - el conductor:" + d.Name + " " + d.Surnames + " ha sido sancionado con: " + it.Points + " puntos.");

                id = null;
                d  = null;
                it = null;
                v  = null;
            }
        }
示例#6
0
 private void btnSearchTopDrivers_Click(object sender, EventArgs e)
 {
     dgvTopDrivers.DataSource = Drivers.Top(decimal.ToInt32(nudTop.Value));
 }