コード例 #1
0
ファイル: FrmAddNewInfraction.cs プロジェクト: okfiera/dgt
        private async void GetVehicleByLicense(string license)
        {
            var infraction = this.infractionDTOBindingSource.Current as InfractionDTO;

            if (infraction != null)
            {
                var v = await ApiManagerVehicles.GetByLicense(license);

                if (v != null)
                {
                    infraction.VehicleId       = v.Id;
                    infraction.VehicleFullName = v.VehicleFullName;
                    infraction.VehicleLicense  = v.License;

                    this.lblVehicleFullName.Text = v.VehicleFullName;

                    GetDriversByVehicleLicense(license);
                }
                else
                {
                    MessageBox.Show("No se ha encontrado ningún resultado", "Buscar vehículo", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);

                    infraction.VehicleId       = Guid.Empty;
                    infraction.VehicleFullName = "";
                    infraction.VehicleLicense  = "";

                    this.lblVehicleFullName.Text = "";

                    this.vehicleDriverDTOBindingSource.DataSource = null;
                }
            }
        }
コード例 #2
0
        private async Task GetDriverVehicles()
        {
            var currentDriver = this.driverDTOBindingSource.Current as DriverDTO;

            if (currentDriver != null)
            {
                var vehicles = await ApiManagerVehicles.ByDriverIdentifier(currentDriver.Identifier);

                this.vehicleDriverDTOBindingSource.DataSource = vehicles;
            }
        }
コード例 #3
0
ファイル: FrmAddNewVehicle.cs プロジェクト: okfiera/dgt
        private async void cmdAccept_Click(object sender, EventArgs e)
        {
            if (this.ValidateData())
            {
                try
                {
                    this._vehicle = await ApiManagerVehicles.AddNew(this._vehicle);

                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido el siguiente error:" + Environment.NewLine + Environment.NewLine + ex.GetBaseException().Message, "DGT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #4
0
        public async Task SearchVehicles(string filter = null)
        {
            if (filter == null)
            {
                filter = this.txtFilter.Text;
            }

            this.vehicles = await ApiManagerVehicles.Search(filter);

            if (vehicles == null || !vehicles.Any())
            {
                MessageBox.Show("No se ha encontrado ningún resultado", "Búsqueda de vehículos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                this.vehicleDTOBindingSource.DataSource = vehicles;
                this.vehicleDriverDTOBindingSource.MoveFirst();
            }
        }
コード例 #5
0
ファイル: FrmAttachDriver.cs プロジェクト: okfiera/dgt
        private async void cmdAccept_Click(object sender, EventArgs e)
        {
            if (this.driverDTO != null)
            {
                try
                {
                    this.vehicleDriverDTO = await ApiManagerVehicles.AttachDriver(this.vehicleDTO.License, this.driverDTO.Identifier);

                    this.DialogResult = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido el siguiente error:" + Environment.NewLine + Environment.NewLine + ex.GetBaseException().Message, "DGT", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("No hay conductor seleccionado", "Añadir conductor habitual",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }