Пример #1
0
        private void enroll(object sender, EventArgs e)
        {
            DateTime initDate        = Convert.ToDateTime(dtInicio.Text);
            DateTime endDate         = Convert.ToDateTime(dtFin.Text);
            int      id              = Convert.ToInt16(numID.Value);
            string   day             = numSesiones.Value.ToString();
            int      quota           = Convert.ToInt16(numCuota.Value);
            int      sessionDuration = Convert.ToInt16(numDuracionSesion.Value);
            int      totalPrice      = Convert.ToInt16(numPrecio.Value);
            Course   courseAux       = (Course)taughtCourseCB.SelectedItem;

            if (courseAux == null)
            {
                MessageBox.Show("No se ha seleccionado ningun curso.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Course course = businessController.findCourseById(courseAux.Id);

            try
            {
                TaughtCourse taughtCourse = new TaughtCourse(initDate, endDate, id, day, quota, sessionDuration, totalPrice, course);
                businessController.addTaughtCourse(taughtCourse);
                this.Close();
            } catch (Exception ex)
            {
                MessageBox.Show("Error insertando curso. " + ex.Message, "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        void addTaughtCourses(int courseId)
        {
            Course c;

            Console.WriteLine();
            Console.WriteLine("ADDING TAUGHT COURSES FOR COURSE <" + courseId + "> ...");

            for (int taughtCourseId = 1; taughtCourseId <= 10; taughtCourseId++)
            {
                Console.Write("Adding Taught Course " + taughtCourseId + " - ");
                try {
                    c = controller.findCourseByID(courseId);
                    controller.addTaughtCourse(new TaughtCourse(taughtCourseId, DateTime.Now, DateTime.Now, "Tuesday", 120, 1200, 30, c));
                    Console.WriteLine("OK");
                }
                catch (BusinessLogicException e)
                {
                    printError(e.Message);
                }
            }
        }
Пример #3
0
        private void botonAceptTC_Click(object sender, EventArgs e)
        {
            cursoT.Course = curso;
            if (Int32.TryParse(datosQuota.Text, out quota))
            {
                cursoT.Quota = quota;
            }
            else
            {
                DialogResult msgQuota = MessageBox.Show(this, "Quota debe ser un entero", "Error",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Error
                                                        );
                return;
            }
            if (Int32.TryParse(textBox2.Text, out duracionMin))
            {
                cursoT.SessionDuration = duracionMin;
            }
            else
            {
                DialogResult msgDuración = MessageBox.Show(this, "Inserte los segundos que dura la clase", "Error",
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Error
                                                           );
                return;
            }


            inicio = dateTimePicker1.Value;
            cursoT.StartDateTime = inicio;
            if (Int32.TryParse(precioTotalbox.Text, out precio))
            {
                cursoT.TotalPrice = precio;
            }
            else
            {
                DialogResult msgprecioTotal = MessageBox.Show(this, "Inserte el precio como un numero", "Error",
                                                              MessageBoxButtons.OK,
                                                              MessageBoxIcon.Error
                                                              );
                return;
            }
            dias = despDias.Text;
            cursoT.TeachingDay = dias;
            final          = dateFinal.Value;
            cursoT.EndTime = final;


            if (Int32.TryParse(txtId.Text, out id))
            {
                if (businessControl.findTaughtCourseById(id) != null)
                {
                    DialogResult msgID2 = MessageBox.Show(this, "El curso impartido ya existe", "Error",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Error
                                                          );
                    return;
                }
                else
                {
                    cursoT.Id = id;
                }
            }
            else
            {
                DialogResult msgID = MessageBox.Show(this, "El id debe ser un entero", "Error",
                                                     MessageBoxButtons.OK,
                                                     MessageBoxIcon.Error
                                                     );
                return;
            }

            try
            {
                businessControl.addTaughtCourse(cursoT);
            }
            catch (BusinessLogicException ex)
            {
                DialogResult msgID = MessageBox.Show(this, ex.Message, "Error",
                                                     MessageBoxButtons.OK,
                                                     MessageBoxIcon.Error
                                                     );
                return;
            }

            if (int.TryParse(comboTeach.Text, out idaux))
            {
                try
                {
                    businessControl.assignTeacherToTaughtCourse(comboTeach.Text, cursoT.Id);
                }
                catch (BusinessLogicException ex)
                {
                    DialogResult msgID = MessageBox.Show(this, ex.Message, "Error",
                                                         MessageBoxButtons.OK,
                                                         MessageBoxIcon.Error
                                                         );
                }
            }

            int idOffice;

            if (int.TryParse(comboClase.Text, out idOffice))
            {
                try
                {
                    businessControl.assignOfficeToTaughtCourse(idOffice, id);
                }
                catch (BusinessLogicException ex)
                {
                    DialogResult msgOffice = MessageBox.Show(this, ex.Message, "Error",
                                                             MessageBoxButtons.OK,
                                                             MessageBoxIcon.Error
                                                             );
                }
            }

            DialogResult exitoRotundo = MessageBox.Show(this, "Añadido correctamente", "Añadido correctamente",
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk
                                                        );

            this.Close();
        }