private void ExecuteAddNew(object parameter) { _canexecuteadd = false; Associates.Add(new Models.AssociateModel()); ScrollToLastItem = true; AssociateListEnabled = false; }
private void LoadAssociates(int salesdivisionid) { FullyObservableCollection <UserModel> associatess = DatabaseQueries.GetUsers(); FilterListItem fi; Associates?.Clear(); var q = from associat in associatess where !associat.Deleted && associat.BusinessUnits.Split(',').ToList().Contains(salesdivisionid.ToString()) select associat; if (CurrentUser.ShowOthers) { foreach (UserModel ag in q) { fi = new FilterListItem(); { fi.ID = ag.ID; fi.Name = ag.Name; fi.IsSelected = false; fi.VisibleState = Visibility.Visible; fi.PropertyChanged += FlAssociates_PropertyChanged; Associates.Add(fi); } } foreach (FilterListItem fil in associates) { if (fil.ID == CurrentUser.ID) { fil.IsSelected = true; } } } else { fi = new FilterListItem(); { fi.ID = CurrentUser.ID; fi.Name = CurrentUser.Name; fi.IsSelected = true; fi.VisibleState = Visibility.Visible; fi.PropertyChanged += FlAssociates_PropertyChanged; Associates.Add(fi); } } }
private void ExecuteAddNew(object parameter) { // _canexecuteadd = false; Models.SelectedSalesDivisionModel salesdiv; FullyObservableCollection <Models.SelectedSalesDivisionModel> salesdivcoll = new FullyObservableCollection <Models.SelectedSalesDivisionModel>(); foreach (Models.SalesDivisionModel sd in _salesdivisions) { salesdiv = new Models.SelectedSalesDivisionModel(); salesdiv.ID = sd.GOM.ID; salesdiv.IsSelected = false; salesdiv.Name = sd.GOM.Name; salesdivcoll.Add(salesdiv); } salesdivcoll.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged; Models.SelectedCountriesModel _newcountry; FullyObservableCollection <Models.SelectedCountriesModel> countriescoll = new FullyObservableCollection <Models.SelectedCountriesModel>(); foreach (Models.CountryModel cm in _countries) { _newcountry = new Models.SelectedCountriesModel(); _newcountry.Name = cm.GOM.Name; _newcountry.ID = cm.GOM.ID; if (cm.GOM.ID == SelectedCountry.GOM.ID) { _newcountry.IsSelected = true; } else { _newcountry.IsSelected = false; } countriescoll.Add(_newcountry); } countriescoll.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged; Models.UserPermissionTypesModel usrperms; FullyObservableCollection <Models.UserPermissionTypesModel> permissionscoll = new FullyObservableCollection <Models.UserPermissionTypesModel>(); foreach (EnumValue ev in EnumerationLists.UserPermissionTypeList) { usrperms = new Models.UserPermissionTypesModel(); if (ev.ID == (int)UserPermissionsType.ViewOwnProjects) { usrperms.IsSelected = true; } else { usrperms.IsSelected = false; } usrperms.GOM.Name = ev.Description; usrperms.GOM.ID = ev.ID; permissionscoll.Add(usrperms); } permissionscoll.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged; Associates.Add(new Models.UserModel() { GOM = new Models.GenericObjModel(), LoginName = string.Empty, SalesDivisions = string.Empty, SalesDivisionsColl = salesdivcoll, UserPermissions = 0, PermissionsColl = permissionscoll, CountryID = 1, GIN = string.Empty, CountriesColl = countriescoll, Administrator = false, IsEnabled = true }); Associates.ItemPropertyChanged += Associates_ItemPropertyChanged; ScrollToSelectedItem = Associates.Count - 1; AddDirty(Associates.Count - 1); }