Example #1
0
        private void addWarriorButton_Click(object sender, EventArgs e)
        {
            bool a = true;

            foreach (var b in dbInter.GetAllWarriors())
            {
                if (b.Vardas == warriorNameLabel.Text)
                {
                    a = false;
                }
            }


            if (warriorNameLabel.Text != "" && a)
            {
                dbInter.GenerateNewWarrior(warriorNameLabel.Text, new Random().Next(1, 50), country);
            }

            LoadWarriors();
        }
Example #2
0
        private void allPowersButton_Click(object sender, EventArgs e)
        {
            List <Karvedys> allWarriors = dbInter.GetAllWarriors();
            List <Valstybe> allCountrys = dbInter.GetAllCountrys();

            var sb = new StringBuilder();

            var query = from warrior in allWarriors
                        join country in allCountrys
                        on warrior.Tarnauja equals country
                        group warrior by country.Pavadinimas;

            foreach (var rez in query)
            {
                foreach (var b in rez)
                {
                    sb.Append("Warrior Name: ").Append(b.Vardas).Append(", He serves: ").Append(b.Tarnauja.Pavadinimas).Append(", His power is: ").Append(b.PulkuSkaicius.ToString()).Append("\n");
                }
                sb.Append("\n");
            }

            MessageBox.Show(sb.ToString(), "Country Powers", MessageBoxButtons.OK);
        }