Пример #1
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);
            }
        }
Пример #2
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);
        }
Пример #3
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);
            }
        }