示例#1
0
        private void button6_Click(object sender, EventArgs e)
        {
            trenerOpcija1Pnl.BackColor = System.Drawing.Color.FromArgb(253, 185, 39);
            trenerOpcija2Pnl.BackColor = trenerOpcija3Pnl.BackColor = trenerOpcija4Pnl.BackColor = System.Drawing.Color.Transparent;

            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var Tcollection = db.GetCollection <Trener>("treneri");
            var Kcollection = db.GetCollection <Klub>("klubovi");

            dataGridView1.Rows.Clear();
            dataGridView1.ColumnCount     = 5;
            dataGridView1.Columns[0].Name = "Ime";
            dataGridView1.Columns[1].Name = "Prezime";
            dataGridView1.Columns[2].Name = "Godisnja plata";
            dataGridView1.Columns[3].Name = "Naziv kluba";
            dataGridView1.Columns[4].Name = "Stil igre";
            string nazivkluba = "";

            string stilovi;

            foreach (Trener t in Tcollection.FindAll().SetSortOrder(new string[] { "ime", "prezime" }))
            {
                if (t.Klub != null)
                {
                    Klub klub = db.FetchDBRefAs <Klub>(t.Klub);
                    nazivkluba = klub.naziv;
                }
                else
                {
                    nazivkluba = "";
                }
                if (t.stiligre != null)
                {
                    stilovi = t.stiligre.Aggregate((x, y) => x + "," + y);
                }
                else
                {
                    stilovi = "";
                }

                dataGridView1.Rows.Add(t.ime, t.prezime, t.godisnjaplata, nazivkluba, stilovi);
            }
        }
示例#2
0
        private void button9_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox5.Text == "")
            {
                MessageBox.Show("Uneti potrebne podatke!");
                return;
            }
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var collection = db.GetCollection <Klub>("klubovi");

            var  query   = Query.EQ("naziv", textBox1.Text);
            Klub klubovi = collection.FindOne(query);

            if (klubovi == null)
            {
                MessageBox.Show("Nema takvog kluba!");
                return;
            }

            if (klubovi.titule == null)
            {
                var update = MongoDB.Driver.Builders.Update.Set("titule", BsonValue.Create(new List <string> {
                    textBox5.Text
                }));
                collection.Update(query, update);
            }
            else
            {
                var update = MongoDB.Driver.Builders.Update.Push("titule", textBox5.Text);
                collection.Update(query, update);
            }

            DataGridViewRow row = dataGridView1.Rows.Cast <DataGridViewRow>()
                                  .Where(r => r.Cells["naziv"].Value.ToString().Equals(textBox1.Text))
                                  .First();

            int rowIndex = row.Index;

            dataGridView1.Rows[rowIndex].Cells[5].Value = dataGridView1.Rows[rowIndex].Cells[5].Value + "," + textBox5.Text;

            textBox5.Text = "";
        }
示例#3
0
        private void button4_Click(object sender, EventArgs e)
        {
            placeholderLbl.Visible = false;
            dataGridView1.Visible  = true;

            igracOpcija2Pnl.BackColor = System.Drawing.Color.FromArgb(253, 185, 39);
            igracOpcija1Pnl.BackColor = igracOpcija3Pnl.BackColor = igracOpcija4Pnl.BackColor = igracOpcija5Pnl.BackColor = System.Drawing.Color.Transparent;

            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var collection = db.GetCollection("kosarkasi");

            var query =
                from kosarkasi in collection.AsQueryable <Kosarkas>()
                where kosarkasi.pozicija == textBox8.Text
                orderby kosarkasi.ime, kosarkasi.prezime
            select kosarkasi;


            dataGridView1.Rows.Clear();
            dataGridView1.ColumnCount     = 3;
            dataGridView1.Columns[0].Name = "Ime";
            dataGridView1.Columns[1].Name = "Prezime";
            dataGridView1.Columns[2].Name = "Klub";

            string nazivkluba;

            foreach (Kosarkas kos in query)
            {
                if (kos.Klub != null)
                {
                    Klub klub = db.FetchDBRefAs <Klub>(kos.Klub);
                    nazivkluba = klub.naziv;
                }
                else
                {
                    nazivkluba = "";
                }

                dataGridView1.Rows.Add(kos.ime, kos.prezime, nazivkluba);
            }
        }
