public void addStudent(int kurs, int student)
        {
            DAO_Kurs      dao   = new DAO_Kurs();
            List <Kurs>   list  = dao.getKursy();
            List <string> ls    = list[kurs].students;
            bool          check = false;

            for (int i = 0; i < ls.Count; i++)
            {
                string[] enteries = ls[i].Split(',');
                if (enteries[0] == student.ToString())
                {
                    check = true;
                }
            }

            DAO_Student    dao_s    = new DAO_Student();
            List <Student> studenci = dao_s.getStudenci();

            for (int i = 0; i < studenci.Count; i++)
            {
                if (studenci[i].id == student)
                {
                    if (!check)
                    {
                        ls.Add(studenci[i].id.ToString() + "," + studenci[i].imie.ToString() + "," + studenci[i].nazwisko.ToString() + "," + studenci[i].indeks.ToString());
                    }
                }
            }
            list[kurs].students = ls;
            dao.setKursy(list);
        }
Exemplo n.º 2
0
        public void addStudent(string imie, string nazwisko, string indeks)
        {
            DAO_Student    dao   = new DAO_Student();
            List <Student> list  = dao.getStudenci();
            int            index = list.Last().id;
            Student        nstud = new Student(index + 1, imie, nazwisko, indeks);

            list.Add(nstud);
            dao.setStudenci(list);
        }
Exemplo n.º 3
0
 public void editStudent(int index, string imie, string nazwisko, string indeks)
 {
     if (index != 0)
     {
         DAO_Student    dao  = new DAO_Student();
         List <Student> list = dao.getStudenci();
         foreach (var k in list)
         {
             if (k.id == index)
             {
                 k.imie     = imie;
                 k.nazwisko = nazwisko;
                 k.indeks   = indeks;
             }
         }
         dao.setStudenci(list);
     }
 }
Exemplo n.º 4
0
        public void deleteStudent(int index)
        {
            DAO_Student    dao       = new DAO_Student();
            List <Student> list      = dao.getStudenci();
            Student        to_delete = null;

            foreach (var k in list)
            {
                if (k.id == index)
                {
                    to_delete = k;
                }
            }
            if (to_delete != null)
            {
                list.Remove(to_delete);
            }
            dao.setStudenci(list);
        }