Ejemplo n.º 1
0
 private void bDelete_Click(object sender, EventArgs e)
 {
     if (dgvUserinRoles.SelectedCells != null)
     {
         DialogResult result = MessageBox.Show("Удалить   запись?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (result.ToString() == "Yes")
         {
             BusinessUserInRoles obj = new BusinessUserInRoles();
             obj = bindingSourceUserinRoles.Current as BusinessUserInRoles;
             BusinessUserInRolesRepository brep = new BusinessUserInRolesRepository();
             brep.Delete(obj);
             GetUserRoles(cbUsers.SelectedValue, 0);
         }
     }
 }
Ejemplo n.º 2
0
        private List <BusinessUserInRoles> DeleteUserinRoles(Roles role) // Метод для удаления связи между ролями и пользователями
        {
            List <BusinessUserInRoles> busUsinRol = new List <BusinessUserInRoles>();

            int RoleId = role.RoleId;

            GetUserRoles(0, RoleId);
            BusinessUserInRoles           obj  = new BusinessUserInRoles();
            BusinessUserInRolesRepository brep = new BusinessUserInRolesRepository();

            while (bindingSourceUserinRoles.Current != null)
            {
                obj = bindingSourceUserinRoles.Current as BusinessUserInRoles;
                busUsinRol.Add(obj);
                brep.Delete(obj);
                GetUserRoles(0, RoleId);
            }
            return(busUsinRol);
        }