Exemplo n.º 1
0
        private async void btnNo_Click_1(object sender, EventArgs e)
        {
            try
            {
                SqlConnection conn = new SqlConnection("Data Source=PATRICK-PC; Initial Catalog=okoriet; integrated security=true");
                conn.Open();

                SqlCommand command = new SqlCommand("", conn);
                command.CommandText = "SELECT * FROM spoergsmaal WHERE spoergsmaal='" + Question.Text + "'";
                SqlDataReader reader = null;
                reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        labelId.Text = reader["id"].ToString();
                    }
                }

                reader.Close();
                labelId.Text = labelId.Text;

                command.CommandText = "INSERT INTO svar(svar,spoergsmaal) VALUES ('nej','" + labelId.Text + "')";
                command.ExecuteNonQuery();

                btnYes.Hide();
                btnNo.Hide();

                labelSvarEfterBrugerSvar.Text = "Tak for dit svar. Du svarede: Nej";
                panelAddProcent.Show();

                command.CommandText = "SELECT COUNT(*) FROM svar WHERE spoergsmaal='" + labelId.Text + "'";
                double fullcount = Convert.ToDouble(command.ExecuteScalar());
                command.CommandText = "SELECT COUNT(*) FROM svar WHERE svar='nej' AND spoergsmaal='" + labelId.Text + "'";
                double countno = Convert.ToDouble(command.ExecuteScalar());

                double procent = (countno / fullcount) * 100;

                labelProcent.Text = procent.ToString("N2") + "% af besøgende har svaret det samme som dig.";


                buttonBack.Visible = false;
                await Task.Delay(5000);

                buttonBack.Visible = true;

                string    formid      = labelId.Text;
                int       id          = int.Parse(formid);
                questions reload_form = new questions(id);
                await Task.Delay(30000);

                this.Dispose();
                reload_form.Show();
            }
            catch (SqlException)
            {
                labelError.Text = "Der skete en fejl i dit svar, prøv igen senere eller kontakt personalet";
            }
        }
Exemplo n.º 2
0
        private void buttonQ2_Click(object sender, EventArgs e)
        {
            int       id = 2;                 //Giver knap 2 id'et 2 for at vi kan bruge den i den næste form
            questions q  = new questions(id); //Definere den nye form så vi kan åbne den

            q.Show();                         //Her vises den nye form.
            this.Hide();
        }
Exemplo n.º 3
0
        private void buttonBack_Click(object sender, EventArgs e)
        {
            string    formid      = labelId.Text;
            int       id          = int.Parse(formid);
            questions reload_form = new questions(id);

            this.Dispose();
            reload_form.Show();
        }
Exemplo n.º 4
0
        private void ReloadForm()
        {
            int       id = 0;
            questions q  = new questions(id);

            q.Refresh();
            Refresh();
            q.Hide();
            q.Show();
        }