Ejemplo n.º 1
0
        public void ArsenalServiceRefreshCache_Test()
        {
            try
            {
                Config.Cache.RefreshCache();

                RelationLeagueTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                League.Cache.RefreshCache();
                Match.Cache.RefreshCache();
                Player.Cache.RefreshCache();
                Team.Cache.RefreshCache();
                Video.Cache.RefreshCache();

                //AcnCasino
                CasinoItem.Clean();
                ChoiceOption.Clean();
                Bet.Clean();
                BetDetail.Clean();

                // Clean Log
                Log.Clean();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void BindData()
        {
            if (CurrentMatch != Guid.Empty)
            {
                //var m = new Match(CurrentMatch);

                //var homeT = Team.Cache.Load(m.Home);
                //var awayT = Team.Cache.Load(m.Away);

                var betList = Bet.GetMatchAllBet(CurrentMatch);

                if (betList != null && betList.Count > 0)
                {
                    ltrlSingleChoiceCount.Text = betList.FindAll(bet => bet.BetAmount.HasValue).Count.ToString();
                    ltrlMatchResultCount.Text  = betList.FindAll(bet => !bet.BetAmount.HasValue).Count.ToString();

                    float totalBetCount = 0;
                    betList.ForEach(delegate(Bet bet) { totalBetCount += bet.BetAmount.GetValueOrDefault(0f); });
                    ltrlTotalBetCount.Text = totalBetCount.ToString("N0");

                    var itemGuid = CasinoItem.GetCasinoItemGuidByMatch(CurrentMatch, CasinoType.MatchResult);

                    betList = itemGuid.HasValue ? Bet.GetBetByCasinoItemGuid(itemGuid.Value, null) : null;

                    if (betList != null)
                    {
                        gvBet.PageSize   = betList.Count;
                        gvBet.DataSource = betList;
                    }

                    gvBet.DataBind();
                }
            }
        }
Ejemplo n.º 3
0
        private void BindData()
        {
            var betList = Bet.GetUserMatchAllBet(userid, CurrentMatch);

            var matchResultGuid = CasinoItem.GetCasinoItemGuidByMatch(CurrentMatch, CasinoType.MatchResult);

            if (matchResultGuid.HasValue && betList.Exists(bet => bet.CasinoItemGuid == matchResultGuid.Value))
            {
                trMatchResult.Visible = false;
            }
            else if (!matchResultGuid.HasValue)
            {
                trMatchResult.Visible = false;
            }
            else
            {
                trMatchResult.Visible = true;
            }

            gvBet.DataSource = betList;
            gvBet.DataBind();

            var dtHistory = CasinoItem.GetHistoryViewByMatch(CurrentMatch);

            gvMatch.DataSource = dtHistory;
            gvMatch.DataBind();
        }
Ejemplo n.º 4
0
        protected void btnSingleChoice_Click(object sender, EventArgs e)
        {
            try
            {
                var guid = CasinoItem.GetCasinoItemGuidByMatch(CurrentMatch, CasinoType.SingleChoice);

                if (guid.HasValue)
                {
                    if (CasinoItem.GetCasinoItem(guid.Value).CloseTime < DateTime.Now)
                    {
                        throw new Exception("已超出投注截止时间");
                    }

                    //Gambler in Lower could not bet above the SingleBetLimit of DefaultLeague (Contest)
                    var m = new Match(CurrentMatch);

                    if (m.LeagueGuid.Equals(ConfigGlobal.DefaultLeagueID))
                    {
                        if (Gambler.GetGamblerTotalBetByUserId(userid, m.LeagueGuid) < ConfigGlobal.TotalBetStandard)
                        {
                            var   alreadyMatchBet = Bet.GetUserMatchTotalBet(userid, CurrentMatch);
                            float currentMatchBet;

                            if (!string.IsNullOrEmpty(tbBet.Text.Trim()) &&
                                float.TryParse(tbBet.Text.Trim(), out currentMatchBet))
                            {
                                if (ConfigGlobal.SingleBetLimit > 0 && alreadyMatchBet + currentMatchBet > ConfigGlobal.SingleBetLimit)
                                {
                                    throw new Exception(
                                              $"下半赛区博彩玩家单场投注不能超过{ConfigGlobal.SingleBetLimit.ToString("f2")}博彩币");
                                }
                            }
                        }
                    }


                    //get selected option
                    var item          = (SingleChoice)CasinoItem.GetCasinoItem(guid.Value);
                    var seletedOption = item.Options.Find(option => option.OptionValue == rblSingleChoice.SelectedValue);

                    var bet = new Bet
                    {
                        BetAmount      = Convert.ToSingle(tbBet.Text.Trim()),
                        BetRate        = seletedOption.OptionRate,
                        CasinoItemGuid = guid.Value,
                        UserID         = userid,
                        UserName       = username
                    };

                    bet.Insert(seletedOption.OptionValue);

                    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);
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_userId != -1)
            {
                phAnonymous.Visible    = false;
                phAthenticated.Visible = true;

                ltrlUserName.Text      = _userName;
                linkLogout.NavigateUrl = $"{linkLogout.NavigateUrl}{_userKey}";
            }
            else
            {
                phAnonymous.Visible    = true;
                phAthenticated.Visible = false;
            }

            ltrlTitle.Text =
                $"<a href=\"/index.aspx\">{"阿森纳中国官方球迷会"}</a> &raquo; <a href=\"default.aspx\">{ConfigGlobal.PluginDisplayName}</a> &raquo; <strong>{Page.Title}</strong>";

            ltrlGamblerCount.Text = Gambler.GetGamblerCount().ToString();
            ltrlGameCount.Text    = (CasinoItem.GetMatchCasinoItemCount() + CasinoItem.GetOtherCasinoItemCount()).ToString();

            var defaultBanker = new Banker(Banker.DefaultBankerID);

            ltrlDefaultBanker.Text = defaultBanker.Cash.ToString("N2");
        }
Ejemplo n.º 6
0
        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";
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Top Match Earning

            var rank = 1;
            int months;
            var dtTopEarning = CasinoItem.GetTopMatchEarning(out months);

            if (dtTopEarning != null)
            {
                dtTopEarning.Columns.Add("Rank", typeof(int));
                foreach (DataRow dr in dtTopEarning.Rows)
                {
                    dr["Rank"] = rank;
                    rank++;
                }
            }

            rptMatchEarning.DataSource = dtTopEarning;
            rptMatchEarning.DataBind();

            ltrlEarning.Text = $"盈余排行({DateTime.Today.AddMonths(months).Month}月)";

            #endregion

            #region Top Match Loss

            rank = 1;
            var dtTopLoss = CasinoItem.GetTopMatchLoss(out months);

            if (dtTopLoss != null)
            {
                dtTopLoss.Columns.Add("Rank", typeof(int));
                foreach (DataRow dr in dtTopLoss.Rows)
                {
                    dr["Rank"] = rank;
                    rank++;
                }
            }

            rptMatchLoss.DataSource = dtTopLoss;
            rptMatchLoss.DataBind();

            ltrlLoss.Text = $"亏损排行({DateTime.Today.AddMonths(months).Month}月)";

            #endregion
        }
Ejemplo n.º 8
0
        public void Execute(object state)
        {
            var logInfo = new LogInfo
            {
                MethodInstance = MethodBase.GetCurrentMethod(),
                ThreadInstance = Thread.CurrentThread
            };

            //string _scheduleType = this.GetType().DeclaringType.FullName;

            try
            {
                log.Info("Scheduler Start: (RefreshCache)", logInfo);

                Config.UpdateAssemblyInfo(Assembly.GetExecutingAssembly(), ConfigSystem.Arsenal);

                ConfigGlobal_Arsenal.Refresh();

                RelationLeagueTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                RelationGroupTeam.Clean();
                RelationLeagueTeam.Cache.RefreshCache();

                League.Cache.RefreshCache();
                Match.Cache.RefreshCache();
                Player.Cache.RefreshCache();
                Team.Cache.RefreshCache();
                Video.Cache.RefreshCache();

                //AcnCasino
                CasinoItem.Clean();
                ChoiceOption.Clean();
                Bet.Clean();
                BetDetail.Clean();

                // Clean Log
                Log.Clean();

                log.Info("Scheduler End: (RefreshCache)", logInfo);
            }
            catch (Exception ex)
            {
                log.Warn(ex, logInfo);
            }
        }
Ejemplo n.º 9
0
        private void BindData()
        {
            var dt = CasinoItem.GetMatchCasinoItemView(false);

            dt.Columns.Add("HomeDisplay", typeof(string));
            dt.Columns.Add("AwayDisplay", typeof(string));

            foreach (DataRow dr in dt.Rows)
            {
                var m = new Match((Guid)dr["MatchGuid"]);

                dr["HomeDisplay"] = Team.Cache.Load(m.Home).TeamDisplayName;
                dr["AwayDisplay"] = Team.Cache.Load(m.Away).TeamDisplayName;
            }

            gvMatch.DataSource = dt;
            gvMatch.DataBind();
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Assign Control Property

            ctrlLeftPanel.UserId   = userid;
            ctrlLeftPanel.UserName = username;

            ctrlFieldTooBar.UserId = userid;

            ctrlMenuTabBar.CurrentMenu = CasinoMenuType.CasinoPortal;

            ctrlGamblerHeader.UserId   = userid;
            ctrlGamblerHeader.UserName = username;

            #endregion

            if (!IsPostBack)
            {
                var dtMatch = CasinoItem.GetMatchCasinoItemView(true);

                //if (dtMatch != null)
                //{
                //    dtMatch.Columns.Add("League", typeof(string));

                //    foreach (DataRow dr in dtMatch.Rows)
                //    {
                //        string league = dr["LeagueName"].ToString();

                //        //if (!string.IsNullOrEmpty(dr["LeagueSeason"].ToString()))
                //        //    league += dr["LeagueSeason"].ToString();

                //        if (!Convert.IsDBNull(dr["Round"]))
                //            league += string.Format("赛季 第{0}轮", dr["Round"]);

                //        dr["League"] = league;
                //    }
                //}

                gvMatch.DataSource = dtMatch;
                gvMatch.DataBind();

                btnSubmit.Visible = _itemAvailable;
            }
        }
Ejemplo n.º 11
0
        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);
            }
        }
