/// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/7/27 10:32:48</remarks>
        public bool Update(ConfigPotentialEntity entity, DbTransaction trans)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_ConfigPotential_Update");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx);
            database.AddInParameter(commandWrapper, "@PotentialId", DbType.Int32, entity.PotentialId);
            database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name);
            database.AddInParameter(commandWrapper, "@Level", DbType.Int32, entity.Level);
            database.AddInParameter(commandWrapper, "@MinBuff", DbType.Decimal, entity.MinBuff);
            database.AddInParameter(commandWrapper, "@MaxBuff", DbType.Decimal, entity.MaxBuff);
            database.AddInParameter(commandWrapper, "@BuffType", DbType.Int32, entity.BuffType);
            database.AddInParameter(commandWrapper, "@GKGetType", DbType.Int32, entity.GKGetType);
            database.AddInParameter(commandWrapper, "@BuffId", DbType.Int32, entity.BuffId);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }


            return(Convert.ToBoolean(results));
        }
        /// <summary>
        /// 将IDataReader的当前记录读取到ConfigPotentialEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public ConfigPotentialEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new ConfigPotentialEntity();

            obj.Idx         = (System.Int32)reader["Idx"];
            obj.PotentialId = (System.Int32)reader["PotentialId"];
            obj.Name        = (System.String)reader["Name"];
            obj.Level       = (System.Int32)reader["Level"];
            obj.MinBuff     = (System.Decimal)reader["MinBuff"];
            obj.MaxBuff     = (System.Decimal)reader["MaxBuff"];
            obj.BuffType    = (System.Int32)reader["BuffType"];
            obj.GKGetType   = (System.Int32)reader["GKGetType"];
            obj.BuffId      = (System.Int32)reader["BuffId"];

            return(obj);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取潜力值
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public Potential GetPotentialValue(ConfigPotentialEntity config)
        {
            Potential p = new Potential();

            p.Idx   = config.PotentialId;
            p.Level = config.Level;
            if (config.BuffType == 2) //百分比
            {
                var buff = RandomHelper.GetInt32((int)(config.MinBuff * 100),
                                                 (int)(config.MaxBuff * 100));
                p.Buff = (decimal)buff / 100;
            }
            else
            {
                p.Buff = RandomHelper.GetInt32((int)config.MinBuff, (int)config.MaxBuff);
            }
            return(p);
        }
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="idx">idx</param>
        /// <returns>ConfigPotentialEntity</returns>
        /// <remarks>2016/7/27 10:32:48</remarks>
        public ConfigPotentialEntity GetById(System.Int32 idx)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_ConfigPotential_GetById");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx);


            ConfigPotentialEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Ejemplo n.º 5
0
        public static bool Update(ConfigPotentialEntity configPotentialEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new ConfigPotentialProvider(zoneId);

            return(provider.Update(configPotentialEntity, trans));
        }
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 /// <remarks>2016/7/27 10:32:48</remarks>
 public bool Update(ConfigPotentialEntity entity)
 {
     return(Update(entity, null));
 }
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="trans">The trans.</param>
 /// <returns></returns>
 /// <remarks>2016/7/27 10:32:48</remarks>
 public bool Insert(ConfigPotentialEntity entity)
 {
     return(Insert(entity, null));
 }