예제 #1
0
    protected void btnTop10_Click(object sender, EventArgs e)
    {
        ResetUsedStones();

        pnlInTop10.Visible   = false;
        lblYourScore.Visible = false;
        txtYourScore.Visible = false;

        //Stored procedure
        string sStoredProc = "SP_Read_Top10";

        // a list of parameters for stored procedors only!
        List <string> sParams = new List <string>();

        sParams.Clear();

        DataTable dt = new DataTable();

        Data da = new Data();

        SqlDataReader objDataReader = da.ExecuteReader(sStoredProc, sParams);

        dt.Load(objDataReader);

        objDataReader.Close();

        TableTop10 tt10 = new TableTop10();

        pnlTop10.Controls.Add(new LiteralControl(tt10.BuildTop10(dt)));

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "topModal", "$('#topModal').modal();", true);
    }
예제 #2
0
    void EndOfGame(int piFinalScore)
    {
        txtYourScore.Text = piFinalScore.ToString();


        lblYourScore.Visible = true;
        txtYourScore.Visible = true;

        //Stored procedure
        string sStoredProc = "SP_Read_Top10";

        // a list of parameters for stored procedors only!
        List <string> sParams = new List <string>();

        sParams.Clear();

        DataTable dt = new DataTable();

        Data da = new Data();

        SqlDataReader objDataReader = da.ExecuteReader(sStoredProc, sParams);

        dt.Load(objDataReader);

        objDataReader.Close();

        //check higher scores
        int[] iScore = new int[10];

        for (int i = 0; i <= dt.Rows.Count - 1; i++)
        {
            //write data to local arrays
            iScore[i] = Convert.ToInt32(dt.Rows[i]["Score"]);
        }

        TableTop10 tt10 = new TableTop10();

        pnlTop10.Controls.Add(new LiteralControl(tt10.BuildTop10(dt)));

        // Check the scores
        int iRef = 0;

        for (int i = 0; i < 10; i++)
        {
            if (piFinalScore > iScore[i])
            {
                txtMessageDisplay.Text = "IN TOP10";
                iRef++;
            }
        }

        if (iRef > 0)
        {
            pnlInTop10.Visible = true;
        }
        else
        {
            pnlInTop10.Visible = false;
        }

        //lblNickNameRequired.Visible = false;

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "topModal", "$('#topModal').modal();", true);
    }