private void SetDataToTheList() { try { listWorkers.Items.Clear(); WorkersCatalog.Model.Archive.Instance.data = WorkersCatalog.Database.DatabaseProvider.Instance.GetWorkers(); string fullName; foreach (var item in WorkersCatalog.Model.Archive.Instance.data) { fullName = item.Name.ToString() + " " + item.Surname.ToString(); fullName = fullName.ToLower(); if (fullName.Contains(searchingString.ToLower())) { listWorkers.Items.Add(item.Name + " " + item.Surname); } } } catch (Exception err) { if (MessageBox.Show(ShowText.ConnectionError(), ShowText.ConnectionErrorTitle(), MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes) { View.DatabaseConnectionWindow databaseSettings = new View.DatabaseConnectionWindow(); databaseSettings.ShowDialog(); SetDataToTheList(); } } }
public void ListFiller() { try { lstChoose.Items.Clear(); WorkersCatalog.Model.Archive.Instance.data = WorkersCatalog.Database.DatabaseProvider.Instance.GetWorkers(); foreach (var item in WorkersCatalog.Model.Archive.Instance.data) { lstChoose.Items.Add(item.Name + " " + item.Surname); } } catch (Exception err) { if (MessageBox.Show(ShowText.ConnectionError(), ShowText.ConnectionErrorTitle(), MessageBoxButton.YesNo, MessageBoxImage.Error, MessageBoxResult.Yes) == MessageBoxResult.Yes) { View.DatabaseConnectionWindow databaseSettings = new View.DatabaseConnectionWindow(); databaseSettings.ShowDialog(); ListFiller(); } MessageBox.Show(err.Message); } }