Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
- using System.Net;
- using System.ServiceModel.Syndication;
- using MySql.Data.MySqlClient;
- namespace WindowsFormsApp1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void richTextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void richTextBox2_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- richTextBox1.Clear();
- string URL = textBox1.Text;
- XmlReader reader = XmlReader.Create(URL);
- SyndicationFeed feed = SyndicationFeed.Load(reader);
- reader.Close();
- int id = 1;
- foreach (SyndicationItem item in feed.Items)
- {
- richTextBox1.SelectionColor = Color.Red;
- richTextBox1.AppendText(id + ". " + item.Title.Text + "\r\n");
- richTextBox1.SelectionColor = Color.Black;
- richTextBox1.AppendText(item.Summary.Text + "\r\n");
- richTextBox1.SelectionColor = Color.Gray;
- richTextBox1.AppendText(item.PublishDate + "\r\n");
- richTextBox1.AppendText(item.Links[0].GetAbsoluteUri() + "\r\n");
- richTextBox1.SelectionColor = Color.Black;
- richTextBox1.AppendText("_____________________________________________________________________\r\n");
- id += 1;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int id = 1;
- string delete = "DELETE FROM news_rss";
- string ConnStr = "server=localhost;user=root;database=database;password=;";
- MySqlConnection conn = new MySqlConnection(ConnStr);
- conn.Open();
- string URL = textBox1.Text;
- XmlReader reader = XmlReader.Create(URL);
- SyndicationFeed feed = SyndicationFeed.Load(reader);
- reader.Close();
- MySqlCommand command_delete = new MySqlCommand(delete, conn);
- command_delete.ExecuteNonQuery();
- foreach (SyndicationItem item in feed.Items)
- {
- string add_text = "INSERT INTO news_rss SET id='" + id + "', name='"
- + item.Title.Text + "', description='" + item.Summary.Text + "', data='"
- + item.PublishDate + "', link='" + item.Links[0].GetAbsoluteUri() + "'";
- MySqlCommand command_add = new MySqlCommand(add_text, conn);
- id += 1;
- command_add.ExecuteNonQuery();
- }
- conn.Close();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- richTextBox2.Clear();
- string ConnStr = "server=localhost;user=root;database=database;password=;";
- MySqlConnection conn = new MySqlConnection(ConnStr);
- conn.Open();
- string sql = "SELECT id, name, description, data, link FROM news_rss";
- MySqlCommand command = new MySqlCommand(sql, conn);
- MySqlDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- richTextBox2.SelectionColor = Color.Red;
- richTextBox2.AppendText(reader[0].ToString() + ". " + reader[1].ToString() + "\r\n");
- richTextBox2.SelectionColor = Color.Black;
- richTextBox2.AppendText(reader[2] + "\r\n");
- richTextBox2.SelectionColor = Color.Gray;
- richTextBox2.AppendText(reader[3] + "\r\n");
- richTextBox2.SelectionColor = Color.Black;
- richTextBox2.AppendText(reader[4] + "\r\n");
- richTextBox2.AppendText("_____________________________________________________________________\r\n");
- }
- reader.Close();
- conn.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement