Пример #1
0
        private void addCourseButton_Click(object sender, EventArgs e)
        {
            int id = 0;

            try
            {
                id = int.Parse(idBox.Text);
            }
            catch (FormatException ex)
            {
                MessageBox.Show("La ID no puede ser vacia.", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Course c = controller.findCourseById(id);

            if (c != null)
            {
                MessageBox.Show("Esta ID ya existe, asignele otra!!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                try
                {
                    controller.addCourse(new Course(id, nameBox.Text, descriptionBox.Text));
                    this.Close();
                }
                catch (Exception ex) { MessageBox.Show("Se produjo un error en la creación del nuevo curso: \n \n " + ex, "", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            }
        }
Пример #2
0
        private void aceptarBtn_Click(object sender, EventArgs e)
        {
            int id;

            if (Int32.TryParse(IdTextBox.Text, out id))
            {
                IdErrorLabel.Visible = false;
                String nombre      = nombreTextBox.Text;
                String descripcion = descripcionRichTextBox.Text;

                Course curso = new Course(id, nombre, descripcion);
                try
                {
                    businessControl.addCourse(curso);
                }
                catch (BusinessLogicException ex)
                {
                    DialogResult answer = MessageBox.Show(this, ex.Message, "Error",
                                                          MessageBoxButtons.OK,
                                                          MessageBoxIcon.Error
                                                          );
                }
                DialogResult exito = MessageBox.Show(this, "Agregado con exito", "Exito",
                                                     MessageBoxButtons.OK,
                                                     MessageBoxIcon.Asterisk
                                                     );
            }
            else
            {
                IdErrorLabel.Visible = true;
            }
        }
Пример #3
0
 private void resetDbButton_Click(object sender, EventArgs e)
 {
     controller = BusinessController.getBusinessController();
     controller.removeAllData();
     // poblar la base de datos
     try
     {
         int i = 0;
         controller.addCourse(new Course(i++, "Inglés I", "Inglés básico"));
         controller.addCourse(new Course(i++, "Francés I", "Francés básico"));
         controller.addCourse(new Course(i++, "Alemán I", "Alemán básico"));
         controller.addCourse(new Course(i++, "Inglés II", "Inglés intermedio"));
         controller.addCourse(new Course(i++, "Inglés III", "Inglés avanzado"));
         controller.addCourse(new Course(i++, "Contabilidad", "Contabilidad"));
         controller.addStudent(new Student("87855022J", "Paulette Villagómez Negrete",
                                           "Ventanilla de Beas, 97", 27860, "978321645"));
         controller.addStudent(new Student("25427728D", "Otoniel Montano Bernal",
                                           "Reyes Católicos, 22", 11130, "159482637"));
         controller.addStudent(new Student("86142742Z", "Neiber Munguia Saldana",
                                           "Padre Caro, 85", 13740, "246835719"));
         controller.addTeacher(new Teacher("26341722Y", "Juan García Ramírez",
                                           "Calle Rosa de los Vientos, 84", 11350, "999123456"));
         controller.addTeacher(new Teacher("86272838E", "Felicia Vera Aguayo",
                                           "Cartagena, 43", 30500, "133244689"));
     }
     catch (BusinessLogicException ex)
     {
         MessageBox.Show(ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     MessageBox.Show("Base de datos reseteada.");
 }
Пример #4
0
        void addCourses()
        {
            Console.WriteLine();
            Console.WriteLine("ADDING COURSES ...");

            for (int courseId = 1; courseId <= 10; courseId++)
            {
                Console.Write("Adding Course " + courseId + " - ");
                try
                {
                    controller.addCourse(new Course(courseId, "Course-Name-" + courseId, "Course-Description-" + courseId));
                    Console.WriteLine("OK");
                }
                catch (BusinessLogicException e)
                {
                    printError(e.Message);
                }
            }
        }