private void button1_Click(object sender, EventArgs e)
        {
            Select_Instructor_Result ins = ent.Select_Instructor(instructorID).First();
            int     deptID = int.Parse(ins.Department_ID.ToString());
            Student std    = new Student();

            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
            {
                std.Fname   = textBox2.Text;
                std.Lname   = textBox1.Text;
                std.Address = textBox3.Text;
                std.DoB     = Convert.ToDateTime(textBox4.Text);
                std.DeptId  = deptID;
                ent.Students.Add(std);
                MessageBox.Show("ADDED");
                ent.SaveChanges();
                loadStudentData();
            }
            else
            {
                MessageBox.Show("PLEASE ENTER FULL DATA");
            }

            //ent.Insert_Student()
        }
Exemple #2
0
        private void insertChoicesForQuestById(int questID)
        {
            OnlineExam ent = new OnlineExam();

            if (!isChoiceDataValid())
            {
                MessageBox.Show("Please Enter All Data Rrequired", "Waring");
                return;
            }

            Dictionary <string, TextBox> choices = new Dictionary <string, TextBox>(4);

            choices.Add("a", ansA);
            choices.Add("b", ansB);
            choices.Add("c", ansC);
            choices.Add("d", ansD);
            foreach (var item in choices)
            {
                Ques_Choices ques_Choices = new Ques_Choices()
                {
                    QuesId  = questID,
                    choices = item.Key,
                    body    = item.Value.Text.Trim()
                };

                ent.Ques_Choices.Add(ques_Choices);
            }
            ent.SaveChanges();

            ansA.Text = ansB.Text = ansC.Text = ansD.Text = string.Empty;
        }
Exemple #3
0
        private void deletePrevGradeIfExist()
        {
            OnlineExam exam = new OnlineExam();
            var        msg  = exam.deletePrevGrade(studentID, examID);

            exam.SaveChanges();
        }
Exemple #4
0
        // Delete
        private void button3_Click(object sender, EventArgs e)
        {
            int examId = 0;

            if (comboBox1.SelectedItem != null)
            {
                examId = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("There Is No Exam Selected");
                return;
            }

            OnlineExam ent  = new OnlineExam();
            var        exam = (from ex in ent.Exams
                               where ex.Enumber == examId
                               select ex).First();

            int crsId = (int)exam.CrsId;

            ent.Exams.Remove(exam);
            ent.SaveChanges();
            comboBox1.Text = comboBox2.Text = string.Empty;

            loadCourse();
            loadExams(crsId);
        }
Exemple #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            int questID = 0;
            int crsID   = 0;

            if (comboBox2.SelectedItem != null)
            {
                questID = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select quest id", "Waring");
            }

            if (comboBox1.SelectedItem != null)
            {
                crsID = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("Please select course id", "Waring");
                return;
            }

            if (!isQuestDataValid())
            {
                MessageBox.Show("Please Enter Valid Data", "Waring");
                return;
            }

            string qbody    = qcont.Text.Trim();
            int    qdeg     = (int)qdegree.Value;
            string modelAns = qmodel.Text.Trim();

            OnlineExam ent   = new OnlineExam();
            var        quest = (from q in ent.Questions
                                where q.QuesId == questID
                                select q).First();

            quest.Qcontent = qbody;
            quest.Answer   = modelAns;
            quest.Degree   = qdeg;

            if (quest.Type.ToLower().Trim() == "mcq")
            {
                updateChoice(questID);
            }

            ent.SaveChanges();
            loadCourse();
            loadQuestions(crsID);
            questionInfo(questID);
            qcont.Text     = qmodel.Text = string.Empty;
            qdegree.Value  = 1;
            comboBox3.Text = string.Empty;
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "" && comboBox2.Text != "" && textBox1.Text != "")
     {
         Course crs = new Course();
         crs.CrsName = textBox1.Text;
         var myins = ent.Instructors.Where(i => i.InsName == comboBox2.Text).Select(i => i).First();
         crs.Instructors.Add(myins);
         ent.Courses.Add(crs);
         ent.SaveChanges();
         MessageBox.Show("ADDED");
         var courses = ent.Courses.Select(d => new { d.CrsId, d.CrsName }).ToList();
         dataGridView1.DataSource = courses;
     }
     else
     {
         MessageBox.Show("PLEASE ENTER VALID DATA");
     }
 }
