ADDemo.main.addGroup_Click C# (CSharp) Метод

addGroup_Click() приватный Метод

Process clicks to the addGroup button
private addGroup_Click ( object sender, EventArgs e ) : void
sender object object from which the event was sent
e EventArgs Arguments to the event
Результат void
        private void addGroup_Click(object sender, EventArgs e)
        {
            if (newGroup.Text.Length > 0)
            {
                //Get the group by that name
                GroupPrincipal group = ad.GetGroup(newGroup.Text);
                Boolean abortAdd = false;

                if (group == null)
                {
                    //Group doesn't exist, create it?
                    DialogResult result = MessageBox.Show("Group doesn't exist, create it?", "Adding group...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        //Create the group
                        ad.CreateGroup(newGroup.Text);
                    }
                    else
                    {
                        //Don't add the non-existant group if we're not creating it
                        abortAdd = true;
                    }
                }

                //If we're still adding the group
                if (!abortAdd)
                {
                    //Add the group
                    currentUser.Groups.Add(newGroup.Text);

                    //Reset bindings to update the controls
                    userBinding.ResetBindings(false);

                    //Clear the newGroup text
                    newGroup.Clear();
                }
            }
        }