Beispiel #1
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;
         }
     }
 }
Beispiel #2
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            var username = tbxusername.Text;
            var password = tbxpassword.Text;

            if (db.Users.Any(user => user.Username == username && user.UserPassword == password))
            {
                var userName = db.Users.Where(user => user.Username == username).First();
                if (CheckUserType())
                {
                    this.Hide();
                    UsersLog log = new UsersLog()
                    {
                        UserId    = userName.UserId,
                        BeginDate = DateTime.Now
                    };
                    db.UsersLogs.Add(log);
                    db.SaveChanges();
                    ExamCreateStudio createexamstudio = new ExamCreateStudio();
                    createexamstudio.ActiveUserFullName = userName.UserFullName;
                    createexamstudio.Show();
                }
                else
                {
                    this.Hide();
                    StudentExamCenter testcenter = new StudentExamCenter();
                    testcenter.ActiveUserFullName = userName.UserFullName;
                    testcenter.Show();
                }
            }

            this.Hide();
        }
Beispiel #3
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();
            }
        }
Beispiel #4
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;
                }
            }
        }
Beispiel #5
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();
            }
        }
Beispiel #6
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);
                }
            }
        }