예제 #1
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 = "";
            }
        }
예제 #2
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 = "";
            }
        }
예제 #3
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 = "";
            }
        }