private void ExecuteDelete(object parameter) { IMessageBoxService msg = new MessageBoxService(); string title = "Deleting Strategic Move Code"; string confirmtxt = "Do you want to delete the selected item"; if (SMCodes.Where(x => x.IsChecked).Count() > 1) { title = title + "s"; confirmtxt = confirmtxt + "s"; } if (msg.ShowMessage(confirmtxt + "?", title, GenericMessageBoxButton.OKCancel, GenericMessageBoxIcon.Question).Equals(GenericMessageBoxResult.OK)) { foreach (SMCodeModel si in SMCodes) { if (si.IsChecked) { if (si.ID > 0) { DeleteSMCode(si.ID); } deleteditems.Add(si); } } foreach (SMCodeModel pm in deleteditems) { SMCodes.Remove(pm); } deleteditems.Clear(); CheckValidation(); } msg = null; }
private void SMCodes_ItemPropertyChanged(object sender, ItemPropertyChangedEventArgs e) { if (e.PropertyName != "IsChecked") { CheckValidation(); isdirty = true; } IsSelected = SMCodes.Where(x => x.IsChecked).Count() > 0; }
private bool IsDuplicateName() { var query = SMCodes.GroupBy(x => x.Name.Trim().ToUpper() + "-" + x.IndustryID.ToString()) .Where(g => g.Count() > 1) .Select(y => y.Key) .ToList(); return(query.Count > 0); }
private void GetSMCodes() { FullyObservableCollection <SMCodeModel> smcodes = DatabaseQueries.GetSMCodes(); SMCodes?.Clear(); foreach (SMCodeModel sm in smcodes) { if (sm.ID > 0) { SMCodes.Add(sm); } } SMCodes.ItemPropertyChanged += SMCodes_ItemPropertyChanged; }
private void ExecuteAddNew(object parameter) { SMCodes.Add(new SMCodeModel() { ID = 0, Name = string.Empty, Description = string.Empty, IndustryID = 0, IsChecked = false, IsEnabled = true }); ScrollToIndex = SMCodes.Count() - 1; CheckValidation(); }
private bool IsIndustryMissing() { int nummissing = SMCodes.Where(x => x.IndustryID == 0).Count(); return(nummissing > 0); }
private bool IsDescriptionMissing() { int nummissing = SMCodes.Where(x => string.IsNullOrEmpty(x.Description.Trim())).Count(); return(nummissing > 0); }
private bool IsNameMissing() { int nummissing = SMCodes.Where(x => string.IsNullOrEmpty(x.Name.Trim())).Count(); return(nummissing > 0); }