示例#4
0
        private void button9_Click(object sender, EventArgs e)
        {
            placeholderLbl.Visible = false;
            dataGridView1.Visible  = true;

            igracOpcija4Pnl.BackColor = System.Drawing.Color.FromArgb(253, 185, 39);
            igracOpcija2Pnl.BackColor = igracOpcija3Pnl.BackColor = igracOpcija1Pnl.BackColor = igracOpcija5Pnl.BackColor = System.Drawing.Color.Transparent;

            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var collection = db.GetCollection <Kosarkas>("kosarkasi");

            var query =
                (from kosarkas in collection.AsQueryable <Kosarkas>()
                 orderby kosarkas.visina descending
                 select kosarkas).Take(10);

            dataGridView1.Rows.Clear();
            dataGridView1.ColumnCount     = 6;
            dataGridView1.Columns[0].Name = "Ime";
            dataGridView1.Columns[1].Name = "Prezime";
            dataGridView1.Columns[2].Name = "Pozicija";
            dataGridView1.Columns[3].Name = "Visina";
            dataGridView1.Columns[4].Name = "Tezina";
            dataGridView1.Columns[5].Name = "Koledz";
            string nazivkluba = "";


            foreach (Kosarkas kos in query)
            {
                if (kos.Klub != null)
                {
                    Klub klub = db.FetchDBRefAs <Klub>(kos.Klub);
                    nazivkluba = klub.naziv;
                }
                dataGridView1.Rows.Add(kos.ime, kos.prezime, kos.pozicija, kos.visina, kos.tezina, kos.koledz, nazivkluba);
            }
        }
示例#5
0
        private void button5_Click(object sender, EventArgs e)
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var Kcollection = db.GetCollection("klubovi");
            var Tcollection = db.GetCollection("treneri");

            var queryK =
                from klub in Kcollection.AsQueryable <Klub>()
                where klub.naziv == textBox3.Text
                select klub;

            Klub k = queryK.FirstOrDefault();

            var queryT =
                from trener in Tcollection.AsQueryable <Trener>()
                where trener.ime == textBox1.Text && trener.prezime == textBox2.Text
                select trener;

            Trener t = queryT.FirstOrDefault();

            if (k != null && t != null)
            {
                t.Klub = new MongoDBRef("klubovi", k.Id);
                Tcollection.Save(t);
                MessageBox.Show("Uspelo!");

                textBox1.Text = "";
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }
            else
            {
                MessageBox.Show("Nevalidni podaci!");
            }
        }
示例#6
0
        private void button7_Click(object sender, EventArgs e)
        {
            trenerOpcija3Pnl.BackColor = System.Drawing.Color.FromArgb(253, 185, 39);
            trenerOpcija2Pnl.BackColor = trenerOpcija1Pnl.BackColor = trenerOpcija4Pnl.BackColor = System.Drawing.Color.Transparent;

            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("kosarka");

            var Tcollection = db.GetCollection <Trener>("treneri");
            var Kcollection = db.GetCollection <Klub>("klubovi");

            dataGridView1.Rows.Clear();
            dataGridView1.ColumnCount     = 4;
            dataGridView1.Columns[0].Name = "Ime";
            dataGridView1.Columns[1].Name = "Prezime";
            dataGridView1.Columns[2].Name = "Godisnja plata";
            dataGridView1.Columns[3].Name = "Naziv kluba";


            var query = (from trener in Tcollection.AsQueryable <Trener>()
                         orderby trener.ime, trener.prezime
                         select trener);

            foreach (Trener t in query)
            {
                if (t.Klub != null)
                {
                    Klub klub = db.FetchDBRefAs <Klub>(t.Klub);
                    if (klub.divizija == textBox7.Text)
                    {
                        dataGridView1.Rows.Add(t.ime, t.prezime, t.godisnjaplata, klub.naziv);
                    }
                }
            }

            textBox7.Text = "";
        }