/// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/3/11 15:09:28</remarks>
        public bool Update(TemplateActivityexdetailEntity entity, DbTransaction trans)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_TemplateActivityexdetail_Update");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx);
            database.AddInParameter(commandWrapper, "@ExcitingId", DbType.Int32, entity.ExcitingId);
            database.AddInParameter(commandWrapper, "@GroupId", DbType.Int32, entity.GroupId);
            database.AddInParameter(commandWrapper, "@ExStep", DbType.Int32, entity.ExStep);
            database.AddInParameter(commandWrapper, "@Count", DbType.Int32, entity.Count);
            database.AddInParameter(commandWrapper, "@Condition", DbType.Int32, entity.Condition);
            database.AddInParameter(commandWrapper, "@ConditionSub", DbType.Int32, entity.ConditionSub);
            database.AddInParameter(commandWrapper, "@EffectType", DbType.Int32, entity.EffectType);
            database.AddInParameter(commandWrapper, "@EffectRate", DbType.Int32, entity.EffectRate);
            database.AddInParameter(commandWrapper, "@EffectValue", DbType.Int32, entity.EffectValue);


            int results = 0;

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


            return(Convert.ToBoolean(results));
        }
Exemplo n.º 2
0
        MessageCode Receive()
        {
            var exRecord = new ActivityexCountrecordEntity();

            exRecord.Idx              = 1;
            exRecord.ZoneActivityId   = 19;
            exRecord.ExcitingId       = 32;
            exRecord.GroupId          = 2;
            exRecord.ExData           = 6000;
            exRecord.CurData          = 6000;
            exRecord.ExStep           = 1;
            exRecord.AlreadySendCount = 0;

            var detail         = new TemplateActivityexdetailEntity(105, 32, 2, 1, 5000, 0, 0, 0, 1, 310161);
            int prizeItemcode  = detail.EffectValue;
            int prizeItemCount = exRecord.ExData - exRecord.AlreadySendCount;
            int itemCount      = 0;
            var group          = new TemplateActivityexgroupEntity(103, 32, 2, 1, 108, 3, false, 0, 5000);

            if (group.ExRequireId == (int)EnumActivityExRequire.ChargeCount) //充值计数
            {
                itemCount = prizeItemCount / group.RankCount;
                exRecord.AlreadySendCount += (itemCount * group.RankCount);
                if (detail.EffectRate > 0)
                {
                    prizeItemCount = itemCount * detail.EffectRate;
                }
            }
            else
            {
                exRecord.AlreadySendCount += prizeItemCount;
            }
            MessageCode           code           = MessageCode.Success;
            ItemPackageFrame      package        = null;
            ScoutingGoldbarEntity goldBarManager = null;
            bool isInsert = false;

            if (prizeItemcode > 10000) //物品
            {
                package = ItemCore.Instance.GetPackage(new Guid("A995C3B5-4CA2-4348-A1B0-A60E013163A5"), EnumTransactionType.ActivityExPrize);
                if (package == null || package.PackageSize < prizeItemCount)
                {
                    return(MessageCode.ItemPackageFull);
                }
                code = package.AddItems(prizeItemcode, prizeItemCount);
                if (code != MessageCode.Success)
                {
                    return(code);
                }
            }
            return(MessageCode.Success);
        }
        /// <summary>
        /// 将IDataReader的当前记录读取到TemplateActivityexdetailEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public TemplateActivityexdetailEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new TemplateActivityexdetailEntity();

            obj.Idx          = (System.Int32)reader["Idx"];
            obj.ExcitingId   = (System.Int32)reader["ExcitingId"];
            obj.GroupId      = (System.Int32)reader["GroupId"];
            obj.ExStep       = (System.Int32)reader["ExStep"];
            obj.Count        = (System.Int32)reader["Count"];
            obj.Condition    = (System.Int32)reader["Condition"];
            obj.ConditionSub = (System.Int32)reader["ConditionSub"];
            obj.EffectType   = (System.Int32)reader["EffectType"];
            obj.EffectRate   = (System.Int32)reader["EffectRate"];
            obj.EffectValue  = (System.Int32)reader["EffectValue"];

            return(obj);
        }
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="idx">idx</param>
        /// <returns>TemplateActivityexdetailEntity</returns>
        /// <remarks>2016/3/11 15:09:28</remarks>
        public TemplateActivityexdetailEntity GetById(System.Int32 idx)
        {
            var database = new SqlDatabase(this.ConnectionString);

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

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


            TemplateActivityexdetailEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
        public static bool Update(TemplateActivityexdetailEntity templateActivityexdetailEntity, DbTransaction trans = null)
        {
            var provider = new TemplateActivityexdetailProvider();

            return(provider.Update(templateActivityexdetailEntity, trans));
        }
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 /// <remarks>2016/3/11 15:09:28</remarks>
 public bool Update(TemplateActivityexdetailEntity entity)
 {
     return(Update(entity, null));
 }
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="trans">The trans.</param>
 /// <returns></returns>
 /// <remarks>2016/3/11 15:09:28</remarks>
 public bool Insert(TemplateActivityexdetailEntity entity)
 {
     return(Insert(entity, null));
 }