Ejemplo n.º 1
0
        // Update
        private void Update_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                MessageBox.Show("Enter your StudentId");
            }
            else
            {
                try
                {
                    using (Online_Exame ent = new Online_Exame())
                    {
                        var ins      = ent.Instractors.Find(ins_id);
                        int Ins_dept = (int)ins.Dept_id;

                        Student student = ent.Students.Find(int.Parse(comboBox1.Text));
                        ent.UpdateStudent(student.St_id, txtFname.Text, txtLname.Text,
                                          txtaddress.Text, int.Parse(txtage.Text), txtEmail.Text, Ins_dept);
                        comboBox1.Text = txtFname.Text = txtLname.Text = txtEmail.Text = txtage.Text
                                                                                             = txtaddress.Text = string.Empty;
                        MessageBox.Show("Updated successfully");
                        loadDataGrid();
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Incorrect ID");
                }
                catch (FormatException)
                {
                    MessageBox.Show("Invaild Format");
                }
            }
        }
        //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;
            }

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

            comboBox1.Text       = comboBox2.Text = textBox1.Text = string.Empty;
            numericUpDown1.Value = numericUpDown2.Value = numericUpDown3.Value = 0;

            int crsId = (int)exam.C_id;

            ent.Exams.Remove(exam);
            ent.SaveChanges();
            loadCourses();
            loadExam(crsId);
        }
        private void loadEaxam(int cId)
        {
            Online_Exame exam = new Online_Exame();

            var course = from c in exam.courses where c.C_id == cId select c;

            var exames = from ex in exam.Exams
                         where ex.C_id == cId
                         select ex;

            if (exames.Count() == 0)
            {
                flowLayoutPanel1.Controls.Clear();
                comboBox1.Items.Clear();
                comboBox1.Text = string.Empty;
                Label nolabel = new Label();
                nolabel.Text      = "There Is No Exams Available";
                nolabel.Size      = new Size(350, 30);
                nolabel.ForeColor = Color.FromArgb(55, 187, 77);
                nolabel.Font      = new Font("Microsoft Sans Serif", 18);
                flowLayoutPanel1.Controls.Add(nolabel);
                ExamID = -1;
                StartButtonStatus();
            }
            else
            {
                flowLayoutPanel1.Controls.Clear();
                comboBox1.Items.Clear();
                foreach (var item in exames)
                {
                    string exams = $"{item.Ex_id}, {item.Ex_Des}";
                    comboBox1.Items.Add(exams);
                }
            }
        }
Ejemplo n.º 4
0
 // Search
 private void Search_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "")
     {
         MessageBox.Show("Enter your TopicId");
     }
     else
     {
         try
         {
             using (Online_Exame ent = new Online_Exame())
             {
                 var Topic = ent.Topics.Find(int.Parse(comboBox1.Text));
                 textBox1.Text = Topic.Name;
             }
         }
         catch (InvalidOperationException)
         {
             MessageBox.Show("Incorrect ID");
         }
         catch (FormatException)
         {
             MessageBox.Show("Incorrect ID");
         }
     }
 }
        private void loadQuestion(int index)
        {
            flowLayoutPanel2.FlowDirection = FlowDirection.TopDown;
            Online_Exame ex = new Online_Exame();

            currentIndex = index;
            ButtonsStates();
            flowLayoutPanel2.Controls.Clear();
            getExam_Question_Result q = list[index];

            labelQuestion.Text = $"{index + 1}) {q.Qustion}";
            NumQuest.Text      = $"{index + 1} / {list.Count}";

            var choices = from c in ex.Choices

                          where c.Quset_id == q.Quest_Id
                          select c;

            foreach (var item in choices)
            {
                RadioButton radio = new RadioButton();
                radio.CheckedChanged += new System.EventHandler(getAnswer);
                string answer = item.ch_id + ") " + item.choices;
                radio.Text = answer;
                radio.Size = new Size(200, 20);

                flowLayoutPanel2.Controls.Add(radio);
            }
        }
        //--login buuton
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Please enter your Id");
            }
            else
            {
                try
                {
                    inputId = int.Parse(textBox1.Text);
                    Online_Exame ent  = new Online_Exame();
                    var          item = (from d in ent.Departments
                                         where d.Dept_manger == inputId
                                         select d).First();

                    this.Close();
                    MangerHome mn = new MangerHome();
                    mn.Show();
                }
                catch (InvalidOperationException)
                {
                    MessageBox.Show("Incorrect ID");
                }
                catch (FormatException)
                {
                    MessageBox.Show("Incorrect ID");
                }
            }
        }
Ejemplo n.º 7
0
 // Search
 private void Search_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "")
     {
         MessageBox.Show("Enter your StudentId");
     }
     else
     {
         try
         {
             using (Online_Exame ent = new Online_Exame())
             {
                 Student student = ent.Students.Find(int.Parse(comboBox1.Text));
                 txtFname.Text   = student.St_fname;
                 txtLname.Text   = student.St_lname;
                 txtEmail.Text   = student.Email;
                 txtage.Text     = student.Age.ToString();
                 txtaddress.Text = student.Address;
             }
         }
         catch (InvalidOperationException)
         {
             MessageBox.Show("Incorrect ID");
         }
         catch (FormatException)
         {
             MessageBox.Show("Incorrect ID");
         }
     }
 }
        private void insertChoicesForQuestById(int questID)
        {
            Online_Exame ent = new Online_Exame();

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

            TextBox[] ch = { ans1, ans2, ans3, ans4 };
            for (int i = 0; i < ch.Length; i++)
            {
                Choice chois = new Choice()
                {
                    ch_id    = i,
                    Quset_id = questID,
                    choices  = ch[i].Text
                };
                ent.Choices.Add(chois);
            }

            ent.SaveChanges();
            ans1.Text = ans2.Text = ans3.Text = ans4.Text = string.Empty;
        }
