Ejemplo n.º 1
0
        private void FormKlub_Load(object sender, EventArgs e)
        {
            this.BackgroundImage       = Image.FromFile("../../slike/pozadina4.jpg");
            this.BackgroundImageLayout = ImageLayout.Stretch;

            btnUpdate.BackgroundImage       = Image.FromFile("../../icons/edit.png");
            btnUpdate.BackgroundImageLayout = ImageLayout.Stretch;

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

            this.Text      = K.Ime;
            lblNaziv.Text  = K.Ime;
            lblGrad.Text   = K.Grad;
            lblGodina.Text = K.God_osn.ToString();

            if (!String.IsNullOrEmpty(K.Slika))
            {
                pictureBox1.ImageLocation = K.Slika;
            }

            Liga l = db.FetchDBRefAs <Liga>(K.Liga);

            lblLiga.Text = l.Ime + " (" + l.Drzava + ")";

            UcitajDGVIgraci();
        }
Ejemplo n.º 2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridView1))
            {
                return;
            }

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

            var collection = db.GetCollection <Liga>("lige");

            Liga l = dataGridView1.CurrentRow.DataBoundItem as Liga;

            if (l.Klubovi.Count > 0 || l.Utakmice.Count > 0)
            {
                MessageBox.Show("Ne moze da se obrise liga koja sadrzi klubove i utakmice");
                return;
            }
            else
            {
                collection.Remove(Query.EQ("_id", l.Id));
                MessageBox.Show("Liga je obrisana");
                ucitajDGV();
            }
        }
Ejemplo n.º 3
0
        private void btnDeleteU_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewUtakmice))
            {
                return;
            }

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

            var utakmiceColl  = db.GetCollection <Utakmica>("utakmice");
            var dogadjajiColl = db.GetCollection <Dogadjaj>("dogadjaji");
            var ligeColl      = db.GetCollection <Liga>("lige");
            var kluboviColl   = db.GetCollection <Klub>("klubovi");

            //pribavljanje utakmice
            ObjectId objid = (ObjectId)dataGridViewUtakmice.CurrentRow.Tag;

            query = Query.EQ("_id", objid);
            Utakmica u = utakmiceColl.Find(query).Single();

            //pribavljanje lige i brisanje utakmice iz liste
            query = Query.EQ("_id", u.Liga.Id);
            Liga       lg          = ligeColl.Find(query).Single();
            MongoDBRef utakmicaRef = new MongoDBRef("utakmice", objid);

            lg.Utakmice.Remove(utakmicaRef);
            ligeColl.Save(lg);

            //pribavljanje kluba i brisanje utakmice iz liste
            query = Query.EQ("_id", u.Klub1.Id);
            Klub k1 = kluboviColl.Find(query).Single();

            query = Query.EQ("_id", u.Klub2.Id);
            Klub k2 = kluboviColl.Find(query).Single();

            k1.Utakmice.Remove(utakmicaRef);
            k2.Utakmice.Remove(utakmicaRef);
            kluboviColl.Save(k1);
            kluboviColl.Save(k2);

            //brisanje dogadjaja
            foreach (MongoDBRef d in u.Dogadjaji)
            {
                query = Query.EQ("_id", d.Id);
                dogadjajiColl.Remove(query);
            }

            //brisanje utakmica
            query = Query.EQ("_id", objid);
            utakmiceColl.Remove(query);
            UcitajDGVUtakmice();
        }
Ejemplo n.º 4
0
        private void btnIzaberi_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridView1))
            {
                return;
            }

            Liga     l     = dataGridView1.CurrentRow.DataBoundItem as Liga;
            FormLiga lform = new FormLiga();

            lform.L = l;
            lform.ShowDialog();
            ucitajDGV();
        }
Ejemplo n.º 5
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridView1))
            {
                return;
            }

            Liga l = dataGridView1.CurrentRow.DataBoundItem as Liga;

            DodajLigu lform = new DodajLigu();

            lform.UpdateItem = l;
            lform.ShowDialog();
            ucitajDGV();
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db         = server.GetDatabase("fudbal");
            var collection = db.GetCollection <Liga>("lige");

            Liga jsl = new Liga {
                Ime = "Srpska liga", Drzava = "Srbija"
            };


            collection.Insert(jsl);


            foreach (Liga lg in collection.FindAll())
            {
                MessageBox.Show(lg.Ime);
            }
        }
Ejemplo n.º 7
0
        private void Azuriraj()
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("fudbal");

            var collection = db.GetCollection <Liga>("lige");



            var  query = Query.EQ("_id", UpdateItem.Id);
            Liga lg    = collection.Find(query).Single();



            lg.Ime    = txtNaziv.Text;
            lg.Drzava = txtDrzava.Text;

            collection.Save(lg);
            this.Close();
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //validacija
            if ((txtNaziv.Text == "") || (txtDrzava.Text == ""))
            {
                MessageBox.Show("Niste uneli sva potrebna polja");
                return;
            }

            if (UpdateItem != null)
            {
                Azuriraj();
                return;
            }

            string naziv  = txtNaziv.Text;
            string drzava = txtDrzava.Text;

            if (String.IsNullOrEmpty(naziv) || String.IsNullOrEmpty(drzava))
            {
                return;
            }

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

            var collection = db.GetCollection <Liga>("lige");

            Liga liga = new Liga {
                Ime = naziv, Drzava = drzava
            };


            collection.Insert(liga);

            this.Close();
        }