Ejemplo n.º 1
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            var programid = Convert.ToInt32(ProgramList.SelectedValue);
            var course    = new Courses()
            {
                CourseID      = txt_courseid.Text,
                CourseName    = txt_coursename.Text,
                Credits       = Convert.ToDecimal(txt_credit.Text),
                TotalHours    = Convert.ToInt32(txt_totalhours.Text),
                ClassroomType = Convert.ToInt32(txt_classroomtype.Text),
                Term          = Convert.ToInt32(txt_term.Text),
                Tuition       = Convert.ToDecimal(txt_tuition.Text),
                Description   = txt_description.Text
            };
            CoursesController coursesController = new CoursesController();

            coursesController.AddCourse(course);

            var programCourse = new ProgramCourses();

            programCourse.Active    = true;
            programCourse.Comments  = "";
            programCourse.CourseID  = course.CourseID;
            programCourse.ProgramID = programid;
            programCourse.Required  = true;
            ProgramCoursesController programCoursesController = new ProgramCoursesController();

            programCoursesController.AddProgramCourse(programCourse);

            FindPrograms_Click(null, null);
        }
Ejemplo n.º 2
0
        private void Button_add_Click(object sender, EventArgs e)
        {
            if (button_add.Text.Equals("ADD"))
            {
                foreach (TextBox box in boxes)
                {
                    if (box.Text.Trim().Equals(""))
                    {
                        MessageBox.Show("Please do not leave any empty fields.");
                        return;
                    }
                }

                if (controller.GetEmployeeId(textBox_trainer.Text) == 0)
                {
                    MessageBox.Show("Could not find such employee called " + textBox_trainer.Text);
                    return;
                }

                if (comboBox_active.Text.Equals(""))
                {
                    MessageBox.Show("Please choose if the course is active or not at the moment.");
                    return;
                }

                currentCourse = new Course(controller.GetEmployeeId(textBox_trainer.Text), textBox_course_name.Text,
                                           textBox_description.Text, textBox_day.Text, comboBox_active.Text.Equals("Yes") ? true : false);

                controller.AddCourse(currentCourse);

                MessageBox.Show("Course " + textBox_course_name.Text + " has been added.");

                CourseChanged(comboBox.Items.Count);
            }
            else
            {
                Course newCourse = new Course(controller.GetEmployeeId(textBox_trainer.Text), textBox_course_name.Text,
                                              textBox_description.Text, textBox_day.Text, comboBox_active.Text.Equals("Yes") ? true : false);

                if (currentCourse.GetDifferences(newCourse).Equals(""))
                {
                    MessageBox.Show("Nothing has changed.");
                    return;
                }

                if (controller.GetEmployeeId(textBox_trainer.Text) == 0)
                {
                    MessageBox.Show("Could not find such employee called " + textBox_trainer.Text);
                    return;
                }

                controller.Change(currentCourse, newCourse);

                MessageBox.Show("Course " + textBox_course_name.Text + " has been changed.");

                CourseChanged(comboBox.SelectedIndex);
            }
        }