示例#1
0
文件: CreatUrl.cs 项目: jksharp/kanng
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "")
            {
                return;
            }

            string guid = Guid.NewGuid().ToString().Replace("-", "");

            if (urlModel != null)
            {
                guid = urlModel.guid;
                bool rlb = UrlXmlIO.UpdateNode(textBox2.Text, textBox1.Text, guid, txt_UserName.Text, txt_Pwd.Text);
                if (rlb)
                {
                    MessageBox.Show("更新成功!");
                }

                StartProccess startFrom = (StartProccess)CheckMdiFormIsOpen("StartProccess");
                UrlModel      model     = new UrlModel();
                model.guid     = guid;
                model.name     = textBox2.Text;
                model.url      = textBox1.Text;
                model.username = txt_UserName.Text.Trim();
                model.password = txt_Pwd.Text.Trim();

                startFrom.updateControl(model);
            }
            else
            {
                bool rlb = UrlXmlIO.Create(textBox2.Text, textBox1.Text, guid, txt_UserName.Text, txt_Pwd.Text);
                if (rlb)
                {
                    MessageBox.Show("添加成功!");
                }

                StartProccess startFrom = (StartProccess)CheckMdiFormIsOpen("StartProccess");
                UrlModel      model     = new UrlModel();
                model.guid     = guid;
                model.name     = textBox2.Text;
                model.url      = textBox1.Text;
                model.username = txt_UserName.Text.Trim();
                model.password = txt_Pwd.Text.Trim();
                startFrom.addControl(model);
            }

            this.Close();
        }
示例#2
0
        public void addControl(UrlModel model)
        {
            //this.Refresh();
            this.urlPatte1 = new UrlPatte();

            urlPatte1.SetModel(model.guid, model.url, model.name);
            //
            // urlPatte1
            //
            this.urlPatte1.Cursor   = System.Windows.Forms.Cursors.Hand;
            this.urlPatte1.Location = new System.Drawing.Point(3, 3);
            this.urlPatte1.Name     = "urlPatte1";
            this.urlPatte1.Size     = new System.Drawing.Size(87, 51);
            this.urlPatte1.TabIndex = 3;
            this.flowLayoutPanel1.Controls.Add(this.urlPatte1);
        }
示例#3
0
        public void updateControl(UrlModel model)
        {
            //this.Refresh();
            this.urlPatte1 = (UrlPatte)this.flowLayoutPanel1.Controls.Find(model.guid, false)[0];

            urlPatte1.SetModel(model.guid, model.url, model.name, model.username, model.password);
            //
            // urlPatte1
            //
            this.urlPatte1.Cursor   = System.Windows.Forms.Cursors.Hand;
            this.urlPatte1.Location = new System.Drawing.Point(3, 3);
            this.urlPatte1.Name     = model.guid;
            this.urlPatte1.Size     = new System.Drawing.Size(87, 51);
            this.urlPatte1.TabIndex = 3;
            urlPatte1.label1.Text   = model.name;
            this.urlPatte1.Refresh();
        }
示例#4
0
文件: UrlXmlIO.cs 项目: jksharp/kanng
        public static List <UrlModel> ReadAllUrl()
        {
            //要读的id为1的book子节点
            string xpath = "/root/url";

            XmlNodeList     nodeList   = XMLHelper.GetXmlNodeListByXpath(xmlFileName, xpath);
            string          strAllNode = "";
            List <UrlModel> list       = new List <UrlModel>();

            //遍历节点中所有的子节点
            foreach (XmlNode node in nodeList)
            {
                UrlModel   model   = new UrlModel();
                XmlElement element = (XmlElement)node;
                model.guid = node.Attributes[0].Value;

                foreach (XmlNode node2 in node.ChildNodes)
                {
                    if (node2.Name == "name")
                    {
                        model.name = element.GetElementsByTagName("name").Item(0).InnerText;
                    }
                    else if (node2.Name == "url")
                    {
                        model.url = element.GetElementsByTagName("url").Item(0).InnerText;
                    }
                    else if (node2.Name == "username")
                    {
                        model.username = element.GetElementsByTagName("username").Item(0).InnerText;
                    }
                    else if (node2.Name == "password")
                    {
                        model.password = element.GetElementsByTagName("password").Item(0).InnerText;
                    }
                }


                list.Add(model);
            }

            return(list);
        }
示例#5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string guid = Guid.NewGuid().ToString().Replace("-", "");

            bool rlb = UrlXmlIO.Create(textBox1.Text, guid);

            if (rlb)
            {
                MessageBox.Show("添加成功!");
            }

            StartProccess startFrom = (StartProccess)CheckMdiFormIsOpen("StartProccess");
            UrlModel      model     = new UrlModel();

            model.guid = guid;
            model.name = textBox1.Text;
            model.url  = textBox1.Text;
            startFrom.addControl(model);
            this.Close();
        }
示例#6
0
        public static List <UrlModel> ReadAllUrl()
        {
            //要读的id为1的book子节点
            string xpath = "/root/url";

            XmlNodeList     nodeList   = XMLHelper.GetXmlNodeListByXpath(xmlFileName, xpath);
            string          strAllNode = "";
            List <UrlModel> list       = new List <UrlModel>();

            //遍历节点中所有的子节点
            foreach (XmlNode node in nodeList)
            {
                UrlModel model = new UrlModel();
                model.guid = node.Attributes[0].Value;
                model.name = node.ChildNodes[0].InnerText;
                model.url  = node.ChildNodes[1].InnerText;
                list.Add(model);
            }

            return(list);
        }