/// <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.PrizeTicket(); } 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, "操作失败", "系统提示"); } }
/// <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(); } }
private void Bind() { //查询条件 GetSearchItem(); int totalCount = 0; if (bll == null) { bll = new BLL.PrizeTicket(); } rpData.DataSource = bll.GetDataSet(AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalCount, sqlWhere, parms == null ? null : parms.ToArray());; rpData.DataBind(); AspNetPager1.RecordCount = totalCount; }
/// <summary> /// 获取当前区间数据行的数据列表 /// </summary> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public static List <Model.PrizeTicket> GetList(int pageIndex, int pageSize) { BLL.PrizeTicket bll = new BLL.PrizeTicket(); if (!enableCaching) { return(bll.GetList(pageIndex, pageSize, "", null)); } string key = "prizeTicket_" + pageIndex + "_" + pageSize + ""; List <Model.PrizeTicket> data = (List <Model.PrizeTicket>)HttpRuntime.Cache[key]; if (data == null) { data = bll.GetList(pageIndex, pageSize, "", null); AggregateCacheDependency cd = DependencyFactory.GetUserTicketDependency(); HttpRuntime.Cache.Add(key, data, cd, DateTime.Now.AddHours(userTicketTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null); } return(data); }
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; } } }
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() { Guid categoryId = Guid.Empty; string sCategory = txtCategory.Value.Trim(); if (!string.IsNullOrEmpty(sCategory)) { if (!Guid.TryParse(sCategory, out categoryId)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "所属分类ID格式不正确,请检查", "错误提醒", "error"); return; } } string sName = txtName.Value.Trim(); if (string.IsNullOrEmpty(sName)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "名称不能为空,请检查", "错误提醒", "error"); return; } string sPieceNum = txtPieceNum.Value.Trim(); if (string.IsNullOrEmpty(sPieceNum)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "棋子数不能为空,请检查", "错误提醒", "error"); return; } decimal pointNum = 0; if (!decimal.TryParse(sPieceNum, out pointNum)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "棋子数输入格式不正确,请检查", "错误提醒", "error"); return; } string sImageUrl = txtImageUrl.Value.Trim(); if (string.IsNullOrEmpty(sImageUrl)) { WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "图片不能为空,请检查", "错误提醒", "error"); return; } string sPNum = txtPNum.Value.Trim(); string sStockNum = txtStock.Value.Trim(); int stockNum = 0; if (!string.IsNullOrEmpty(sStockNum)) { Int32.TryParse(sStockNum, out stockNum); } if (bll == null) { bll = new BLL.PrizeTicket(); } Model.PrizeTicket model = new Model.PrizeTicket(); model.CategoryID = categoryId; model.TicketName = sName; model.PointNum = pointNum; model.ImageUrl = sImageUrl; model.LastUpdatedDate = DateTime.Now; model.PNum = sPNum; model.StockNum = stockNum; model.TicketDescr = txtDescr.Value.Trim(); model.FlowDescr = txtFlow.Value.Trim(); 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, "操作失败"); } }