Ejemplo n.º 9
0
        //--- add course
        private void button1_Click(object sender, EventArgs e)
        {
            comboBox1.Text = string.Empty;
            try
            {
                using (Online_Exame ent = new Online_Exame())
                {
                    ent.InsertNewCourse(textBox1.Text);
                    ent.SaveChanges();

                    MessageBox.Show("Added Successfully");
                    Courses.Items.Clear();
                    Instructors.Items.Clear();
                    label7.Text = comboBox1.Text = comboBox3.Text = textBox1.Text = string.Empty;


                    LoadCourses();
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Please complete the information");
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Invalid Information");
            }
        }
        private void Course_List_Load(object sender, EventArgs e)
        {
            Online_Exame exam  = new Online_Exame();
            var          grade = exam.Examresults(stdId);

            dataGridView1.DataSource = grade;
        }
        private void finish_Click(object sender, EventArgs e)
        {
            Online_Exame ex = new Online_Exame();

            IfStdExameExestBefor();
            foreach (var item in StudentAnswers)
            {
                //var msg = ex.NewStudentExam(studentID, item.Key, examID, 0, item.Value);
                Student_Exam se = new Student_Exam()
                {
                    St_id     = studentID,
                    Ex_id     = examID,
                    Q_id      = item.Key,
                    Result    = 0,
                    St_answer = item.Value
                };
                ex.Student_Exam.Add(se);

                ex.SaveChanges();
            }
            ex.ExamCorrection(studentID, examID);
            var res = ex.ExamRes(studentID, examID).First();

            MessageBox.Show($"your grade {res}");
            StudentDashbord std = new StudentDashbord(studentID);

            this.Close();
            std.Show();
        }
Ejemplo n.º 12
0
 // Delete
 private void Delete_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "")
     {
         MessageBox.Show("Enter your StudentId");
     }
     else
     {
         try
         {
             using (Online_Exame ent = new Online_Exame())
             {
                 Student student = ent.Students.Find(int.Parse(comboBox1.Text));
                 //ent.deleteStudent(student.St_id);
                 ent.Students.Remove(student);
                 ent.SaveChanges();
                 MessageBox.Show("Deleted Successfully");
                 load();
                 loadDataGrid();
             }
         }
         catch (NullReferenceException)
         {
             MessageBox.Show("Incorrect ID");
         }
         catch (FormatException)
         {
             MessageBox.Show("Invaild Format");
         }
     }
 }
        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    = textBox1.Text.Trim();
            int    qdeg     = (int)numericUpDown1.Value;
            int    modelAns = int.Parse(textBox2.Text.Trim());

            Online_Exame ent = new Online_Exame();

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

            quest.Qustion      = qbody;
            quest.CorectAnswer = modelAns;
            quest.Grade        = qdeg;

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

            ent.SaveChanges();
            LoadCourses();
            loadQuestions(crsID);
            questionInfo(questID);
            textBox1.Text        = textBox2.Text = string.Empty;
            ans1.Text            = ans2.Text = ans3.Text = ans4.Text = string.Empty;
            numericUpDown1.Value = 1;
            comboBox3.Text       = string.Empty;
        }
        // display department instructors in grid view
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int deptId = (int)comboBox1.SelectedItem;

            using (Online_Exame ent = new Online_Exame())
            {
                dataGridView1.DataSource = ent.Get_instructor_by_deptId(deptId);
            }
        }
        private void examDetails(int exId)
        {
            Online_Exame exam = new Online_Exame();
            var          data = (from e in exam.Exams where e.Ex_id == exId select e).First();

            textBox1.Text        = data.Ex_Des;
            numericUpDown1.Value = int.Parse(data.T_F.ToString());
            numericUpDown2.Value = int.Parse(data.MC.ToString());
            numericUpDown3.Value = int.Parse(data.Duration.ToString());
        }
        private void loadCourses()
        {
            comboBox2.Items.Clear();
            Online_Exame exam = new Online_Exame();
            var          cour = exam.getInsCourses(inst);

            foreach (var item in cour)
            {
                comboBox2.Items.Add($"{item.C_id} , {item.C_name}");
            }
        }
        //function to load Dept ids
        private void LoadDepartments()
        {
            comboBox1.Items.Clear();
            Online_Exame ent     = new Online_Exame();
            var          deptids = from v in ent.Departments
                                   select v.Dept_id;

            foreach (var i in deptids)
            {
                comboBox1.Items.Add(i);
            }
        }
        // display choosen instructor information
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            int          insId = (int)comboBox2.SelectedItem;
            Online_Exame ent   = new Online_Exame();
            var          item  = (from d in ent.Instractors
                                  where d.Ins_id == insId
                                  select d).First();

            textBox1.Text          = item.Ins_fname;
            textBox2.Text          = item.Ins_lname;
            comboBox1.SelectedItem = item.Dept_id;
        }
Ejemplo n.º 19
0
        // Add
        private void Add_Click(object sender, EventArgs e)
        {
            if (txtFname.Text == "")
            {
                MessageBox.Show("Please enter your Fname");
            }
            else if (txtLname.Text == "")
            {
                MessageBox.Show("Please enter your Lname");
            }
            else if (txtEmail.Text == "")
            {
                MessageBox.Show("Please enter your Email");
            }
            else if (txtage.Text == "")
            {
                MessageBox.Show("Please enter your Age");
            }
            else if (txtaddress.Text == "")
            {
                MessageBox.Show("Please enter your Address");
            }
            else
            {
                try
                {
                    using (Online_Exame ent = new Online_Exame())
                    {
                        var ins      = ent.Instractors.Find(ins_id);
                        int Ins_dept = (int)ins.Dept_id;

                        /* ent.insertNewStudent(txtFname.Text, txtLname.Text,
                         *  txtaddress.Text, int.Parse(txtage.Text), txtEmail.Text, Ins_dept);*/
                        Student std = new Student();
                        std.St_fname = txtFname.Text;
                        std.St_lname = txtLname.Text;
                        std.Address  = txtaddress.Text;
                        std.Age      = int.Parse(txtage.Text);
                        std.Email    = txtEmail.Text;
                        std.Dept_id  = Ins_dept;
                        ent.Students.Add(std);
                        ent.SaveChanges();
                        MessageBox.Show("Added Successfully");
                        load();
                        loadDataGrid();
                    }
                }
                catch (FormatException)
                {
                    MessageBox.Show("Invalid format");
                }
            }
        }
