Beispiel #1
0
 public void Reset(object sender, EventArgs e)
 {
     BingoPattern.SelectedPattern++;
     BingoPattern.SelectedPattern %= BingoPattern.Patterns.Length;
     NumberGenerator.ResetGeneratedNumbers();
     BINGO_Load(sender, e);
 }
Beispiel #2
0
        private void BtnPrevious_Click(object sender, EventArgs e)
        {
            Round a = Round.GetPreviousRound();

            clicked = a.ClickedCells;
            NumberGenerator.SetGeneratedNumbers(a.GeneratedNumbers);
            BINGO_Load(sender, e);
        }
Beispiel #3
0
        private void BtnGenerate_Click(object sender, EventArgs e)
        {
            //Save pattern
            string query = "Select * from WinningPattern where Patterns > 0";

            try
            {
                connection.DB();
                SqlCommand    command = new SqlCommand(query, connection.conn);
                SqlDataReader reader  = command.ExecuteReader();

                if (!reader.Read())
                {
                    savePattern();
                }

                connection.conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            patternDisable();
            setSelectedRows();


            int  num    = NumberGenerator.GenerateRandomNumber(selectedRows);
            char letter = NumberGenerator.GetCharEquivalent();

            if (num != -1)
            {
                bingoNumbers[num - 1].BackColor = Color.Red;
                lblLetter.Text = "" + letter;

                lblNumber.Text = "" + num;

                try
                {
                    connection.DB();
                    String     a       = "Insert into Generated_Numbers values(" + lblNumber.Text + ")";
                    SqlCommand command = new SqlCommand(a, connection.conn);
                    command.ExecuteNonQuery();
                    connection.conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                lblLetter.Text = "";
                lblNumber.Text = "";
            }
        }
Beispiel #4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            selectedRows = new bool[5];

            DialogResult res = MessageBox.Show("You are about to declare a winner.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

            if (res == DialogResult.OK)
            {
                Round.SavePreviousRound(clicked, NumberGenerator.GeneratedNumbers());
                new WeHaveAWinner(this).ShowDialog();

                patternEnable();
                deletePattern();
                recolor();

                try
                {
                    connection.DB();

                    String     x       = "DELETE FROM Generated_Numbers";
                    SqlCommand command = new SqlCommand(x, connection.conn);
                    command.ExecuteNonQuery();
                    connection.conn.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                String controlName;
                String a = "";

                for (int i = 0; i < 75; ++i)
                {
                    controlName               = "label" + (i + 1);
                    bingoNumbers[i]           = this.Controls.Find(controlName, true)[0];
                    bingoNumbers[i].Text      = "" + (i + 1);
                    bingoNumbers[i].BackColor = Color.DarkViolet;
                    a += bingoNumbers[i].Name + "\n";
                }
            }
        }
Beispiel #5
0
        public void BINGO_Load(object sender, EventArgs e)
        {
            patternDisable();

            bingoNumbers       = new Control[75];
            generatedNumbers   = new bool[75];
            bingoCells         = new Control[5, 5];
            clicked            = new bool[5, 5];
            cellClickedCounter = new int[5, 5];
            string a = "";
            string controlName;
            int    counter = 1;

            lblLetter.Text = "";
            lblNumber.Text = "";

            string control = ""; // added
            string query   = "";

            for (int i = 0; i < 75; ++i)
            {
                controlName               = "label" + (i + 1);
                bingoNumbers[i]           = this.Controls.Find(controlName, true)[0];
                bingoNumbers[i].Text      = "" + (i + 1);
                bingoNumbers[i].BackColor = NumberGenerator.GeneratedNumbers()[i]? Color.Red : Color.DarkViolet;
                a += bingoNumbers[i].Name + "\n";
            }

            for (int i = 0; i < 5; ++i)
            {
                for (int ii = 0; ii < 5; ++ii)
                {
                    bingoCells[i, ii] = Controls.Find("b" + counter, true)[0];
                    if (counter == 13)
                    {
                        ++counter;
                        continue;
                    }
                    else
                    {
                        bingoCells[i, ii].BackColor = clicked[i, ii] ? Color.Green : Color.White;
                    }

                    ++counter;
                }
            }
            retrievePattern();

            //added
            try
            {
                Control c;
                connection.DB();
                query = "Select * From Generated_Numbers";
                SqlCommand    command = new SqlCommand(query, connection.conn);
                SqlDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    reader.GetValue(0);
                    for (int i = 0; i < 75; i++)
                    {
                        if (i == Int32.Parse(reader.GetValue(0).ToString()))
                        {
                            control     = "label" + reader.GetValue(0).ToString();
                            c           = this.Controls.Find(control, true)[0];
                            c.BackColor = Color.Red;
                        }
                    }
                }
                connection.conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }