예제 #1
0
        private void tsbDeleteUser_Click(object sender, EventArgs e)
        {
            if (UserID != 0)
            {
                if (UserReferenced())
                {
                    MessageBox.Show("The user cannot be deleted, " + tName.Text + " is still referenced in the system.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                try
                {
                    using (DataStuff sn = new DataStuff())
                    {
                        if (sn.DeleteNetworkSystemUser(UserID))
                        {
                            MessageBox.Show("User successfully deleted.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            tNetworkName.Visible      = false;
                            cbNetworkName.Visible     = true;
                            tsbCancelUserEdit.Enabled = false;
                            tsbSaveUser.Enabled       = true;
                            tsbDeleteUser.Enabled     = true;

                            LoadUsers();

                            //cbNetworkName.SelectedIndex = 1;
                        }
                    }
                }

                catch
                {
                    MessageBox.Show("There was an error deleting the user.", "User Maintenance", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }