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; } }
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; } }
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(); } }
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(); } }
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(); }
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; }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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; }
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(); }
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(); }
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; } }
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; } }
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(); }
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); } }
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); } }
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); } }
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); } }