protected void gvBet_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var ltrlResult = e.Row.FindControl("ltrlResult") as Literal; var ltrlBetRate = e.Row.FindControl("ltrlBetRate") as Literal; var ltrlBonusCalc = e.Row.FindControl("ltrlBonusCalc") as Literal; if (ltrlResult != null && ltrlBetRate != null && ltrlBonusCalc != null) { var bet = e.Row.DataItem as Bet; if (bet != null) { var item = CasinoItem.GetCasinoItem(bet.CasinoItemGuid); switch (item.ItemType) { case CasinoType.SingleChoice: var dt = BetDetail.GetBetDetailByBetId(bet.ID); foreach (DataRow dr in dt.Rows) { if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue) { ltrlResult.Text = "主队胜"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue) { ltrlResult.Text = "双方平"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue) { ltrlResult.Text = "客队胜"; } } break; case CasinoType.MatchResult: var matchResult = new MatchResultBetDetail(BetDetail.GetBetDetailByBetId(bet.ID)); ltrlResult.Text = $"{matchResult.Home} : {matchResult.Away}"; break; } } if (bet?.BetRate != null) { ltrlBetRate.Text = Convert.ToSingle(bet.BetRate).ToString("f2"); ltrlBonusCalc.Text = "+" + ((Convert.ToSingle(bet.BetRate) - 1) * Convert.ToSingle(bet.BetAmount)) .ToString("N2"); } else { ltrlBetRate.Text = "/"; ltrlBonusCalc.Text = "RP+1"; } } } }
protected void btnMatchResult_Click(object sender, EventArgs e) { try { var guid = CasinoItem.GetCasinoItemGuidByMatch(CurrentMatch, CasinoType.MatchResult); if (guid.HasValue) { if (CasinoItem.GetCasinoItem(guid.Value).CloseTime < DateTime.Now) { throw new Exception("已超出投注截止时间"); } if (Bet.GetUserCasinoItemAllBet(userid, guid.Value).Count > 0) { throw new Exception("已经投过此注,不能重复猜比分"); } var bet = new Bet { BetAmount = null, BetRate = null, CasinoItemGuid = guid.Value, UserID = userid, UserName = username }; var matchResult = new MatchResultBetDetail { Home = Convert.ToInt16(tbHome.Text), Away = Convert.ToInt16(tbAway.Text) }; bet.Insert(matchResult); ClientScript.RegisterClientScriptBlock(typeof(string), "succeed", "alert('投注成功'); window.location.href = window.location.href;", true); } } catch (Exception ex) { ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}')", true); } }
protected void gvBetLog_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var drv = e.Row.DataItem as DataRowView; if (drv != null) { var m = new Match((Guid)drv["MatchGuid"]); var hlHome = e.Row.FindControl("hlHome") as HyperLink; var hlAway = e.Row.FindControl("hlAway") as HyperLink; var hlVersus = e.Row.FindControl("hlVersus") as HyperLink; if (hlHome != null && hlAway != null && hlVersus != null) { var tHome = Team.Cache.Load(m.Home); var tAway = Team.Cache.Load(m.Away); hlHome.Text = tHome.TeamDisplayName; hlHome.NavigateUrl = $"CasinoTeam.aspx?Team={m.Home}"; hlAway.Text = tAway.TeamDisplayName; hlAway.NavigateUrl = $"CasinoTeam.aspx?Team={m.Away}"; hlVersus.NavigateUrl = $"CasinoTeam.aspx?Match={m.MatchGuid}"; hlVersus.Text = $"<em title=\"{tHome.Ground}{(tHome.Capacity.HasValue ? ("(" + tHome.Capacity.Value + ")") : string.Empty)}\">vs</em>"; } } var ltrlResult = e.Row.FindControl("ltrlResult") as Literal; var ltrlBetResult = e.Row.FindControl("ltrlBetResult") as Literal; var ltrlBetRate = e.Row.FindControl("ltrlBetRate") as Literal; var btnReturnBet = e.Row.FindControl("btnReturnBet") as LinkButton; if (drv != null && ltrlResult != null && ltrlBetResult != null && ltrlBetRate != null && btnReturnBet != null) { var itemGuid = (Guid)drv["CasinoItemGuid"]; var item = CasinoItem.GetCasinoItem(itemGuid); var dt = BetDetail.GetBetDetailByBetId((int)drv["ID"]); if (dt != null) { var dr = dt.Rows[0]; switch (item.ItemType) { case CasinoType.SingleChoice: if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue) { ltrlResult.Text = "主队胜"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue) { ltrlResult.Text = "双方平"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue) { ltrlResult.Text = "客队胜"; } break; case CasinoType.MatchResult: var betDetail = new MatchResultBetDetail(dt); ltrlResult.Text = $"{betDetail.Home}:{betDetail.Away}"; break; } } if (!Convert.IsDBNull(drv["IsWin"])) { ltrlBetResult.Visible = true; btnReturnBet.Visible = false; if (Convert.ToBoolean(drv["IsWin"])) { if (item.ItemType == CasinoType.SingleChoice) { ltrlBetResult.Text = "<span class=\"CasinoSys_True\" title=\"猜对输赢\"></span>"; } else if (item.ItemType == CasinoType.MatchResult) { ltrlBetResult.Text = "<span class=\"CasinoSys_Good\" title=\"猜对比分\"></span>"; } e.Row.CssClass = "RowCasinoSys_True"; } else { ltrlBetResult.Text = "<span class=\"CasinoSys_False\" title=\"失败\"></span>"; } } else if (Convert.IsDBNull(drv["IsWin"]) && (CurrentUserId == userid) && (item.CloseTime > DateTime.Now)) { btnReturnBet.Visible = true; btnReturnBet.CommandArgument = drv["ID"].ToString(); } else { ltrlBetResult.Visible = false; btnReturnBet.Visible = false; } } if (drv != null && ltrlBetRate != null) { ltrlBetRate.Text = Convert.IsDBNull(drv["BetRate"]) ? "/" : Convert.ToSingle(drv["BetRate"]).ToString("f2"); } } }
protected void gvBet_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var bet = e.Row.DataItem as Bet; if (bet != null) { var item = CasinoItem.GetCasinoItem(bet.CasinoItemGuid); var ltrlClub = e.Row.FindControl("ltrlClub") as Literal; if (ltrlClub != null) { var pathAcnClub = ConfigGlobal.PluginAcnClubPath; if ((!string.IsNullOrEmpty(pathAcnClub)) && (pathAcnClub != bool.FalseString.ToLower())) { var drClub = UserClub.GetUserClubHistoryInfo(bet.UserID, bet.BetTime); if ((drClub != null) && ((drClub["ClubUid"].ToString() == ddlClub.SelectedValue) || (ddlClub.SelectedValue == "0"))) { ltrlClub.Text = $"<a href=\"/{pathAcnClub}/ClubView.aspx?ClubID={drClub["ClubUid"]}\" target=\"_blank\">{drClub["ClubName"]}</a>"; } else if ((drClub == null) && (ddlClub.SelectedValue == "0")) { ltrlClub.Text = "/"; } else { e.Row.Visible = false; return; } } else { Response.Redirect($"CasinoBetLog.aspx?Match={CurrentMatch}"); } } var ltrlResult = e.Row.FindControl("ltrlResult") as Literal; var dt = BetDetail.GetBetDetailByBetId(bet.ID); if (dt != null && ltrlResult != null) { var dr = dt.Rows[0]; switch (item.ItemType) { case CasinoType.SingleChoice: if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue) { ltrlResult.Text = "主队胜"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue) { ltrlResult.Text = "双方平"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue) { ltrlResult.Text = "客队胜"; } break; case CasinoType.MatchResult: var betDetail = new MatchResultBetDetail(dt); ltrlResult.Text = $"{betDetail.Home}:{betDetail.Away}"; break; } } var ltrlBetResult = e.Row.FindControl("ltrlBetResult") as Literal; if (ltrlBetResult != null) { if (!bet.IsWin.HasValue) { ltrlBetResult.Text = string.Empty; } else { if (bet.IsWin.Value) { if (item.ItemType == CasinoType.SingleChoice) { ltrlBetResult.Text = "<span class=\"CasinoSys_True\" title=\"猜对输赢\"></span>"; } else if (item.ItemType == CasinoType.MatchResult) { ltrlBetResult.Text = "<span class=\"CasinoSys_Good\" title=\"猜对比分\"></span>"; } e.Row.CssClass = "RowCasinoSys_True"; } else { ltrlBetResult.Text = "<span class=\"CasinoSys_False\" title=\"失败\"></span>"; } } } } } }
protected void gvMatch_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var drv = e.Row.DataItem as DataRowView; if (drv != null) { var m = new Match((Guid)drv["MatchGuid"]); var ltrlLeagueInfo = e.Row.FindControl("ltrlLeagueInfo") as Literal; if (ltrlLeagueInfo != null) { var strLeague = "<a href=\"CasinoGame.aspx?League={0}\" title=\"{1}\"><img src=\"{2}\" alt=\"{1}\" class=\"CasinoSys_CategoryImg\" /></a>"; var strLeagueName = $"{m.LeagueName}{(m.Round.HasValue ? $" 第{m.Round}轮" : string.Empty)}"; ltrlLeagueInfo.Text = string.Format(strLeague, m.LeagueGuid, strLeagueName, League.Cache.Load(m.LeagueGuid).LeagueLogo); } var lblHome = e.Row.FindControl("lblHome") as Label; var lblAway = e.Row.FindControl("lblAway") as Label; var hlVersus = e.Row.FindControl("hlVersus") as HyperLink; if (lblHome != null && lblAway != null && hlVersus != null) { var tHome = Team.Cache.Load(m.Home); var tAway = Team.Cache.Load(m.Away); var strTeamName = "<a class=\"StrongLink\" href=\"CasinoTeam.aspx?Team={0}\" title=\"{1}\">{2}</a> "; var strTeamLogo = "<img src=\"{3}\" alt=\"{1}\" /> "; lblHome.Text = string.Format(strTeamName + strTeamLogo, tHome.ID, tHome.TeamEnglishName, tHome.TeamDisplayName, tHome.TeamLogo); lblAway.Text = string.Format(strTeamLogo + strTeamName, tAway.ID, tAway.TeamEnglishName, tAway.TeamDisplayName, tAway.TeamLogo); hlVersus.NavigateUrl = $"CasinoTeam.aspx?Match={m.MatchGuid}"; hlVersus.Text = $"<em title=\"{tHome.Ground}{(tHome.Capacity.HasValue ? ("(" + tHome.Capacity.Value + ")") : string.Empty)}\">vs</em>"; } var guid = CasinoItem.GetCasinoItemGuidByMatch(m.MatchGuid, CasinoType.SingleChoice); if (guid.HasValue) { var item = CasinoItem.GetCasinoItem(guid.Value); if (item != null) { var options = ((SingleChoice)item).Options; var winOption = options.Find(option => option.OptionValue == MatchChoiceOption.HomeWinValue); var drawOption = options.Find(option => option.OptionValue == MatchChoiceOption.DrawValue); var loseOption = options.Find(option => option.OptionValue == MatchChoiceOption.AwayWinValue); if (!string.IsNullOrEmpty(winOption.OptionValue) && !string.IsNullOrEmpty(drawOption.OptionValue) && !string.IsNullOrEmpty(loseOption.OptionValue) && winOption.OptionRate.HasValue && drawOption.OptionRate.HasValue && loseOption.OptionRate.HasValue) { var ltrlWinRate = e.Row.FindControl("ltrlWinRate") as Literal; var ltrlDrawRate = e.Row.FindControl("ltrlDrawRate") as Literal; var ltrlLoseRate = e.Row.FindControl("ltrlLoseRate") as Literal; if (ltrlWinRate != null) { ltrlWinRate.Text = Convert.ToSingle(winOption.OptionRate.Value).ToString("f2"); } if (ltrlDrawRate != null) { ltrlDrawRate.Text = Convert.ToSingle(drawOption.OptionRate.Value).ToString("f2"); } if (ltrlLoseRate != null) { ltrlLoseRate.Text = Convert.ToSingle(loseOption.OptionRate.Value).ToString("f2"); } } } } //bet for match result guid = CasinoItem.GetCasinoItemGuidByMatch(m.MatchGuid, CasinoType.MatchResult); if (guid.HasValue) { var item = CasinoItem.GetCasinoItem(guid.Value); if (item?.ItemGuid != null) { var bets = Bet.GetUserCasinoItemAllBet(userid, item.ItemGuid.Value); if (bets.Count != 0) { var betDetail = new MatchResultBetDetail(BetDetail.GetBetDetailByBetId(bets[0].ID)); var tbHomeScore = e.Row.FindControl("tbHomeScore") as TextBox; var tbAwayScore = e.Row.FindControl("tbAwayScore") as TextBox; if (tbHomeScore != null) { tbHomeScore.Text = betDetail.Home.ToString(); tbHomeScore.ReadOnly = true; tbHomeScore.Style.Add("border", "none"); tbHomeScore.Style.Add("font-weight", "bold"); tbHomeScore.Style.Add("background", "none"); tbHomeScore.Style.Add("color", "#aa0000"); } if (tbAwayScore != null) { tbAwayScore.Text = betDetail.Away.ToString(); tbAwayScore.ReadOnly = true; tbAwayScore.Style.Add("border", "none"); tbAwayScore.Style.Add("font-weight", "bold"); tbAwayScore.Style.Add("background", "none"); tbAwayScore.Style.Add("color", "#aa0000"); } } else { _itemAvailable = true; } } } } } }
protected void btnSubmit_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvMatch.Rows) { var tbHomeScore = row.FindControl("tbHomeScore") as TextBox; var tbAwayScore = row.FindControl("tbAwayScore") as TextBox; if (tbHomeScore != null && tbAwayScore != null && gvMatch.DataKeys[row.RowIndex] != null) { var matchGuid = (Guid)gvMatch.DataKeys[row.RowIndex].Value; var guid = CasinoItem.GetCasinoItemGuidByMatch(matchGuid, CasinoType.MatchResult); if (guid.HasValue) { var item = CasinoItem.GetCasinoItem(guid.Value); if (item?.ItemGuid != null) { short homeScore, awayScore; if (short.TryParse(tbHomeScore.Text, out homeScore) && short.TryParse(tbAwayScore.Text, out awayScore)) { //save if (CasinoItem.GetCasinoItem(guid.Value).CloseTime < DateTime.Now) { continue; } if (homeScore < 0 || awayScore < 0) { continue; } var bets = Bet.GetUserCasinoItemAllBet(userid, item.ItemGuid.Value); if (bets.Count > 0) { //already bet continue; } try { var bet = new Bet { BetAmount = null, BetRate = null, CasinoItemGuid = guid.Value, UserID = userid, UserName = username }; if (bet.BetCheck()) { var matchResult = new MatchResultBetDetail { Home = homeScore, Away = awayScore }; bet.Insert(matchResult); } } catch { ClientScript.RegisterClientScriptBlock(typeof(string), "failed", "alert('投注失败'); window.location.href = window.location.href;", true); } } } } } } ClientScript.RegisterClientScriptBlock(typeof(string), "failed", "alert('您的投注单已提交'); window.location.href = window.location.href;", true); }
protected void gvBet_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var bet = e.Row.DataItem as Bet; var ltrlHome = e.Row.FindControl("ltrlHome") as Literal; var ltrlAway = e.Row.FindControl("ltrlAway") as Literal; var btnReturnBet = e.Row.FindControl("btnReturnBet") as LinkButton; if (bet != null) { var item = CasinoItem.GetCasinoItem(bet.CasinoItemGuid); if (item.MatchGuid != null) { var m = new Match(item.MatchGuid.Value); { var homeT = Team.Cache.Load(m.Home); var awayT = Team.Cache.Load(m.Away); if (ltrlHome != null) { ltrlHome.Text = homeT.TeamDisplayName; } if (ltrlAway != null) { ltrlAway.Text = awayT.TeamDisplayName; } } } var ltrlResult = e.Row.FindControl("ltrlResult") as Literal; var dt = BetDetail.GetBetDetailByBetId(bet.ID); if (dt != null && ltrlResult != null) { var dr = dt.Rows[0]; switch (item.ItemType) { case CasinoType.SingleChoice: if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue) { ltrlResult.Text = "主队胜"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue) { ltrlResult.Text = "双方平"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue) { ltrlResult.Text = "客队胜"; } break; case CasinoType.MatchResult: var betDetail = new MatchResultBetDetail(dt); ltrlResult.Text = $"{betDetail.Home}:{betDetail.Away}"; break; } } } var ltrlBetRate = e.Row.FindControl("ltrlBetRate") as Literal; if (bet != null) { if (ltrlBetRate != null) { ltrlBetRate.Text = bet.BetRate.HasValue ? Convert.ToSingle(bet.BetRate).ToString("f2") : "/"; } if (btnReturnBet != null) { btnReturnBet.Visible = true; btnReturnBet.CommandArgument = bet.ID.ToString(); } } } }
protected void gvBet_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var bet = e.Row.DataItem as Bet; var ltrlHome = e.Row.FindControl("ltrlHome") as Literal; var ltrlAway = e.Row.FindControl("ltrlAway") as Literal; var ltrlVs = e.Row.FindControl("ltrlVS") as Literal; if (bet != null && ltrlHome != null && ltrlAway != null && ltrlVs != null) { var item = CasinoItem.GetCasinoItem(bet.CasinoItemGuid); if (CurrentMatch != Guid.Empty) { ltrlHome.Text = _home; ltrlAway.Text = _away; } else { if (item.MatchGuid != null) { var m = new Match(item.MatchGuid.Value); var homeT = Team.Cache.Load(m.Home); var awayT = Team.Cache.Load(m.Away); ltrlHome.Text = $"<a class=\"StrongLink\" href=\"CasinoTeam.aspx?Team={homeT.ID}\">{homeT.TeamDisplayName}</a>"; ltrlAway.Text = $"<a class=\"StrongLink\" href=\"CasinoTeam.aspx?Team={awayT.ID}\">{awayT.TeamDisplayName}</a>"; ltrlVs.Text = $"<a href=\"CasinoTeam.aspx?Match={m.MatchGuid}\"><em title=\"{homeT.Ground}({homeT.Capacity})\">vs</em></a>"; } } var ltrlResult = e.Row.FindControl("ltrlResult") as Literal; var dt = BetDetail.GetBetDetailByBetId(bet.ID); if (dt != null && ltrlResult != null) { var dr = dt.Rows[0]; switch (item.ItemType) { case CasinoType.SingleChoice: if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue) { ltrlResult.Text = "主队胜"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue) { ltrlResult.Text = "双方平"; } else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue) { ltrlResult.Text = "客队胜"; } break; case CasinoType.MatchResult: var betDetail = new MatchResultBetDetail(dt); ltrlResult.Text = $"{betDetail.Home}:{betDetail.Away}"; break; } } var ltrlBetResult = e.Row.FindControl("ltrlBetResult") as Literal; if (ltrlBetResult != null) { if (!bet.IsWin.HasValue) { ltrlBetResult.Text = string.Empty; } else { if (bet.IsWin != null && bet.IsWin.Value) { if (item.ItemType == CasinoType.SingleChoice) { ltrlBetResult.Text = "<span class=\"CasinoSys_True\" title=\"猜对输赢\"></span>"; } else if (item.ItemType == CasinoType.MatchResult) { ltrlBetResult.Text = "<span class=\"CasinoSys_Good\" title=\"猜对比分\"></span>"; } e.Row.CssClass = "RowCasinoSys_True"; } else { ltrlBetResult.Text = "<span class=\"CasinoSys_False\" title=\"失败\"></span>"; } } } var ltrlBetRate = e.Row.FindControl("ltrlBetRate") as Literal; if (ltrlBetRate != null) { ltrlBetRate.Text = bet.BetRate.HasValue ? Convert.ToSingle(bet.BetRate).ToString("f2") : "/"; } } } }