예제 #1
0
        private void SetAdministrator(int collectionindex, bool presetvalue)
        {
            //add divisions if necessary
            //check divisions
            Models.SelectedSalesDivisionModel salesdiv;
            _associates[collectionindex].SalesDivisionsColl.Clear();
            foreach (Models.SalesDivisionModel sd in _salesdivisions)
            {
                salesdiv            = new Models.SelectedSalesDivisionModel();
                salesdiv.ID         = sd.GOM.ID;
                salesdiv.IsSelected = presetvalue;
                salesdiv.Name       = sd.GOM.Name;
                _associates[collectionindex].SalesDivisionsColl.Add(salesdiv);
            }
            _associates[collectionindex].SalesDivisionsColl.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged;

            //add countries if necessary
            //check countries
            Models.SelectedCountriesModel _newcountry;
            _associates[collectionindex].CountriesColl.Clear();
            foreach (Models.CountryModel cm in _countries)
            {
                if (cm.GOM.ID > 0)
                {
                    _newcountry            = new Models.SelectedCountriesModel();
                    _newcountry.Name       = cm.GOM.Name;
                    _newcountry.ID         = cm.GOM.ID;
                    _newcountry.IsSelected = presetvalue;
                    _associates[collectionindex].CountriesColl.Add(_newcountry);
                }
            }
            _associates[collectionindex].CountriesColl.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged;

            //add permissions if necessary
            //check permissions
            Models.UserPermissionTypesModel usrperms;
            _associates[collectionindex].PermissionsColl.Clear();
            foreach (EnumValue ev in EnumerationLists.UserPermissionTypeList)
            {
                usrperms            = new Models.UserPermissionTypesModel();
                usrperms.IsSelected = presetvalue;
                usrperms.GOM.Name   = ev.Description;
                usrperms.GOM.ID     = ev.ID;
                _associates[collectionindex].PermissionsColl.Add(usrperms);
            }
            _associates[collectionindex].PermissionsColl.ItemPropertyChanged += Permissions_ItemPropertyChanged;
        }
예제 #2
0
        private void BuildAssociatesColl()
        {
            Models.SelectedCountriesModel     _newcountry;
            Models.UserPermissionTypesModel   usrperms;
            Models.SelectedSalesDivisionModel salesdiv;

            foreach (Models.UserModel am in Associates)
            {
                am.IsEnabled = !(_currentuser.GOM.ID == am.GOM.ID);

                am.SalesDivisionsColl = new FullyObservableCollection <Models.SelectedSalesDivisionModel>();
                List <string> _associatessaledivs = am.SalesDivisions.Split(',').ToList();
                foreach (Models.SalesDivisionModel sd in _salesdivisions)
                {
                    salesdiv    = new Models.SelectedSalesDivisionModel();
                    salesdiv.ID = sd.GOM.ID;
                    if (am.Administrator)
                    {
                        salesdiv.IsSelected = true;
                    }
                    else
                    {
                        salesdiv.IsSelected = _associatessaledivs.Contains(sd.ID.ToString());
                    }
                    salesdiv.Name = sd.GOM.Name;
                    am.SalesDivisionsColl.Add(salesdiv);
                }

                am.SalesDivisionsColl.ItemPropertyChanged += SalesDivisions_ItemPropertyChanged;

                am.CountriesColl = new FullyObservableCollection <Models.SelectedCountriesModel>();
                List <string> _associatescountries = am.Countries.Split(',').ToList();
                foreach (Models.CountryModel cm in _countries)
                {
                    if (cm.GOM.ID > 0)
                    {
                        _newcountry            = new Models.SelectedCountriesModel();
                        _newcountry.Name       = cm.GOM.Name;
                        _newcountry.ID         = cm.GOM.ID;
                        _newcountry.IsSelected = _associatescountries.Contains(cm.ID.ToString());
                        am.CountriesColl.Add(_newcountry);
                    }
                }

                am.CountriesColl.ItemPropertyChanged += Countries_ItemPropertyChanged;

                am.PermissionsColl = new FullyObservableCollection <Models.UserPermissionTypesModel>();
                foreach (EnumValue ev in EnumerationLists.UserPermissionTypeList)
                {
                    usrperms = new Models.UserPermissionTypesModel();
                    if (am.Administrator)
                    {
                        usrperms.IsSelected = true;
                    }
                    else
                    {
                        usrperms.IsSelected = (am.UserPermissions & (UserPermissionsType)ev.ID) == (UserPermissionsType)ev.ID;
                    }
                    usrperms.GOM.Name = ev.Description;
                    usrperms.GOM.ID   = ev.ID;
                    am.PermissionsColl.Add(usrperms);
                }
                am.PermissionsColl.ItemPropertyChanged += Permissions_ItemPropertyChanged;
            }
            Associates.ItemPropertyChanged += Associates_ItemPropertyChanged;
        }
예제 #3
0
        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);
        }