public static List <Zaposlenik> GetZaposlenike() { List <Zaposlenik> zaposlenici = new List <Zaposlenik>(); SqliteCommand c = DB.con.CreateCommand(); c.CommandText = String.Format(@"SELECT * FROM Zaposlenik"); SqliteDataReader reader = c.ExecuteReader(); while (reader.Read()) { Zaposlenik z = new Zaposlenik((long)reader["id"], (string)reader["ime"], (string)reader["prezime"], (string)reader["password"], DateTime.FromFileTime((Int64)reader["datum_zaposlenja"]), Zaposlenik.StatusFromString((string)reader["status"]), Zaposlenik.UlogaFromString((string)reader["uloga"])); zaposlenici.Add(z); } c.Dispose(); return(zaposlenici); }
public static Zaposlenik GetZaposlenik(string ime, string password) { SqliteCommand c = DB.con.CreateCommand(); c.CommandText = String.Format(@"SELECT * FROM Zaposlenik WHERE ime = '{0}' AND password = '******' ", ime, password); SqliteDataReader reader = c.ExecuteReader(); Zaposlenik z; if (!reader.HasRows) { z = null; } else { reader.Read(); z = new Zaposlenik((long)reader["id"], (string)reader["ime"], (string)reader["prezime"], (string)reader["password"], DateTime.FromFileTime((Int64)reader["datum_zaposlenja"]), Zaposlenik.StatusFromString((string)reader["status"]), Zaposlenik.UlogaFromString((string)reader["uloga"])); } c.Dispose(); return(z); }