示例#1
0
        protected void Spinbtn_Click(object sender, EventArgs e)
        {
            //   try {
            //decimal bet = 50;
            decimal bet;

            try {
                bet = Convert.ToDecimal(tbBet.Text);
                if (bet > 0 && player.money - bet > -1)
                {
                    resultLbl.Text = "";
                    Session["bet"] = bet;
                    SpinandDisplay();


                    if (Pos[0, 0] == Pos[1, 0] && Pos[1, 0] == Pos[2, 0] && Pos[1, 0] == Pos[3, 0] && Pos[3, 0] == Pos[4, 0])
                    {
                        win(2);
                    }
                    else if (Pos[0, 1] == Pos[1, 1] && Pos[1, 1] == Pos[2, 1] && Pos[2, 1] == Pos[3, 1] && Pos[3, 1] == Pos[4, 1])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 2] && Pos[1, 2] == Pos[2, 2] && Pos[2, 2] == Pos[3, 2] && Pos[3, 2] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 0] == Pos[1, 1] && Pos[1, 1] == Pos[2, 0] && Pos[2, 0] == Pos[3, 1] && Pos[3, 1] == Pos[4, 0])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 1] && Pos[1, 1] == Pos[2, 0] && Pos[2, 0] == Pos[3, 1] && Pos[3, 1] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[2, 0] == Pos[1, 1] && Pos[1, 1] == Pos[2, 1] && Pos[2, 1] == Pos[3, 1] && Pos[3, 1] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 0] == Pos[1, 2] && Pos[1, 2] == Pos[2, 0] && Pos[2, 0] == Pos[3, 2] && Pos[3, 2] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 1] && Pos[1, 1] == Pos[2, 1] && Pos[2, 1] == Pos[3, 1] && Pos[3, 1] == Pos[4, 0])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 2] && Pos[1, 2] == Pos[2, 0] && Pos[2, 0] == Pos[3, 2] && Pos[3, 2] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 1] == Pos[1, 2] && Pos[1, 2] == Pos[2, 1] && Pos[2, 0] == Pos[3, 2] && Pos[3, 2] == Pos[4, 1])
                    {
                        win(2);
                    }
                    else if (Pos[0, 0] == Pos[1, 2] && Pos[1, 2] == Pos[2, 2] && Pos[2, 2] == Pos[3, 2] && Pos[3, 2] == Pos[4, 0])
                    {
                        win(2);
                    }
                    else if (Pos[0, 0] == Pos[1, 1] && Pos[1, 1] == Pos[2, 0] && Pos[2, 0] == Pos[3, 1] && Pos[3, 1] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 0] && Pos[1, 0] == Pos[2, 2] && Pos[2, 2] == Pos[3, 0] && Pos[3, 0] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 2] == Pos[1, 1] && Pos[1, 1] == Pos[2, 1] && Pos[2, 1] == Pos[3, 1] && Pos[3, 1] == Pos[4, 2])
                    {
                        win(2);
                    }
                    else if (Pos[0, 0] == Pos[1, 2] && Pos[1, 2] == Pos[2, 1] && Pos[2, 1] == Pos[3, 2] && Pos[3, 2] == Pos[4, 1])
                    {
                        win(2);
                    }
                    else
                    {
                        lose();
                    }

                    Session["User"] = player;
                    using (SqlConnection conn = new SqlConnection())
                    {
                        conn.ConnectionString = DAO.ConnectionString();

                        using (SqlCommand cmd = DAO.updatePlayer((Player)Session["User"]))
                        {
                            conn.Open();
                            cmd.Connection = conn;
                            cmd.ExecuteScalar();
                        }
                    }
                }
            }catch {
                lbWarning.Text = "Please enter a valid number";
            }
        }