Ejemplo n.º 12
0
        private void BindData()
        {
            DataTable dt;

            if (CurrentGroup != Guid.Empty)
            {
                var group = new Group(CurrentGroup);
                dt = CasinoItem.GetEndViewByMatch(group.LeagueGuid, group.GroupGuid, group.IsTable);
            }
            else if (ddlSeason.Items.Count != 0)
            {
                dt = CasinoItem.GetEndViewByMatch(new Guid(ddlSeason.SelectedValue));
            }
            else
            {
                dt = CasinoItem.GetEndViewByMatch();
            }

            ltrlMatchCount.Text = dt?.Rows.Count.ToString() ?? "0";

            gvMatch.DataSource = dt;
            gvMatch.DataBind();
        }
Ejemplo n.º 13
0
        private void BindData()
        {
            DataTable dt = null;

            if (CurrentTeam != Guid.Empty)
            {
                dt = CasinoItem.GetEndViewByTeam(CurrentTeam);
                ctrlTeamHeader.TeamGuid  = CurrentTeam;
                ctrlTeamHeader.Visible   = true;
                ctrlCasinoHeader.Visible = false;
            }
            else if (CurrentMatch != Guid.Empty)
            {
                dt = CasinoItem.GetHistoryViewByMatch(CurrentMatch);
                ctrlCasinoHeader.MatchGuid     = CurrentMatch;
                ctrlCasinoHeader.IsHistoryView = true;
                ctrlCasinoHeader.Visible       = true;
                ctrlTeamHeader.Visible         = false;
            }
            else
            {
                Response.Redirect("CasinoPortal.aspx");
            }

            if (dt != null)
            {
                gvMatch.DataSource = dt;
                gvMatch.DataBind();

                ltrlMatchCount.Text = dt.Rows.Count.ToString();
            }
            else
            {
                Response.Redirect("CasinoPortal.aspx");
            }
        }
