예제 #1
0
        private void btnUkloniOrganizatora_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvPostojeciOrganizatori))
            {
                return;
            }

            try
            {
                ISession s = DataLayer.GetSession();

                Organizator o = dgvPostojeciOrganizatori.CurrentRow.DataBoundItem as Organizator;

                Organizuje org = (from z in s.Query <Organizuje>()
                                  where z.OrganizujeOrganizator == o && z.OrganizujeTurnir == Turn
                                  select z).First();
                s.Delete(org);
                s.Flush();

                OsveziPostojeceGridove();

                MessageBox.Show("Organizator vise ne organizuje turnir: " + Turn.Naziv);
                s.Close();
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
                return;
            }
        }
예제 #2
0
        private void btnUkloniSponzora_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvPostojeciSponzori))
            {
                return;
            }

            try
            {
                ISession s = DataLayer.GetSession();

                Sponzor spon = dgvPostojeciSponzori.CurrentRow.DataBoundItem as Sponzor;

                Sponzorise sp = (from z in s.Query <Sponzorise>()
                                 where z.SponzoriseSponzor == spon && z.SponzoriseTurnir == Turn
                                 select z).First();
                s.Delete(sp);
                s.Flush();

                OsveziPostojeceGridove();

                MessageBox.Show("Sponzor vise ne sponzorise turnir: " + Turn.Naziv);
                s.Close();
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
                return;
            }
        }
예제 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewTabela))
            {
                return;
            }

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

            var kluboviColl = db.GetCollection <Klub>("klubovi");
            var ligeColl    = db.GetCollection <Liga>("lige");

            Klub k = dataGridViewTabela.CurrentRow.DataBoundItem as Klub;

            if (k.Igraci.Count > 0 || k.Utakmice.Count > 0)
            {
                MessageBox.Show("Ne moze da se obrise klub koji sadrzi igrace i/ili utakmice");
                return;
            }
            else
            {
                MongoDBRef kref = new MongoDBRef("klubovi", k.Id);
                L.Klubovi.Remove(kref);
                ligeColl.Save(L);

                kluboviColl.Remove(Query.EQ("_id", k.Id));
                MessageBox.Show("Klub je obrisan");
                UcitajDGVTabela();
            }
        }
예제 #4
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();
            }
        }
예제 #5
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();
        }
예제 #6
0
        private void btnSudija_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvSudija))
            {
                return;
            }

            Sudija item = dgvSudija.CurrentRow.DataBoundItem as Sudija;

            lblSudija.Text = dgvSudija.CurrentRow.Cells["ime"].Value.ToString();
            Sudac          = item;
        }
예제 #7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewIgraci))
            {
                return;
            }
            DodajFudbalera duform = new DodajFudbalera();

            duform.UpdateItem = dataGridViewIgraci.CurrentRow.DataBoundItem as Fudbaler;
            duform.ShowDialog();
            UcitajDGVIgraci();
        }
예제 #8
0
        private void btnVidi_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewIgraci))
            {
                return;
            }

            FormFudbaler duform = new FormFudbaler();

            duform.F = dataGridViewIgraci.CurrentRow.DataBoundItem as Fudbaler;
            duform.ShowDialog();
            UcitajDGVIgraci();
        }
예제 #9
0
        private void btnIzaberiKlub_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewTabela))
            {
                return;
            }
            FormKlub formk = new FormKlub();
            Klub     k     = new Klub();

            k       = dataGridViewTabela.CurrentRow.DataBoundItem as Klub;
            formk.K = k;
            formk.ShowDialog();
            UcitajDGVTabela();
        }
예제 #10
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();
        }
예제 #11
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();
        }
예제 #12
0
        private void btnVezaOrgSpon_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }

            if (!(dgv1.CurrentRow.DataBoundItem is Turnir))
            {
                MessageBox.Show("Niste selektovali turnir");
                return;
            }
            FormVezaOrgSpon f = new FormVezaOrgSpon(dgv1.CurrentRow.DataBoundItem as Turnir);

            f.ShowDialog();
        }
예제 #13
0
        private void btnDodajPartiju_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }

            if (!(dgv1.CurrentRow.DataBoundItem is Turnir))
            {
                MessageBox.Show("Niste selektovali turnir");
                return;
            }
            FormDodajPartija f = new FormDodajPartija();

            f.Turn = dgv1.CurrentRow.DataBoundItem as Turnir;
            f.ShowDialog();
        }
