private void btnInsert_Click(object sender, EventArgs e)
        {
            string crsname = cmboxcrs.SelectedItem.ToString();
            Course crs     = (from obj in db.Courses
                              where obj.crsName == crsname
                              select obj).Distinct().FirstOrDefault();
            Question ques = new Question();
            //
            QuesType quest = new QuesType();

            ques.question1 = txtQues.Text;
            //
            quest.type         = comboBoxType.Text;
            ques.grade         = int.Parse(txtGrade.Text);
            ques.crsID         = crs.crsID;
            ques.correctChoice = textCorrrectChoice.Text;
            db.Questions.Add(ques);
            db.QuesTypes.Add(quest);
            db.SaveChanges();
            txtGrade.Text = txtQues.Text = txtQuesD.Text = cmboxcrs.Text = comboBoxType.Text = textCorrrectChoice.Text = string.Empty;
            cmboxcrs.Items.Clear();
            comboBoxType.Items.Clear();
            fillDataGridView();
            fillCombobox();
            fillcourseType();
            MessageBox.Show("Question Added Successfully");
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string FullName = "";
            string fName    = "";
            string lName    = "";

            if (cmboxStudent.SelectedItem != null)
            {
                FullName = cmboxStudent.SelectedItem.ToString();
                int pos = FullName.IndexOf(" ");
                fName = FullName.Substring(0, pos);
                lName = FullName.Substring(pos + 1);
            }
            Student std = (from obj in db.Students
                           where obj.fName == fName && obj.lName == lName
                           select obj).Distinct().FirstOrDefault();
            string crsName = cmboxCourse.SelectedItem.ToString();
            Course crs     = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();
            stdCourse stdCrs = new stdCourse();

            stdCrs.crsID      = crs.crsID;
            stdCrs.stdID      = std.stdID;
            stdCrs.stdCrsCode = 1000;
            db.stdCourses.Add(stdCrs);
            db.SaveChanges();
            cmboxCourse.Text = cmboxStudent.Text = string.Empty;
            cmboxStudent.Items.Clear();
            cmboxCourse.Items.Clear();
            cmboxCourseSearch.Items.Clear();
            fillComboboxCrs();
            fillComboboxStd();
            fillDataGridView();
        }
예제 #3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string FullName = "";
            string fName    = "";
            string lName    = "";

            if (cmboxMGRS.SelectedItem != null)
            {
                FullName = cmboxMGRS.SelectedItem.ToString();
                int pos = FullName.IndexOf(" ");
                fName = FullName.Substring(0, pos);
                lName = FullName.Substring(pos + 1);
            }

            Instructor instructor = (from obj in db.Instructors
                                     where obj.fName == fName && obj.lName == lName
                                     select obj).Distinct().FirstOrDefault();
            Department dept = new Department();

            dept.deptName = txtDeptName.Text;
            if (cmboxMGRS.SelectedItem != null)
            {
                dept.instID = instructor.instID;
            }
            db.Departments.Add(dept);
            db.SaveChanges();
            txtDeptID.Text = txtDeptName.Text = cmboxMGRS.Text = string.Empty;
            cmboxMGRS.Items.Clear();
            MessageBox.Show("Department Saved Correctlly");
            fillDataGridView();
            fillCombobox();
        }
예제 #4
0
 private void btnInsert_Click_1(object sender, EventArgs e)
 {
     if (txtChoiceName.Text != string.Empty && cmboxQuestions.Text != string.Empty)
     {
         string   questionName = cmboxQuestions.SelectedItem.ToString();
         Question question     = (from obj in entities.Questions
                                  where obj.question1 == questionName
                                  select obj).Distinct().FirstOrDefault();
         Choice c1 = new Choice();
         c1.choice1 = txtChoiceName.Text;
         c1.quesID  = question.questionID;
         entities.Choices.Add(c1);
         entities.SaveChanges();
         MessageBox.Show("Saved");
         cmboxQuestions.Text    = txtChoiceID.Text =
             txtChoiceName.Text = string.Empty;
         cmboxQuestions.Items.Clear();
         fillCombobox();
         fillGrid();
     }
     else
     {
         MessageBox.Show("Choose your Answer plz");
     }
 }
