示例#1
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="en"></param>
        /// <returns></returns>
        public static int Insert_del(Entity en)
        {
            if (en.EnMap.EnType == EnType.Ext)
            {
                throw new Exception("@实体[" + en.EnDesc + "]是扩展类型,不能执行插入。");
            }

            if (en.EnMap.EnType == EnType.View)
            {
                throw new Exception("@实体[" + en.EnDesc + "]是视图类型,不能执行插入。");
            }

            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    return(DBAccess.RunSQL(SqlBuilder.Insert(en)));

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Insert(en)));

                case DBUrlType.DBAccessOfOracle:
                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Insert(en)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                en.CheckPhysicsTable();                 // 检查物理表。
                throw ex;
            }
        }
示例#2
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        public static int Update(Entity en)
        {
            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    switch (SystemConfig.AppCenterDBType)
                    {
                    case DBType.Oracle:
                        return(DBAccess.RunSQL(en.SQLCash.Update, SqlBuilder.GenerParas(en, null)));

                    case DBType.Access:
                        return(DBAccess.RunSQL(SqlBuilder.UpdateOfMSAccess(en, null)));

                    default:
                        return(DBAccess.RunSQL(SqlBuilder.Update(en, null)));
                    }

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Update(en, null)));

                case DBUrlType.DBAccessOfOracle:
                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Update(en, null)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                if (BP.SystemConfig.IsDebug)
                {
                    en.CheckPhysicsTable();
                }
                throw ex;
            }
        }
示例#3
0
        public int ToDBUrlRunDropTable(string table)
        {
            switch (this.ToDBUrl)
            {
            case DBUrlType.AppCenterDSN:
                return(DBAccess.RunSQLDropTable(table));

            case DBUrlType.DBAccessOfMSMSSQL:
                return(DBAccessOfMSMSSQL.RunSQL(table));

            case DBUrlType.DBAccessOfODBC:
                return(DBAccessOfODBC.RunSQL(table));

            case DBUrlType.DBAccessOfOLE:
                return(DBAccessOfOLE.RunSQL(table));

            case DBUrlType.DBAccessOfOracle:
                return(DBAccessOfOracle.RunSQLTRUNCATETable(table));

            default:
                throw new Exception("@ error it");
            }
        }
示例#4
0
        /// <summary>
        /// 删除之后插入, 用于数据量不太大,更新频率不太频繁的数据处理.
        /// </summary>
        public void DeleteInsert()
        {
            this.DoBefore();             //调用业务处理。
            // 得到源表.
            DataTable FromDataTable = this.GetFromDataTable();

            this.DeleteObjData();

            #region  遍历源表 插入操作
            string InsertSQL = "";
            foreach (DataRow FromDR in FromDataTable.Rows)
            {
                InsertSQL = "INSERT INTO " + this.ToTable + "(";
                foreach (FF ff in this.FFs)
                {
                    InsertSQL += ff.ToField.ToString() + ",";
                }
                InsertSQL  = InsertSQL.Substring(0, InsertSQL.Length - 1);
                InsertSQL += ") values(";
                foreach (FF ff in this.FFs)
                {
                    if (ff.DataType == DataType.AppString || ff.DataType == DataType.AppDateTime)
                    {
                        InsertSQL += "'" + FromDR[ff.FromField].ToString() + "',";
                    }
                    else
                    {
                        InsertSQL += FromDR[ff.FromField].ToString() + ",";
                    }
                }
                InsertSQL  = InsertSQL.Substring(0, InsertSQL.Length - 1);
                InsertSQL += ")";

                switch (this.ToDBUrl)
                {
                case DA.DBUrlType.AppCenterDSN:
                    DBAccess.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfMSMSSQL:
                    DBAccessOfMSMSSQL.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfOLE:
                    DBAccessOfOLE.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfOracle:
                    DBAccessOfOracle.RunSQL(InsertSQL);
                    break;

                case DA.DBUrlType.DBAccessOfODBC:
                    DBAccessOfODBC.RunSQL(InsertSQL);
                    break;

                default:
                    break;
                }
            }
            #endregion



            this.DoAfter();             // 调用业务处理。
        }
示例#5
0
文件: EnDa.cs 项目: zhaoyingju/ccflow
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="en">产生要更新的语句</param>
        /// <param name="keys">要更新的属性(null,认为更新全部)</param>
        /// <returns>sql</returns>
        public static int Update(Entity en, string[] keys)
        {
            if (en.EnMap.EnType == EnType.View)
            {
                return(0);
            }
            try
            {
                switch (en.EnMap.EnDBUrl.DBUrlType)
                {
                case DBUrlType.AppCenterDSN:
                    switch (SystemConfig.AppCenterDBType)
                    {
                    case DBType.MSSQL:
                    case DBType.Oracle:
                    case DBType.MySQL:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas(en, keys)));

                    case DBType.Informix:
                        return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), SqlBuilder.GenerParas_Update_Informix(en, keys)));

                    case DBType.Access:
                        return(DBAccess.RunSQL(SqlBuilder.UpdateOfMSAccess(en, keys)));

                    default:
                        //return DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                        //    SqlBuilder.GenerParas(en, keys));
                        if (keys != null)
                        {
                            Paras ps   = new Paras();
                            Paras myps = SqlBuilder.GenerParas(en, keys);
                            foreach (Para p in myps)
                            {
                                foreach (string s in keys)
                                {
                                    if (s == p.ParaName)
                                    {
                                        ps.Add(p);
                                        break;
                                    }
                                }
                            }
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys), ps));
                        }
                        else
                        {
                            return(DBAccess.RunSQL(en.SQLCash.GetUpdateSQL(en, keys),
                                                   SqlBuilder.GenerParas(en, keys)));
                        }
                        break;
                    }

                case DBUrlType.DBAccessOfMSMSSQL:
                    return(DBAccessOfMSMSSQL.RunSQL(SqlBuilder.Update(en, keys)));

                case DBUrlType.DBAccessOfOracle:

                    return(DBAccessOfOracle.RunSQL(SqlBuilder.Update(en, keys)));

                default:
                    throw new Exception("@没有设置类型。");
                }
            }
            catch (Exception ex)
            {
                if (BP.SystemConfig.IsDebug)
                {
                    en.CheckPhysicsTable();
                }
                throw ex;
            }
        }