Exemplo n.º 1
0
        protected bool ReplaceProc(string labelName)
        {
            LabelManageInfo ainfo = new LabelManageInfo();

            ainfo = LabelManage.GetLabelByName(labelName);
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labelname", StringComparison.OrdinalIgnoreCase) == 0)
            {
                string str = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                if (this.ChkAdd.Checked)
                {
                    ainfo.Name = str;
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo, str));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labeltype", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(ainfo.Define.ToString());
                if (document.SelectSingleNode("root/LabelType") != null)
                {
                    document.SelectSingleNode("root/LabelType").InnerText = document.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "labelintro", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document2 = new XmlDocument();
                document2.LoadXml(ainfo.Define.ToString());
                if (document2.SelectSingleNode("root/LabelIntro") != null)
                {
                    document2.SelectSingleNode("root/LabelIntro").InnerText = document2.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document2.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "sql", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document3 = new XmlDocument();
                document3.LoadXml(ainfo.Define.ToString());
                if (document3.SelectSingleNode("root/LabelSqlString") != null)
                {
                    document3.SelectSingleNode("root/LabelSqlString").InnerText = document3.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document3.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            if (string.Compare(this.RadioButtonList2.SelectedValue, "template", StringComparison.OrdinalIgnoreCase) == 0)
            {
                XmlDocument document4 = new XmlDocument();
                document4.LoadXml(ainfo.Define.ToString());
                if (document4.SelectSingleNode("root/LabelTemplate") != null)
                {
                    document4.SelectSingleNode("root/LabelTemplate").InnerText = document4.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
                }
                ainfo.Define = new StringBuilder(document4.InnerXml);
                if (this.ChkAdd.Checked)
                {
                    return(LabelManage.Add(ainfo));
                }
                return(LabelManage.Update(ainfo));
            }
            string      newLableName = ainfo.Name.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            XmlDocument document5    = new XmlDocument();

            document5.LoadXml(ainfo.Define.ToString());
            if (document5.SelectSingleNode("root/LabelType") != null)
            {
                document5.SelectSingleNode("root/LabelType").InnerText = document5.SelectSingleNode("root/LabelType").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelIntro") != null)
            {
                document5.SelectSingleNode("root/LabelIntro").InnerText = document5.SelectSingleNode("root/LabelIntro").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelSqlString") != null)
            {
                document5.SelectSingleNode("root/LabelSqlString").InnerText = document5.SelectSingleNode("root/LabelSqlString").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            if (document5.SelectSingleNode("root/LabelTemplate") != null)
            {
                document5.SelectSingleNode("root/LabelTemplate").InnerText = document5.SelectSingleNode("root/LabelTemplate").InnerText.Replace(this.ReplaceSource.Text, this.ReplaceTarget.Text);
            }
            ainfo.Define = new StringBuilder(document5.InnerXml);
            if (this.ChkAdd.Checked)
            {
                ainfo.Name = newLableName;
                return(LabelManage.Add(ainfo));
            }
            return(LabelManage.Update(ainfo, newLableName));
        }