예제 #14
0
        private void btnCrni_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvSahista))
            {
                return;
            }

            Sahista item = dgvSahista.CurrentRow.DataBoundItem as Sahista;

            if (item == Beli)
            {
                MessageBox.Show("Sahista ne moze igrati sa samim sobom");
                return;
            }
            Crni         = item;
            lblCrni.Text = Crni.Ime + " " + Crni.Prezime;
        }
예제 #15
0
        private void btnIzmeni_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }

            if (dgv1.CurrentRow.DataBoundItem is Sahista)
            {
                var          item = dgv1.CurrentRow.DataBoundItem;
                FormDodajSah f    = new FormDodajSah();
                f.UpdateItem = item as Sahista;
                f.ShowDialog();
                SahistaIzvedeni(dgv1.DataSource as SortableBindingList <Sahista>);
            }
            else if (dgv1.CurrentRow.DataBoundItem is Turnir)
            {
                var             item = dgv1.CurrentRow.DataBoundItem as Turnir;
                FormDodajTurnir f    = new FormDodajTurnir();
                f.UpdateItem = item;
                f.ShowDialog();
            }
            else if (dgv1.CurrentRow.DataBoundItem is Organizator)
            {
                var          item = dgv1.CurrentRow.DataBoundItem as Organizator;
                FormDodajOrg f    = new FormDodajOrg();
                f.UpdateItem = item;
                f.ShowDialog();
            }
            else if (dgv1.CurrentRow.DataBoundItem is Sponzor)
            {
                MessageBox.Show("Ne mozete azurirati sponzora");
            }
            else if (dgv1.CurrentRow.DataBoundItem is Partija)
            {
                var item           = dgv1.CurrentRow.DataBoundItem as Partija;
                FormDodajPartija f = new FormDodajPartija();
                f.UpdateItem = item;
                f.ShowDialog();
                osveziSudiju(dgv1.DataSource as SortableBindingList <Partija>);
            }
            //ovde jedino mora da update i refresh da bi se videle promene
            dgv1.Update();
            dgv1.Refresh();
        }
예제 #16
0
        private void showPotez_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }
            if (!(dgv1.CurrentRow.DataBoundItem is Partija))
            {
                return;
            }
            var item = dgv1.CurrentRow.DataBoundItem as Partija;

            FormPotezi f = new FormPotezi();

            f.Part = item;

            f.ShowDialog();
        }
예제 #17
0
        private void btnPoveziOrganizatora_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvSviOrganizatori))
            {
                return;
            }

            try
            {
                ISession s = DataLayer.GetSession();

                Organizator o = dgvSviOrganizatori.CurrentRow.DataBoundItem as Organizator;

                Organizuje org = new Organizuje();
                org.OrganizujeOrganizator = o;
                org.OrganizujeTurnir      = Turn;

                //if ((from z in s.Query<Organizuje>()
                //     where z.OrganizujeOrganizator == o && z.OrganizujeTurnir == Turn
                //     select z).Count() == 0)
                if ((from z in s.Query <Turnir>()
                     where z.Id == Turn.Id && z.OrganizujeOrganizator.All(x => x.OrganizujeOrganizator.MatBr != o.MatBr)
                     select z).Count() == 1)
                {
                    s.Save(org);
                }
                else
                {
                    s.Close();
                    MessageBox.Show("Ovaj organizator je vec prisutan");
                    return;
                }
                s.Flush();

                OsveziPostojeceGridove();

                s.Close();
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
                return;
            }
        }
예제 #18
0
        private void btnPoveziSponzora_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgvSviSponzori))
            {
                return;
            }

            try
            {
                ISession s = DataLayer.GetSession();

                Sponzor sp = dgvSviSponzori.CurrentRow.DataBoundItem as Sponzor;

                Sponzorise spon = new Sponzorise();
                spon.SponzoriseSponzor = sp;
                spon.SponzoriseTurnir  = Turn;

                //if ((from z in s.Query<Sponzorise>()
                //    where z.SponzoriseSponzor == sp && z.SponzoriseTurnir == Turn
                //    select z).Count() == 0)
                if ((from z in s.Query <Turnir>()
                     where z.Id == Turn.Id && z.SponzoriseSponzor.All(x => x.SponzoriseSponzor.Naziv != sp.Naziv)
                     select z).Count() == 1)
                {
                    s.Save(spon);
                }
                else
                {
                    s.Close();
                    MessageBox.Show("Ovaj sponzor je vec prisutan");
                    return;
                }
                s.Flush();

                OsveziPostojeceGridove();

                s.Close();
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
                return;
            }
        }
