//---------------------------------------------------------------------------------------------- //Eliminar Lectura public String ModificarLecturaDAL(UTIL_Lectura utilLe) { ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("update_lectura", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iMedidor); postCommand.Parameters.Add("_cantidad", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iLectura); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { return(ex.Message); throw new Exception(ex.Message); } finally { conn.Close(); } return(messageOutput); }
//---------------------------------------------------------------------------------------------- //Buscar Lectura por medidor public DataTable BuscarLecturaDAL(UTIL_Lectura utilLe) { DataSet ds = new DataSet(); ConnectionBD stringconn = new ConnectionBD(); NpgsqlConnection conn = new NpgsqlConnection(stringconn.Postgreconnection()); NpgsqlCommand postCommand = new NpgsqlCommand("buscar_medidor", conn); postCommand.CommandType = CommandType.StoredProcedure; try { postCommand.Parameters.Add("_id_medidor", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilLe.iMedidor); NpgsqlParameter message = postCommand.Parameters.Add("message", NpgsqlTypes.NpgsqlDbType.Text, 250); message.Direction = ParameterDirection.Output; conn.Open(); postCommand.ExecuteNonQuery(); NpgsqlDataAdapter dta = new NpgsqlDataAdapter(postCommand); dta.Fill(ds); messageOutput = postCommand.Parameters["message"].Value.ToString(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } if (ds.Tables.Count > 0) { return(ds.Tables[0]); } else { return(null); } }