Exemple #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "" && comboBox2.Text != "" && textBox2.Text != "")
     {
         var   crsName  = comboBox2.Text;
         var   myCourse = ent.Courses.Where(d => d.CrsName == crsName).Select(d => d).First();
         Topic mytopic  = new Topic();
         mytopic.CrsId   = myCourse.CrsId;
         mytopic.Topname = textBox2.Text;
         ent.Topics.Add(mytopic);
         ent.SaveChanges();
         MessageBox.Show("ADDED");
         comboBox1.Text = comboBox2.Text = textBox2.Text = "";
         var topics = ent.Topics.Select(d => new { d.TopId, d.Topname, d.Course.CrsName }).ToList();
         dataGridView1.DataSource = topics;
     }
     else
     {
         MessageBox.Show("PLEASE ENTER DATA");
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text != "" && comboBox2.Text != "" && textBox2.Text != "")
     {
         var        deptName = comboBox1.SelectedItem.ToString();
         var        mydept   = ent.Departments.Where(d => d.DeptName == deptName).Select(d => d).First();
         int        insid    = int.Parse(comboBox2.Text.ToString());
         string     insname  = textBox2.Text;
         Instructor myins    = new Instructor();
         myins.InsId   = insid;
         myins.InsName = insname;
         myins.DeptId  = mydept.DeptId;
         ent.Instructors.Add(myins);
         ent.SaveChanges();
         MessageBox.Show("ADDED");
         var instructors = ent.Instructors.Select(d => new { d.InsId, d.InsName, d.DeptId }).ToList();
         dataGridView1.DataSource = instructors;
     }
     else
     {
         MessageBox.Show("PLEASE ENTER THE FULL DATA");
     }
 }
Exemple #9
0
        // add
        private void button1_Click(object sender, EventArgs e)
        {
            OnlineExam ent   = new OnlineExam();
            int        crsId = 0;
            string     desc  = textBox2.Text;

            if (comboBox2.SelectedItem != null)
            {
                crsId = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("invalid Course ID entred", "Waring");
                return;
            }
            int nMcq = (int)numericUpDown1.Value;

            if (isNumberOfMcqOutOfRange(crsId, nMcq))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }

            int nTF = (int)numericUpDown2.Value;

            if (isNumberOfTFRange(crsId, nTF))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }


            int  duration = (int)numericUpDown3.Value;
            Exam exam     = new Exam()
            {
                CrsId        = crsId,
                Edescription = desc,
                NumOfMcq     = nMcq,
                NumOfTF      = nTF,
                Eduration    = duration,
                Edate        = DateTime.Now
            };

            ent.Exams.Add(exam);
            ent.SaveChanges();
            comboBox1.Text       = comboBox2.Text = textBox2.Text = string.Empty;
            numericUpDown1.Value = numericUpDown2.Value = numericUpDown3.Value = 0;
            loadCourse();
            loadExams(crsId);
        }
Exemple #10
0
        private void updateChoice(int QuestID)
        {
            OnlineExam ent = new OnlineExam();

            if (!isChoiceDataValid())
            {
                MessageBox.Show("Please Enter All Data Rrequired", "Waring");
                return;
            }

            var chlist = ent.Select_MCQ_Question(QuestID).ToList();

            chlist[0].body = ansA.Text;
            chlist[1].body = ansB.Text;
            chlist[2].body = ansC.Text;
            chlist[3].body = ansD.Text;
            ent.SaveChanges();
            ansA.Text = ansB.Text = ansC.Text = ansD.Text = string.Empty;
        }
Exemple #11
0
        // update
        private void Update_Click(object sender, EventArgs e)
        {
            int        examId = 0;
            int        crsId  = 0;
            OnlineExam ent    = new OnlineExam();

            if (comboBox2.SelectedItem != null)
            {
                crsId = int.Parse(comboBox2.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("invalid Course ID entred", "Waring");
                return;
            }

            if (comboBox1.SelectedItem != null)
            {
                examId = int.Parse(comboBox1.SelectedItem.ToString().Split(',')[0]);
            }
            else
            {
                MessageBox.Show("There Is No Exam Selected");
                return;
            }

            if (!isDataValid())
            {
                MessageBox.Show("There is Data Is Missing", "Waring");
                return;
            }

            string desc = textBox2.Text;
            int    nMcq = (int)numericUpDown1.Value;

            if (isNumberOfMcqOutOfRange(crsId, nMcq))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }

            int nTF = (int)numericUpDown2.Value;

            if (isNumberOfTFRange(crsId, nTF))
            {
                MessageBox.Show("The Number Is out of Range\nplease go and insert more Question to Continue", "Waring");
                return;
            }


            int duration = (int)numericUpDown3.Value;

            if (duration < 10)
            {
                MessageBox.Show("Mim Duration is 10 Min");
                return;
            }

            var exam = (from ex in ent.Exams
                        where ex.Enumber == examId
                        select ex).First();

            exam.Edescription = desc;
            exam.Eduration    = duration;
            exam.NumOfMcq     = nMcq;
            exam.NumOfTF      = nTF;

            ent.SaveChanges();
            comboBox1.Text       = comboBox2.Text = textBox2.Text = string.Empty;
            numericUpDown1.Value = numericUpDown2.Value = numericUpDown3.Value = 0;
            loadCourse();
            loadExams(crsId);
        }