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, "操作失败");
            }
        }
Exemple #2
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();
            }
        }