public void dodaj(string s1, string s2) { Partija p = new Partija(); var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("nesto1"); var collection = database.GetCollection("ggg"); //string ss = s; p.pozicija = s2; p.ime = s1; try { collection.Insert(p); } catch { // MessageBox.Show("Doslo je do greske!!!"); } }
public void dodajAutomatski(string s2) { Partija p = new Partija(); var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var db = server.GetDatabase("nesto1"); try { var collection = db.GetCollection <Partija>("ggg"); var query = Query.EQ("ime", "prekinuta"); collection.Remove(query); p.pozicija = s2; p.ime = "prekinuta"; collection.Insert(p); } catch { //MessageBox.Show("Doslo je do greske!"); } }
/// <summary> /// ob pritisku na gumb nova Igra,se prične nova partija /// </summary> /// <param name="sender">object BNovaIgra</param> /// <param name="e"></param> private void BNovaIgra_Click(object sender, EventArgs e) { if (this.jeIgra == false) { this.Mod = "vnosPredIgro"; this.jeIgra = true; } else if (this.Mod == "vnosPredIgro") { this.NastaviZacStanje(); this.moznePoteze = this.trenutnaPoz.IzracunajPoteze(); //prebere in pobriše vnosa belega in črnega string beli = this.TBvnosBelega.Text; string crni = this.TBvnosCrnega.Text; novaPartija = new Partija(beli, crni); //začnemo novo partijo novaPartija.dodajPozicijo(this.trenutnaPoz.PovejPozicijoZaIzpis()); this.Mod = "novaPartija"; } }
public void PripraviPregledPartije(string partija) { this.BringToFront(); this.Mod = "baza"; this.novaPartija = new Partija(partija); this.indeksPozicije = 0; //izpisemo poteze na zaslon for (int i = 0; i < this.novaPartija.Poteze.Count(); i += 2) { ListViewItem enaPoteza = new ListViewItem("" + (i / 2 + 1)); enaPoteza.SubItems.Add(this.novaPartija.PotezeZaIzpis[i]); if (i + 1 < this.novaPartija.Poteze.Count()) enaPoteza.SubItems.Add(this.novaPartija.PotezeZaIzpis[i + 1]); this.LVPartija.Items.Add(enaPoteza); } Sahovnica poz = new Sahovnica(); this.trenutnaPoz = poz; novaPartija.DodajPozicijoZaOgled(poz.sahovnica); this.VstaviSlike(); foreach (string pot in this.novaPartija.Poteze) { if (pot == "0-0") { poz = poz.IzvediMaloRokado(); } else if (pot == "0-0-0") { poz = poz.IzvediVelRokado(); } else if (pot.Length == 6) { poz = poz.Promocija("" + pot[5], int.Parse("" + pot[2]), int.Parse("" + pot[4])); } else if (pot[0] == 'P' && pot[4] != pot[2] && poz.sahovnica[int.Parse("" + pot[3]), int.Parse("" + pot[4])] == ".") { poz = poz.IzvediEP(int.Parse("" + pot[2]), int.Parse("" + pot[4])); } else { poz = poz.Premik(int.Parse("" + pot[3]), int.Parse("" + pot[4]), new Figura(int.Parse("" + pot[1]), int.Parse("" + pot[2]), poz.sahovnica[int.Parse("" + pot[1]), int.Parse("" + pot[2])])); } novaPartija.DodajPozicijoZaOgled(poz.sahovnica); } }