public void Agregar(roles rol, DataGridView dtgPermisos) { using (TransactionScope scope = new TransactionScope()) { try { rolDAL.AgregarRol(rol); int numFila = dtgPermisos.RowCount - 1; for (int i = 0; i < numFila; i++) { permisosDeRol permisosRol = new permisosDeRol { idrol = rol.idrol, idventana = Convert.ToInt32(dtgPermisos.Rows[i].Cells[0].Value), consultar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[2].Value), insertar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[3].Value), modificar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[4].Value), eliminar = Convert.ToInt32(dtgPermisos.Rows[i].Cells[5].Value) }; new Cls_PermisosRol().Agregar(permisosRol); } scope.Complete(); } catch (Exception ex) { scope.Dispose(); throw ex; } } }