private async void GetDriverByIdentifier(string identifier) { if (!String.IsNullOrEmpty(identifier)) { var result = await ApiManagerDrivers.GetByNifNie(identifier); if (result != null) { this.driverDTOBindingSource.DataSource = result; this.driverDTO = result; this.cmdAccept.Enabled = true; this.cmdAccept.Focus(); } else { this.driverDTO = null; this.driverDTOBindingSource.Clear(); this.cmdAccept.Enabled = false; MessageBox.Show("No se ha encontrado ningún Conductor con el NIF/NIE " + identifier, "Añadir conductor habitual", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { this.cmdAccept.Enabled = false; MessageBox.Show("Debes introducir el NIF/NIE del conductor", "Añadir conductor habitual", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private async void cmdAccept_Click(object sender, EventArgs e) { if (this.ValidateData()) { try { this._driver = await ApiManagerDrivers.AddNew(this._driver); 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); } } }
private async void GetDriversByVehicleLicense(string license) { var infraction = this.infractionDTOBindingSource.Current as InfractionDTO; if (infraction != null) { var drivers = await ApiManagerDrivers.GetDriversByVehicleLicense(license); if (drivers != null && drivers.Any()) { this.vehicleDriverDTOBindingSource.DataSource = drivers; if (drivers.Count == 1) { infraction.DriverId = drivers.First().DriverId; infraction.DriverFullName = drivers.First().DriverFullName; infraction.DriverIdentifier = drivers.First().DriverIdentifier; this.lblDriverIdentifier.Text = drivers.First().DriverIdentifier; this.lblDriverFullName.Text = drivers.First().DriverFullName; } else { infraction.DriverId = drivers.First().DriverId; infraction.DriverFullName = drivers.First().DriverFullName; infraction.DriverIdentifier = drivers.First().DriverIdentifier; this.lblDriverIdentifier.Text = drivers.First().DriverIdentifier; this.lblDriverFullName.Text = drivers.First().DriverFullName; } } else { infraction.DriverId = Guid.Empty; infraction.DriverFullName = ""; infraction.DriverIdentifier = ""; this.lblDriverIdentifier.Text = ""; this.lblDriverFullName.Text = ""; this.vehicleDriverDTOBindingSource.DataSource = null; } } }
public async Task SearchDrivers(string filter = null) { if (filter == null) { filter = this.txtFilter.Text; } if (!String.IsNullOrEmpty(filter)) { this.drivers = await ApiManagerDrivers.Search(filter); if (drivers == null || !drivers.Any()) { MessageBox.Show("No se ha encontrado ningún resultado", "Búsqueda de conductores", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { this.driverDTOBindingSource.DataSource = drivers; } } }
private async void GetDriverByIdentifier(string identifier) { var driver = await ApiManagerDrivers.GetByNifNie(identifier); if (driver != null) { var current = this.vehicleDTOBindingSource.Current as VehicleDTO; if (current != null) { current.DriverId = driver.Id; this.driverDTOBindingSource.DataSource = driver; ShowDriver(true); } } else { MessageBox.Show("No se ha encontrado ningún resultado", "Búsqueda de conductor", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ShowDriver(false); } }
private async void GetDrivers(string license) { var results = await ApiManagerDrivers.GetDriversByVehicleLicense(license); this.vehicleDriverDTOBindingSource.DataSource = results; }