コード例 #1
0
        private void btn_endexam_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                GetValueOfRadios();
                pnl_sual1.Hide();
                panel1.Show();
                var selectedexamid = (from am in db.Exams where am.ExamName == cmbx_selectexam.Text select am.ExamId).First();
                var c    = db.ExamsToQuestions.Where(item => item.ExamId == selectedexamid).Select(n => n).ToList();
                var name = from r in c
                           where r.Question.CorrectAnswer.Length > 0
                           select r.Question.CorrectAnswer;
                for (int i = 0; i < cavablar.Count; i++)
                {
                    if (cavablar[i] == name.ToList().ElementAt(i))
                    {
                        score++;
                    }
                }
            }

            label3.Text = score.ToString();
            if (Convert.ToInt32(label3.Text) >= 1)
            {
                lbl_cong.Text = "Tebrikler aga";
            }
            else
            {
                lbl_cong.Text = "Kecenmedin aga";
            }
            btn_endexam.Enabled = false;
        }
コード例 #2
0
 private void btn_create_type_Click(object sender, EventArgs e)
 {
     using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
     {
         if (db.QuestionTypes.Any(item => item.QuestionTypeName == tbx_newtype.Text))
         {
             MessageBox.Show("You can not add it to Database", "Same Question Type",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             db.QuestionTypes.Add(new QuestionType()
             {
                 QuestionTypeName = tbx_newtype.Text
             });
             var popupNotifier = new PopupNotifier();
             popupNotifier.TitleText     = "Exam Management System";
             popupNotifier.ContentText   = $"Question Type is added at {DateTime.Now} : Question Type is {tbx_newtype.Text}";
             popupNotifier.IsRightToLeft = false;
             popupNotifier.Popup();
             db.SaveChanges();
             var bindingsource = new BindingSource();
             bindingsource.DataSource      = db.QuestionTypes.ToList();
             dgw_question_types.DataSource = bindingsource;
             dgw_question_types.Columns["Questions"].Visible = false;
         }
     }
 }
コード例 #3
0
        private void btn_next_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                GetValueOfRadios();
                var selectedexamid   = (from am in db.Exams where am.ExamName == cmbx_selectexam.Text select am.ExamId).First();
                var examsualuzunlugu = db.ExamsToQuestions
                                       .Where(x => x.ExamId == selectedexamid)
                                       .Count();
                for (int i = 1; i < examsualuzunlugu; i++)
                {
                    if (i == examsualuzunlugu - 1)
                    {
                        btn_next.Enabled = false;
                    }
                    var c    = db.ExamsToQuestions.Where(item => item.ExamId == selectedexamid).Select(n => n).ToList();
                    var name = from r in c
                               where r.QuestionId > 0
                               select r.QuestionId;
                    var firstquestionid = name.ToList().ElementAt(i);

                    var questiontitle         = (from am in db.Questions where am.QuestionId == firstquestionid select am.QuestionTitle);
                    var questioncorrectanswer = (from am in db.Questions where am.QuestionId == firstquestionid select am.CorrectAnswer);
                    var questionanswer2       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer1);
                    var questionanswer3       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer2);
                    var questionanswer4       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer3);

                    lbl_sual.Text          = questiontitle.First().ToString();
                    rdn_sual1_answer1.Text = questionanswer2.First().ToString();
                    rdn_sual1_answer2.Text = questionanswer3.First().ToString();
                    rdn_sual1_answer3.Text = questionanswer4.First().ToString();
                    rdn_sual1_answer4.Text = questioncorrectanswer.First().ToString();
                }
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                try
                {
                    var selectedexamid = (from am in db.Exams where am.ExamName == cmbx_selectexam.Text select am.ExamId).First();
                    var a = db.ExamsToQuestions
                            .Where(x => x.ExamId == selectedexamid)
                            .Count();

                    var c    = db.ExamsToQuestions.Where(item => item.ExamId == selectedexamid).Select(n => n).ToList();
                    var name = from r in c
                               where r.QuestionId > 0
                               select r.QuestionId;
                    var firstquestionid = name.ToList().ElementAt(0);

                    var questiontitle         = (from am in db.Questions where am.QuestionId == firstquestionid select am.QuestionTitle);
                    var questioncorrectanswer = (from am in db.Questions where am.QuestionId == firstquestionid select am.CorrectAnswer);
                    var questionanswer2       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer1);
                    var questionanswer3       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer2);
                    var questionanswer4       = (from am in db.Questions where am.QuestionId == firstquestionid select am.Answer3);

                    lbl_sual.Text             = questiontitle.First().ToString();
                    rdn_sual1_answer1.Text    = questionanswer2.First().ToString();
                    rdn_sual1_answer2.Text    = questionanswer3.First().ToString();
                    rdn_sual1_answer3.Text    = questionanswer4.First().ToString();
                    rdn_sual1_answer4.Text    = questioncorrectanswer.First().ToString();
                    btn_start.Enabled         = true;
                    lbl_sual.Visible          = true;
                    rdn_sual1_answer1.Visible = true;
                    rdn_sual1_answer2.Visible = true;
                    rdn_sual1_answer3.Visible = true;
                    rdn_sual1_answer4.Visible = true;
                    btn_endexam.Visible       = true;
                    btn_next.Visible          = true;
                    btn_start.Enabled         = false;
                }
                catch
                {
                    MessageBox.Show("There are not questions in this exam", "Cannot Find Questions",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #5
0
        public StudentExamCenter()
        {
            ExamManagementSystemEntities db = new ExamManagementSystemEntities();

            InitializeComponent();
            lblformname.Text = "Student Profile";
            foreach (var item in db.Exams)
            {
                cmbx_selectexam.Items.Add(item.ExamName);
            }
            lbl_sual.Visible          = false;
            rdn_sual1_answer1.Visible = false;
            rdn_sual1_answer2.Visible = false;
            rdn_sual1_answer3.Visible = false;
            rdn_sual1_answer4.Visible = false;
            btn_endexam.Visible       = false;
            btn_next.Visible          = false;
            panel1.SendToBack();
        }
コード例 #6
0
        private void btn_create_newuser_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                var username     = tbx_newuser_username.Text;
                var password     = tbx_newuser_password.Text;
                var email        = tbx_newuser_email.Text;
                var userfullname = tbx_newuser_fullname.Text;
                var usertype     = (from item in db.UserTypes where item.UserTypeName == cmbx_newuser_usertype.Text select item.UserTypeId).First();
                if (db.Users.Any(item => item.Username == username))
                {
                    MessageBox.Show("You can not add it to Database", "Same Exam Name",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    db.Users.Add(new User()
                    {
                        Username     = username,
                        UserFullName = userfullname,
                        UserEmail    = email,
                        UserTypeId   = usertype,
                        UserPassword = password,
                    });
                    db.SaveChanges();
                    var bindingsource = new BindingSource();
                    bindingsource.DataSource = db.Users.ToList();
                    dgw_users.DataSource     = bindingsource;

                    var popupNotifier = new PopupNotifier();
                    popupNotifier.TitleText     = "Exam Management System";
                    popupNotifier.ContentText   = $"User is added at {DateTime.Now} : User is {username}";
                    popupNotifier.IsRightToLeft = false;
                    popupNotifier.Popup();


                    var bindingsource2 = new BindingSource();
                    bindingsource2.DataSource = db.Users.Where(item => item.UserTypeId == 3).ToList();
                    dgw_students.DataSource   = bindingsource2;
                }
            }
        }
コード例 #7
0
        private void exitlabel_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                this.Close();

                int index = (from item in db.Users
                             where item.UserFullName == userFullName
                             select item.UserId).First();
                var lastlog = db.UsersLogs.OrderByDescending(p => p.LogId).Take(1);

                if (lastlog.First().EndDate == null)
                {
                    lastlog.First().EndDate = DateTime.Now;
                    db.SaveChanges();
                }
                Login frmMainMenu = new Login();
                frmMainMenu.Show();
            }
        }
