Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            WorkHorse W = new WorkHorse();

            string LS = textBox1.Text + "," + textBox2.Text + "," + textBox3.Text + "," + textBox4.Text + "," + textBox5.Text + "," + textBox6.Text;

            W.Add(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text);/*
                                                                                                             *
                                                                                                             * string UserQuery = "INSERT INTO Questions (Subject, Question, CorrectAnswer, AnswerA, AnswerB, AnswerC) Values (@Subject, @Question, @CorrectAnswer, @AnswerA, @AnswerB, @AnswerC)";//Adding Into Our Database To Add To The Likes
                                                                                                             * SqlConnection UserConnect = new SqlConnection(ConfigurationManager.ConnectionStrings["CsData"].ConnectionString);
                                                                                                             * SqlCommand UserCmd = new SqlCommand(UserQuery, UserConnect); //Our Query To Execute
                                                                                                             *
                                                                                                             * UserCmd.Parameters.AddWithValue("@Subject", textBox1.Text);  //Adds It To Check
                                                                                                             * UserCmd.Parameters.AddWithValue("@Question", textBox2.Text);  //Adds It To Check
                                                                                                             * UserCmd.Parameters.AddWithValue("@CorrectAnswer", textBox3.Text);  //Adds It To Check
                                                                                                             * UserCmd.Parameters.AddWithValue("@AnswerA", textBox4.Text);  //Adds It To Check
                                                                                                             * UserCmd.Parameters.AddWithValue("@AnswerB", textBox5.Text);  //Adds It To Check
                                                                                                             * UserCmd.Parameters.AddWithValue("@AnswerC", textBox6.Text);  //Adds It To Check
                                                                                                             *
                                                                                                             * UserConnect.Open(); //Opens Our Connection
                                                                                                             * UserCmd.ExecuteNonQuery(); //Execute Our Query
                                                                                                             * UserConnect.Close(); //Close Our Connection
                                                                                                             * textBox2.Clear();
                                                                                                             * textBox3.Clear();
                                                                                                             * textBox4.Clear();
                                                                                                             * textBox5.Clear();
                                                                                                             * textBox6.Clear();*/
        }
Ejemplo n.º 2
0
        public GetResults(int Type, int Score, string GID, int PID)
        {
            InitializeComponent();
            int Swap = 0;

            System.Threading.Thread.Sleep(5000);
            WorkHorse W   = new WorkHorse();
            Random    Ran = new Random();

            if (Type == 1)
            {
                if (PID == 1)
                {
                    Swap = 2;
                    string OP = W.GetResults(GID, Swap);
                    int    OS = Convert.ToInt32(OP);
                    LblP1S.Text = "Your score: " + Score.ToString();
                    LblP2S.Text = "Opponent's score: " + OP;

                    if (Score > OS)
                    {
                        LblWinner.Text = "You won!";
                    }
                    else if (OS > Score)
                    {
                        LblWinner.Text = "You lost!";
                    }
                    else
                    {
                        LblWinner.Text = "You drew!";
                    }
                }

                else if (PID == 2)
                {
                    Swap = 1;
                    string OP = W.GetResults(GID, Swap);
                    int    OS = Convert.ToInt32(OP);
                    LblP1S.Text = "Your score: " + Score.ToString();
                    LblP2S.Text = "Opponent's score: " + OP;
                    if (Score > OS)
                    {
                        LblWinner.Text = "You won!";
                    }
                    else if (OS > Score)
                    {
                        LblWinner.Text = "You lost!";
                    }
                    else
                    {
                        LblWinner.Text = "You drew!";
                    }
                }
            }
            if (Type == 2)
            {
                int Comp = Ran.Next(0, 10);
                LblP1S.Text = "Your score: " + Score.ToString();
                LblP2S.Text = "Computer's score: " + Comp;
                if (Score > Comp)
                {
                    LblWinner.Text = "You won!";
                }
                else if (Comp > Score)
                {
                    LblWinner.Text = "You lost!";
                }
                else
                {
                    LblWinner.Text = "You drew!";
                }
            }
        }