public static List <UplataUcenika> GetAll(SqlConnection conn) { List <UplataUcenika> sveUplateIUcenici = new List <UplataUcenika>(); try { string query = "SELECT id, ucenik_id, uplata_id " + "FROM uplata_ucenika"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { int id = (int)r["id"]; int uplataId = (int)r["uplata_id"]; int ucenikId = (int)r["ucenik_id"]; Uplata uplata = UplataDAO.GetUplataById(Program.conn, uplataId); Ucenik ucenik = UcenikDAO.GetUcenikById(Program.conn, ucenikId); sveUplateIUcenici.Add(new UplataUcenika(id, uplata, ucenik)); } r.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } return(sveUplateIUcenici); }
public static List <PohadjaPredaje> GetAll(SqlConnection conn) { List <PohadjaPredaje> sviPp = new List <PohadjaPredaje>(); try { string query = "SELECT id, kurs_id, ucenik_id, nastavnik_id " + "FROM pohadja_predaje"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { int id = (int)r["id"]; int kursId = (int)r["kurs_id"]; int nastId = (int)r["nastavnik_id"]; int ucId = (int)r["ucenik_id"]; Kurs kurs = KursDAO.GetKursById(Program.conn, kursId); Nastavnik nast = NastavnikDAO.GetNastavnikById(Program.conn, nastId); Ucenik uc = UcenikDAO.GetUcenikById(Program.conn, ucId); sviPp.Add(new PohadjaPredaje(id, nast, uc, kurs)); } r.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } return(sviPp); }
public static UplataUcenika GetUplataByUcenikId(SqlConnection conn, int id) { UplataUcenika uplUc = null; try { string query = "SELECT uplata_id, ucenik_id " + "FROM uplata_ucenika " + "WHERE id=" + id; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader r = cmd.ExecuteReader(); if (r.Read()) { int uplataId = (int)r["uplata_id"]; int ucenikId = (int)r["ucenik_id"]; Uplata uplata = UplataDAO.GetUplataById(Program.conn, uplataId); Ucenik ucenik = UcenikDAO.GetUcenikById(Program.conn, ucenikId); uplUc = new UplataUcenika(id, uplata, ucenik); } r.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } return(uplUc); }
public static PohadjaPredaje GetPPByID(SqlConnection conn, int id) { PohadjaPredaje pp = null; try { string query = "SELECT kurs_id, nastavnik_id, ucenik_id " + "FROM pohadja_predaje " + "WHERE id = " + id; SqlCommand cmd = new SqlCommand(query, conn); SqlDataReader r = cmd.ExecuteReader(); if (r.Read()) { int kursId = (int)r["kurs_id"]; int nastId = (int)r["nastavnik_id"]; int ucId = (int)r["ucenik_id"]; Kurs kurs = KursDAO.GetKursById(Program.conn, kursId); Nastavnik nast = NastavnikDAO.GetNastavnikById(Program.conn, nastId); Ucenik uc = UcenikDAO.GetUcenikById(Program.conn, ucId); pp = new PohadjaPredaje(id, nast, uc, kurs); } r.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } return(pp); }