コード例 #8
0
        private void btn_createexam_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                if (db.Exams.Any(item => item.ExamName == tbxnewexam.Text))
                {
                    MessageBox.Show("You can not add it to Database", "Same Exam Name",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    db.Exams.Add(new Exam()
                    {
                        ExamName = tbxnewexam.Text
                    });
                    var popupNotifier = new PopupNotifier();
                    popupNotifier.TitleText     = "Exam Management System";
                    popupNotifier.ContentText   = $"Exam is added at {DateTime.Now} : Exam Name is {tbxnewexam.Text}";
                    popupNotifier.IsRightToLeft = false;
                    popupNotifier.Popup();
                    db.SaveChanges();
                    var bindingsource3 = new BindingSource();
                    bindingsource3.DataSource = db.Exams.ToList();
                    dgw_exams2.DataSource     = bindingsource3;
                    dgw_exams2.Columns["ExamsToQuestions"].Visible = false;
                    dgw_exams2.Columns["UsersExams"].Visible       = false;

                    var bindingsource2 = new BindingSource();
                    bindingsource2.DataSource = db.Exams.ToList();
                    dgw_exams.DataSource      = bindingsource2;
                    dgw_exams.Columns["ExamsToQuestions"].Visible = false;
                    dgw_exams.Columns["UsersExams"].Visible       = false;
                }
                cmbx_createquestions.Items.Clear();
                foreach (var item in db.Exams)
                {
                    cmbx_createquestions.Items.Add(item.ExamName);
                }
            }
        }
