示例#1
0
        protected void btnToQSB_Click(object sender, EventArgs e)
        {
            try
            {
                var cash = (int) (Convert.ToInt32(tbQSB.Text)/(1 - ConfigGlobal.ExchangeFee)*ConfigGlobal.ExchangeRate);

                if (cash > CurrentGambler.Cash || cash <= 0)
                    throw new Exception("Insufficient Founds");

                CurrentGambler.Cash -= cash;
                CurrentGambler.Update();

                var banker = new Banker(Banker.DefaultBankerID);
                banker.Cash += cash*ConfigGlobal.ExchangeFee;
                banker.Update(null);

                Users.UpdateUserExtCredits(userid, 2, Convert.ToInt32(tbQSB.Text));
                ClientScript.RegisterClientScriptBlock(typeof (string), "succeed",
                    "alert('套现枪手币成功');window.location.href = window.location.href;", true);
            }
            catch
            {
                ClientScript.RegisterClientScriptBlock(typeof (string), "failed", "alert('套现失败');", true);
            }
        }
示例#2
0
        protected void btnToCash_Click(object sender, EventArgs e)
        {
            try
            {
                // Remove ExchangeFee

                //int qsb = (int)(Convert.ToInt32(tbCash.Text) * (1 + Entity.ConfigGlobal.ExchangeFee) / Entity.ConfigGlobal.ExchangeRate);

                var qsb = Convert.ToInt32(tbCash.Text)/ConfigGlobal.ExchangeRate;

                if (qsb > Users.GetUserExtCredits(userid, 2) || qsb <= 0)
                    throw new Exception("Insufficient Founds");

                CurrentGambler.Cash += Convert.ToInt32(tbCash.Text.Trim());
                CurrentGambler.Update();

                var banker = new Banker(Banker.DefaultBankerID);
                banker.Cash += qsb*ConfigGlobal.ExchangeFee*ConfigGlobal.ExchangeRate;
                banker.Update(null);

                Users.UpdateUserExtCredits(userid, 2, -qsb);

                ClientScript.RegisterClientScriptBlock(typeof (string), "succeed",
                    "alert('充值博彩币成功');window.location.href = window.location.href;", true);
            }
            catch
            {
                ClientScript.RegisterClientScriptBlock(typeof (string), "failed", "alert('充值失败');", true);
            }
        }
示例#3
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");
        }
示例#4
0
        public void Insert(string optionValue)
        {
            using (var conn = SQLConn.GetConnection())
            {
                conn.Open();
                var trans = conn.BeginTransaction();
                try
                {
                    if (BetCheck(trans))
                    {
                        //update gambler statistics
                        var gambler = new Gambler(UserID, trans);
                        gambler.TotalBet += BetAmount.GetValueOrDefault(0f);

                        if (BetAmount.HasValue)
                            gambler.Cash -= BetAmount.GetValueOrDefault(0f);
                        gambler.Update(trans);

                        var banker = new Banker(CasinoItem.GetCasinoItem(CasinoItemGuid).BankerID);
                        banker.Cash += BetAmount.GetValueOrDefault(0f);
                        banker.Update(trans);

                        var key = DataAccess.Bet.InsertBet(UserID, UserName, CasinoItemGuid, BetAmount, BetRate, trans);
                        MatchChoiceOption.SaveMatchChoiceOption(key, optionValue, trans);

                        trans.Commit();
                    }
                    else
                        throw new Exception("Failed to create bet (SingleChoice).");
                }
                catch
                {
                    trans.Rollback();
                }

                //conn.Close();
            }
        }
示例#5
0
        //public static void CleanNoCasinoItemBet()
        //{
        //    using (var conn = SQLConn.GetConnection())
        //    {
        //        conn.Open();
        //        var trans = conn.BeginTransaction();
        //        try
        //        {
        //            DataAccess.Bet.CleanBet(trans);
        //            DataAccess.BetDetail.CleanBetDetail(trans);
        //            trans.Commit();
        //        }
        //        catch
        //        {
        //            trans.Rollback();
        //        }
        //        //conn.Close();
        //    }
        //}
        public static void ReturnBet(int key)
        {
            using (var conn = SQLConn.GetConnection())
            {
                conn.Open();
                var trans = conn.BeginTransaction();
                try
                {
                    var bet = new Bet(key);

                    if (bet.BetAmount.HasValue && bet.BetAmount >= 0f)
                    {
                        var betAmount = Convert.ToSingle(bet.BetAmount);

                        var banker = new Banker(CasinoItem.GetCasinoItem(bet.CasinoItemGuid).BankerID);
                        var gambler = new Gambler(bet.UserID, trans);

                        gambler.Cash += betAmount;
                        gambler.TotalBet -= betAmount;
                        banker.Cash -= betAmount;

                        gambler.Update(trans);
                        banker.Update(trans);
                    }
                    else if (!bet.BetAmount.HasValue && !bet.Earning.HasValue && bet.EarningDesc == "RP+1")
                    {
                        Users.UpdateUserExtCredits(bet.UserID, 4, -1);
                    }

                    DataAccess.Bet.DeleteBetById(key, trans);
                    DataAccess.BetDetail.CleanBetDetail(trans);
                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                }
            }
        }
