예제 #1
0
        public List <Harcos> JatHarcosLekerdez()
        {
            KarakterRaktar kar           = KarakterRaktar.getInstance();
            List <string>  karakternevek = new List <string>();
            List <string>  kasztok       = new List <string>();
            List <string>  fegyverek     = new List <string>();
            List <string>  kepek         = new List <string>();

            string connectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};" + "DBQ=" + Environment.CurrentDirectory + @"\Fajlok\DB\jatekosadatbazis.xlsx" + ";ReadOnly=0;";

            string queryString =
                "SELECT * FROM [JatHarcos$]";

            using (OdbcConnection connection =
                       new OdbcConnection(connectionString))
            {
                OdbcCommand command = new OdbcCommand(queryString, connection);

                try
                {
                    connection.Open();
                    OdbcDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        karakternevek.Add((string)reader[0]);
                        kasztok.Add((string)reader[1]);
                        fegyverek.Add((string)reader[2]);
                        kepek.Add((string)reader[3]);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                for (int i = 0; i < karakternevek.Count; i++)
                {
                    FegyverAdatbazis   fa           = FegyverAdatbazis.getInstance();
                    List <KozelharciF> fegyverbazis = fa.KhFegyverLekerdez();
                    Harcos             ujharcos     = new Harcos();
                    ujharcos.nev        = karakternevek[i];
                    ujharcos.maxeletero = 1000;
                    ujharcos.eletero    = 1000;
                    ujharcos.kep        = kepek[i];
                    for (int j = 0; j < fegyverbazis.Count; j++)
                    {
                        if (fegyverek[i] == fegyverbazis[j].nev)
                        {
                            ujharcos.harcosfegyver = fegyverbazis[j];
                        }
                    }
                    kar.JatHarcosHozzaad(ujharcos);
                }
                return(kar.jatharcosok);
            }
        }
예제 #2
0
        public List <Ellenseg> EllensegLekerdez()
        {
            EllensegRaktar er            = EllensegRaktar.getInstance();
            List <string>  ellensegnevek = new List <string>();
            List <int>     maxeleterok   = new List <int>();
            List <string>  kepek         = new List <string>();

            FegyverAdatbazis   fa  = FegyverAdatbazis.getInstance();
            List <KozelharciF> khf = fa.KhFegyverLekerdez();

            string connectionString = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};" + "DBQ=" + Environment.CurrentDirectory + @"\Fajlok\DB\hosadatbazis.xlsx" + ";ReadOnly=0;";

            string queryString =
                "SELECT * FROM [Harcosok$]";

            using (OdbcConnection connection =
                       new OdbcConnection(connectionString))
            {
                OdbcCommand command = new OdbcCommand(queryString, connection);

                try
                {
                    connection.Open();
                    OdbcDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        ellensegnevek.Add((string)reader[0]);
                        maxeleterok.Add(int.Parse(reader[1].ToString()));
                        kepek.Add((string)reader[2]);
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                for (int i = 0; i < ellensegnevek.Count; i++)
                {
                    Ellenseg ujellenseg = new Ellenseg();
                    ujellenseg.nev          = ellensegnevek[i];
                    ujellenseg.maxeletero   = maxeleterok[i];
                    ujellenseg.eletero      = 1000;
                    ujellenseg.kaszt        = "Harcos";
                    ujellenseg.ellenfegyver = khf[rnd.Next(0, khf.Count)];
                    //ujellenseg.kep = kepek[i];
                    er.JatEllensegHozzaad(ujellenseg);
                }
                return(er.jatellenseg);
            }
        }