示例#1
0
        public bool read(ENReseña en)
        {
            SqlConnection conn    = new SqlConnection(constring);
            String        comando = "select * from [dbo].[Reseña] where id = '" + en.Id + "'";

            try
            {
                conn.Open();
                SqlCommand    cmd = new SqlCommand(comando, conn);
                SqlDataReader dr  = cmd.ExecuteReader();
                dr.Read();
                if (int.Parse(dr["id"].ToString()) == en.Id)
                {
                    en.Id        = int.Parse(dr["id"].ToString());
                    en.Contenido = dr["contenido"].ToString();
                    dr.Close();
                    conn.Close();
                    return(true);
                }
                return(false);
            }
            catch (Exception)
            {
                conn.Close();
                return(false);
            }
        }
示例#2
0
        public bool create(ENReseña en)
        {
            SqlConnection conn    = new SqlConnection(constring);
            string        comando = "Insert Into Reseña (id, contenido) " + "VALUES ('" + en.Id + "', '" + en.Contenido + "')";

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(comando, conn);
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception e)
            {
                conn.Close();
                Console.WriteLine("Error: " + e);
                return(false);
            }
            Console.WriteLine(en.Id + en.Contenido);
            return(true);
        }
示例#3
0
        public bool delete(ENReseña en)
        {
            SqlConnection conn    = new SqlConnection(constring);;
            string        comando = "Delete from [dbo].[Reseña] where id = '" + en.Id + "'";

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(comando, conn);
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                conn.Close();
                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }
示例#4
0
        public bool update(ENReseña en)
        {
            SqlConnection conn    = new SqlConnection(constring);
            string        comando = "UPDATE [dbo].[Reseña] " + "SET contenido = '" + en.Contenido + "' where id ='" + en.Id + "'";

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(comando, conn);
                cmd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                conn.Close();
                Console.WriteLine("Error: " + e);
                return(false);
            }
            finally
            {
                conn.Close();
            }
            return(true);
        }
示例#5
0
 public ENOrden(ENReseña orden)
 {
     this.id          = orden.Id;
     this.descripcion = orden.Contenido;
 }
 public ENReseña(ENReseña reseña)
 {
     this.id        = reseña.id;
     this.contenido = reseña.contenido;
 }