⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frametransvalue.cs

📁 结构很好的三层数据访问组件。开放源码。是微软企业库数据访问的替代产品之一。
💻 CS
字号:
namespace FrameCountry
{
    using System;
    using System.Reflection;
    using System.Xml;

    public class FrameTransValue
    {
        private string ClassAlias;
        private FrameCity frameCity;
        private XmlDocument parentXmlDoc;
        private XmlNode ValueXmlNode;

        public FrameTransValue()
        {
            this.ClassAlias = "TV";
            this.frameCity = new FrameCity();
            this.parentXmlDoc = new XmlDocument();
        }

        public FrameTransValue(string NodeInnerXML)
        {
            this.ClassAlias = "TV";
            this.frameCity = new FrameCity();
            this.parentXmlDoc = new XmlDocument();
            this.parentXmlDoc.LoadXml("<?xml version='1.0' encoding='gb2312'?><root>" + NodeInnerXML + "</root>");
            this.ValueXmlNode = this.parentXmlDoc.ChildNodes[1];
        }

        public bool GetName(int index, ref string TheName, ref string ErrorInfo)
        {
            string functionAlias = "04";
            try
            {
                if ((index < 0) || (index > this.ValueXmlNode.ChildNodes.Count))
                {
                    throw new Exception("索引越界!");
                }
                TheName = this.ValueXmlNode.ChildNodes[index].Name;
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }

        public bool GetValueXmlNode(ref string NodeInnerXML, ref string ErrorInfo)
        {
            string functionAlias = "03";
            try
            {
                NodeInnerXML = this.ValueXmlNode.InnerXml;
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
            }
            return true;
        }

        public bool SetValueXmlNode(string NodeInnerXML, ref string ErrorInfo)
        {
            string functionAlias = "02";
            try
            {
                this.parentXmlDoc.LoadXml("<?xml version='1.0' encoding='gb2312'?><root>" + NodeInnerXML + "</root>");
                this.ValueXmlNode = this.parentXmlDoc.ChildNodes[1];
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
            }
            return true;
        }

        public int Count
        {
            get
            {
                try
                {
                    return this.ValueXmlNode.ChildNodes.Count;
                }
                catch
                {
                    return 0;
                }
            }
        }

        public string this[string index]
        {
            get
            {
                try
                {
                    return this.ValueXmlNode.SelectNodes("./" + index)[0].InnerText;
                }
                catch
                {
                    return null;
                }
            }
            set
            {
                try
                {
                    this.ValueXmlNode.SelectNodes("./" + index)[0].InnerText = value;
                }
                catch
                {
                    XmlElement newChild = this.parentXmlDoc.CreateElement(index);
                    newChild.InnerText = value;
                    this.ValueXmlNode.AppendChild(newChild);
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -