示例#1
0
    /// <summary>
    /// 取得序列号,主键为非自增时使用
    /// </summary>
    /// <param name="tableName">表名称</param>
    /// <returns>序列</returns>
    protected string GetSequence(string tableName)
    {
        string sequence = string.Empty;
        var    manager  = new CiSequenceManager(this.RDIFrameworkDbProvider, true);

        sequence = manager.GetSequence(tableName);
        return(sequence);
    }
示例#2
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="cASE_PRODUCTIN_DETAILEntity">实体</param>
        public string AddEntity(CASE_PRODUCTIN_DETAILEntity cASE_PRODUCTIN_DETAILEntity)
        {
            string sequence = string.Empty;

            this.Identity = false;
            if (cASE_PRODUCTIN_DETAILEntity.ID != null)
            {
                sequence = cASE_PRODUCTIN_DETAILEntity.ID.ToString();
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CASE_PRODUCTIN_DETAILTable.FieldID);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(cASE_PRODUCTIN_DETAILEntity.ID))
                {
                    sequence = BusinessLogic.NewGuid();
                    cASE_PRODUCTIN_DETAILEntity.ID = sequence;
                }
                sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldID, cASE_PRODUCTIN_DETAILEntity.ID);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CASE_PRODUCTIN_DETAILTable.FieldID, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CASE_PRODUCTIN_DETAILTable.FieldID, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(cASE_PRODUCTIN_DETAILEntity.ID))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            cASE_PRODUCTIN_DETAILEntity.ID = sequence;
                        }
                        sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldID, cASE_PRODUCTIN_DETAILEntity.ID);
                    }
                }
            }
            this.SetEntity(sqlBuilder, cASE_PRODUCTIN_DETAILEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldCREATEUSERID, UserInfo.Id);
                sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldCREATEBY, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CASE_PRODUCTIN_DETAILTable.FieldCREATEON);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldMODIFIEDUSERID, UserInfo.Id);
                sqlBuilder.SetValue(CASE_PRODUCTIN_DETAILTable.FieldMODIFIEDBY, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(CASE_PRODUCTIN_DETAILTable.FieldMODIFIEDON);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#3
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="cUSTOMERCHANCEEntity">实体</param>
        public string AddEntity(CUSTOMERCHANCEEntity cUSTOMERCHANCEEntity)
        {
            string sequence = string.Empty;

            if (cUSTOMERCHANCEEntity.SORTCODE == null || cUSTOMERCHANCEEntity.SORTCODE == 0)
            {
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                cUSTOMERCHANCEEntity.SORTCODE = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, CUSTOMERCHANCETable.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(CUSTOMERCHANCETable.FieldId, cUSTOMERCHANCEEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(CUSTOMERCHANCETable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(CUSTOMERCHANCETable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (cUSTOMERCHANCEEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            cUSTOMERCHANCEEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(CUSTOMERCHANCETable.FieldId, cUSTOMERCHANCEEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, cUSTOMERCHANCEEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(CUSTOMERCHANCETable.FieldCreateUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(CUSTOMERCHANCETable.FieldCreateOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
示例#4
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="productInfoEntity">实体</param>
        public string AddEntity(ProductInfoEntity productInfoEntity)
        {
            var sequence = string.Empty;

            this.Identity = false;
            if (productInfoEntity.Id != null)
            {
                sequence = productInfoEntity.Id;
            }

            var sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, ProductInfoTable.FieldId);
            if (!this.Identity)
            {
                if (string.IsNullOrEmpty(productInfoEntity.Id))
                {
                    sequence             = BusinessLogic.NewGuid();
                    productInfoEntity.Id = sequence;
                }

                sqlBuilder.SetValue(ProductInfoTable.FieldId, productInfoEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(ProductInfoTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(ProductInfoTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (string.IsNullOrEmpty(productInfoEntity.Id))
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                var sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            productInfoEntity.Id = sequence;
                        }
                        sqlBuilder.SetValue(ProductInfoTable.FieldId, productInfoEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, productInfoEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(ProductInfoTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(ProductInfoTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(ProductInfoTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(ProductInfoTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(ProductInfoTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString(CultureInfo.InvariantCulture);
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="linkManEntity">实体</param>
        public string AddEntity(LinkManEntity linkManEntity)
        {
            string sequence = string.Empty;

            if (linkManEntity.SortCode == null || linkManEntity.SortCode == 0)
            {
                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                linkManEntity.SortCode = int.Parse(sequence);
            }
            SQLBuilder sqlBuilder = new SQLBuilder(DBProvider, this.Identity, this.ReturnId);

            sqlBuilder.BeginInsert(this.CurrentTableName, LinkManTable.FieldId);
            if (!this.Identity)
            {
                sqlBuilder.SetValue(LinkManTable.FieldId, linkManEntity.Id);
            }
            else
            {
                if (!this.ReturnId && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                {
                    if (DBProvider.CurrentDbType == CurrentDbType.Oracle)
                    {
                        sqlBuilder.SetFormula(LinkManTable.FieldId, "SEQ_" + this.CurrentTableName.ToUpper() + ".NEXTVAL ");
                    }
                    if (DBProvider.CurrentDbType == CurrentDbType.DB2)
                    {
                        sqlBuilder.SetFormula(LinkManTable.FieldId, "NEXT VALUE FOR SEQ_" + this.CurrentTableName.ToUpper());
                    }
                }
                else
                {
                    if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.Oracle || DBProvider.CurrentDbType == CurrentDbType.DB2))
                    {
                        if (linkManEntity.Id == null)
                        {
                            if (string.IsNullOrEmpty(sequence))
                            {
                                CiSequenceManager sequenceManager = new CiSequenceManager(DBProvider, this.Identity);
                                sequence = sequenceManager.GetSequence(this.CurrentTableName);
                            }
                            linkManEntity.Id = int.Parse(sequence);
                        }
                        sqlBuilder.SetValue(LinkManTable.FieldId, linkManEntity.Id);
                    }
                }
            }
            this.SetEntity(sqlBuilder, linkManEntity);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(LinkManTable.FieldCreateUserId, UserInfo.Id);
                sqlBuilder.SetValue(LinkManTable.FieldCreateBy, UserInfo.RealName);
            }
            sqlBuilder.SetDBNow(LinkManTable.FieldCreateOn);
            if (UserInfo != null)
            {
                sqlBuilder.SetValue(LinkManTable.FieldModifiedBy, UserInfo.RealName);
                sqlBuilder.SetValue(LinkManTable.FieldModifiedUserId, UserInfo.Id);
            }
            sqlBuilder.SetDBNow(LinkManTable.FieldModifiedOn);
            if (this.Identity && (DBProvider.CurrentDbType == CurrentDbType.SqlServer || DBProvider.CurrentDbType == CurrentDbType.Access))
            {
                sequence = sqlBuilder.EndInsert().ToString();
            }
            else
            {
                sqlBuilder.EndInsert();
            }
            return(sequence);
        }