Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count != 0)
            {
                Entities.Prevoz z = new Entities.Prevoz();
                z = (Entities.Prevoz)dataGridView1.CurrentRow.DataBoundItem;
                DialogResult dlg = MessageBox.Show("Da li ste sigurni da zelite da obrisete Opstinu?\nPromene su trajne!",
                                                   "Obavestenje!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dlg == DialogResult.Yes)
                {
                    var connectionString = "mongodb://localhost/?safe=true";
                    var server           = MongoServer.Create(connectionString);
                    var db = server.GetDatabase("TouristGuide");


                    var collection = db.GetCollection <Entities.Prevoz>("prevozi");

                    collection.Remove(Query.EQ("_id", z.Id));
                    MessageBox.Show("Uspeno je obrisano!");
                }
                else
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("Selektujte opstinu!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public DodajFormu(bool n, Entities.Prevoz p)
            : this()
        {
            button1.Text      = "Azuriraj";
            azuriraj          = n;
            comboBox1.Enabled = false;
            textBox1.Text     = p.Tip;
            textBox2.Text     = p.Naziv;
            textBox3.Text     = p.AdresaCentrale;

            foreach (Entities.Prevoz z in vratiPrevoz())
            {
                if (z.Id == p.Id)
                {
                    prevoziUpd = z;
                }
            }
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("TouristGuide");

            if (textBox1.Text == "" && textBox2.Text == "" && textBox3.Text == "")
            {
                MessageBox.Show("Niste popunili sva polja!");
            }
            if (!azuriraj)
            {
                if (comboBox1.SelectedIndex == -1)
                {
                    MessageBox.Show("Izaberite opstinu! Ukoliko ne postoji morate je napraviti!");
                    return;
                }
                var             collection = db.GetCollection <Entities.Prevoz>("prevozi");
                Entities.Prevoz s          = new Entities.Prevoz();
                s.Tip            = textBox1.Text;
                s.Naziv          = textBox2.Text;
                s.AdresaCentrale = textBox3.Text;

                collection.Insert(s);
                s.Opstina = new MongoDBRef("opstine", opstine[comboBox1.SelectedIndex].Id);
                collection.Save(s);

                opstine[comboBox1.SelectedIndex].Prevozi.Add(new MongoDBRef("prevozi", s.Id));
                azurirajOpstinu(opstine);
                MessageBox.Show("Prevoz je dodat!");
            }
            else
            {
                var collection = db.GetCollection <Entities.Prevoz>("prevozi");
                prevoziUpd.Tip            = textBox1.Text;
                prevoziUpd.Naziv          = textBox2.Text;
                prevoziUpd.AdresaCentrale = textBox3.Text;
                collection.Save(prevoziUpd);
                MessageBox.Show("Prevoz je azuriran!");
            }
            this.Close();
        }
Esempio n. 4
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count != 0)
     {
         Entities.Prevoz z = new Entities.Prevoz();
         z = (Entities.Prevoz)dataGridView1.CurrentRow.DataBoundItem;
         DialogResult dlg = MessageBox.Show("Da li ste sigurni da zelite da izmenite Prevoz?\nPromene su trajne!",
                                            "Obavestenje!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
         if (dlg == DialogResult.Yes)
         {
             DodajFormu p = new DodajFormu(true, z);
             p.Show();
         }
         else
         {
             return;
         }
     }
     else
     {
         MessageBox.Show("Selektujte opstinu!", "Greska!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 5
0
        private void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            var connectionString = "mongodb://localhost/?safe=true";
            var server           = MongoServer.Create(connectionString);
            var db = server.GetDatabase("TouristGuide");

            Entities.Prevoz u = (Entities.Prevoz)dataGridView1.CurrentRow.DataBoundItem;
            // var ustanoveCollection = db.GetCollection<Ustanova>("ustanove");
            var opstine = db.GetCollection <Opstina>("opstine");

            MongoCursor <Opstina> ops = opstine.FindAll();

            String opstinica = "";

            foreach (Opstina o in ops)
            {
                if (o.Id == u.Opstina.Id)
                {
                    opstinica = o.Naziv;
                }
            }
            MessageBox.Show("Prevoznik se nalazi u opstini: " + opstinica);
        }