コード例 #1
0
        //Permite consultar los detalles de un tipo de orden
        public CatTipoOrden ConsultarListaTipoOrden(int?id)
        {
            Conexion     conn      = new Conexion();
            CatTipoOrden tipoOrden = new CatTipoOrden();

            try
            {
                SqlCommand    comando = new SqlCommand();
                SqlDataReader leer    = null;
                comando.Connection  = conn.AbrirConexion();
                comando.CommandText = "SELECT * FROM CAT_TYPE_ORDER ";
                comando.CommandType = CommandType.Text;
                comando.Parameters.AddWithValue("@Id", id);
                leer = comando.ExecuteReader();
                while (leer.Read())
                {
                    tipoOrden.IdTipoOrden = Convert.ToInt32(leer["ID_TYPE_ORDER"]);
                    tipoOrden.TipoOrden   = leer["TYPE_ORDER"].ToString();
                }
                leer.Close();
            }
            finally
            {
                conn.CerrarConexion();
                conn.Dispose();
            }
            return(tipoOrden);
        }
コード例 #2
0
        public IEnumerable <CatTipoOrden> ListaTipoOrden()
        {
            List <CatTipoOrden> listTipoOrden = new List <CatTipoOrden>();
            Conexion            conn          = new Conexion();

            try
            {
                SqlCommand    comando = new SqlCommand();
                SqlDataReader leer    = null;
                comando.Connection  = conn.AbrirConexion();
                comando.CommandText = "SELECT * FROM CAT_TYPE_ORDER ";
                leer = comando.ExecuteReader();
                while (leer.Read())
                {
                    CatTipoOrden tipoOrden = new CatTipoOrden()
                    {
                        IdTipoOrden = Convert.ToInt32(leer["ID_TYPE_ORDER"]),
                        TipoOrden   = leer["TYPE_ORDER"].ToString()
                    };

                    listTipoOrden.Add(tipoOrden);
                }
                leer.Close();
            }
            finally
            {
                conn.CerrarConexion();
                conn.Dispose();
            }

            return(listTipoOrden);
        }