private void FillData() { listBoxParts.Items.Clear(); listBoxCountries.Items.Clear(); listBoxManufacturers.Items.Clear(); LocalDataHolder.Part_SelectAll() .ForEach(part => listBoxParts.Items.Add($"{part.Id}: {part.Name}")); LocalDataHolder.Country_SelectAll() .ForEach(country => listBoxCountries.Items.Add($"{country.Id}: {country.Name}")); LocalDataHolder.Manufacturers_SelectAll().ForEach(manufacturer => listBoxManufacturers.Items.Add($"{manufacturer.Id}: {manufacturer.Name}")); comboBoxPartCountry.Items.Clear(); comboBoxPartManufacturer.Items.Clear(); var countries = LocalDataHolder.Country_SelectAll(); countries.ForEach(country => comboBoxPartCountry.Items.Add($"{country.Id}: {country.Name}")); var manufacturers = LocalDataHolder.Manufacturers_SelectAll(); manufacturers.ForEach(manufacturer => comboBoxPartManufacturer.Items.Add($"{manufacturer.Id}: {manufacturer.Name}")); }
void FillPart(Part part) { textBoxPartId.Text = part.Id.ToString(); var countries = LocalDataHolder.Country_SelectAll(); var countryIndex = countries.FindIndex(t => t.Id == part.CountryId); comboBoxPartCountry.SelectedIndex = countryIndex; var manufacturers = LocalDataHolder.Manufacturers_SelectAll(); var manufacturerIndex = manufacturers.FindIndex(t => t.Id == part.ManufacturerId); comboBoxPartManufacturer.SelectedIndex = manufacturerIndex; textBoxPartName.Text = part.Name; richTextBoxPartTechnicalData.Text = JToken.Parse(part.TechnicalData).ToString(Formatting.Indented); textBoxPartLifetime.Text = part.Lifetime.ToString(); textBoxPartCount.Text = part.Count.ToString(); }