Exemplo n.º 1
0
        public static DialogResult ShowConfirmation(ref bool removeUsers)
        {
            DropRoleConfirmation frm    = new DropRoleConfirmation();
            DialogResult         result = frm.ShowDialog();

            removeUsers = frm.checkBox1.Checked;
            return(result);
        }
Exemplo n.º 2
0
        public bool DropSelectedRoles(bool confirm)
        {
            if (grd.SelectedRows.Count == 0)
            {
                return(false);
            }

            bool removeUsers = false;

            if (confirm && DropRoleConfirmation.ShowConfirmation(ref removeUsers) != DialogResult.Yes)
            {
                return(false);
            }

            string roletype = String.Empty;

            using (SqlConnection conn = _cp.CreateSqlConnection(true, false))
            {
                foreach (DataGridViewRow row in grd.SelectedRows)
                {
                    if (row.Cells[2].Value == null || row.Cells[2].GetType() == typeof(DBNull))
                    {
                        continue;
                    }

                    //Remove users
                    if (removeUsers)
                    {
                        DbCmd.RemoveUsersFromRole(conn, row.Cells[2].Value.ToString());
                    }

                    roletype = (string)row.Cells[3].Value;
                    DbCmd.DropRole(conn, _cp.Database, row.Cells[2].Value.ToString(), roletype.ToLower() == "standard");
                }
            }

            RefreshRoles();
            return(true);
        }