protected void btnEnd_Click(object sender, EventArgs e) { try { DateTime date = DateTime.Now; int matchId = ConvertHelper.ConvertToInt(txtMatchId.Text.Trim()); int homeGoals = ConvertHelper.ConvertToInt(txtHomeGoals.Text.Trim()); int awayGoals = ConvertHelper.ConvertToInt(txtAwayGoals.Text.Trim()); if (matchId == 0) { ShowMessage("比赛ID不能为0"); return; } var match = EuropeMatchMgr.GetById(matchId); if (match == null) { ShowMessage("没有找到比赛"); return; } //if (match.MatchTime.AddHours(2) > date) //{ // ShowMessage("开始时间不足两小时"); // return; //} if (match.States != (int)EnumEuropeStatus.MatchIng) { ShowMessage("比赛还未开始"); return; } match.HomeGoals = homeGoals; match.AwayGoals = awayGoals; if (homeGoals > awayGoals) { match.ResultType = 1; } else if (homeGoals < awayGoals) { match.ResultType = 3; } else { match.ResultType = 2; } match.States = (int)EnumEuropeStatus.MatchEnd; if (!EuropeMatchMgr.Update(match)) { ShowMessage("更新失败"); return; } BindData(); ShowMessage("成功"); } catch (Exception ex) { ShowMessage("失败:" + ex.ToString()); } txtMatchId.Text = ""; txtHomeGoals.Text = ""; txtAwayGoals.Text = ""; }
public void SendPrize(int matchId, string zoneId) { DateTime date = DateTime.Now; var match = EuropeMatchMgr.GetById(matchId); var _season = EuropeSeasonMgr.GetSeason(date, zoneId); if (match == null) { return; } var season = EuropeSeasonMgr.GetSeason(date, zoneId); //获取未发奖的竞猜 var sendPrizeList = EuropeGamblerecordMgr.GetNotPrize(matchId, zoneId); foreach (var item in sendPrizeList) { if (item.IsSendPrize) { continue; } item.IsSendPrize = true; item.UpdateTime = date; MailBuilder mail = null; EuropeGambleEntity gambleInfo = null; bool isInsertInfo = false; if (item.GambleType == match.ResultType) //竞猜正确 { item.IsGambleCorrect = true; item.ReturnPoint = item.Point * 2; //发邮件 mail = new MailBuilder(item.ManagerId, EnumMailType.Europe, item.ReturnPoint, match.HomeName, match.AwayName); gambleInfo = EuropeGambleMgr.GetById(item.ManagerId, zoneId); if (gambleInfo == null) { isInsertInfo = true; gambleInfo = new EuropeGambleEntity(item.ManagerId, 1, "0,0,0,0", date, date, season.Idx); } else { if (_season != null && gambleInfo.SeasonId != _season.Idx) { //插入记录 EuropeRecordMgr.Insert(new EuropeRecordEntity(0, gambleInfo.ManagerId, gambleInfo.SeasonId, gambleInfo.CorrectNumber, gambleInfo.PrizeRecord, date), null, zoneId); //更新活动 gambleInfo.CorrectNumber = 0; gambleInfo.PrizeRecord = "0,0,0,0"; gambleInfo.SeasonId = _season.Idx; } gambleInfo.CorrectNumber++; gambleInfo.UpdateTime = date; } } else { item.IsGambleCorrect = false; } MessageCode code = MessageCode.FailUpdate; if (mail != null) { if (!mail.Save(zoneId)) { ShowMessage("发送邮件失败"); return; } } if (gambleInfo != null) { if (isInsertInfo) { if (!EuropeGambleMgr.Insert(gambleInfo, null, zoneId)) { code = MessageCode.NbUpdateFail; } } else { if (!EuropeGambleMgr.Update(gambleInfo, null, zoneId)) { code = MessageCode.NbUpdateFail; } } } if (!EuropeGamblerecordMgr.Update(item, null, zoneId)) { code = MessageCode.NbUpdateFail; } if (code != MessageCode.Success) { ShowMessage("保存失败"); } } }