private void cmbStatus_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e) { MessageBoxResult confirm = MessageBox.Show("Do you really want to change Status filter?\r\nAll unsaved jobs will be reset.", "", MessageBoxButton.OKCancel); if (confirm == MessageBoxResult.OK) { EstimateStatus selectedEstimateStatus = (EstimateStatus)cmbStatus.SelectedItem; _currentApp.SelectedStatusId = selectedEstimateStatus.StatusId; ResetEditEstimateUserID(); if (MainFrame.Source != null && MainFrame.Source.OriginalString == "/EstimateList.xaml") { MainFrame.Refresh(); } else { MainFrame.Navigate(new Uri("/EstimateList.xaml", UriKind.Relative)); } } else { //Change Status to what it was //Remove SelectionChanged EventHandler before modifying value cmbStatus.SelectionChanged -= new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbStatus_SelectionChanged); //Modify value cmbStatus.SelectedValue = _currentApp.SelectedStatusId; //Add SelectionChanged EventHandler cmbStatus.SelectionChanged += new Telerik.Windows.Controls.SelectionChangedEventHandler(cmbStatus_SelectionChanged); } }
public void Update(EstimateStatus estimateStatus) { estimateStatus = Validate(estimateStatus); _estimateStatuses.Attach(estimateStatus); _repository.Entry(estimateStatus).State = EntityState.Modified; _repository.SaveChanges(); }
private EstimateStatus Validate(EstimateStatus estimateStatus) { if (!string.IsNullOrWhiteSpace(estimateStatus.Description)) estimateStatus.Description = estimateStatus.Description.Trim(); else throw new BusinessLogicException("A name or description is required for all estimate statuses."); return estimateStatus; }
public void Delete(EstimateStatus estimateStatus) { if (estimateStatus.Estimates.Any()) throw new BusinessLogicException(string.Format("This estimate status cannot be deleted because {0} estimates are using it.", estimateStatus.Estimates.Count)); _estimateStatuses.Attach(estimateStatus); _repository.Entry(estimateStatus).State = EntityState.Deleted; _repository.SaveChanges(); }
public void Insert(EstimateStatus estimateStatus) { estimateStatus = Validate(estimateStatus); if (_estimateStatuses.Any(i => i.Description.Equals(estimateStatus.Description, StringComparison.InvariantCultureIgnoreCase))) throw new BusinessLogicException("An estimate status with that description already exists."); _estimateStatuses.Add(estimateStatus); _repository.SaveChanges(); }
public List <PurchaseEstimate> ListByStatus(EstimateStatus status) => erpNodeDBContext.PurchaseEstimates .Where(e => e.Status == status) .ToList();