Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            MenegerAndTeacherForm m = new MenegerAndTeacherForm();

            m.Show();
        }
        // update game settings
        private void button2_Click(object sender, EventArgs e)
        {
            int    level      = 0;
            int    markSize   = 0;
            string background = null;
            string GameName   = null;

            if (!(comboBox1.Items.Contains("some value")))
            {
                try
                {
                    GameName = comboBox1.SelectedItem.ToString();
                }
                catch
                {
                }
                int GmameIndex = 0;
                switch (GameName)
                {
                case "הכרת ספרות":
                    GmameIndex = 1;
                    break;

                case "מנייה":
                    GmameIndex = 2;
                    break;

                case "התאמת ספרות לכמות":
                    GmameIndex = 3;
                    break;

                case "רצף מספרים":
                    GmameIndex = 4;
                    break;

                case "משחק הזיכרון":
                    GmameIndex = 5;
                    break;

                case "חיבור וחיסור":
                    GmameIndex = 6;
                    break;

                default:

                    GmameIndex = 0;
                    break;
                }

                if (SmallMouse.Checked)
                {
                    markSize = 0;
                }
                else
                {
                    markSize = 1;
                }

                if (MultiCollor.Checked)
                {
                    background = "MultiCollor";
                }
                else
                {
                    background = "blackBackground";
                }

                level = (int)(numericUpDown1.Value);

                if (GmameIndex == 0)
                {
                    MessageBox.Show("בחר משחק");
                }
                else
                {
                    CountNumGames++;
                    connection.Open();
                    sql     = "INSERT INTO [StudentPlay](PlayGameCode,GameCode,Level,UserId,MarkSize,background) VALUES('" + CountNumGames + "','" + GmameIndex + "', '" + level + "','" + UserID + "','" + markSize + "','" + background + "')";
                    command = new SqlCommand(sql, connection);
                    SqlDataAdapter da = new SqlDataAdapter(command);

                    command.ExecuteNonQuery();
                    connection.Close();
                    MessageBox.Show("פרטי משחק נשמרו");
                    connection.Close();
                    this.Hide();
                    MenegerAndTeacherForm mf = new MenegerAndTeacherForm();
                    mf.Show();
                }
            }
            else
            {
                MessageBox.Show("בחר משחק");
            }
        }