Ejemplo n.º 1
0
        //----------------------------------------------------------------------------------------------
        //Eliminar Abonado
        public String EliminarAbonadoDAL(UTIL_Abonado utilAb)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("Eliminar_Abonado", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_cedula", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAb.iCedula);
                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);
        }
Ejemplo n.º 2
0
        //----------------------------------------------------------------------------------------------
        //Buscar Abonado por cedula
        public DataTable BuscarAbonadoDAL(UTIL_Abonado utilAb)
        {
            ConnectionBD     stringconn  = new ConnectionBD();
            NpgsqlConnection conn        = new NpgsqlConnection(stringconn.Postgreconnection());
            NpgsqlCommand    postCommand = new NpgsqlCommand("buscar_abonado", conn);

            postCommand.CommandType = CommandType.StoredProcedure;

            try
            {
                postCommand.Parameters.Add("_cedula", NpgsqlTypes.NpgsqlDbType.Integer).Value = UTIL.UTIL.ObtenerValor(utilAb.iCedula);
                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);
            }
        }