Example #1
0
 public int InsertPrize(GameActPrizeInfo prize)
 {
     try
     {
         DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO [Hishop_Game_Prize]([GameId],[PrizeName],[sort],[PrizeType],[GrivePoint],[PointNumber],[PointRate],[GiveCouponId],[CouponNumber],[CouponRate],[GiveProductId],[ProductNumber],[ProductRate])VALUES(@GameId,@PrizeName,@sort,@PrizeType,@GrivePoint,@PointNumber ,@PointRate,@GiveCouponId,@CouponNumber,@CouponRate,@GiveProductId,@ProductNumber,@ProductRate)  SELECT CAST(scope_identity() AS int)");
         this.database.AddInParameter(sqlStringCommand, "GameId", DbType.Int32, prize.GameId);
         this.database.AddInParameter(sqlStringCommand, "PrizeName", DbType.String, prize.PrizeName);
         this.database.AddInParameter(sqlStringCommand, "sort", DbType.Int32, prize.sort);
         this.database.AddInParameter(sqlStringCommand, "PrizeType", DbType.Int64, (long)prize.PrizeType);
         this.database.AddInParameter(sqlStringCommand, "GrivePoint", DbType.Int32, prize.GrivePoint);
         this.database.AddInParameter(sqlStringCommand, "PointNumber", DbType.Int32, prize.PointNumber);
         this.database.AddInParameter(sqlStringCommand, "PointRate", DbType.Decimal, prize.PointRate);
         this.database.AddInParameter(sqlStringCommand, "GiveCouponId", DbType.Int32, prize.GiveCouponId);
         this.database.AddInParameter(sqlStringCommand, "CouponNumber", DbType.Int32, prize.CouponNumber);
         this.database.AddInParameter(sqlStringCommand, "CouponRate", DbType.Decimal, prize.CouponRate);
         this.database.AddInParameter(sqlStringCommand, "GiveProductId", DbType.Int32, prize.GiveProductId);
         this.database.AddInParameter(sqlStringCommand, "ProductNumber", DbType.Int32, prize.ProductNumber);
         this.database.AddInParameter(sqlStringCommand, "ProductRate", DbType.Decimal, prize.ProductRate);
         return((int)this.database.ExecuteScalar(sqlStringCommand));
     }
     catch (Exception)
     {
         return(0);
     }
 }
Example #2
0
        public GameActPrizeInfo GetPrize(int gameId, int prizeId)
        {
            GameActPrizeInfo result = null;

            System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("SELECT * FROM Hishop_Game_Prize  where [GameID]= @GameID and [ID] = @ID");
            this.database.AddInParameter(sqlStringCommand, "GameID", System.Data.DbType.Int32, gameId);
            this.database.AddInParameter(sqlStringCommand, "ID", System.Data.DbType.Int32, prizeId);
            using (System.Data.IDataReader dataReader = this.database.ExecuteReader(sqlStringCommand))
            {
                result = ReaderConvert.ReaderToModel <GameActPrizeInfo>(dataReader);
            }
            return(result);
        }
Example #3
0
 public bool UpdatePrize(GameActPrizeInfo prize)
 {
     System.Data.Common.DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE [Hishop_Game_Prize]   SET [GameId] = @GameId , [PrizeName] = @PrizeName , [sort] = @sort , [PrizeType] = @PrizeType , [GrivePoint] = @GrivePoint , [PointNumber] = @PointNumber , [PointRate] = @PointRate , [GiveCouponId] = @GiveCouponId , [CouponNumber] = @CouponNumber , [CouponRate] = @CouponRate , [GiveProductId] = @GiveProductId , [ProductNumber] = @ProductNumber , [ProductRate] = @ProductRate  where [GameId]= @GameId and [Id] = @Id");
     this.database.AddInParameter(sqlStringCommand, "GameId", System.Data.DbType.Int32, prize.GameId);
     this.database.AddInParameter(sqlStringCommand, "Id", System.Data.DbType.Int32, prize.Id);
     this.database.AddInParameter(sqlStringCommand, "PrizeName", System.Data.DbType.String, prize.PrizeName);
     this.database.AddInParameter(sqlStringCommand, "sort", System.Data.DbType.Int32, prize.sort);
     this.database.AddInParameter(sqlStringCommand, "PrizeType", System.Data.DbType.Int64, (long)prize.PrizeType);
     this.database.AddInParameter(sqlStringCommand, "GrivePoint", System.Data.DbType.Int32, prize.GrivePoint);
     this.database.AddInParameter(sqlStringCommand, "PointNumber", System.Data.DbType.Int32, prize.PointNumber);
     this.database.AddInParameter(sqlStringCommand, "PointRate", System.Data.DbType.Decimal, prize.PointRate);
     this.database.AddInParameter(sqlStringCommand, "GiveCouponId", System.Data.DbType.Int32, prize.GiveCouponId);
     this.database.AddInParameter(sqlStringCommand, "CouponNumber", System.Data.DbType.Int32, prize.CouponNumber);
     this.database.AddInParameter(sqlStringCommand, "CouponRate", System.Data.DbType.Decimal, prize.CouponRate);
     this.database.AddInParameter(sqlStringCommand, "GiveProductId", System.Data.DbType.Int32, prize.GiveProductId);
     this.database.AddInParameter(sqlStringCommand, "ProductNumber", System.Data.DbType.Int32, prize.ProductNumber);
     this.database.AddInParameter(sqlStringCommand, "ProductRate", System.Data.DbType.Decimal, prize.ProductRate);
     return(this.database.ExecuteNonQuery(sqlStringCommand) > 0);
 }
Example #4
0
 protected void save_Step3_Click(object sender, EventArgs e)
 {
     try
     {
         string str = this.txt_json.Text.Trim();
         if (str.Length <= 0)
         {
             this.ShowMsg("请设定奖品信息!", false);
         }
         else
         {
             List <GameActPrizeInfo> list = new List <GameActPrizeInfo>();
             JArray  array = (JArray)JsonConvert.DeserializeObject(str);
             decimal num   = 0M;
             if (array.Count > 0)
             {
                 for (int i = 0; i < array.Count; i++)
                 {
                     GameActPrizeInfo item = new GameActPrizeInfo();
                     int prizeId           = int.Parse(array[i]["prizeId"].ToString());
                     if (prizeId != 0)
                     {
                         item = GameActHelper.GetPrize(_gameId, prizeId);
                     }
                     else
                     {
                         item.Id = 0;
                     }
                     item.PrizeName     = array[i]["prizeName"].ToString();
                     item.PrizeType     = (ePrizeType)int.Parse(array[i]["prizeType"].ToString());
                     item.GrivePoint    = int.Parse(array[i]["point"].ToString());
                     item.PointNumber   = int.Parse(array[i]["pointNumber"].ToString());
                     item.PointRate     = int.Parse(array[i]["pointRate"].ToString());
                     item.GiveCouponId  = int.Parse(array[i]["coupon"].ToString());
                     item.CouponNumber  = int.Parse(array[i]["couponNumber"].ToString());
                     item.CouponRate    = int.Parse(array[i]["couponRate"].ToString());
                     item.GiveProductId = int.Parse(array[i]["product"].ToString());
                     item.ProductNumber = int.Parse(array[i]["productNumber"].ToString());
                     item.ProductRate   = int.Parse(array[i]["productRate"].ToString());
                     item.sort          = i + 1;
                     item.GameId        = _gameId;
                     num += (item.PointRate + item.CouponRate) + item.ProductRate;
                     list.Add(item);
                 }
             }
             if (num > 100M)
             {
                 this.ShowMsg("中奖率总和不能大于100!", false);
             }
             else
             {
                 foreach (GameActPrizeInfo info2 in list)
                 {
                     if (info2.Id != 0)
                     {
                         GameActHelper.UpdatePrize(info2);
                     }
                     else
                     {
                         GameActHelper.InsertPrize(info2);
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
         this.ShowMsg("保存奖品失败!", false);
     }
 }
Example #5
0
 public static bool UpdatePrize(GameActPrizeInfo prize)
 {
     return(_game.UpdatePrize(prize));
 }
Example #6
0
 public static int InsertPrize(GameActPrizeInfo prize)
 {
     return(_game.InsertPrize(prize));
 }
Example #7
0
 protected void save_Step3_Click(object sender, System.EventArgs e)
 {
     try
     {
         string text = this.txt_json.Text.Trim();
         if (text.Length <= 0)
         {
             this.ShowMsg("请设定奖品信息!", false);
         }
         else
         {
             System.Collections.Generic.List <GameActPrizeInfo> list = new System.Collections.Generic.List <GameActPrizeInfo>();
             JArray  jArray = (JArray)JsonConvert.DeserializeObject(text);
             decimal d      = 0m;
             if (jArray.Count > 0)
             {
                 for (int i = 0; i < jArray.Count; i++)
                 {
                     GameActPrizeInfo gameActPrizeInfo = new GameActPrizeInfo();
                     int num = int.Parse(jArray[i]["prizeId"].ToString());
                     if (num != 0)
                     {
                         gameActPrizeInfo = GameActHelper.GetPrize(AddGameAct._gameId, num);
                     }
                     else
                     {
                         gameActPrizeInfo.Id = 0;
                     }
                     gameActPrizeInfo.PrizeName     = jArray[i]["prizeName"].ToString();
                     gameActPrizeInfo.PrizeType     = (ePrizeType)int.Parse(jArray[i]["prizeType"].ToString());
                     gameActPrizeInfo.GrivePoint    = int.Parse(jArray[i]["point"].ToString());
                     gameActPrizeInfo.PointNumber   = int.Parse(jArray[i]["pointNumber"].ToString());
                     gameActPrizeInfo.PointRate     = int.Parse(jArray[i]["pointRate"].ToString());
                     gameActPrizeInfo.GiveCouponId  = int.Parse(jArray[i]["coupon"].ToString());
                     gameActPrizeInfo.CouponNumber  = int.Parse(jArray[i]["couponNumber"].ToString());
                     gameActPrizeInfo.CouponRate    = int.Parse(jArray[i]["couponRate"].ToString());
                     gameActPrizeInfo.GiveProductId = int.Parse(jArray[i]["product"].ToString());
                     gameActPrizeInfo.ProductNumber = int.Parse(jArray[i]["productNumber"].ToString());
                     gameActPrizeInfo.ProductRate   = int.Parse(jArray[i]["productRate"].ToString());
                     gameActPrizeInfo.sort          = i + 1;
                     gameActPrizeInfo.GameId        = AddGameAct._gameId;
                     d += gameActPrizeInfo.PointRate + gameActPrizeInfo.CouponRate + gameActPrizeInfo.ProductRate;
                     list.Add(gameActPrizeInfo);
                 }
             }
             if (d > 100m)
             {
                 this.ShowMsg("中奖率总和不能大于100!", false);
             }
             else
             {
                 foreach (GameActPrizeInfo current in list)
                 {
                     if (current.Id != 0)
                     {
                         GameActHelper.UpdatePrize(current);
                     }
                     else
                     {
                         GameActHelper.InsertPrize(current);
                     }
                 }
             }
         }
     }
     catch (System.Exception)
     {
         this.ShowMsg("保存奖品失败!", false);
     }
 }