예제 #19
0
        private void btnIzaberiUtakmicu_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dataGridViewUtakmice))
            {
                return;
            }
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("fudbal");

            FormUtakmica uform = new FormUtakmica();
            ObjectId     objid = (ObjectId)dataGridViewUtakmice.CurrentRow.Tag;

            MongoDBRef mref = new MongoDBRef("utakmice", objid);
            Utakmica   u    = db.FetchDBRefAs <Utakmica>(mref);

            uform.U = u;
            uform.ShowDialog();
            UcitajDGVUtakmice();
        }
예제 #20
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Provera.chkIfSelected(dgv1))
                {
                    return;
                }

                DialogResult r = MessageBox.Show("Da li ste sigurni", "Upozorenje", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.No)
                {
                    return;
                }

                ISession s = DataLayer.GetSession();

                if (dgv1.CurrentRow.DataBoundItem is Sahista)
                {
                    var item = dgv1.CurrentRow.DataBoundItem as Sahista;
                    s.Update(item);
                    delSahista(item, s);
                }
                else if (dgv1.CurrentRow.DataBoundItem is Turnir)
                {
                    var item = dgv1.CurrentRow.DataBoundItem as Turnir;
                    s.Update(item);
                    String nazivTurnira = item.Naziv;
                    s.Delete(item);
                    s.Flush();
                    s.Close();
                    MessageBox.Show("Uspesno ste izbrisali turnir \"" + nazivTurnira + "\"");
                    dgv1.Rows.Remove(this.dgv1.CurrentRow);
                }
                else if (dgv1.CurrentRow.DataBoundItem is Organizator)
                {
                    var item = dgv1.CurrentRow.DataBoundItem as Organizator;
                    s.Update(item);
                    delOrganizator(item, s);
                }
                else if (dgv1.CurrentRow.DataBoundItem is Sponzor)
                {
                    var item = dgv1.CurrentRow.DataBoundItem as Sponzor;
                    s.Update(item);
                    String nazivSponzora = item.Naziv;
                    s.Delete(item);
                    s.Flush();
                    s.Close();
                    MessageBox.Show("Uspesno ste izbrisali sponzora \"" + nazivSponzora + "\"");
                    dgv1.Rows.Remove(this.dgv1.CurrentRow);
                }
                else if (dgv1.CurrentRow.DataBoundItem is Partija)
                {
                    var item = dgv1.CurrentRow.DataBoundItem as Partija;
                    s.Update(item);
                    s.Delete(item);
                    s.Flush();
                    s.Close();
                    MessageBox.Show("Uspesno ste izbrisali partiju");
                    dgv1.Rows.Remove(this.dgv1.CurrentRow);
                }
                else
                {
                    s.Close();
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }
예제 #21
0
        private void btnOtpusti_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }
            try
            {
                if (dgv1.CurrentRow.DataBoundItem is Majstor)
                {
                    var m = dgv1.CurrentRow.DataBoundItem as Majstor;
                    if (m.SudijaId != null)
                    {
                        ISession s = DataLayer.GetSession();

                        int cnt = (from o in s.Query <Partija>()
                                   where (o.Sudija == m.SudijaId)
                                   select o).Count();

                        if (cnt > 0)
                        {
                            s.Close();
                            MessageBox.Show("Ne mozete otpustiti sudiju koji je sudio neku partiju");
                            return;
                        }

                        s.Update(m);
                        s.Delete(m.SudijaId);
                        m.SudijaId = null;

                        s.Flush();
                        s.Close();

                        MessageBox.Show("Uspesno otpusten sudija");
                    }
                    else
                    {
                        MessageBox.Show("Izabrani majstor nije sudija");
                    }
                }
                else if (dgv1.CurrentRow.DataBoundItem is Organizator)
                {
                    var org = dgv1.CurrentRow.DataBoundItem as Organizator;
                    if (org.SudijaId != null)
                    {
                        ISession s = DataLayer.GetSession();

                        int cnt = (from o in s.Query <Partija>()
                                   where (o.Sudija == org.SudijaId)
                                   select o).Count();

                        if (cnt > 0)
                        {
                            s.Close();
                            MessageBox.Show("Ne mozete otpustiti sudiju koji je sudio neku partiju");
                            return;
                        }

                        s.Update(org);
                        s.Delete(org.SudijaId);
                        org.SudijaId = null;

                        s.Flush();
                        s.Close();

                        MessageBox.Show("Uspesno otpusten sudija");
                    }
                    else
                    {
                        MessageBox.Show("Izabrani organizator nije sudija");
                    }
                }
                else
                {
                    MessageBox.Show("Nije selektovan odgovarajuci podatak");
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }
예제 #22
0
        private void btnPromovisi_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }
            try
            {
                if (dgv1.CurrentRow.DataBoundItem is Majstor)
                {
                    var      m = dgv1.CurrentRow.DataBoundItem as Majstor;
                    ISession s = DataLayer.GetSession();
                    s.Update(m);

                    if (m.SudijaId == null)
                    {
                        Sudija sud = new Sudija();
                        sud.FlagMajstor     = 1;
                        sud.FlagOrganizator = 0;

                        m.SudijaId = sud;
                        s.SaveOrUpdate(sud);

                        s.Flush();
                        s.Close();
                        MessageBox.Show("Uspeno promovisan majstor u sudiju");
                    }
                    else
                    {
                        MessageBox.Show("Majstor je vec sudija");
                        s.Close();
                    }
                }
                else if (dgv1.CurrentRow.DataBoundItem is Organizator)
                {
                    var      m = dgv1.CurrentRow.DataBoundItem as Organizator;
                    ISession s = DataLayer.GetSession();
                    s.Update(m);
                    if (m.SudijaId == null)
                    {
                        Sudija sud = new Sudija();
                        sud.FlagMajstor     = 0;
                        sud.FlagOrganizator = 1;

                        m.SudijaId = sud;
                        s.SaveOrUpdate(sud);

                        s.Flush();
                        s.Close();
                        MessageBox.Show("Uspeno promovisan organizator u sudiju");
                    }
                    else
                    {
                        MessageBox.Show("Organizator je vec sudija");
                        s.Close();
                    }
                    //dgv1.Update();
                    //dgv1.Refresh();
                }
                else
                {
                    MessageBox.Show("Nije selektovan odgovarajuci podatak");
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }
예제 #23
0
        private void btnPrikazPartije_Click(object sender, EventArgs e)
        {
            if (!Provera.chkIfSelected(dgv1))
            {
                return;
            }
            lblNaslov.Text           = "Partije";
            btnPromovisi.Visible     = false;
            btnOtpusti.Visible       = false;
            btnPrikazPartije.Visible = false;
            btnVezaOrgSpon.Visible   = false;
            btnDodajPartiju.Visible  = false;
            showPotez.Visible        = true;

            try
            {
                if (dgv1.CurrentRow.DataBoundItem is Sahista)
                {
                    ISession s   = DataLayer.GetSession();
                    Sahista  sah = dgv1.CurrentRow.DataBoundItem as Sahista;

                    IList <Partija> lsp = (from o in s.Query <Partija>()
                                           where (o.BeliIgrac == sah || o.CrniIgrac == sah)
                                           select o).ToList <Partija>();

                    SortableBindingList <Partija> a = new SortableBindingList <Partija>(lsp);

                    dgv1.Columns.Clear();
                    dgv1.DataSource = a;

                    dgv1.Columns["Potezi"].Visible = false;
                    dgv1.Columns["Sudija"].Visible = false;
                    dgv1.Columns.Add("sd", "Sudija");
                    string sts;
                    foreach (Partija p in a)
                    {
                        sts = SudOP.ucitajSudiju(s, p.Sudija);
                        dgv1.Rows[a.IndexOf(p)].Cells["sd"].Value = sts;
                    }

                    //dgv1.Update();
                    //dgv1.Refresh();

                    s.Close();
                }
                else if (dgv1.CurrentRow.DataBoundItem is Turnir)
                {
                    ISession s = DataLayer.GetSession();

                    Turnir trn = dgv1.CurrentRow.DataBoundItem as Turnir;
                    s.Update(trn);

                    SortableBindingList <Partija> a = new SortableBindingList <Partija>(trn.TPartije);

                    dgv1.Columns.Clear();
                    dgv1.DataSource = a;

                    dgv1.Columns["Potezi"].Visible = false;
                    dgv1.Columns["Sudija"].Visible = false;
                    dgv1.Columns["Turnir"].Visible = false;

                    dgv1.Columns.Add("sd", "Sudija");
                    string sts;
                    foreach (Partija p in a)
                    {
                        sts = SudOP.ucitajSudiju(s, p.Sudija);
                        dgv1.Rows[a.IndexOf(p)].Cells["sd"].Value = sts;
                    }

                    //dgv1.Update();
                    //dgv1.Refresh();

                    s.Close();
                }
            }
            catch (Exception ec)
            {
                MessageBox.Show(ec.Message);
            }
        }