예제 #1
0
        public void actualizar(MCategoria obj)
        {
            conexion();
            string       query = "UPDATE categoria SET categoria= '" + obj.categoria + "' WHERE pk_categoria = '" + obj.pk_categoria + "'";
            MySqlCommand cmd   = new MySqlCommand(query, con);

            cmd.ExecuteNonQuery();

            cmd.Dispose();
            con.Close();
        }
예제 #2
0
        public MCategoria insertar(MCategoria obj)
        {
            conexion();
            string       query = "INSERT INTO categoria(categoria)VALUES('" + obj.categoria + "')";
            MySqlCommand cmd   = new MySqlCommand(query, con);

            cmd.ExecuteNonQuery();

            cmd.Dispose();
            con.Close();
            return(obj);
        }
예제 #3
0
        public MCategoria modificar(int pk)
        {
            conexion();
            string          query  = "SELECT * FROM categoria WHERE pk_categoria = '" + pk + "'";
            MySqlCommand    cmd    = new MySqlCommand(query, con);
            MySqlDataReader cursor = cmd.ExecuteReader();

            MCategoria obj = new MCategoria();

            if (cursor.HasRows)
            {
                while (cursor.Read())
                {
                    obj.pk_categoria = Convert.ToInt32(cursor["pk_categoria"].ToString());
                    obj.categoria    = cursor["categoria"].ToString();
                }
            }

            cursor.Dispose();
            cmd.Dispose();
            con.Close();

            return(obj);
        }