Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (choice)
            {
            case "group":
                var editGroup = new EditGroup("exists", this.listBox1.SelectedItem.ToString());
                var result    = editGroup.ShowDialog();
                if (result == DialogResult.OK)
                {
                    try
                    {
                        this.listBox1.DataSource = Administration.GetAllGroups();
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    catch (System.Security.SecurityException se)
                    {
                        MessageBox.Show("Permission denied " + se.Message);
                    }
                }

                break;

            case "user":
                var userToEdit = Administration.GetUser(listBox1.SelectedItem.ToString());
                var editUser   = new EditUser("exists", userToEdit);
                var resultuser = editUser.ShowDialog();
                if (resultuser == DialogResult.OK)
                {
                    try
                    {
                        var           userslist    = Administration.GetAllUsers();
                        List <String> usernamelist = new List <String>();
                        foreach (UserResult resultlist in userslist)
                        {
                            usernamelist.Add(resultlist.login);
                        }
                        this.listBox1.DataSource = usernamelist;
                    }
                    catch (System.Security.SecurityException se)
                    {
                        MessageBox.Show("Permission denied " + se.Message);
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                break;

            default:
                MessageBox.Show("Wybierz element do modyfikacji");
                break;
            }
        }
Exemplo n.º 2
0
        private void dodajUżytkownikaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var editUser = new EditUser("new");
            var result   = editUser.ShowDialog();

            if (result == DialogResult.OK && this.choice != null)
            {
                var           userslist    = Administration.GetAllUsers();
                List <String> usernamelist = new List <String>();
                foreach (UserResult resultuser in userslist)
                {
                    usernamelist.Add(resultuser.login);
                }
                this.listBox1.DataSource = usernamelist;
            }
        }