Exemple #1
0
        public void AddSubjectRegister(SubjectList aSubjectList)
        {
            if (aSubjectList.getCount() == 0)
            {
                Console.WriteLine("\n ************************************************************************");
                Console.WriteLine("\t Para utilizar esta opcion debe agregar asignaturas.");
                Console.WriteLine("\n ************************************************************************");
            }
            else
            {
                var newSubjectRegister = new SubjectRegister();

                Console.WriteLine("\n Agregar registro de asignatura \n");
                Console.WriteLine("\t Asignaturas disponibles para creacion de registro de asignatura: \n");
                aSubjectList.ListSubjects();
                Console.Write("\n \n Escriba el ID de la asignatura con que desea crear nuevo registro de asignatura: ");
                int id = Convert.ToInt32("0" + Console.ReadLine());
                if (aSubjectList.GetIdList().Contains(id))
                {
                    newSubjectRegister.SetSubject(aSubjectList.SearchAndReturn(id));

                    newSubjectRegister.SetAtributes(lastId + 1);
                    lastId++;

                    this.subjectRegisters.Add(newSubjectRegister);
                }
                else
                {
                    Console.WriteLine("Id invalido.");
                }
            }
        }
Exemple #2
0
        //Funciones nuevas para serializar/deserializar

        static void ClearRegisterObjects() //Limpia objetos y guarda los cambios
        {
            Students         = new StudentList();
            Subjects         = new SubjectList();
            SubjectsRegister = new SubjectRegisterList();
            Serialize();
        }
Exemple #3
0
        static void DeserializeSubjects() //Deserializa el objeto Subjects
        {
            try
            {
                using (Stream stream = File.Open("subjectsBinary.bin", FileMode.Open))
                {
                    BinaryFormatter bin = new BinaryFormatter();

                    Subjects = (SubjectList)bin.Deserialize(stream);
                }
            }
            catch (IOException)
            {
                Subjects = new SubjectList();
            }
        }
        public void SearchSubject()
        {
            Console.WriteLine("\n ¿Por qué opción desea buscar? \n");
            Console.WriteLine("1- Por Nombre");
            Console.WriteLine("2- Por Carrera");
            Console.Write("Elija una opción: ");
            int sOpt = Convert.ToInt32("0" + Console.ReadLine());

            Console.Write("Digite el valor de busqueda: ");
            string      searchValue   = Console.ReadLine();
            SubjectList searchResults = new SubjectList();

            foreach (var subject in subjects)
            {
                switch (sOpt)
                {
                case 1:
                    if (subject.Name.Contains(searchValue))
                    {
                        searchResults.subjects.Add(subject);
                    }
                    break;

                case 2:
                    if (subject.Career.Contains(searchValue))
                    {
                        searchResults.subjects.Add(subject);
                    }
                    break;
                }
            }
            if (searchResults.subjects.Count == 0)
            {
                Console.WriteLine("\n ******************************************");
                Console.Write("\t No se encontraron registros");
                Console.WriteLine("\n ******************************************");
            }
            else
            {
                searchResults.ListSubjects();
            }
        }