public override bool Actualizar(Dto.Rol obj) { using (MySql.Data.MySqlClient.MySqlConnection cnn = new MySql.Data.MySqlClient.MySqlConnection()) { cnn.ConnectionString = base.CurrentConnectionString.ConnectionString; cnn.Open(); MySql.Data.MySqlClient.MySqlTransaction trans = cnn.BeginTransaction(); try { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand()) { cmd.CommandText = "seguridad.uspGestionRoles"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("intAccion", uspAcciones.Actualizar)); this.CargarParametros(cmd, obj); int intRegistrosAfectados = base.CurrentDatabase.ExecuteNonQuery(cmd, trans); if (intRegistrosAfectados > 0) { //Guardamos los permisos DPermiso objDALPermisos = new DPermiso(); objDALPermisos.Insertar(obj.permisos, (short)obj.idrol, trans); trans.Commit(); return(true); } else { return(false); } } } catch (Exception ex) { trans.Rollback(); throw ex; } } }
public override bool Insertar(Dto.Rol obj) { using (MySql.Data.MySqlClient.MySqlConnection cnn = new MySql.Data.MySqlClient.MySqlConnection(base.CurrentConnectionString.ConnectionString)) { cnn.Open(); MySql.Data.MySqlClient.MySqlTransaction trans = cnn.BeginTransaction(); try { using (MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand()) { cmd.CommandText = "seguridad.uspGestionRoles"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new MySql.Data.MySqlClient.MySqlParameter("intAccion", uspAcciones.Insertar)); this.CargarParametros(cmd, obj); obj.idrol = Convert.ToInt16(base.CurrentDatabase.ExecuteScalar(cmd, trans)); //Guardamos los permisos DPermiso objDALPermisos = new DPermiso(); objDALPermisos.Insertar(obj.permisos, (short)obj.idrol, trans); trans.Commit(); return(obj.idrol > 0); } } catch (Exception ex) { trans.Rollback(); throw ex; } } }