示例#6
0
        public void ReturnBet()
        {
            using (var conn = SQLConn.GetConnection())
            {
                conn.Open();
                var trans = conn.BeginTransaction();
                try
                {
                    var casinoItemGuid = DataAccess.CasinoItem.GetCasinoItemGuidByMatch(MatchGuid,
                        (int)CasinoType.SingleChoice, trans);
                    if (casinoItemGuid.HasValue)
                    {
                        var item = CasinoItem.GetCasinoItem(casinoItemGuid.Value);
                        var banker = new Banker(item.BankerID);

                        var dtMatchBet = DataAccess.Bet.GetMatchAllBet(MatchGuid);

                        var totalBet = 0f;

                        foreach (DataRow dr in dtMatchBet.Rows)
                        {
                            if (!Convert.IsDBNull(dr["Bet"]))
                            {
                                var gambler = new Gambler(Convert.ToInt32(dr["UserID"]), trans);
                                gambler.Cash += Convert.ToSingle(dr["Bet"]);
                                gambler.TotalBet -= Convert.ToSingle(dr["Bet"]);
                                gambler.Update(trans);

                                totalBet += Convert.ToSingle(dr["Bet"]);
                            }
                        }

                        banker.Cash -= totalBet;
                        banker.Update(trans);

                        DataAccess.Bet.DeleteBetByMatchGuid(MatchGuid, trans);
                        DataAccess.BetDetail.CleanBetDetail(trans);

                        trans.Commit();
                    }
                }
                catch
                {
                    trans.Rollback();
                }

                //conn.Close();
            }
        }
示例#7
0
        public void CalcBonus()
        {
            if (string.IsNullOrEmpty(ResultHome.ToString()) || string.IsNullOrEmpty(ResultAway.ToString()))
            {
                throw new Exception("You can not calc bonus without a match result");
            }

            using (var conn = SQLConn.GetConnection())
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    var itemGuid = DataAccess.CasinoItem.GetCasinoItemGuidByMatch(MatchGuid,
                        (int)CasinoType.SingleChoice, trans);

                    if (itemGuid.HasValue)
                    {
                        //single choice bonus
                        var item = CasinoItem.GetCasinoItem(itemGuid.Value);
                        var banker = new Banker(item.BankerID);

                        var totalEarning = 0f;

                        var betList = Bet.GetBetByCasinoItemGuid(itemGuid.Value, trans);

                        foreach (var bet in betList)
                        {
                            var dt = DataAccess.BetDetail.GetBetDetailByBetId(bet.ID);

                            if (dt != null)
                            {
                                var gambler = new Gambler(bet.UserID, trans);

                                if (bet.IsWin == null)
                                {
                                    var isWin = false;

                                    var dr = dt.Rows[0];

                                    if (dr["DetailName"].ToString() == MatchChoiceOption.HomeWinValue &&
                                        ResultHome > ResultAway)
                                        isWin = true;
                                    else if (dr["DetailName"].ToString() == MatchChoiceOption.DrawValue &&
                                             ResultHome == ResultAway)
                                        isWin = true;
                                    else if (dr["DetailName"].ToString() == MatchChoiceOption.AwayWinValue &&
                                             ResultHome < ResultAway)
                                        isWin = true;

                                    bet.IsWin = isWin;

                                    if (bet.BetAmount.HasValue)
                                    {
                                        totalEarning += bet.BetAmount.Value;

                                        if (isWin)
                                        {
                                            bet.Earning = bet.BetAmount * bet.BetRate;

                                            if (bet.Earning != null)
                                            {
                                                bet.EarningDesc = $"{bet.Earning.Value:N2}";

                                                totalEarning -= bet.Earning.Value;

                                                //add gambler cash

                                                gambler.Cash += bet.Earning.Value;
                                                gambler.Win++;

                                                banker.Cash -= bet.Earning.Value;
                                            }
                                        }
                                        else
                                        {
                                            gambler.Lose++;

                                            bet.Earning = 0;
                                            bet.EarningDesc = string.Empty;
                                        }
                                    }
                                }

                                bet.Update(trans);
                                gambler.Update(trans);
                            }
                        }

                        banker.Update(trans);

                        item.Earning = totalEarning;
                        item.Save(trans);
                    }

                    itemGuid = DataAccess.CasinoItem.GetCasinoItemGuidByMatch(MatchGuid, (int)CasinoType.MatchResult,
                        trans);

                    if (itemGuid.HasValue)
                    {
                        //match result bonus
                        var betList = Bet.GetBetByCasinoItemGuid(itemGuid.Value, trans);

                        var item = CasinoItem.GetCasinoItem(itemGuid.Value);
                        item.Earning = 0;
                        item.Save(trans);

                        foreach (var bet in betList)
                        {
                            var gambler = new Gambler(bet.UserID, trans);

                            var dt = DataAccess.BetDetail.GetBetDetailByBetId(bet.ID);

                            var betDetail = new MatchResultBetDetail(dt);

                            if (bet.IsWin == null)
                            {
                                if (betDetail.Home == ResultHome && betDetail.Away == ResultAway)
                                {
                                    //win
                                    bet.IsWin = true;
                                    bet.Earning = 0;
                                    bet.EarningDesc = "RP+1";

                                    gambler.Win++;

                                    //update user rp

                                    Users.UpdateUserExtCredits(bet.UserID, 4, 1);
                                }
                                else
                                {
                                    //lose
                                    bet.IsWin = false;
                                    bet.Earning = 0;
                                    bet.EarningDesc = string.Empty;

                                    gambler.Lose++;
                                }
                            }

                            bet.Update(trans);
                            gambler.Update(trans);
                        }
                    }

                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                }
            }
        }