public async Task <IActionResult> Edit(int id, [Bind("Id,LastName,FirstName,MiddleName,MajorCode,MajorName,ThesisNameRus,ThesisComDate,ComMemberNumberTotal,ComMemberNumberSpecific,EducationDirection,MajorId,TrainingDirectionId")] PhdStudent phdStudent)
        {
            if (id != phdStudent.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Context.Update(phdStudent);
                    await Context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhdStudentExists(phdStudent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(phdStudent));
        }
        public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,MiddleName,MajorCode,MajorName,ThesisNameRus,ThesisComDate,ComMemberNumberTotal,ComMemberNumberSpecific,EducationDirection,MajorId,TrainingDirectionId,DisCouncilId")] PhdStudent phdStudent)
        {
            if (ModelState.IsValid)
            {
                Context.Add(phdStudent);
                await Context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(phdStudent));
        }
Esempio n. 3
0
        protected void OnClickButton(object sender, EventArgs e)
        {
            String line = tbox.Text;

            String[] tokens = line.Split(' ');
            int      length = tokens.Length;

            try
            {
                switch (length)
                {
                case 3:
                    Student s1 = new Student(Convert.ToInt32(tokens[0]), tokens[1], Convert.ToInt32(tokens[2]));
                    c.repo.addObject(s1);
                    break;

                case 4:
                    UndergraduateStudent s2 = new UndergraduateStudent(Convert.ToInt32(tokens[0]), tokens[1], Convert.ToInt32(tokens[2]), Convert.ToInt32(tokens[3]));
                    c.repo.addObject(s2);
                    break;

                case 6:
                    GraduateStudent s3 = new GraduateStudent(Convert.ToInt32(tokens[0]), tokens[1], tokens[2], Convert.ToInt32(tokens[3]), Convert.ToInt32(tokens[4]), Convert.ToInt32(tokens[5]));
                    c.repo.addObject(s3);
                    break;

                case 7:
                    PhdStudent s4 = new PhdStudent(Convert.ToInt32(tokens[0]), tokens[1], tokens[2], tokens[3], Convert.ToInt32(tokens[4]), Convert.ToInt32(tokens[5]), Convert.ToInt32(tokens[6]));
                    c.repo.addObject(s4);
                    break;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            lbox.Items.Clear();
            foreach (Student s in c.getAll())
            {
                lbox.Items.Add(s.ToString());
            }
        }
Esempio n. 4
0
        public void readFromFile()
        {
            String line;

            String[] tokens;
            int      length;

            System.IO.StreamReader infile = new System.IO.StreamReader("studentlist.txt");
            while ((line = infile.ReadLine()) != null)
            {
                tokens = line.Split(' ');
                length = tokens.Length;
                switch (length)
                {
                case 3:
                    Student s1 = new Student(Convert.ToInt32(tokens[0]), tokens[1], Convert.ToInt32(tokens[2]));
                    repo.addObject(s1);
                    break;

                case 4:
                    UndergraduateStudent s2 = new UndergraduateStudent(Convert.ToInt32(tokens[0]), tokens[1], Convert.ToInt32(tokens[2]), Convert.ToInt32(tokens[3]));
                    repo.addObject(s2);
                    break;

                case 6:
                    GraduateStudent s3 = new GraduateStudent(Convert.ToInt32(tokens[0]), tokens[1], tokens[2], Convert.ToInt32(tokens[3]), Convert.ToInt32(tokens[4]), Convert.ToInt32(tokens[5]));
                    repo.addObject(s3);
                    break;

                case 7:
                    PhdStudent s4 = new PhdStudent(Convert.ToInt32(tokens[0]), tokens[1], tokens[2], tokens[3], Convert.ToInt32(tokens[4]), Convert.ToInt32(tokens[5]), Convert.ToInt32(tokens[6]));
                    repo.addObject(s4);
                    break;
                }
            }
            infile.Close();
        }
Esempio n. 5
0
        public bool addMenu()  //Read parameters until they are correct
        {
            try
            {
                int select = 0;
                Console.WriteLine("Type: \n (1)Student \n (2)Graduate \n (3)Undergraduate \n (4)PHD");
                select = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("ID: ");
                String  sid, thesis, supervisor;
                int     id;
                int     grade2, grade3;
                Student s;
                string  input;
                input = Console.ReadLine();
                int.TryParse(input, out id);
                if (id == 0)
                {
                    throw new MyException("Wrong id");
                }

                Console.WriteLine("Name:");
                String name = Console.ReadLine();

                Console.WriteLine("Grade:");
                int grade = Convert.ToInt32(Console.ReadLine());
                this.valid.validateGrade(grade);
                this.valid.validateId(id);
                this.valid.validateName(name);
                switch (select)
                {
                case 1:
                    s = new Student(id, name, grade);
                    cont.addStudent(s);
                    break;

                case 2:
                    Console.WriteLine("Grade 2");
                    grade2 = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Grade 3");
                    grade3 = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Supervisor");
                    supervisor = Console.ReadLine();
                    this.valid.validateGrade(grade2);
                    this.valid.validateGrade(grade3);
                    s = new GraduateStudent(id, name, supervisor, grade, grade2, grade3);
                    cont.addStudent(s);
                    break;

                case 3:
                    Console.WriteLine("Grade2: ");
                    grade2 = Convert.ToInt32(Console.ReadLine());
                    this.valid.validateGrade(grade2);
                    s = new UndergraduateStudent(id, name, grade, grade2);
                    cont.addStudent(s);
                    break;


                case 4:
                    Console.WriteLine("Grade2: ");
                    grade2 = Convert.ToInt32(Console.ReadLine());
                    this.valid.validateGrade(grade2);
                    Console.WriteLine("Grade3: ");
                    grade3 = Convert.ToInt32(Console.ReadLine());
                    this.valid.validateGrade(grade3);
                    Console.WriteLine("Supervisor: ");
                    supervisor = Console.ReadLine();
                    Console.WriteLine("Thesis: ");
                    thesis = Console.ReadLine();
                    s      = new PhdStudent(id, name, thesis, supervisor, grade, grade2, grade3);
                    cont.addStudent(s);
                    break;
                }
                return(true);
            }
            catch (MyException e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }