/// <summary> /// 立即兑换按钮点击事件 /// 作者:姚东 /// 时间:20101015 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnExchange_Click(object sender, EventArgs e) { ////判断会员是否登录系统了 //if (Session["UserGUID"] == null) //{ // PageHelper.ShowExceptionMessage("登录系统后才能进行礼品兑换!"); // return; //} BLL.Entity.GiftsEntity giftEntity = new BLL.Entity.GiftsEntity(GiftGuid); BLL.Entity.PointEntity pointEntity = new BLL.Entity.PointEntity(Session["UserGUID"].ToString()); //判断剩余积分是否够兑换礼品 if (giftEntity.NeedPoint > pointEntity.RemainPoint) { PageHelper.ShowExceptionMessage(string.Format("您的余额为{0}个积分,兑换此礼品需要{1}个积分!", pointEntity.RemainPoint.ToString(), giftEntity.NeedPoint.ToString())); return; } //判断礼品余量是否够兑换 if (giftEntity.RemainAmount <= 0) { PageHelper.ShowExceptionMessage("暂时没有多余的礼品可被兑换,请稍后再试!"); return; } //更新兑换记录 BLL.Entity.ExchangeEntity exchangeEntity = new BLL.Entity.ExchangeEntity(); exchangeEntity.ApplyTime = DateTime.Now; exchangeEntity.GiftGuid = GiftGuid; exchangeEntity.HuiYuanGuid = Session["UserGUID"].ToString(); exchangeEntity.Memo = ""; exchangeEntity.Status = 1; exchangeEntity.UsedPoint = giftEntity.NeedPoint; ExchangeRule exchangeRule = new ExchangeRule(); exchangeRule.Add(exchangeEntity); //更新积分信息 pointEntity.RemainPoint = pointEntity.RemainPoint - giftEntity.NeedPoint; PointRule pointRule = new PointRule(); pointRule.Update(pointEntity); //更新礼品余量 giftEntity.RemainAmount -= 1; new GiftsRule().Update(giftEntity); PageHelper.ShowExceptionMessage("已发送兑换申请。"); }
public void ExchangeCancel(string id) { BLL.Entity.ExchangeEntity entity = new BLL.Entity.ExchangeEntity(NDConvert.ToInt32(id)); if (entity.Status == 2) { PageHelper.ShowExceptionMessage("该礼品已成功兑换,不能取消!"); return; } if (entity.Status == 3) { PageHelper.ShowExceptionMessage("该礼品已成功取消,不能重复取消!"); return; } if (entity.Status == 1) { entity.Status = 3; } //更新兑换记录的状态 BLL.Rule.ExchangeRule rule = new BLL.Rule.ExchangeRule(); rule.Update(entity); //更新会员积分 BLL.Entity.PointEntity pointEntity = new BLL.Entity.PointEntity(entity.HuiYuanGuid); pointEntity.RemainPoint += entity.UsedPoint; BLL.Rule.PointRule pointRule = new BLL.Rule.PointRule(); pointRule.Update(pointEntity); //更新礼品余量 BLL.Entity.GiftsEntity giftsEntity = new BLL.Entity.GiftsEntity(entity.GiftGuid); giftsEntity.RemainAmount += 1; new BLL.Rule.GiftsRule().Update(giftsEntity); _repeaterSelect.JumpPageCtl(_repeaterSelect._gridJump.SelectedValue); }