Esempio n. 1
0
        /// <summary>
        /// 删除,通过给定的ID
        /// </summary>
        /// <param name="model">model实例</param>
        /// <param name="id">id(数据表自增项目)</param>
        /// <returns>是否删除成功(true:成功 false:失败)</returns>
        public bool DeleteByID(object paramModel, object paramId)
        {
            //返回值
            bool result = true;

            CreateSQL    createSQL = new CreateSQL();
            ComCRUDModel param     = new ComCRUDModel();

            //Int64型ID
            if (paramId is Int64)
            {
                //SQL语句
                param.StrSQL = createSQL.CreateSQLForDeleteByInt64ID(paramModel, (Int64)paramId);
            }
            //String型ID
            else if (paramId is string)
            {
                //SQL语句
                param.StrSQL = createSQL.CreateSQLForDeleteByStrID(paramModel, paramId.ToString());
            }
            else
            {
                return(false);
            }

            //执行查询操作
            object objResult = DBManager.Delete(dbConfig, SQLID.COMM_SQL01, param);

            if (objResult != null && (int)objResult < 1)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 更新,通过给定的WHERE条件
        /// </summary>
        /// <param name="paramTBModel">TBModel实例</param>
        /// <param name="paramCondition">条件</param>
        /// <returns>是否更新成功(true:成功 false:失败)</returns>
        public bool UpdateByCondition(object paramTBModel, string paramCondition)
        {
            if (!paramTBModel.GetType().FullName.Contains(DALConst.TBModel))
            {
                ReturnMsg = "the paramTBModel is not TBModel.";
                return(false);
            }
            //返回值
            bool result = true;

            CreateSQL    createSQL = new CreateSQL();
            ComCRUDModel param     = new ComCRUDModel();

            //SQL语句
            param.StrSQL = createSQL.CreateSQLForUpdateByCondition(paramTBModel, paramCondition);
            //执行查询操作
            object objResult = DBManager.Update(dbConfig, SQLID.COMM_SQL01, param);

            if (objResult != null && (int)objResult < 1)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="paramTBModel">TBModel对象</param>
        /// <param name="paramObjResult">返回新增的ID</param>
        public void InsertByTBModel(object paramTBModel, out object paramObjResult)
        {
            if (!paramTBModel.GetType().FullName.Contains(DALConst.TBModel))
            {
                ReturnMsg      = "the paramTBModel is not TBModel.";
                paramObjResult = null;
                return;
            }

            CreateSQL createSQL = new CreateSQL();

            ComCRUDModel param = new ComCRUDModel();

            //SQL语句
            param.StrSQL = createSQL.CreateSQLForInsertOutIdentity(paramTBModel);
            //执行
            paramObjResult = DBManager.Insert(dbConfig, SQLID.COMM_SQL01, param);
        }
Esempio n. 4
0
        /// <summary>
        /// 删除,通过给定的WHERE条件
        /// </summary>
        /// <param name="model">Model实例</param>
        /// <param name="condition">条件</param>
        /// <returns>是否删除成功(true:成功 false:失败)</returns>
        public bool DeleteByCondition(object paramModel, string paramCondition)
        {
            //返回值
            bool result = true;

            CreateSQL    createSQL = new CreateSQL();
            ComCRUDModel param     = new ComCRUDModel();

            //SQL语句
            param.StrSQL = createSQL.CreateSQLForDeleteByCondition(paramModel, paramCondition);
            //执行查询操作
            object objResult = DBManager.Delete(dbConfig, SQLID.COMM_SQL01, param);

            if (objResult != null && (int)objResult < 1)
            {
                result = false;
            }

            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 更新,通过给定的ID
        /// </summary>
        /// <param name="paramTBModel">model实例</param>
        /// <param name="paramId">id(数据表主键)</param>
        /// <returns>是否更新成功(true:成功 false:失败)</returns>
        public bool UpdateByID(object paramTBModel, object paramId)
        {
            if (!paramTBModel.GetType().FullName.Contains(DALConst.TBModel))
            {
                ReturnMsg = "the paramTBModel is not TBModel.";
                return(false);
            }
            //返回值
            bool         result    = true;
            CreateSQL    createSQL = new CreateSQL();
            ComCRUDModel param     = new ComCRUDModel();

            //Int64型ID
            if (paramId is Int64)
            {
                //SQL语句
                param.StrSQL = createSQL.CreateSQLForUpdateByInt64ID(paramTBModel, (Int64)paramId);
            }
            //String型ID
            else if (paramId is string)
            {
                //SQL语句
                param.StrSQL = createSQL.CreateSQLForUpdateByStrID(paramTBModel, paramId.ToString());
            }
            else
            {
                return(false);
            }
            //执行查询操作
            object objResult = DBManager.Update(dbConfig, SQLID.COMM_SQL01, param);

            if (objResult != null && (int)objResult < 1)
            {
                result = false;
            }

            return(result);
        }