Esempio n. 1
0
        void ComboBox2SelectedIndexChanged(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            XElement xel   = XElement.Load(@"data/keyword.xml");
            string   url   = (comboBox1.SelectedItem as MainForm.Textmodel).tid;
            string   str   = (comboBox2.SelectedItem as MainForm.Textmodel).tid;
            var      query = from x in xel.Descendants("keyword")
                             where x.Parent.Attribute("id").Value == str && x.Parent.Parent.Attribute("id").Value == url
                             select new
            {
                keywords = x.Value,
                id       = x.Attribute("id").Value
            };
            int i = 1;

            foreach (var p in query)
            {
                MainForm.Textmodel tm = new MainForm.Textmodel();
                tm.name = p.keywords;
                tm.tid  = p.id;
                dataGridView1.Rows.Add(tm);
                i++;
            }
        }
Esempio n. 2
0
        void ComboBox1SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();
            dataGridView1.Rows.Clear();
            XmlDocument xd = new XmlDocument();

            xd.Load(@"data/keyword.xml");
            XmlNodeList xl = xd.SelectSingleNode("document").ChildNodes;

            foreach (XmlNode xn in xl)
            {
                if (xn.Attributes[0].Value == (comboBox1.SelectedItem as MainForm.Textmodel).tid)
                {
                    XmlNodeList xml = xn.ChildNodes;
                    foreach (XmlNode category in xml)
                    {
                        MainForm.Textmodel tm = new MainForm.Textmodel();
                        tm.Name = category.Attributes[1].Value;
                        tm.tid  = category.Attributes[0].Value;
                        comboBox2.Items.Add(tm);
                    }
                    if (comboBox2.Items.Count > 0)
                    {
                        comboBox2.SelectedIndex = 0;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 添加新的数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Button1Click(object sender, EventArgs e)
        {
            string[] textrow = textBox1.Text.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string key in textrow)
            {
                if (chongfu(key))
                {
                    MainForm.Textmodel tm = new MainForm.Textmodel();
                    tm.Name = key.Trim();
                    MD5_ md5 = new MD5_();
                    tm.tid = md5.Encrypt(key.Trim());
                    //xml添加节点
                    XmlDocument xd = new XmlDocument();
                    xd.Load(@"data/keyword.xml");
                    XmlNode    xn = xd.SelectSingleNode("//document/url[@name='" + comboBox1.Text + "']/category[@name='" + comboBox2.Text + "']");
                    XmlElement xe = xd.CreateElement("keyword");
                    xe.SetAttribute("id", tm.tid);
                    xe.InnerText = tm.name;
                    xn.AppendChild(xe);

                    xd.Save(@"data/keyword.xml");
                    dataGridView1.Rows.Add(tm);
                }
                textBox1.Text = "";
            }
        }
Esempio n. 4
0
        void Button1Click(object sender, EventArgs e)
        {
            if (panduanchongfu())
            {
                MainForm.Textmodel tm = new MainForm.Textmodel();
                tm.Name = textBox1.Text.Trim();
                if (tm.Name.Contains("http://"))
                {
                    tm.Name = tm.Name.Replace("http://", "");
                }
                MD5_ md5 = new MD5_();
                tm.tid = md5.Encrypt(textBox1.Text.Trim());
                //xml添加节点
                XmlDocument xd = new XmlDocument();
                xd.Load(@"data/keyword.xml");
                XmlNode    xn = xd.SelectSingleNode("//document/url[@name='" + comboBox1.Text + "']");
                XmlElement xe = xd.CreateElement("category");
                xe.SetAttribute("id", tm.tid);
                xe.SetAttribute("name", tm.name);
                xe.InnerText = "";
                xn.AppendChild(xe);

                xd.Save(@"data/keyword.xml");
                dataGridView1.Rows.Add(tm);
                textBox1.Text = "";
            }
        }
Esempio n. 5
0
        void AddwebLoad(object sender, EventArgs e)
        {
            XmlDocument xd = new XmlDocument();

            xd.Load(@"data/keyword.xml");
            XmlNodeList xl = xd.SelectSingleNode("document").ChildNodes;

            foreach (XmlNode xd1 in xl)
            {
                MainForm.Textmodel tm = new MainForm.Textmodel();
                tm.Name = xd1.Attributes[1].Value;
                tm.tid  = xd1.Attributes[0].Value;
                dataGridView1.Rows.Add(tm);
            }
        }
Esempio n. 6
0
        void AddkeywordsLoad(object sender, EventArgs e)
        {
            XmlDocument xd = new XmlDocument();

            xd.Load(@"data/keyword.xml");
            XmlNodeList xl = xd.SelectSingleNode("document").ChildNodes;

            foreach (XmlNode doc in xl)
            {
                MainForm.Textmodel tm = new MainForm.Textmodel();
                tm.name = doc.Attributes[1].Value;
                tm.tid  = doc.Attributes[0].Value;
                comboBox1.Items.Add(tm);
            }
            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }
        }
Esempio n. 7
0
        void Button1Click(object sender, EventArgs e)
        {
            if (chongfu(textBox1.Text.Trim()))
            {
                MainForm.Textmodel tm = new MainForm.Textmodel();
                tm.Name = textBox1.Text.Trim();
                MD5_ md5 = new MD5_();
                tm.tid = md5.Encrypt(textBox1.Text.Trim());
                //xml添加节点
                XmlDocument xd = new XmlDocument();
                xd.Load(@"data/keyword.xml");
                XmlNode    xn = xd.SelectSingleNode("document");
                XmlElement xe = xd.CreateElement("url");
                xe.SetAttribute("id", tm.tid);
                xe.SetAttribute("name", tm.name);
                xe.InnerText = "";
                xn.AppendChild(xe);

                xd.Save(@"data/keyword.xml");

                dataGridView1.Rows.Add(tm);
                textBox1.Text = "";
            }
        }