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; } } }
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; } }
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); } } }
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(); } }
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); } }