Ejemplo n.º 1
0
        protected void lnkSave_Click(object sender, EventArgs e)
        {
            XmlDocument xdoc = XmlDataSource3.GetXmlDocument();

            XmlElement  root  = xdoc.DocumentElement;
            XmlNodeList nodes = root.SelectNodes("/properties/property"); // You can also use XPath here
            int         land_register_number = 0;

            foreach (XmlNode node in nodes)
            {
                int ld_register = Int32.Parse(node.Attributes[0].Value);
                if (land_register_number < ld_register)
                {
                    land_register_number = ld_register;
                }
            }

            land_register_number++;

            XmlElement   properties     = xdoc.SelectSingleNode("properties") as XmlElement;
            XmlElement   property       = xdoc.CreateElement("property");
            XmlElement   land_register  = xdoc.CreateElement("land_register");
            XmlElement   address        = xdoc.CreateElement("address");
            XmlElement   city           = xdoc.CreateElement("city");
            XmlElement   street         = xdoc.CreateElement("street");
            XmlElement   port_number    = xdoc.CreateElement("port_number");
            XmlElement   value          = xdoc.CreateElement("value");
            XmlElement   owners         = xdoc.CreateElement("owners");
            XmlAttribute aland_register = xdoc.CreateAttribute("land_register");

            aland_register.InnerText = (land_register_number).ToString();
            land_register.InnerText  = (land_register_number).ToString();
            city.InnerText           = ((TextBox)GridView1.FooterRow.FindControl("txtcity")).Text;
            street.InnerText         = ((TextBox)GridView1.FooterRow.FindControl("txtstreet")).Text;
            port_number.InnerText    = ((TextBox)GridView1.FooterRow.FindControl("txtport")).Text;
            value.InnerText          = ((TextBox)GridView1.FooterRow.FindControl("txtvalue")).Text;

            property.Attributes.Append(aland_register);
            property.AppendChild(land_register);
            property.AppendChild(address);
            address.AppendChild(city);
            address.AppendChild(street);
            address.AppendChild(port_number);
            property.AppendChild(value);
            property.AppendChild(owners);
            properties.AppendChild(property);

            XmlDataSource3.Save();
            XmlDataSource1.DataBind();
            XmlDataSource2.DataBind();

            GridView1.ShowFooter = false;
            Response.Redirect(Request.RawUrl);
        }
Ejemplo n.º 2
0
        private void getTop()
        {
            string link = "http://localhost:49486/RSS/top";

            XmlReader   reader = XmlReader.Create(link);
            XmlDocument doc    = new XmlDocument();

            doc.Load(reader);
            reader.Close();

            XmlDataSource3.Data = doc.OuterXml;
            XmlDataSource3.DataBind();
            XmlDataSource3.XPath = "/rss/channel";

            XmlDataSource2.Data = doc.OuterXml;
            XmlDataSource2.DataBind();
            XmlDataSource2.XPath = "/channel";

            XmlDocument xdoc1    = XmlDataSource3.GetXmlDocument();
            XmlDocument xdoc2    = XmlDataSource2.GetXmlDocument();
            XmlNodeList channel  = xdoc1.SelectNodes("//channel");
            XmlNode     info     = channel[0];
            XmlNodeList noticias = xdoc2.SelectNodes("//item");

            top.InnerHtml = "<ul>";

            foreach (XmlNode i in noticias)
            {
                top.InnerHtml += "" +
                                 "<li>" +
                                 "<a href = \"/Movie?ID=" + i.Attributes["id"].Value + "\" >" +
                                 "<div class=\"thumb\">" +
                                 "<div class=\"img\" style=\"background-image: url('" + i.Attributes["poster"].Value + "');\"></div>" +
                                 "</div>" +
                                 "<div class=\"info\">" +
                                 "<div class=\"title\">" + i.Attributes["title"].Value + "</div>" +
                                 "<div class=\"infos\">" +
                                 "<div class=\"year\">" + i.Attributes["year"].Value + "</div>" +
                                 "<div class=\"imdb\">TMDB: " + i.Attributes["rating"].Value + "</div>" +
                                 "</div>" +
                                 "</div>" +
                                 "</a>" +
                                 "</li>";
            }
            top.InnerHtml += "</ul>";
        }
Ejemplo n.º 3
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("dqwdqwdqw");
            XmlReader   reader = XmlReader.Create("http://www.omdbapi.com/?i=" + idInput.Value.ToString() + "&plot=full&r=xml");
            XmlDocument doc    = new XmlDocument();

            doc.Load(reader);
            reader.Close();

            XmlDataSource2.Data = doc.OuterXml;

            XmlDataSource2.DataBind();
            XmlDataSource2.XPath = "/root/movie";


            XmlDocument xdoc1 = XmlDataSource2.GetXmlDocument();
            XmlNode     info  = xdoc1.SelectSingleNode("/root/movie");

            String query = "INSERT INTO dbo.Movies (id,rating,year,poster,title) VALUES (@id,@rating, @year, @poster, @title)";

            using (SqlConnection connection = new SqlConnection("Data Source=localhost\\SQLEXPRESS;Initial Catalog=MoviesBS;Integrated Security=True;Pooling=False"))
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    //a shorter syntax to adding parameters
                    command.Parameters.Add("@id", SqlDbType.NChar).Value = idInput.Value.ToString();

                    command.Parameters.Add("@rating", SqlDbType.NChar).Value = info.Attributes["imdbRating"].Value;

                    command.Parameters.Add("@year", SqlDbType.NChar).Value = info.Attributes["year"].Value;

                    command.Parameters.Add("@poster", SqlDbType.NChar).Value = info.Attributes["poster"].Value;

                    command.Parameters.Add("@title", SqlDbType.NChar).Value = info.Attributes["title"].Value;

                    //make sure you open and close(after executing) the connection
                    connection.Open();
                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch { }
                    connection.Close();
                }
            stats();
        }
Ejemplo n.º 4
0
        protected void propertyItemUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row   = GridView1.Rows[e.RowIndex];
            HyperLink   hyper = (HyperLink)row.FindControl("HyperLink1");
            XmlDocument xdoc  = XmlDataSource3.GetXmlDocument();

            XmlElement property = xdoc.SelectSingleNode("properties/property[@land_register='" + hyper.Text + "']") as XmlElement;
            XmlNode    address  = property.SelectSingleNode("address");

            address.SelectSingleNode("city").InnerText        = e.NewValues["city"].ToString();
            address.SelectSingleNode("street").InnerText      = e.NewValues["street"].ToString();
            address.SelectSingleNode("port_number").InnerText = e.NewValues["port_number"].ToString();
            property.SelectSingleNode("value").InnerText      = e.NewValues["value"].ToString();

            XmlDataSource3.Save();
            XmlDataSource1.DataBind();
            XmlDataSource2.DataBind();

            e.Cancel            = true;
            GridView1.EditIndex = -1;
            Response.Redirect(Request.RawUrl);
        }