Exemple #1
0
        private void OnSave()
        {
            string sUser = cbbUser.Value.Trim();

            if (string.IsNullOrEmpty(sUser))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "用户为必选项,请检查", "错误提醒", "error");
                return;
            }
            string sPoint = txtPoint.Value.Trim();

            if (string.IsNullOrEmpty(sPoint))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "棋子数不能为空,请检查", "错误提醒", "error");
                return;
            }

            decimal pointNum = 0;

            if (!decimal.TryParse(sPoint, out pointNum))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "棋子数输入格式不正确,请检查", "错误提醒", "error");
                return;
            }

            if (bll == null)
            {
                bll = new BLL.UserPoint();
            }
            Model.UserPoint model = new Model.UserPoint();
            model.UserID          = sUser;
            model.PointNum        = pointNum;
            model.LastUpdatedDate = DateTime.Now;

            int effectCount = -1;

            if (!string.IsNullOrEmpty(nId))
            {
                model.NumberID = nId;
                effectCount    = bll.Update(model);
            }
            else
            {
                effectCount = bll.Insert(model);
            }

            if (effectCount == 110)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "已存在相同记录", "温馨提醒", "error");
                return;
            }
            if (effectCount > 0)
            {
                WebHelper.MessageBox.MessagerShow(this.Page, lbtnPostBack, "操作成功");
            }
            else
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "操作失败");
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        private void OnDelete()
        {
            string itemsAppend = hV.Value.Trim();

            if (string.IsNullOrEmpty(itemsAppend))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "请至少勾选一行进行操作", "错误提醒", "error");
                return;
            }

            if (bll == null)
            {
                bll = new BLL.UserPoint();
            }
            string[]      itemsAppendArr = itemsAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <string> list           = itemsAppendArr.ToList <string>();

            if (bll.DeleteBatch(list))
            {
                WebHelper.MessageBox.MessagerShow(this.Page, lbtnPostBack, "操作成功");
                Bind();
            }
            else
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "操作失败", "系统提示");
            }
        }
Exemple #3
0
 private void Bind()
 {
     if (!string.IsNullOrEmpty(nId))
     {
         if (bll == null)
         {
             bll = new BLL.UserPoint();
         }
         Model.UserPoint model = bll.GetModel(nId);
         if (model != null)
         {
             cbbUser.Value  = model.UserID.ToString();
             txtPoint.Value = model.PointNum.ToString();
         }
     }
 }
        private void Bind()
        {
            //查询条件
            GetSearchItem();

            int totalCount = 0;

            if (bll == null)
            {
                bll = new BLL.UserPoint();
            }

            rpData.DataSource = bll.GetDataSet(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount, sqlWhere, parms == null ? null : parms.ToArray());;
            rpData.DataBind();
            AspNetPager1.RecordCount = totalCount;
        }
        private void Bind()
        {
            decimal pointNum = 0;

            BLL.UserPoint   uBll   = new BLL.UserPoint();
            Model.UserPoint uModel = uBll.GetModelByUser(WebHelper.Common.GetUserId());
            if (uModel != null)
            {
                pointNum = uModel.PointNum;
            }
            Label lbMyPoint = lvUser.FindControl("lbMyPoint") as Label;

            if (lbMyPoint != null)
            {
                lbMyPoint.Text = pointNum.ToString("N");
            }
        }
Exemple #6
0
        /// <summary>
        /// 启用多线程操作
        /// </summary>
        public override void ThreadWork()
        {
            base.IsBackground = true;

            BLL.UserPoint bll = new BLL.UserPoint();

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                Model.UserPoint uModel = bll.GetModelByUser(this.model.UserID);
                if (uModel != null)
                {
                    bll.Update(this.model);
                }
                else
                {
                    bll.Insert(model);
                }

                scope.Complete();
            }
        }
        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;
                }
            }
        }
        private void OnSave()
        {
            string sItemAppend = hItemAppend.Value.Trim();

            if (string.IsNullOrEmpty(sItemAppend))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "投注项不能为空", "错误提示");
                return;
            }

            string[] items = sItemAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (items.Length < 1)
            {
                return;
            }

            BLL.RunLottery rlBll = new BLL.RunLottery();

            Model.RunLottery rlModel = rlBll.GetModel(nId);
            if (rlModel == null)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "不存在的开奖期,非法操作", "错误提示");
                return;
            }

            DateTime runDate = rlModel.RunDate;
            TimeSpan ts      = runDate - DateTime.Now;

            if ((ts.TotalMilliseconds - 8000) < 0)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "当前第" + rlModel.Period + "期,已停止投注", "温馨提示");
                return;
            }

            string[] itemArr = items[0].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);

            int totalBetNum = Int32.Parse(itemArr[1]);

            if (totalBetNum <= 0)
            {
                return;
            }

            object userId = WebHelper.Common.GetUserId();

            //获取当前用户的棋子数
            BLL.UserPoint   uBll   = new BLL.UserPoint();
            Model.UserPoint uModel = uBll.GetModelByUser(userId);
            if (uModel == null)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "您的棋子数不足,不能进行投注!", "系统提示");
                return;
            }

            if ((uModel.PointNum - totalBetNum) < 0)
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "您的棋子数不足,不能进行投注!", "系统提示");
                return;
            }

            string itemAppend   = string.Empty;
            string betNumAppend = string.Empty;
            int    index        = 0;

            foreach (string s in items)
            {
                index++;
                if (index > 1)
                {
                    string[] nvArr = s.Split('|');
                    itemAppend   += nvArr[0] + ",";
                    betNumAppend += nvArr[1] + ",";
                }
            }

            BLL.Order            ublBll   = new BLL.Order();
            Model.UserBetLottery ublModel = new Model.UserBetLottery();
            ublModel.LastUpdatedDate = DateTime.Now;
            ublModel.UserID          = userId;
            ublModel.RunLotteryID    = rlModel.NumberID;
            ublModel.TotalPointNum   = totalBetNum;
            ublModel.ItemAppend      = itemAppend.Trim(',');
            ublModel.BetNumAppend    = betNumAppend.Trim(',');
            ublModel.WinPointNum     = 0;

            int effectCount = -1;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                uModel.PointNum = uModel.PointNum - totalBetNum;
                if (uBll.Update(uModel) > 0)
                {
                    ublBll.Insert(ublModel);
                    effectCount = 1;
                }

                scope.Complete();
            }

            if (effectCount > 0)
            {
                WebHelper.MessageBox.Show(this.Page, lbtnSave, "当前第" + rlModel.Period + "期,投注成功!", Request.Url.ToString());
            }
            else
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnSave, "当前第" + rlModel.Period + "期,投注失败,请检查", "系统提示");
            }
        }