Ejemplo n.º 14
0
        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") : "/";
                    }
                }
            }
        }
Ejemplo n.º 15
0
        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");
                }
            }
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var t = Team.Cache.Load(TeamGuid);

            if (t != null)
            {
                var dt        = CasinoItem.GetEndViewByTeam(t.ID);
                var wonCount  = 0;
                var drawCount = 0;
                var lostCount = 0;

                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        var m = new Match((Guid)dr["MatchGuid"]);
                        if (t.ID == m.Home)
                        {
                            if (m.ResultHome > m.ResultAway)
                            {
                                wonCount++;
                            }
                            else if (m.ResultHome < m.ResultAway)
                            {
                                lostCount++;
                            }
                            else
                            {
                                drawCount++;
                            }
                        }
                        else if (t.ID == m.Away)
                        {
                            if (m.ResultHome < m.ResultAway)
                            {
                                wonCount++;
                            }
                            else if (m.ResultHome > m.ResultAway)
                            {
                                lostCount++;
                            }
                            else
                            {
                                drawCount++;
                            }
                        }
                    }
                    var matchCount = wonCount + lostCount + drawCount;

                    ltrlMatchCount.Text = "<em>" + matchCount + "</em>";
                    ltrlWonCount.Text   = "<em>" + wonCount + "</em>";
                    ltrlDrawCount.Text  = "<em>" + drawCount + "</em>";
                    ltrlLostCount.Text  = "<em>" + lostCount + "</em>";
                }
                else
                {
                    pnlHistoryResult.Visible = false;
                }

                ltrlTeamDisplayName.Text = $"<em>{t.TeamDisplayName}({t.TeamEnglishName})</em>";
                ltrlTeamLogo.Text        = string.Format("<img src=\"{0}\" alt=\"{1}\" title=\"{1}\" />", t.TeamLogo,
                                                         t.TeamDisplayName);
                ltrlTeamCoach.Text = "<em>" + t.Manager + "</em>";
                ltrlGround.Text    = "<em>" + t.Ground + "</em>";
                ltrlCapacity.Text  = "<em>" + t.Capacity + "</em>";
            }
        }
