protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgvResults.SelectedItems.Count == 0 || dgvResults.SelectedItem == null) { return; } OnReloading = true; var roles = dgvResults.SelectedItems.OfType <Role>().ToList(); if (roles.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(roles.Count); progressResources.Show(this); foreach (var role in roles) { if (RolesService.ReferencedToOther(role.RoleID)) { Global.ReferenceFound(this, RolesResources.Referenced); } else if (!RolesService.Instanse.Remove(role)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (roles.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(); } } OnReloading = false; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; var props = dgResults.SelectedItems.OfType <Prop>().ToList(); if (props.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(props.Count); progressResources.Show(this); foreach (var prop in props) { if ( !LabPropsService.Instanse.Remove(new LabProp { PropID = prop.PropID, LabID = (Guid)cmbLabs.SelectedValue })) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (props.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(cmbLabs.SelectedValue); } } OnReloading = false; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; var logs = dgResults.SelectedItems.OfType <Log>().ToList(); if (logs.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressForm = new ProgressWindow(logs.Count); progressForm.Show(this); foreach (var log in logs) { if (!LogsService.Default.Remove(log.LogID)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressForm.IncreaseProgress(); } progressForm.Close(); if (logs.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(); } } aiLoader.Visibility = Visibility.Collapsed; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; var props = dgResults.SelectedItems.OfType <Prop>().ToList(); if (props.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(props.Count); progressResources.Show(this); foreach (var prop in props) { string labName; if (PropsService.ReferencedToOther(prop.PropID, out labName)) { var temp = prop; if ( Global.ReferenceFound(this, string.Format(PropsResources.Referenced, new[] { temp.Name, temp.PropNo.ToString(), labName })) == MessageBoxResult.Yes) { if (!PropsService.Instanse.Remove(prop)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } } } else if (!PropsService.Instanse.Remove(prop)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (props.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(); } } OnReloading = false; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; var materials = dgResults.SelectedItems.OfType <Material>().ToList(); if (materials.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(materials.Count); progressResources.Show(this); foreach (var material in materials) { var id = material; var temp = MaterialsService.Instanse.GetAll().Where(m => m.MaterialID == id.MaterialID).First(); var dialogResult = temp.CurrentAmount > 0 ? Global.ReferenceFound(this, string.Format(MaterialsResources.Referenced, new[] { temp.Name, temp.StringCurrentAmount, temp.StringUnit })) : MessageBoxResult.Yes; if (dialogResult == MessageBoxResult.Yes) { if (!MaterialsService.Instanse.Remove(material)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } } progressResources.IncreaseProgress(); } progressResources.Close(); if (materials.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(); } } OnReloading = false; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; if (_materials) { var repositoryMaterials = dgResults.SelectedItems.OfType <RepositoryMaterial>().ToList(); if (repositoryMaterials.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(repositoryMaterials.Count); progressResources.Show(this); foreach (var repositoryMaterial in repositoryMaterials) { if (!RepositoryMaterialsService.Instanse.Remove(repositoryMaterial)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (repositoryMaterials.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(cmbFilterBy.SelectedIndex); } } } else { var repositoryItems = dgResults.SelectedItems.OfType <RepositoryItem>().ToList(); if (repositoryItems.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(repositoryItems.Count); progressResources.Show(this); foreach (var repositoryItem in repositoryItems) { if (!RepositoryItemsService.Instanse.Remove(repositoryItem)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (repositoryItems.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(cmbFilterBy.SelectedIndex); } } } OnReloading = false; }
protected override void RemoveWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (dgResults.SelectedItems.Count == 0 || dgResults.SelectedItem == null) { return; } OnReloading = true; var categories = dgResults.SelectedItems.OfType <Category>().ToList(); if (categories.Count > 0) { var failed = false; var removedCount = 0; if (Global.DeleteQuestion(this)) { var progressResources = new ProgressWindow(categories.Count); progressResources.Show(this); foreach (var category in categories) { int count; if (CategoriesService.ReferencedToOther(category, out count)) { if ( Global.ReferenceFound(this, string.Format(CategoriesResources.Referenced, category.Name, count)) == MessageBoxResult.Yes) { if (!CategoriesService.Instanse.Remove(category)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } } } else if (!CategoriesService.Instanse.Remove(category)) { failed = true; Global.DeletionFailed(this); } else { removedCount++; } progressResources.IncreaseProgress(); } progressResources.Close(); if (categories.Count > 1 && failed) { Global.DeletionSuceededWithSomeFailures(this); } else if (removedCount > 0 & !failed) { Global.DeletionSuceeded(this); } ResetFields(); TryToLoad(); } } OnReloading = false; }