Ejemplo n.º 20
0
 public void load()
 {
     using (Online_Exame ent = new Online_Exame())
     {
         comboBox2.Items.Clear();
         var crs = ent.getInstractor_Course(ins_id).ToList();
         foreach (var item in crs)
         {
             comboBox2.Items.Add(item);
         }
     }
 }
Ejemplo n.º 21
0
        private void LoadCourses()
        {
            comboBox1.Items.Clear();
            Online_Exame ent   = new Online_Exame();
            var          crsid = from v in ent.courses
                                 select v.C_id;

            foreach (var i in crsid)
            {
                comboBox1.Items.Add(i);
            }
        }
        //function to load instructor ids
        private void Loadinstructor()
        {
            dataGridView1.DataSource = null;
            comboBox2.Items.Clear();
            Online_Exame ent    = new Online_Exame();
            var          insids = from v in ent.Instractors
                                  select v.Ins_id;

            foreach (var i in insids)
            {
                comboBox2.Items.Add(i);
            }
        }
Ejemplo n.º 23
0
        //----- on form load fill combo boxes
        private void MangeCourses_Load(object sender, EventArgs e)
        {
            Online_Exame ent = new Online_Exame();

            LoadCourses();
            var insnames = from v in ent.Instractors
                           select v.Ins_fname + " " + v.Ins_lname;

            foreach (var i in insnames)
            {
                comboBox3.Items.Add(i);
            }
        }
        public StudentDashbord(int id)
        {
            InitializeComponent();
            this.id = id;
            Online_Exame exam    = new Online_Exame();
            var          student = (from s in exam.Students
                                    where s.St_id == id
                                    select s).First();

            label2.Text = student.St_id.ToString();
            label3.Text = student.St_fname + ' ' + student.St_lname;
            label5.Text = student.Address;
        }
        private void LoadCourses()
        {
            Online_Exame exam   = new Online_Exame();
            var          std    = (from s in exam.Instractors where s.Ins_id == inst select s).First();
            var          course = exam.getCoursesByDeptID(std.Dept_id).ToList();


            foreach (var item in course)
            {
                string cour = item.C_id + "," + item.C_name;
                comboBox1.Items.Add(cour);
            }
        }
        private void LoadCourses()
        {
            Online_Exame exam   = new Online_Exame();
            var          std    = (from s in exam.Students where s.St_id == stdID select s).First();
            var          course = exam.getCoursesByDeptID(std.Dept_id).ToList();


            foreach (var item in course)
            {
                string cour = item.C_id + "," + item.C_name;
                listBox1.Items.Add(cour);
            }
        }
 private void IfStdExameExestBefor()
 {
     try
     {
         Online_Exame ex  = new Online_Exame();
         var          msg = ex.deleteStudentExam(studentID, examID);
         ex.SaveChanges();
     }
     catch (Exception)
     {
         return;
     }
 }
Ejemplo n.º 28
0
        public InstructorOperation(int id)
        {
            InitializeComponent();
            this.inst = id;
            Online_Exame exam    = new Online_Exame();
            var          student = (from s in exam.Instractors
                                    where s.Ins_id == id
                                    select s).First();

            label2.Text = student.Ins_id.ToString();
            label4.Text = student.Ins_fname + ' ' + student.Ins_lname;
            label5.Text = student.Dept_id.ToString();
        }
        private void LoadExam()
        {
            Online_Exame exams     = new Online_Exame();
            var          examQuest = exams.getExam_Question(examID);

            list           = examQuest.ToList();
            StudentAnswers = new Dictionary <int, string>(list.Count);

            // show Exam details
            var examInfo = (from e in exams.Exams where e.Ex_id == examID select e).First();

            label1.Text = examInfo.Ex_Des.Trim();
            label2.Text = examInfo.Duration.ToString() + "M";
        }
 private void Login(int id, string email)
 {
     try
     {
         Online_Exame    exam    = new Online_Exame();
         var             std     = (from s in exam.Students where s.St_id == id & s.Email == email select s).First();
         StudentDashbord Student = new StudentDashbord(std.St_id);
         Student.Show();
         this.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Not Autho");
     }
 }