예제 #5
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Course crs = new Course();

            crs.crsName  = txtCrsName.Text;
            crs.duration = txtCrsDuration.Text;
            db.Courses.Add(crs);
            db.SaveChanges();
            txtCrsName.Text = txtCrsDuration.Text = txtCrsID.Text = string.Empty;
            MessageBox.Show("Course Saved Correctlly");
            fillDataGridView();
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string crsName = cmboxCourse.SelectedItem.ToString();
            var    ex      = (from obj in db.Exams
                              join obj1 in db.Questions
                              on obj.quesID equals obj1.questionID
                              join obj2 in db.Courses
                              on obj1.crsID equals obj2.crsID
                              where obj2.crsName == crsName
                              select new
            {
                obj.examName
            }).Distinct().FirstOrDefault();

            if (ex == null)
            {
                //MessageBox.Show("exam not found");
                db.ExamGenerations(crsName);
                db.SaveChanges();
                MessageBox.Show("Exam Generated Succefully");
            }
            else
            {
                MessageBox.Show("This course had exam");
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string question = lblQues.Text;
            int    qId      = (from Q in db.Questions
                               where Q.question1 == question
                               select Q.questionID).Distinct().FirstOrDefault();
            Exam ex = (from E in db.Exams
                       where E.quesID == qId
                       select E).Distinct().FirstOrDefault();

            db.ExamAnswerss(StdID, ex.examNumber, cmboxAnswers.SelectedItem.ToString(), qId);

            db.SaveChanges();
            db.examCorrections(StdID, ex.examNumber, qId);
            db.SaveChanges();
            MessageBox.Show("your Answer saved successfuly");
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //if ((int)comboBox1.SelectedValue != -1)
            //{
            // int courseID = (int)comboBox1.SelectedValue;
            string crsName = comboBox1.SelectedItem.ToString();
            Course course  = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();

            db.SP_DeleteCrsById(course.crsID);
            db.SaveChanges();
            comboBox1.SelectedIndex = 0;
            txtCourseDuration.Text  = txtCourseName.Text = string.Empty;
            MessageBox.Show("Course Deleted !!!");
            // this.ParentForm.Refresh();

            //}
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string crsName = cmboxCourses.SelectedItem.ToString();
            Course course  = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();

            Topic topic = new Topic();

            topic.topicName = txtTopicName.Text;
            topic.crsID     = course.crsID;
            db.Topics.Add(topic);
            db.SaveChanges();
            txtTopicName.Text = cmboxCourses.Text = txtTopicID.Text = string.Empty;
            cmboxCourses.Items.Clear();
            MessageBox.Show("Course Saved Correctlly");
            fillDataGridView();
            fillCombobox();
        }
예제 #10
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string     deptName   = cmboxDepartment.SelectedItem.ToString();
            Department department = (from obj in db.Departments
                                     where obj.deptName == deptName
                                     select obj).Distinct().FirstOrDefault();
            Instructor inst = new Instructor();

            inst.fName        = txtFName.Text;
            inst.lName        = txtLName.Text;
            inst.deptID       = department.deptID;
            inst.instUserName = txtUserName.Text;
            inst.instPassword = txtPassword.Text;
            db.Instructors.Add(inst);
            db.SaveChanges();
            txtFName.Text = txtInstID.Text = txtUserName.Text = txtPassword.Text = txtLName.Text = cmboxDepartment.Text = string.Empty;
            cmboxDepartment.Items.Clear();
            fillDataGridView();
            fillCombobox();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //db.SP_CrsInsert(txtCourseName.Text, txtCourseDuration.Text);
            Course crs = new Course();

            crs.crsName  = txtCourseName.Text;
            crs.duration = txtCourseDuration.Text;
            db.Courses.Add(crs);
            db.SaveChanges();
            MessageBox.Show("Course Saved Correctlly");
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string FullName = "";
            string fName    = "";
            string lName    = "";

            if (cmboxInstructor.SelectedItem != null)
            {
                FullName = cmboxInstructor.SelectedItem.ToString();
                int pos = FullName.IndexOf(" ");
                fName = FullName.Substring(0, pos);
                lName = FullName.Substring(pos + 1);
            }
            var instructor = (from obj in db.Instructors
                              where obj.fName == fName && obj.lName == lName
                              select new {
                obj.instID
            }).FirstOrDefault();
            string crsName = cmboxCourse.SelectedItem.ToString();
            Course crs     = (from obj in db.Courses
                              where obj.crsName == crsName
                              select obj).Distinct().FirstOrDefault();
            instCourse instCourse = new instCourse();

            instCourse.crsID      = crs.crsID;
            instCourse.instID     = instructor.instID;
            instCourse.insCrsCode = 1000;
            db.instCourses.Add(instCourse);
            db.SaveChanges();
            cmboxCourse.Text = cmboxInstructor.Text = string.Empty;
            cmboxInstructor.Items.Clear();
            cmboxCourse.Items.Clear();
            cmboxCourseSearch.Items.Clear();
            fillComboboxCrs();
            fillComboboxInst();
            fillDataGridView();
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            string     deptName   = cmboxDepartment.SelectedItem.ToString();
            Department department = (from obj in db.Departments
                                     where obj.deptName == deptName
                                     select obj).Distinct().FirstOrDefault();
            Student std = new Student();

            std.fName       = txtFName.Text;
            std.lName       = txtLName.Text;
            std.phone       = txtPhone.Text;
            std.address     = txtAddress.Text;
            std.email       = txtEmail.Text;
            std.deptID      = department.deptID;
            std.stdUserName = txtUserName.Text;
            std.stdPassword = txtPassword.Text;
            db.Students.Add(std);
            db.SaveChanges();
            txtFName.Text = txtStdID.Text = txtLName.Text = txtEmail.Text
                                                                = txtPhone.Text = txtAddress.Text = txtPassword.Text = txtUserName.Text = cmboxDepartment.Text = string.Empty;
            cmboxDepartment.Items.Clear();
            fillDataGridView();
            fillCombobox();
        }