Exemple #1
0
        private void CreateAssistant(string domainName)
        {
            if (Database.ProjectInvestigatorAssistants.Any(a => a.ProjectInvestigator1 == Investigator && a.Assistant == domainName))
            {
                MessageBox.Show("The assistant is already helping the investigator.  Try again", "Database Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                EditorTextBox.Focus();
                CreateButton.Enabled = false;
                return;
            }
            var assistant = new ProjectInvestigatorAssistant
            {
                ProjectInvestigator1 = Investigator,
                Assistant            = domainName,
            };

            Database.ProjectInvestigatorAssistants.InsertOnSubmit(assistant);
            if (!SubmitChanges())
            {
                Database.ProjectInvestigatorAssistants.DeleteOnSubmit(assistant);
                EditorTextBox.Focus();
                CreateButton.Enabled = false;
                return;
            }
            OnDatabaseChanged();
            Close();
        }
Exemple #2
0
        private void CreateEditor(string domainName)
        {
            if (Database.ProjectEditors.Any(pe => pe.Project == Project && pe.Editor == domainName))
            {
                MessageBox.Show("The editor is already on the project.  Try again", "Database Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                EditorTextBox.Focus();
                CreateButton.Enabled = false;
                return;
            }
            var editor = new ProjectEditor
            {
                Project = Project,
                Editor  = domainName,
            };

            Database.ProjectEditors.InsertOnSubmit(editor);
            if (!SubmitChanges())
            {
                Database.ProjectEditors.DeleteOnSubmit(editor);
                EditorTextBox.Focus();
                CreateButton.Enabled = false;
                return;
            }
            OnDatabaseChanged();
            Close();
        }
Exemple #3
0
        // ReSharper restore UnusedAutoPropertyAccessor.Local


        private void FindButton_Click(object sender, EventArgs e)
        {
#if NO_ACTIVE_DIRECTORY
            MessageBox.Show("Active Directory Search Disabled.", "Sorry", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
#else
            var    context   = new PrincipalContext(ContextType.Domain, "nps", "OU=AKR,DC=nps,DC=doi,DC=net");
            string search    = EditorTextBox.Text + "*";
            var    principal = new UserPrincipal(context)
            {
                Surname = search, Enabled = true
            };
            var searcher = new PrincipalSearcher {
                QueryFilter = principal
            };
            var query = from Principal p in searcher.FindAll()
                        orderby p.DisplayName
                        select new EditorListItem
            {
                DisplayName = p.Name + " (" + p.Description + ") - NPS\\" + p.SamAccountName,
                DomainName  = "NPS\\" + p.SamAccountName,
            };
            ResultsListBox.DisplayMember = "DisplayName";
            var data = query.ToList();
            ResultsListBox.DataSource = data;
            EnableControls(); //If the Datasource is empty, then SelectedIndexChanged is not called.
            if (data.Count > 0)
            {
                ResultsListBox.Focus();
            }
            else
            {
                MessageBox.Show("Nobody found with that name.", "Try again", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                EditorTextBox.Focus();
            }
#endif
        }