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

📄 framedataset.cs

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

    public class FrameDataSet
    {
        private string ClassAlias;
        private int columncount;
        private int count;
        private FrameCity frameCity;
        private DataSet theDS;

        public FrameDataSet()
        {
            this.ClassAlias = "DS";
            this.frameCity = new FrameCity();
            this.count = 0;
            this.columncount = 0;
            string functionAlias = "00";
            string errorInfo = "";
            this.theDS = new DataSet();
            try
            {
                if (!this.SetState(ref errorInfo))
                {
                    throw new Exception("◇" + errorInfo);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message));
            }
        }

        public FrameDataSet(DataSet theDataSet)
        {
            this.ClassAlias = "DS";
            this.frameCity = new FrameCity();
            this.count = 0;
            this.columncount = 0;
            string functionAlias = "01";
            string errorInfo = "";
            this.theDS = theDataSet;
            try
            {
                if (!this.SetState(ref errorInfo))
                {
                    throw new Exception("◇" + errorInfo);
                }
            }
            catch (Exception exception)
            {
                throw new Exception(this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message));
            }
        }

        public bool Clear(ref string ErrorInfo)
        {
            string functionAlias = "04";
            try
            {
                string errorInfo = "";
                this.theDS = new DataSet();
                if (!this.SetState(ref errorInfo))
                {
                    throw new Exception("◇" + errorInfo);
                }
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }

        public bool SetDataSet(DataSet theDataSet, ref string ErrorInfo)
        {
            string functionAlias = "02";
            string errorInfo = "";
            this.theDS = theDataSet;
            if (!this.SetState(ref errorInfo))
            {
                ErrorInfo = "◇" + errorInfo;
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, ErrorInfo);
                return false;
            }
            return true;
        }

        private bool SetState(ref string ErrorInfo)
        {
            string functionAlias = "03";
            try
            {
                if (this.theDS.Tables.Count == 0)
                {
                    this.count = 0;
                    this.columncount = 0;
                }
                else
                {
                    this.count = this.theDS.Tables[0].Rows.Count;
                    this.columncount = this.theDS.Tables[0].Columns.Count;
                }
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
                return false;
            }
            return true;
        }

        public int ColumnCount
        {
            get
            {
                try
                {
                    return this.columncount;
                }
                catch
                {
                    return 0;
                }
            }
        }

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

        public string this[int Row, string Column]
        {
            get
            {
                string functionAlias = "05";
                if ((Row >= this.count) || (Row < 0))
                {
                    throw new Exception(this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, "行数越界:\n\r总行数为 " + this.count.ToString() + ",提交行数为 " + Row.ToString()));
                }
                return this.theDS.Tables[0].Rows[Row][Column].ToString().Trim();
            }
        }
    }
}

⌨️ 快捷键说明

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