예제 #1
0
        private void btnNextQuestion_Click(object sender, EventArgs e)
        {
            ExamEntities db = new ExamEntities();

            Answer answer = new Answer();

            answer.QuestionId = ObjectPasser.QuestionList[nextClick].Id;
            answer.UserId     = ObjectPasser.UserLoggedIn.Id;
            Choice choice = new Choice();

            if (rbAns1.Checked)
            {
                answer.ChoiceId = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(0).Id;
            }
            else if (rbAns2.Checked)
            {
                answer.ChoiceId = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(1).Id;
            }
            else if (rbAns3.Checked)
            {
                answer.ChoiceId = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(2).Id;
            }
            else if (rbAns4.Checked)
            {
                answer.ChoiceId = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(3).Id;
            }

            db.Answers.Add(answer);
            db.SaveChanges();
            nextClick++;
            if (nextClick == 7 && ObjectPasser.QuestionList[nextClick] == null)
            {
                MessageBox.Show("Testi bitirdiniz Tebrikler");
                this.Close();
                StudentPanel i = new StudentPanel();
                i.Show();
                ObjectPasser.QuestionList = null;
            }
            else if (ObjectPasser.QuestionList.Count > nextClick)
            {
                lblQuestion.Text = ObjectPasser.QuestionList[nextClick].Question1;
                rbAns1.Text      = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(0).Choice1;
                rbAns2.Text      = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(1).Choice1;
                rbAns3.Text      = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(2).Choice1;
                rbAns4.Text      = ObjectPasser.QuestionList[nextClick].Choices.ElementAt(3).Choice1;
            }
        }
예제 #2
0
파일: Login.cs 프로젝트: ulasgokce/E-Class
        private void Login_Click(object sender, EventArgs e)
        {
            using (ExamEntities db = new ExamEntities())
            {
                switch (GetIn.GetInside(txtUserName.Text, txtPassword.Text))
                {
                case 0:
                {
                    //TODO: Admin Login
                    this.Hide();
                    AdminPanel ap = new AdminPanel();
                    ap.Show();
                    break;
                }

                case 1:
                {
                    //TODO: Teacher Login
                    this.Hide();
                    QuestionAdd qa = new QuestionAdd();
                    qa.Show();
                    break;
                }

                case 2:
                {
                    //TODO: Student Login
                    this.Hide();
                    StudentPanel sp = new StudentPanel();
                    sp.Show();
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }