public static FegyverRaktar getInstance() { if (uniqueInstance == null) { uniqueInstance = new FegyverRaktar(); } return(uniqueInstance); }
public List <TavolsagiF> TavFegyverLekerdez() { FegyverRaktar fer = FegyverRaktar.getInstance(); List <string> tavf = new List <string>(); List <int> seb = new List <int>(); string connectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};" + "DBQ=" + Environment.CurrentDirectory + @"\Fajlok\DB\adatbazis.xlsx" + ";ReadOnly=0;"; string queryString = "SELECT * FROM [TavolsagiF$]"; using (OdbcConnection connection = new OdbcConnection(connectionString)) { OdbcCommand command = new OdbcCommand(queryString, connection); try { connection.Open(); OdbcDataReader reader = command.ExecuteReader(); while (reader.Read()) { tavf.Add((string)reader[0]); seb.Add(int.Parse(reader[1].ToString())); } reader.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } for (int i = 0; i < tavf.Count; i++) { TavolsagiF ujf = new TavolsagiF(); ujf.nev = tavf[i]; ujf.sebzes = seb[i]; fer.TavFegyverHozzaad(ujf); } return(fer.tavfegyverek); } }