コード例 #9
0
        private void btn_createquestions_create_Click(object sender, EventArgs e)
        {
            using (ExamManagementSystemEntities db = new ExamManagementSystemEntities())
            {
                var questionbody  = tbx_createquestions_question1.Text;
                var correctanswer = tbx_createquestions_correctanswer.Text;
                var answer1       = tbx_createquestions_answer2.Text;
                var answer2       = tbx_createquestions_answer3.Text;
                var answer3       = tbx_createquestions_answer4.Text;
                var questiontype  = (from item in db.QuestionTypes where item.QuestionTypeName == cmbx_createquestions_questiontype.Text select item.QuestionTypeId).First();
                db.Questions.Add(new Question()
                {
                    QuestionTitle  = questionbody,
                    CorrectAnswer  = correctanswer,
                    Answer1        = answer1,
                    Answer2        = answer2,
                    Answer3        = answer3,
                    QuestionTypeId = questiontype
                });
                db.SaveChanges();
                var result = (from t in db.Questions
                              orderby t.QuestionId descending
                              select t.QuestionId).First();
                var examid = (from item in db.Exams where item.ExamName == cmbx_createquestions.Text select item.ExamId).First();
                db.ExamsToQuestions.Add(new ExamsToQuestion()
                {
                    ExamId     = examid,
                    QuestionId = result
                });
                //qaldigim yer exame suallar add olunur many to many
                db.SaveChanges();

                var popupNotifier = new PopupNotifier();
                popupNotifier.TitleText     = "Exam Management System";
                popupNotifier.ContentText   = $"Question is added at {DateTime.Now}";
                popupNotifier.IsRightToLeft = false;
                popupNotifier.Popup();
            }
        }
コード例 #10
0
        public ExamCreateStudio()
        {
            InitializeComponent();

            ExamManagementSystemEntities db = new ExamManagementSystemEntities();

            cmbx_newuser_usertype.Text                = "Student";
            cmbx_createquestions.Text                 = (from item in db.Exams select item.ExamName).First();
            cmbx_createquestions_questiontype.Text    = (from item in db.QuestionTypes select item.QuestionTypeName).First();
            dgw_status_report.DataSource              = db.UsersLogs.ToList();
            dgw_status_report.Columns["User"].Visible = false;

            dgw_exams2.DataSource = db.Exams.ToList();
            dgw_exams2.Columns["ExamsToQuestions"].Visible = false;
            dgw_exams2.Columns["UsersExams"].Visible       = false;

            dgw_exams.DataSource = db.Exams.ToList();
            dgw_exams.DataSource = db.Exams.ToList();
            dgw_exams.Columns["ExamsToQuestions"].Visible = false;
            dgw_exams.Columns["UsersExams"].Visible       = false;
            dgw_question_types.DataSource = db.QuestionTypes.ToList();
            dgw_question_types.Columns["Questions"].Visible = false;

            dgw_students.DataSource = db.Users.Where(item => item.UserTypeId == 3).ToList();
            //dgw_users.DataSource = db.Users.Join();

            //dgw_users.DataSource = db.Users.Where(x=>x.)



            dgw_students.Columns["UsersExams"].Visible = false;
            dgw_students.Columns["UsersLogs"].Visible  = false;
            dgw_students.Columns["UserType"].Visible   = false;

            var usertypelist = db.UserTypes.ToList();

            foreach (var item in usertypelist)
            {
                cmbx_newuser_usertype.Items.Add(item.UserTypeName);
            }
            foreach (var item in db.Exams.ToList())
            {
                cmbx_createquestions.Items.Add(item.ExamName);
            }
            foreach (var item in db.QuestionTypes)
            {
                cmbx_createquestions_questiontype.Items.Add(item.QuestionTypeName);
            }

            this.ActiveControl         = label1;
            lblformname.Text           = "Teacher Profile";
            pnl_students.Location      = new Point(168, 30);
            pnl_questiontypes.Location = new Point(168, 30);
            pnl_show_exam.Location     = new Point(168, 30);
            pnlstatusreport.Location   = new Point(168, 30);
            pnl_show_students.Location = new Point(168, 30);
            pnl_showquestions.Location = new Point(168, 30);
            pnl_exams.Location         = new Point(168, 30);
            pnl_questions.Location     = new Point(168, 30);
            pnl_exams.Hide();
            pnl_questions.Hide();
            pnl_students.Hide();
            pnl_showquestions.Hide();
            pnl_show_exam.Show();
            pnl_show_students.Hide();
            pnlstatusreport.Hide();
        }