예제 #1
0
        /// <summary>
        /// 绑定奖品列表
        /// </summary>
        private void BindTicket()
        {
            if (!string.IsNullOrEmpty(nId))
            {
                BLL.PrizeTicket          ptBll = new BLL.PrizeTicket();
                Model.PrizeTicket        model = ptBll.GetModel(nId);
                List <Model.PrizeTicket> list  = new List <Model.PrizeTicket>();
                list.Add(model);

                rpData.DataSource = list;
                rpData.DataBind();
            }
        }
예제 #2
0
 private void Bind()
 {
     if (!string.IsNullOrEmpty(nId))
     {
         if (bll == null)
         {
             bll = new BLL.PrizeTicket();
         }
         Model.PrizeTicket model = bll.GetModel(nId);
         if (model != null)
         {
             txtCategory.Value = model.CategoryID.ToString();
             txtName.Value     = model.TicketName;
             txtPieceNum.Value = model.PointNum.ToString();
             txtImageUrl.Value = model.ImageUrl;
             txtPNum.Value     = model.PNum;
             txtStock.Value    = model.StockNum.ToString();
             txtDescr.Value    = model.TicketDescr;
             txtFlow.Value     = model.FlowDescr;
         }
     }
 }
예제 #3
0
        private void OnSave(object nId)
        {
            BLL.PrizeTicket   ptBll   = new BLL.PrizeTicket();
            Model.PrizeTicket ptModel = ptBll.GetModel(nId.ToString());
            if (ptModel == null)
            {
                WebHelper.MessageBox.Messager(this.Page, rpData.Controls[0], "没有找到相关奖品");
                return;
            }

            decimal pointNum = ptModel.PointNum;

            BLL.UserPoint uBll     = new BLL.UserPoint();
            object        userId   = WebHelper.Common.GetUserId();
            DateTime      currTime = DateTime.Now;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                Model.UserPoint uModel = uBll.GetModelByUser(userId);
                if (uModel == null)
                {
                    WebHelper.MessageBox.Messager(this.Page, rpData.Controls[0], "您的棋子数额不足,无法兑换");
                    return;
                }
                decimal userPointNum = uModel.PointNum;
                decimal currPointNum = userPointNum - pointNum;
                if (currPointNum < 0)
                {
                    WebHelper.MessageBox.Messager(this.Page, rpData.Controls[0], "您的棋子数额不足,无法兑换");
                    return;
                }

                Model.UserTicket utModel = new Model.UserTicket();
                utModel.PrizeTicketID   = ptModel.NumberID;
                utModel.UserID          = userId;
                utModel.Status          = 0;
                utModel.LastUpdatedDate = currTime;

                BLL.UserTicket utBll = new BLL.UserTicket();
                if (utBll.Insert(utModel) > 0)
                {
                    uModel.PointNum        = currPointNum;
                    uModel.LastUpdatedDate = currTime;

                    if (uBll.Update(uModel) > 0)
                    {
                        //操作成功,提交事务
                        scope.Complete();

                        Response.Redirect("/u/ta.html");
                    }
                    else
                    {
                        WebHelper.MessageBox.Messager(this.Page, rpData.Controls[0], "奖品兑换失败,无法兑换", "系统异常");
                        return;
                    }
                }
                else
                {
                    WebHelper.MessageBox.Messager(this.Page, rpData.Controls[0], "奖品兑换失败,无法兑换", "系统异常");
                    return;
                }
            }
        }