private void listBox2_SelectedIndexChanged(object sender, EventArgs e) { groupBox5.Enabled = true; int index = listBox2.SelectedIndex; int elementCount; listBox3.Items.Clear(); BsonDocument[] docList = cursor.ToArray <BsonDocument>(); elementCount = docList[index].ElementCount; for (int i = 1; i < elementCount; i++) { listBox3.Items.Add(i.ToString() + ") " + docList[index].GetElement(i).Name + " : " + docList[index].GetElement(i).Value.ToString()); } button1.Enabled = true; }
private void FormClanBiblioteke_Load(object sender, EventArgs e) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); Text = FormClanLogIn.trClan.ime + " " + FormClanLogIn.trClan.prezime; label1.Text = "Ime: " + FormClanLogIn.trClan.ime; label2.Text = "Prezime: " + FormClanLogIn.trClan.prezime; label3.Text = "Zanimanje: " + FormClanLogIn.trClan.zanimanje; label4.Text = "Adresa: " + FormClanLogIn.trClan.adresa; label5.Text = "Broj telefona: " + FormClanLogIn.trClan.brojTelefona; label6.Text = "Broj licne karte:" + FormClanLogIn.trClan.brojLicneKarte; label13.Text = "Broj clanske karte:" + FormClanLogIn.trClan.brojClanskeKarte; //var izn = database.GetCollection<Clan>("clanovi"); var collection = database.GetCollection <Knjiga>("knjige"); MongoCursor <Knjiga> knjige = collection.FindAll(); List <Knjiga> listaKnjiga = new List <Knjiga>(); foreach (Knjiga k in knjige.ToArray <Knjiga>()) { listaKnjiga.Add(k); } dataGridView1.DataSource = listaKnjiga; dataGridView1.Columns["Id"].Visible = false; dataGridView1.Columns["zanr"].Visible = false; dataGridView1.Columns["izdavac"].Visible = false; dataGridView1.Columns["povez"].Visible = false; dataGridView1.Columns["brojStrana"].Visible = false; dataGridView1.Columns["brojPrimeraka"].Visible = false; dataGridView1.Columns["Sektor"].Visible = false; UcitajIznajmljene(); }
private void FormZaposleni_Load(object sender, EventArgs e) { Text = " " + FormZaposleniLogging.logovani.ime + " " + FormZaposleniLogging.logovani.prezime; var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var db = server.GetDatabase("Biblioteka"); var collectionSektori = db.GetCollection <Sektor>("sektori"); foreach (Sektor s in collectionSektori.FindAll()) { comboBox1.Items.Add(s.oznakaSektora); } var collection = db.GetCollection <Clan>("clanovi"); MongoCursor <Clan> clanovi = collection.FindAll(); List <Clan> listaClanova = new List <Clan>(); foreach (Clan c in clanovi.ToArray <Clan>()) { listaClanova.Add(c); } for (int i = 0; i < listaClanova.Count; i++) { cbClanovi.Items.Add(listaClanova[i].brojClanskeKarte); //+ ". " + listaClanova[i].ime + " " + listaClanova[i].prezime); } }
private void btnIzaberi_Click(object sender, EventArgs e) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); var collection = database.GetCollection <Knjiga>("knjige"); string zanr = comboBox1.SelectedItem.ToString(); MongoCursor <Knjiga> knjige = collection.Find(Query.EQ("zanr", zanr)); int loc1 = 10; int loc2 = 100; foreach (Knjiga k in knjige.ToArray <Knjiga>()) { PictureBox picturebox1 = new PictureBox(); Label label = new Label(); // picturebox1[i].Name = "picturebox1"; picturebox1.Location = new Point(loc1, loc2); label.Location = new Point(loc1, loc2 + 130); label.Text = k.naslov; label.Size = new Size(80, 20); picturebox1.Size = new Size(100, 130); picturebox1.BackColor = Color.Aqua; picturebox1.BorderStyle = BorderStyle.Fixed3D; string path = @"../../Resources/" + k.naslov + ".jpg"; if (!File.Exists(path)) { picturebox1.Image = Image.FromFile("../../Resources/NotFound.png"); ///ovde ubaciti sliku Image not Found picturebox1.SizeMode = PictureBoxSizeMode.StretchImage; Controls.Add(label); Controls.Add(picturebox1); } else { picturebox1.Image = Image.FromFile("../../Resources/" + k.naslov + ".jpg"); picturebox1.SizeMode = PictureBoxSizeMode.StretchImage; Controls.Add(label); Controls.Add(picturebox1); } loc1 += 110; if (loc1 > 900) { loc1 = 10; loc2 += 160; } //OpenFileDialog fd = new OpenFileDialog(); picturebox1.MouseDoubleClick += new MouseEventHandler((o, a) => fd.ShowDialog()); } }
public Zaposleni getZaposleni(ObjectId id) { var collection = db.GetCollection <Zaposleni>("zaposleni"); Zaposleni z; var query = Query.EQ("_id", id); MongoCursor <Zaposleni> za = collection.Find(query); z = za.ToArray <Zaposleni>().First(); return(z); }
public Presuda getPresuda(ObjectId id) { var collection = db.GetCollection <Presuda>("presuda"); Presuda p; var query = Query.EQ("_id", id); MongoCursor <Presuda> za = collection.Find(query); p = za.ToArray <Presuda>().First(); return(p); }
public Roditelj getRoditelj(ObjectId id) { var collection = db.GetCollection <Roditelj>("roditelj"); Roditelj r; var query = Query.EQ("_id", id); MongoCursor <Roditelj> za = collection.Find(query); r = za.ToArray <Roditelj>().First(); return(r); }
private void button1_Click(object sender, EventArgs e) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Rina"); var collection = database.GetCollection <Imena>("Imena"); MongoCursor <Imena> imena = collection.FindAll(); foreach (Imena i in imena.ToArray <Imena>()) { MessageBox.Show(i.ime); } }
private void toolStripButton2_Click(object sender, EventArgs e) { //get selected Player[] to_remove = list.ToArray(); Player target = to_remove[playersGridView.CurrentCell.RowIndex]; DialogResult result = MessageBox.Show("Are you sure you want to delete permanently?", "Warning!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { pf.Remove(target); } //remove selected PopulateDataGridView(); }
private static void SearchContactsFromDb() { Console.WriteLine("Please write name..."); string name = Console.ReadLine(); var query = Query <ContactEntity> .Where(p => p.Name.ToLower().StartsWith(name.ToLower())); MongoCursor <ContactEntity> contactEntities = Db.ContactEntityCollection.Find(query); ContactEntity[] entities = contactEntities.ToArray(); foreach (ContactEntity item in entities) { Console.WriteLine("{0} {1} : {2}", item.Name, item.LastName, string.Join(" | ", item.Phones)); } }
public void Zaposleni() // zbog toga sto je potreban refresh { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); var collection = database.GetCollection <Zaposleni>("zaposleni"); MongoCursor <Zaposleni> zaposleni = collection.FindAll(); List <Zaposleni> listaZaposleni = new List <Zaposleni>(); foreach (Zaposleni k in zaposleni.ToArray <Zaposleni>()) { listaZaposleni.Add(k); } dataGridView2.DataSource = listaZaposleni; SakrijZaposleni(); }
public void Knjige() { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); var collection = database.GetCollection <Knjiga>("knjige"); MongoCursor <Knjiga> knjige = collection.FindAll(); List <Knjiga> listaKnjiga = new List <Knjiga>(); foreach (Knjiga k in knjige.ToArray <Knjiga>()) { listaKnjiga.Add(k); } dataGridView1.DataSource = listaKnjiga; Sakrij(); }
public Pocetak() { InitializeComponent(); listView1.Columns.Add("IME"); listView1.AutoArrange = true; listView1.View = View.Details; var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("nesto1"); var collection = database.GetCollection <Partija>("ggg"); MongoCursor <Partija> igraci = collection.FindAll(); foreach (Partija r in igraci.ToArray()) { string[] row = { r.ime }; var listViewItem = new ListViewItem(row); listView1.Items.Add(listViewItem); } }
public Task <Wine[]> QueryWines(int skip, int count) { Deferred <Wine[]> deferred = Deferred.Create <Wine[]>(); MongoCursor cursor = _winesCollection.Find(null) .Sort(new object[] { "_id" }) .Skip(skip).Limit(count); cursor.ToArray(delegate(Exception error, object[] items) { if (error == null) { deferred.Resolve((Wine[])items); return; } deferred.Reject(error); }); return(deferred.Task); }
private void Clanovi() { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); var collection = database.GetCollection <Clan>("clanovi"); MongoCursor <Clan> clanovi = collection.FindAll(); List <Clan> listaClanova = new List <Clan>(); foreach (Clan k in clanovi.ToArray <Clan>()) { listaClanova.Add(k); } dataGridView3.DataSource = listaClanova; dataGridView3.Columns["Id"].Visible = false; dataGridView3.Columns["username"].Visible = false; dataGridView3.Columns["password"].Visible = false; }
private void btnSveKnjige_Click(object sender, EventArgs e) { var connectionString = "mongodb://localhost/?safe=true"; var server = MongoServer.Create(connectionString); var database = server.GetDatabase("Biblioteka"); var collection = database.GetCollection <Knjiga>("knjige"); MongoCursor <Knjiga> knjige = collection.FindAll(); List <Knjiga> listaKnjiga = new List <Knjiga>(); foreach (Knjiga k in knjige.ToArray <Knjiga>()) { listaKnjiga.Add(k); } dataGridView1.DataSource = listaKnjiga; dataGridView1.Columns["Id"].Visible = false; dataGridView1.Columns["Sektor"].Visible = false; }
public String Retrive() { MongoCursor <shoppingListDBModel> all = collection.FindAllAs <shoppingListDBModel>(); return(all.ToArray().ToJson()); }