コード例 #1
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);
            }
        }
コード例 #2
0
        public void EllensegBetolt()
        {
            List <Ellenseg> ellensegek = elladatb.EllensegLekerdez();

            ellenseg = ellensegek[rnd.Next(0, ellensegek.Count)];

            if (ellenseg != null)
            {
                ellennev.Content        = ellenseg.nev;
                ellensegeletero.Content = ellenseg.eletero;
                ellenkasztja.Content    = ellenseg.kaszt;
                ellenfegyvere.Content   = ellenseg.ellenfegyver.nev;
                ellenseg.kep            = ellenkepek[rnd.Next(0, ellenkepek.Count())];
                EllenKepKirak(ellenseg.kep);
            }
            else
            {
                throw new Exception("Hiba");
            }
        }
コード例 #3
0
 public void JatEllensegHozzaad(Ellenseg jellenseg)
 {
     jatellenseg.Add(jellenseg);
 }