Exemple #1
0
        public Form1()
        {
            InitializeComponent();

            cmbNumberInfringement.DataSource    = InfringementType.GetAll();
            cmbNumberInfringement.ValueMember   = "number";
            cmbNumberInfringement.DisplayMember = "infringement";
        }
Exemple #2
0
        public void AddInfringement(string infringement, int points)
        {
            InfringementType it = new InfringementType();

            it.Infringement = infringement;
            it.Points       = decimal.ToInt32(points);

            it.Add();

            it = null;

            System.Windows.Forms.MessageBox.Show("Registro grabado");
        }
        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;
            }
        }