private void confirmButton_Click_1(object sender, EventArgs e)
        {
            Enrollment en = new Enrollment(enrollmentID, myCourse.StartDateTime, myCourse.EndTime, true, myStudent, myCourse);

            controller.addEnrollment(en);
            confirmLabel.Visible = true;
            enrollmentID++;
            confirmButton.Enabled = false;
        }
Пример #2
0
        void addEnrollments()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING ENROLLMENTS...");

            Student s = new Student("33333333Z", "Javier Jaen", "Camino de vera", 46022, "2233445566778899");

            try
            {
                controller.addStudent(s);

                //Enrolling a student twice
                controller.addEnrollment(new Enrollment(1, DateTime.Now, DateTime.Now, true, s, controller.findTaughtCourseById(1)));
                Console.WriteLine("Student <" + s.Name + "> enrolled in TaughtCourse <1>");

                // Second must fail
                controller.addEnrollment(new Enrollment(1, DateTime.Now, DateTime.Now, true, s, controller.findTaughtCourseById(1)));
            }
            catch (BusinessLogicException e)
            {
                printError(e.Message);
            }
        }
        private void aceptarButton_Click(object sender, EventArgs e)
        {
            int enId = Int32.Parse(enIdTextBox.Text);

            Enrollment enrr = new Enrollment();

            enrr.EnrollmentDate   = cursoImAnadir.StartDateTime;
            enrr.CancellationDate = cursoImAnadir.EndTime;
            enrr.UniquePayment    = true;
            enrr.TaughtCourse     = Tc;

            if (enIdTextBox.TextLength == 0 || enIdTextBox.TextLength == 0)
            {
                MessageBox.Show("Debe rellenar la casilla", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation
                                );
            }
            else
            {
                foreach (Enrollment en in Tc.Enrollments)
                {
                    if (en.TaughtCourse.Id == enrr.Id)
                    {
                        DialogResult errorAsig = MessageBox.Show(this, "El ID introducido ya se está usando", "Error",
                                                                 MessageBoxButtons.OK,
                                                                 MessageBoxIcon.Error);
                        return;
                    }
                }
                try
                {
                    enrr = new Enrollment(enId, cursoImAnadir.StartDateTime, cursoImAnadir.EndTime, true, estudianteAnadir, cursoImAnadir);
                    businessControl.addEnrollment(enrr);
                }
                catch (BusinessLogicException ex)
                {
                    DialogResult errorAsignar = MessageBox.Show(this, ex.Message, "Error",
                                                                MessageBoxButtons.OK,
                                                                MessageBoxIcon.Error);
                    return;
                }
            }

            //datos = new datosInscripcion(businessControl, student, Tc, enrollment);
            //this.datos.ShowDialog();
            this.Close();
        }
Пример #4
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            String  dni    = infoIdLabel.Text;
            Student alumno = businessControl.findStudentByID(dni);
            String  idAl   = alumno.Id;

            int enId = Int32.Parse(idEnrollmentTextBox.Text);

            Enrollment enrr = new Enrollment();

            enrr.EnrollmentDate   = cursoImAnadir.StartDateTime;
            enrr.CancellationDate = cursoImAnadir.EndTime;
            enrr.UniquePayment    = true;
            enrr.TaughtCourse     = tc;

            if (idEnrollmentTextBox.TextLength == 0 || idEnrollmentTextBox.TextLength == 0)
            {
                MessageBox.Show("Debe rellenar la casilla", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation
                                );
            }
            else
            {
                foreach (Enrollment en in tc.Enrollments)
                {
                    if (en.TaughtCourse.Id == enrr.Id)
                    {
                        DialogResult errorAsig = MessageBox.Show(this, "El ID introducido ya se está usando", "Error",
                                                                 MessageBoxButtons.OK,
                                                                 MessageBoxIcon.Error);
                        return;
                    }
                }
                try
                {
                    enrr = new Enrollment(enId, cursoImAnadir.StartDateTime, cursoImAnadir.EndTime, true, estudianteAnadir, cursoImAnadir);
                    businessControl.addEnrollment(enrr);
                    businessControl.assignStudentToTaughtCourse(idAl, enrr);
                }
                catch (BusinessLogicException ex)
                {
                    DialogResult errorAsignar = MessageBox.Show(this, ex.Message, "Error",
                                                                MessageBoxButtons.OK,
                                                                MessageBoxIcon.Error);
                    return;
                }

                /*foreach (Enrollment en in tc.Enrollments) // la lista de Enrollments es Count = 0
                 * {
                 *  if (en.Student.Id == idAl)
                 *  {
                 *      DialogResult errorAsig = MessageBox.Show(this, "El alumno ya pertenece a este curso", "Error",
                 *      MessageBoxButtons.OK,
                 *      MessageBoxIcon.Error);
                 *      return;
                 *  }
                 * }
                 * try
                 * {
                 *  //businessControl.addEnrollment(enrr);
                 *  businessControl.assignStudentToTaughtCourse(idAl, enrr);
                 * }
                 * catch (BusinessLogicException ex)
                 * {
                 *  DialogResult errorAsignar = MessageBox.Show(this, ex.Message, "Error",
                 *  MessageBoxButtons.OK,
                 *  MessageBoxIcon.Error);
                 *  return;
                 * }*/
            }
            DialogResult exitoRotundo = MessageBox.Show(this, "Inscripción completa", "Inscripción realizada correctamente",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk
                                                        );

            this.Close();
            //this.Close();
        }