Пример #1
0
        private void CheckRolesForSelectedUser()
        {
            var name          = Request.QueryString["NAME"];
            var UsersRoleList = (Repeater)FormProfile.FindControl("UsersRoleList");
            // Determine what roles the selected user belongs to
            var selectedUserName   = name;
            var selectedUsersRoles = Roles.GetRolesForUser(selectedUserName);

            // Loop through the Repeater's Items and check or uncheck the checkbox as needed
            foreach (RepeaterItem ri in UsersRoleList.Items)
            {
                // Programmatically reference the CheckBox
                var RoleCheckBox = ri.FindControl("RoleCheckBox") as CheckBox;

                // See if RoleCheckBox.Text is in selectedUsersRoles
                if (selectedUsersRoles.Contains(RoleCheckBox.Text))
                {
                    RoleCheckBox.Checked = true;
                }
                else
                {
                    RoleCheckBox.Checked = false;
                }
            }
        }
Пример #2
0
        private void itemProfile_Click(object sender, EventArgs e)
        {
            FormProfile form = new FormProfile();

            form.MdiParent = this;
            form.Show();
        }
Пример #3
0
        /// <summary>
        /// Activates the form network card.
        /// </summary>
        /// <param name="selectedNetworkCardForm">The selected network card form.</param>
        public static void ActivateFormProfile(FormProfile selectedProfileForm)
        {
            /*
             * // profili
             * ViewModel.MainView.rbtnProfileNew.Enabled = true;
             * ViewModel.MainView.rbtnProfileView.Enabled = true;
             * ViewModel.MainView.rbtnProfileDelete.Enabled = true;
             *
             * // profilo
             * ViewModel.MainView.rbtnProfileRun.Enabled = true;
             * ViewModel.MainView.rbtnProfileSave.Enabled = true;
             *
             * // documento
             * ViewModel.MainView.rbtnConfigSave.Enabled = true;
             * ViewModel.MainView.rbtnConfigLoad.Enabled = true;
             *
             * // networkcard
             * ViewModel.MainView.rbtnCardsRefresh.Enabled = false;
             * ViewModel.MainView.rbtnCardView.Enabled = false;*/

            ViewModel.MainView.ribbon.ActiveTab = ViewModel.MainView.rtOperations;

            // form selezionati
            ViewModel.SelectedView = selectedProfileForm;
        }
Пример #4
0
        private void BindRolesToList()
        {
            var UsersRoleList = (Repeater)FormProfile.FindControl("UsersRoleList");
            // Get all of the roles
            var roles = Roles.GetAllRoles();

            UsersRoleList.DataSource = roles;
            UsersRoleList.DataBind();
        }
Пример #5
0
 void pbAccountImage_Click(object sender, EventArgs e)
 {
     if (Program.empLogin != null)
     {
         FormProfile profile = new FormProfile(Program.empLogin);
         profile.FormClosed += profile_FormClosed;
         profile.ShowDialog();
     }
 }
Пример #6
0
 //Mở form con
 private void openChildForm(FormProfile childForm)
 {
     if (activeForm != null)
     {
         activeForm.Close();
     }
     activeForm = childForm;
     childForm.FormBorderStyle = FormBorderStyle.FixedDialog;
     childForm.BringToFront();
     childForm.ShowDialog();
 }
Пример #7
0
        /// <summary>
        /// Возвращает созданный профайл или null
        /// </summary>
        /// <returns>созданный профайл или null</returns>
        internal static UserConfig CreateNewConfig()
        {
            using (var formProfile = new FormProfile(null))
            {
                if (formProfile.ShowDialog() == DialogResult.OK)
                {
                    formProfile.SelectedUserConfig.Save();
                    return(formProfile.SelectedUserConfig);
                }

                return(null);
            }
        }
Пример #8
0
        /// <summary>
        /// Saves the current profile.
        /// </summary>
        public static void SaveProfile(NetworkProfile profile = null)
        {
            if (profile == null)
            {
                FormProfile viewProfile = ViewModel.SelectedView as FormProfile;

                if (viewProfile == null)
                {
                    MyMessageBox.ShowAlert("No profile selected!");
                    return;
                }

                // ANS-10: check if any nic is selected
                if (viewProfile.SelectedNetworkCard == null)
                {
                    MyMessageBox.ShowAlert("No network card is selected, profile is not saved!");
                    return;
                }

                // check if it is possibile do operation
                if (UseCaseApplication.CheckIsOperationNotAllowedNow())
                {
                    return;
                }


                viewProfile.StoreFormOnData();
                profile = viewProfile.Profile;
            }
            if (profile.IsNew)
            {
                profile.Id = CreateNewProfileId();
                // if not exist add it
                DataModel.NetworkProfileList.Add(profile);
            }
            else
            {
                // save profile
                for (int i = 0; i < DataModel.NetworkProfileList.Count; i++)
                {
                    if (profile.Id == DataModel.NetworkProfileList[i].Id)
                    {
                        // found e replace
                        DataModel.NetworkProfileList[i] = profile;
                        break;
                    }
                }
            }
            // list refresh
            Refresh();
        }
Пример #9
0
        /// <summary>
        /// Shows the specified profile.
        /// </summary>
        /// <param name="profile">The profile.</param>
        public static void ShowProfile(NetworkProfile profile)
        {
            if (profile == null)
            {
                return;
            }

            NetworkProfile item;

            foreach (FormProfile itemForm in ViewModel.ProfileViewList)
            {
                if ((itemForm.Tag is NetworkProfile))
                {
                    item = (NetworkProfile)itemForm.Tag;

                    if (item.Id.Equals(profile.Id))
                    {
                        if (!itemForm.Visible)
                        {
                            itemForm.Show(ViewModel.MainView.Pannello);
                        }

                        itemForm.Focus();
                        //UseCaseView.ActivateFormProfile(itemForm);
                        return;
                    }
                }
            }

            FormProfile form = new FormProfile();

            form.Profile = profile;

            // update networkcard for security
            //profile.NetworkCardInfo = DataModel.FindNetworkCard(profile.NetworkCardInfo.Id);

            form.ViewDataOnForm();

            ViewModel.ProfileViewList.Add(form);
            form.Show(ViewModel.MainView.Pannello);
            form.DockState = DockState.Document;
        }
Пример #10
0
        /// <summary>
        /// Возвращает исправленный профайл или null. Может потребовать ввести пароль.
        /// </summary>
        /// <param name="userConfig">Профайл для редактирования</param>
        /// <returns>исправленный профайл или null</returns>
        internal static UserConfig EditExistingConfig(UserConfig userConfig)
        {
            if (userConfig == null)
            {
                throw new ArgumentNullException("userConfig");
            }

            userConfig = TryDecrypt(userConfig);
            if (userConfig == null)
            {
                return(null);
            }

            using (var formProfile = new FormProfile(userConfig))
            {
                if (formProfile.ShowDialog() == DialogResult.OK)
                {
                    formProfile.SelectedUserConfig.Save();
                    return(formProfile.SelectedUserConfig);
                }

                return(null);
            }
        }
Пример #11
0
 /// <summary>
 /// Closes the form.
 /// </summary>
 /// <param name="formProfile">The form profile.</param>
 public static void Hide(FormProfile formProfile)
 {
     DataModel.SelectedNetworkProfile = null;
     ViewModel.ProfileViewList.Remove(formProfile);
 }