Exemplo n.º 1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (txtNme.Text != "" && txtSecPass.Text != "")
     {
         lblNameError.Visible    = false;
         lblSecPassError.Visible = false;
         string conString = null;
         conString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\Tido\Desktop\17749831 NAMENG THATO PROG 2A TASK-2\StudentQuizzes
         \StudentQuizzes\Student Information.mdf;Integrated Security=True;Connect Timeout=30";
         SqlConnection con = new SqlConnection(conString);
         con.Open();
         SqlDataAdapter sda = new SqlDataAdapter(@"SELECT Student Password, Student Name FROM Registration", con);
         con.Close();
         this.Hide();
         frmQuiz takeQuiz = new frmQuiz();
         takeQuiz.Show();
     }
     if (txtNme.Text == "" && txtSecPass.Text != "")
     {
         lblNameError.Visible    = true;
         lblSecPassError.Visible = false;
     }
     if (txtNme.Text != "" && txtSecPass.Text == "")
     {
         lblNameError.Visible    = false;
         lblSecPassError.Visible = true;
     }
     if (txtNme.Text == "" && txtSecPass.Text == "")
     {
         lblNameError.Visible    = true;
         lblSecPassError.Visible = true;
     }
 }
Exemplo n.º 2
0
        private void menuLecture_Click(object sender, EventArgs e)
        {
            DialogResult Message;

            Message = MessageBox.Show("Are you sure that you would like to" +
                                      "leave? ", "Wait...", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (Message == DialogResult.Yes)
            {
                this.Hide();
                frmQuiz Letcure = new frmQuiz();
                Letcure.Show();
            }
        }
Exemplo n.º 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtNme.Text != "" && txtSurname.Text != "" && txtSecPass.Text != "")
            {
                lblNameError.Visible    = false;
                lblSurnameErr.Visible   = false;
                lblSecPassError.Visible = false;
                string conString = null;
                conString = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C: \Users\Tido\Desktop\17749831 NAMENG 
                    THATO PROG 2A TASK-2\StudentQuizzes\StudentQuizzes\Student Information.mdf;Integrated Security=True;Connect Timeout=30";
                SqlConnection con = new SqlConnection(conString);
                con.Open();
                SqlCommand cmd = new SqlCommand(@"INSERT INTO StudentData (Student Password, Student Name, Student Surname) 
                    VALUES ('" + txtSecPass.Text + "','" + txtNme.Text + "','" + txtSurname.Text +
                                                "','" + "')'", con);
                MessageBox.Show("Data was saved");
                con.Close();

                this.Hide();
                frmQuiz qz = new frmQuiz();
                qz.Show();
            }
            else
            if (txtNme.Text == "" && txtSurname.Text == "" && txtSecPass.Text == "")
            {
                lblNameError.Visible    = true;
                lblSurnameErr.Visible   = true;
                lblSecPassError.Visible = true;
            }
            else
            if (txtNme.Text != "" && txtSurname.Text == "" && txtSecPass.Text == "")
            {
                lblNameError.Visible    = false;
                lblSurnameErr.Visible   = true;
                lblSecPassError.Visible = true;
            }
            else
            if (txtNme.Text == "" && txtSurname.Text != "" && txtSecPass.Text == "")
            {
                lblNameError.Visible    = true;
                lblSurnameErr.Visible   = false;
                lblSecPassError.Visible = true;
            }
            else
            if (txtNme.Text == "" && txtSurname.Text == "" && txtSecPass.Text != "")
            {
                lblNameError.Visible    = true;
                lblSurnameErr.Visible   = true;
                lblSecPassError.Visible = false;
            }
            else
            if (txtNme.Text != "" && txtSurname.Text != "" && txtSecPass.Text == "")
            {
                lblNameError.Visible    = false;
                lblSurnameErr.Visible   = false;
                lblSecPassError.Visible = true;
            }
            else
            if (txtNme.Text == "" && txtSurname.Text != "" && txtSecPass.Text != "")
            {
                lblNameError.Visible    = true;
                lblSurnameErr.Visible   = false;
                lblSecPassError.Visible = false;
            }
            else
            if (txtNme.Text != "" && txtSurname.Text == "" && txtSecPass.Text != "")
            {
                lblNameError.Visible    = false;
                lblSurnameErr.Visible   = true;
                lblSecPassError.Visible = false;
            }
        }