Ejemplo n.º 17
0
        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();
                    }
                }
            }
        }
Ejemplo n.º 18
0
        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>";
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        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;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Assign Control Property

            ctrlLeftPanel.UserId   = userid;
            ctrlLeftPanel.UserName = username;

            ctrlFieldTooBar.UserId = userid;

            ctrlMenuTabBar.CurrentMenu = CasinoMenuType.CasinoPortal;

            ctrlCasinoHeader.UserId        = userid;
            ctrlCasinoHeader.MatchGuid     = CurrentMatch;
            ctrlCasinoHeader.IsHistoryView = true;

            #endregion

            var match = new Match(CurrentMatch);

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (match != null)
            {
                var dtPlay = match.PlayTime;

                if (DateTime.Now >= dtPlay)
                {
                    phBet.Visible    = false;
                    pnlClose.Visible = true;
                }
                else
                {
                    phBet.Visible    = true;
                    pnlClose.Visible = false;
                }

                var guid = CasinoItem.GetCasinoItemGuidByMatch(CurrentMatch, CasinoType.SingleChoice);

                if (!IsPostBack)
                {
                    #region 设置其他可投注比赛的下拉框

                    var dtMatch = CasinoItem.GetMatchCasinoItemView(true);

                    if (dtMatch != null)
                    {
                        dtMatch.Columns.Add("MatchTeamDisplay", typeof(string));

                        foreach (DataRow drM in dtMatch.Rows)
                        {
                            var m = new Match((Guid)drM["MatchGuid"]);

                            drM["MatchTeamDisplay"] =
                                $"{Team.Cache.Load(m.Home).TeamDisplayName} vs {Team.Cache.Load(m.Away).TeamDisplayName}";
                        }
                    }

                    ddlCasinoGame.DataSource     = dtMatch;
                    ddlCasinoGame.DataTextField  = "MatchTeamDisplay";
                    ddlCasinoGame.DataValueField = "MatchGuid";
                    ddlCasinoGame.DataBind();

                    ddlCasinoGame.Items.Insert(0, new ListItem("--选择其他比赛场次--", Guid.Empty.ToString()));

                    #endregion

                    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))
                            {
                                throw new Exception();
                            }

                            var liWin = rblSingleChoice.Items[0];
                            liWin.Text  = $"<em>主队胜({Convert.ToSingle(winOption.OptionRate).ToString("f2")})</em>";
                            liWin.Value = MatchChoiceOption.HomeWinValue;

                            var liDraw = rblSingleChoice.Items[1];
                            liDraw.Text  = $"<em>双方平({Convert.ToSingle(drawOption.OptionRate).ToString("f2")})</em>";
                            liDraw.Value = MatchChoiceOption.DrawValue;

                            var liLose = rblSingleChoice.Items[2];
                            liLose.Text  = $"<em>客队胜({Convert.ToSingle(loseOption.OptionRate).ToString("f2")})</em>";
                            liLose.Value = MatchChoiceOption.AwayWinValue;
                        }
                    }
                }

                BindData();
            }
        }
