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

📄 framewhere.cs

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

    internal class FrameWhere
    {
        private string ClassAlias = "WH";
        private int count = 0;
        private string DBType = "";
        private FrameCity frameCity = new FrameCity();
        private WhereList[] pList;

        public FrameWhere(string dBType)
        {
            this.DBType = dBType;
        }

        public bool AddWhere(int index, string Name, string Depiction, string DataType, string Col, string Operator, ref string ErrorInfo)
        {
            string functionAlias = "04";
            try
            {
                if (((DataType.ToLower() != "string") && (DataType.ToLower() != "datetime")) && (DataType.ToLower() != "number"))
                {
                    throw new Exception("不支持数据类型:" + DataType.ToString() + " !");
                }
                this.pList[index].Name = Name;
                this.pList[index].Depiction = Depiction;
                this.pList[index].DataType = DataType;
                this.pList[index].Col = Col;
                this.pList[index].Operator = Operator;
            }
            catch (Exception exception)
            {
                ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, "加载 Where 项错误:\n\r" + exception.Message);
                return false;
            }
            return true;
        }

        private void AddWhereList(string Name, string Depiction, string DataType, string Operator, string Col, string Value)
        {
            this.count++;
            WhereList[] listArray = new WhereList[this.Count];
            for (int i = 0; i < (this.Count - 1); i++)
            {
                listArray[i].Name = this.pList[i].Name;
                listArray[i].Depiction = this.pList[i].Depiction;
                listArray[i].DataType = this.pList[i].DataType;
                listArray[i].Operator = this.pList[i].Operator;
                listArray[i].Col = this.pList[i].Col;
                listArray[i].Value = this.pList[i].Value;
            }
            listArray[this.Count - 1].Name = Name;
            listArray[this.Count - 1].Depiction = Depiction;
            listArray[this.Count - 1].DataType = DataType;
            listArray[this.Count - 1].Operator = Operator;
            listArray[this.Count - 1].Col = Col;
            listArray[this.Count - 1].Value = Value;
            this.pList = listArray;
        }

        public void Clear()
        {
            for (int i = 0; i < this.count; i++)
            {
                this.pList[i].Value = null;
            }
        }

        public void CreatNew(int thecount)
        {
            this.count = thecount;
            this.pList = new WhereList[thecount];
        }

        public bool ReplaceWhere(ref string returnSQL, string MiddleSQL, string CommandName, ref string ErrorInfo)
        {
            string functionAlias = "02";
            string str2 = "";
            int index = 0;
            try
            {
                int num3;
                int num4;
                int num5;
                int num6;
                switch (CommandName.ToLower())
                {
                    case "insert":
                    case "other":
                        goto Label_0A74;

                    case "update":
                        str2 = MiddleSQL + " where 1=1 ";
                        for (int i = 0; i < this.count; i++)
                        {
                            if (this.pList[i].Value != null)
                            {
                                if (this.pList[i].Operator != "in")
                                {
                                    str2 = str2 + " and " + this.pList[i].Col + " " + this.pList[i].Operator + " " + this.frameCity.GetValueData(this.pList[i].Value, this.DBType, this.pList[i].DataType);
                                }
                                else if (this.pList[i].Operator == "in")
                                {
                                    str2 = str2 + " and " + this.pList[i].Col + " " + this.pList[i].Operator + " (" + this.pList[i].Value + ")";
                                }
                            }
                        }
                        returnSQL = str2;
                        goto Label_0A74;

                    case "delete":
                        str2 = " where 1=1 ";
                        num3 = 0;
                        goto Label_0430;

                    case "select":
                        str2 = "";
                        num4 = 0;
                        goto Label_05C4;

                    case "procedure":
                        str2 = "";
                        index = 0;
                        while (index < this.count)
                        {
                            if (this.pList[index].Value != null)
                            {
                                str2 = str2 + ", " + this.frameCity.GetValueData(this.pList[index].Value, this.DBType, this.pList[index].DataType);
                            }
                            index++;
                        }
                        if (index > 0)
                        {
                            str2 = str2.Substring(1, str2.Length - 1);
                            str2 = "(" + str2 + ")";
                        }
                        returnSQL = str2;
                        goto Label_0A74;

                    case "procedurequery":
                        str2 = "";
                        index = 0;
                        goto Label_06D4;

                    case "extendselect":
                        str2 = "";
                        num5 = 0;
                        goto Label_0889;

                    case "table":
                        str2 = "";
                        num6 = 0;
                        goto Label_0A1D;

                    default:
                        throw new Exception(this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, "数据库操作类型 " + CommandName + " 不存在!"));
                }
            Label_02BF:
                if (this.pList[num3].Value != null)
                {
                    if (this.pList[num3].Operator != "in")
                    {
                        str2 = str2 + " and " + this.pList[num3].Col + " " + this.pList[num3].Operator + " " + this.frameCity.GetValueData(this.pList[num3].Value, this.DBType, this.pList[num3].DataType);
                    }
                    else if (this.pList[num3].Operator == "in")
                    {
                        str2 = str2 + " and " + this.pList[num3].Col + " " + this.pList[num3].Operator + " (" + this.pList[num3].Value + ")";
                    }
                }
                num3++;
            Label_0430:
                if (num3 < this.count)
                {
                    goto Label_02BF;
                }
                returnSQL = str2;
                goto Label_0A74;
            Label_0453:
                if (this.pList[num4].Value != null)
                {
                    if (this.pList[num4].Operator != "in")
                    {
                        str2 = str2 + " and " + this.pList[num4].Col + " " + this.pList[num4].Operator + " " + this.frameCity.GetValueData(this.pList[num4].Value, this.DBType, this.pList[num4].DataType);
                    }
                    else if (this.pList[num4].Operator == "in")
                    {
                        str2 = str2 + " and " + this.pList[num4].Col + " " + this.pList[num4].Operator + " (" + this.pList[num4].Value + ")";
                    }
                }
                num4++;
            Label_05C4:
                if (num4 < this.count)
                {
                    goto Label_0453;
                }
                returnSQL = str2;
                goto Label_0A74;
            Label_067E:
                if (this.pList[index].Value != null)
                {
                    str2 = str2 + ", " + this.frameCity.GetValueData(this.pList[index].Value, this.DBType, this.pList[index].DataType);

⌨️ 快捷键说明

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