//checks for incorrect format of date
        public void CourseFormDateFormatTest()
        {
            //create instane to test
            CourseForm stForm = new CourseForm(ref mainform, true);
            //define a test input and output value

            bool expectedResult = false;

            stForm.SetStartDateAdded("19-08-19");

            //run the method under test
            bool actualResult = stForm.ValidateFields();

            //checks results
            Assert.AreEqual(expectedResult, actualResult);

            //do the same for end data of course form

            stForm.SetEndDateAdded("0000-00-00");

            //run the method under test
            actualResult = stForm.ValidateFields();
            //checks results
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> InsertCourseAsync(CourseForm courseForm)
        {
            string json     = new JavaScriptSerializer().Serialize(courseForm);
            var    response = await GetHttpClient()
                              .PostAsync("courses", new StringContent(json, Encoding.UTF8, "application/json"));

            return(response);
        }
Exemplo n.º 3
0
 private string MapCourseFormToString(CourseForm courseForm)
 {
     return(courseForm switch
     {
         CourseForm.Classes => "Class",
         CourseForm.Laboratory => "Laboratory",
         CourseForm.Lecture => "Lecture",
         CourseForm.Project => "Project",
         CourseForm.Seminar => "Seminar",
         _ => "Laboratory",
     });
Exemplo n.º 4
0
        public void OpenFormEditCourse(int id)
        {
            var course = _courseServices.GetCourseById(id);
            IList <Lecturer> lecturers;
            IList <Student>  students;

            getLecturersAndStudents(out lecturers, out students);

            var courseForm = new CourseForm(this, course, lecturers, students);

            courseForm.Show();
        }
        //check course level for incorrect data
        public void CourseFormCourseLevelErroenousData()
        {
            //create instane to test
            CourseForm stForm = new CourseForm(ref mainform, true);
            //define a test input and output value

            bool expectedResult = false;

            stForm.SetCourseLevelAdded("3");

            //run the method under test
            bool actualResult = stForm.ValidateFields();

            //checks results
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 6
0
        public void OpenFormNewCourse()
        {
            var course = new Course();

            course.LecturersInCharge = new List <Lecturer>();
            course.StudentsEnrolled  = new List <Student>();
            course.Components        = new List <Component>();

            IList <Lecturer> lecturers;
            IList <Student>  students;

            getLecturersAndStudents(out lecturers, out students);

            var courseForm = new CourseForm(this, course, lecturers, students);

            courseForm.Show();
        }
Exemplo n.º 7
0
        private void gvCourses_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == gvCourses.Columns["editButton"].Index)
            {
                Course course     = (Course)gvCourses.CurrentRow.DataBoundItem;
                var    CourseForm = new CourseForm(course, FinishCallback);
                CourseForm.ShowDialog();
            }

            if (e.ColumnIndex == gvCourses.Columns["delButton"].Index)
            {
                Course course = (Course)gvCourses.CurrentRow.DataBoundItem;
                var    form   = new DialogForm("ยืนยันการลบคอร์ส?", $"ลบคอร์ส {course.CourseName}");
                if (form.ShowDialog() == DialogResult.OK)
                {
                    StorageManager.GetSingleton().RemoveCourse(course);
                    FinishCallback();
                }
            }
        }
        /// <summary>
        /// Handles the Courses grid's click event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
        private void CoursesGrid_Clicked(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row    = CoursesGrid.Rows[e.RowIndex];
            Course          course = (Course)row.Tag;

            switch (e.ColumnIndex)
            {
            case (int)CoursesGridColumn.Enrollment:
                CourseStudentsForm courseStudentsForm = new CourseStudentsForm(course);
                courseStudentsForm.Show();
                break;

            case (int)CoursesGridColumn.Tasks:
                new CourseGradeableTasksForm(course).Show();
                break;

            case (int)CoursesGridColumn.Grades:
                MessageBox.Show(this, String.Format("View grades clicked for course \"{0}\"", course.Name));
                break;

            case (int)CoursesGridColumn.Edit:
                CourseForm courseForm = new CourseForm(course);
                courseForm.Show();
                break;

            case (int)CoursesGridColumn.Delete:
                switch (MessageBox.Show(this, String.Format("Are you sure you want to delete {0}", course.Name),
                                        "Delete Course", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation))
                {
                case DialogResult.OK:
                    course.Delete();
                    break;

                default:
                    break;
                }
                Refresh();
                break;
            }
        }
        /// <summary>
        /// Handles the Add New Course button's click event.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void AddNewCourseButton_Click(object sender, EventArgs e)
        {
            CourseForm courseForm = new CourseForm();

            courseForm.Show();
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            var CourseForm = new CourseForm(null, FinishCallback);

            CourseForm.ShowDialog();
        }