Ejemplo n.º 21
0
        protected void gvMatch_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Match m = e.Row.DataItem as Match;
                var drv = e.Row.DataItem as DataRowView;

                if (drv != null)
                {
                    var m = new Match((Guid)drv["MatchGuid"]);

                    var matchResult  = e.Row.FindControl("ltrlMatchResult") as Literal;
                    var btnCalcBonus = e.Row.FindControl("btnCalcBonus") as LinkButton;
                    var btnReturnBet = e.Row.FindControl("btnReturnBet") as LinkButton;
                    var lblBonus     = e.Row.FindControl("lblBonus") as Label;
                    var tbPlayTime   = e.Row.FindControl("tbPlayTime") as TextBox;
                    var tbRound      = e.Row.FindControl("tbRound") as TextBox;
                    var tbHome       = e.Row.FindControl("tbHome") as TextBox;
                    var tbAway       = e.Row.FindControl("tbAway") as TextBox;

                    if (tbPlayTime != null)
                    {
                        tbPlayTime.Text = m.PlayTime.ToString("yyyy-MM-dd HH:mm");
                    }

                    if (tbRound != null)
                    {
                        tbRound.Text = m.Round.ToString();
                    }

                    if (tbHome != null && tbAway != null && m.ResultHome.HasValue && m.ResultAway.HasValue)
                    {
                        tbHome.Text = m.ResultHome.ToString();
                        tbAway.Text = m.ResultAway.ToString();
                    }

                    if (btnCalcBonus != null && btnReturnBet != null && lblBonus != null)
                    {
                        if (matchResult != null && m.ResultHome.HasValue && m.ResultAway.HasValue)
                        {
                            matchResult.Text = $"{m.ResultHome}:{m.ResultAway}";

                            var matchGuid = m.MatchGuid;

                            var itemGuid = CasinoItem.GetCasinoItemGuidByMatch(matchGuid, CasinoType.SingleChoice);

                            if (itemGuid.HasValue)
                            {
                                var item = CasinoItem.GetCasinoItem(itemGuid.Value);

                                if (item.Earning.HasValue)
                                {
                                    //hide button calc bonus
                                    btnCalcBonus.Visible = false;
                                    btnReturnBet.Visible = false;
                                    lblBonus.Text        = item.Earning.Value.ToString("N2");
                                    lblBonus.Visible     = true;
                                }
                                else
                                {
                                    //show button calc bonus
                                    btnCalcBonus.Visible = true;
                                    btnReturnBet.Visible = false;
                                    lblBonus.Visible     = false;

                                    //set button command argument
                                    btnCalcBonus.CommandArgument = m.MatchGuid.ToString();
                                }
                            }
                        }
                        else
                        {
                            var betList = Bet.GetMatchAllBet(m.MatchGuid);

                            var betCount = 0;
                            if (betList != null && betList.Count > 0)
                            {
                                betCount = betList.Count;
                            }

                            btnReturnBet.Text    = $"退还:{betCount}注";
                            btnReturnBet.Visible = true;

                            btnCalcBonus.Visible = false;
                            lblBonus.Visible     = false;

                            btnReturnBet.CommandArgument = m.MatchGuid.ToString();

                            if (betCount <= 0)
                            {
                                btnReturnBet.Enabled = false;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        protected void gvMatch_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var tbHome     = gvMatch.Rows[gvMatch.EditIndex].FindControl("tbHome") as TextBox;
            var tbAway     = gvMatch.Rows[gvMatch.EditIndex].FindControl("tbAway") as TextBox;
            var tbPlayTime = gvMatch.Rows[gvMatch.EditIndex].FindControl("tbPlayTime") as TextBox;
            var tbRound    = gvMatch.Rows[gvMatch.EditIndex].FindControl("tbRound") as TextBox;

            var key = gvMatch.DataKeys[gvMatch.EditIndex];


            if (tbHome != null && tbAway != null && tbPlayTime != null && tbRound != null && key != null)
            {
                try
                {
                    var guid = (Guid)key.Value;

                    var m = new Match(guid);

                    short rHome;
                    short rAway;
                    if (short.TryParse(tbHome.Text, out rHome) && short.TryParse(tbAway.Text, out rAway))
                    {
                        m.ResultHome = rHome;
                        m.ResultAway = rAway;
                    }
                    else if (string.IsNullOrEmpty(tbHome.Text) && string.IsNullOrEmpty(tbAway.Text))
                    {
                        m.ResultHome = null;
                        m.ResultAway = null;
                    }

                    m.PlayTime = Convert.ToDateTime(tbPlayTime.Text);

                    if (!string.IsNullOrEmpty(tbRound.Text))
                    {
                        m.Round = Convert.ToInt16(tbRound.Text);
                    }

                    m.Update();

                    var casinoItemGuid = CasinoItem.GetCasinoItemGuidByMatch(guid, CasinoType.MatchResult);

                    if (casinoItemGuid.HasValue && m.ResultHome.HasValue && m.ResultAway.HasValue)
                    {
                        Match.UpdateMatchResult(casinoItemGuid.Value, m.ResultHome.Value, m.ResultAway.Value);
                    }

                    if (casinoItemGuid.HasValue)
                    {
                        CasinoItem.UpdateCasinoItemCloseTime(guid, m.PlayTime);
                    }
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}');", true);
                }
            }

            gvMatch.EditIndex = -1;

            BindData();
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (MatchGuid != Guid.Empty)
            {
                var m = new Match(MatchGuid);

                var leagueDisplay = m.LeagueName;
                if (m.Round.HasValue)
                {
                    leagueDisplay += $" 第{m.Round}轮";
                }

                ltrlLeagueSeason.Text = leagueDisplay;

                var homeGuid = m.Home;
                var awayGuid = m.Away;

                HomeTeam = Team.Cache.Load(homeGuid);
                AwayTeam = Team.Cache.Load(awayGuid);

                ltrlPlayTime.Text = m.PlayTime.ToString("yyyy-MM-dd HH:mm");

                var guid = CasinoItem.GetCasinoItemGuidByMatch(MatchGuid, CasinoType.SingleChoice);

                var matchTotalBet = 0f;

                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))
                        {
                            throw new Exception("该比赛没有赔率");
                        }
                        var txtString = "<em title=\"共有{0}注,总计:{1}博彩币\">{2}</em>";

                        if (winOption.OptionRate.HasValue && drawOption.OptionRate.HasValue && loseOption.OptionRate.HasValue)
                        {
                            var rateWin  = Math.Round(winOption.OptionRate.Value, 2).ToString("f2");
                            var rateDraw = Math.Round(drawOption.OptionRate.Value, 2).ToString("f2");
                            var rateLose = Math.Round(loseOption.OptionRate.Value, 2).ToString("f2");

                            var totalBetWin =
                                ChoiceOption.GetOptionTotalBet(guid.Value, winOption.OptionValue).ToString("N0");
                            var totalBetDraw =
                                ChoiceOption.GetOptionTotalBet(guid.Value, drawOption.OptionValue).ToString("N0");
                            var totalBetLose =
                                ChoiceOption.GetOptionTotalBet(guid.Value, loseOption.OptionValue).ToString("N0");

                            var betCountWin  = ChoiceOption.GetOptionTotalCount(guid.Value, winOption.OptionValue).ToString();
                            var betCountDraw =
                                ChoiceOption.GetOptionTotalCount(guid.Value, drawOption.OptionValue).ToString();
                            var betCountLose =
                                ChoiceOption.GetOptionTotalCount(guid.Value, loseOption.OptionValue).ToString();

                            ltrlWin.Text  = string.Format(txtString, betCountWin, totalBetWin, rateWin);
                            ltrlDraw.Text = string.Format(txtString, betCountDraw, totalBetDraw, rateDraw);
                            ltrlLose.Text = string.Format(txtString, betCountLose, totalBetLose, rateLose);

                            matchTotalBet = Convert.ToSingle(totalBetWin) + Convert.ToSingle(totalBetDraw) +
                                            Convert.ToSingle(totalBetLose);
                        }
                    }

                    var betList = Bet.GetMatchAllBet(MatchGuid);

                    if (betList != null && betList.Count > 0)
                    {
                        ltrlMatchBetCount.Text = betList.Count.ToString();
                    }
                    else
                    {
                        ltrlMatchBetCount.Text = "0";
                    }

                    ltrlMatchTotalBet.Text = matchTotalBet.ToString("N0");

                    if (!IsHistoryView)
                    {
                        pnlHistoryResult.Visible = false;

                        if (item?.Earning != null)
                        {
                            ltrlEarning.Text = Convert.ToSingle(item.Earning).ToString("N2");
                        }

                        ltrlTopBet.Text     = Bet.GetMatchTopBet(MatchGuid).ToString("N0");
                        ltrlTopEarning.Text = Bet.GetMatchTopEarning(MatchGuid).ToString("N2");

                        var matchResultGuid = CasinoItem.GetCasinoItemGuidByMatch(MatchGuid, CasinoType.MatchResult);

                        if (matchResultGuid.HasValue)
                        {
                            var matchResultItem = CasinoItem.GetCasinoItem(matchResultGuid.Value);

                            if (((MatchResult)matchResultItem)?.Home != null &&
                                ((MatchResult)matchResultItem).Away.HasValue)
                            {
                                pnlMatchResult.Visible = true;
                                ltrlMatchResult.Text   =
                                    $"{((MatchResult) matchResultItem).Home}:{((MatchResult) matchResultItem).Away}";
                            }
                            else
                            {
                                pnlMatchResult.Visible = false;
                                ltrlMatchResult.Text   = "暂无结果";
                                ltrlEarning.Text       = "暂无结果";
                            }
                        }
                    }
                    else
                    {
                        pnlHistoryResult.Visible = true;
                        pnlMatchResult.Visible   = false;

                        var historyResultArr = CasinoItem.GetHistoryResultByMatch(MatchGuid);

                        ltrlMatchCount.Text = historyResultArr[0].ToString();
                        ltrlHomeWon.Text    = historyResultArr[1].ToString();
                        ltrlHomeDraw.Text   = historyResultArr[2].ToString();
                        ltrlHomeLost.Text   = historyResultArr[3].ToString();
                    }
                }
            }
        }
Ejemplo n.º 24
0
        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);
        }