Exemple #1
0
        // GET: Tereni/Edit/5
        public ActionResult Edit(long?id)
        {
            Korisnik korisnik = (Korisnik)db.Users.Find(User.Identity.GetUserId());

            if (korisnik == null || !korisnik.IsSystemAdmin)
            {
                return(RedirectToAction("Index", "Sobas"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Teren teren = db.Tereni.Find(id);

            if (teren == null)
            {
                return(HttpNotFound());
            }
            ViewBag.KvartId = new SelectList(db.Kvartovi, "Id", "Naziv", teren.KvartId);
            return(View(teren));
        }
Exemple #2
0
        //***************************IZCRTAVANJE DUGMETA*******************////////////////

        private void dgvTereni_SelectionChanged(object sender, EventArgs e)
        {
            if (dgvTereni.SelectedRows.Count > 0)
            {
                DialogTereniDetails.getInstance.setLblValueOfIme(dgvTereni.SelectedCells[1].Value.ToString());
                DialogTereniDetails.getInstance.setLblValueOfLokacija(dgvTereni.SelectedCells[2].Value.ToString());
                DialogTereniDetails.getInstance.setLblValueOfGodinaOpremljenja(dgvTereni.SelectedCells[3].Value.ToString());
                DialogTereniDetails.getInstance.setLblValueOfSportovi(dgvTereni.SelectedCells[4].Value.ToString());
                DialogTereniDetails.getInstance.setLblValueOfKapacitet(dgvTereni.SelectedCells[5].Value.ToString());

                DialogTereniDetails.getInstance.setLblValueOfStatus(dgvTereni.SelectedCells[6].Value.ToString());


                Teren temp = new Teren(null, null, null, false, null, -1, null);
                Tereni_Collection.getInstance.Teren_collection.TryGetValue(new Guid(dgvTereni.SelectedCells[0].Value.ToString()), out temp);
                if (temp.Slobodan)
                {
                    btnBrisanje.Enabled         = true;
                    btnBrisanje.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.button));
                    btnIzmena.Enabled           = true;
                    btnIzmena.BackgroundImage   = ((System.Drawing.Image)(Properties.Resources.button));
                }
                else
                {
                    btnBrisanje.Enabled         = false;
                    btnBrisanje.BackgroundImage = null;
                    btnIzmena.Enabled           = false;
                    btnIzmena.BackgroundImage   = null;
                }
            }
            else
            {
                btnBrisanje.Enabled         = false;
                btnBrisanje.BackgroundImage = null;
                btnIzmena.Enabled           = false;
                btnIzmena.BackgroundImage   = null;
            }
        }
Exemple #3
0
        private bool checkSportOfTerenAndTim()
        {
            List <Guid> terenSportovi = new List <Guid>();
            bool        izlaz         = false;
            Teren       teren         = new Teren(null, null, null, false, null, -1, null);

            Tereni_Collection.getInstance.Teren_collection.TryGetValue(trenutnaSifraTerena, out teren);
            trenutnoImeTerena = teren.Ime;
            Tim tim = new Tim(null, null, null, null);

            Timovi_Collection.getInstance.Timovi_collection.TryGetValue(trenutnaSifraTima, out tim);
            trenutnoImeTima = tim.Ime;

            foreach (KeyValuePair <Guid, Sport> temp in teren.Sportovi)
            {
                if (temp.Key.Equals(tim.Sport.Sifra))
                {
                    izlaz = true;
                    break;
                }
            }
            return(izlaz);
        }
Exemple #4
0
        private void btnPotvrda_Click(object sender, EventArgs e)
        {
            bool same = false;

            foreach (KeyValuePair <Guid, Teren> teren in Tereni_Collection.getInstance.Teren_collection)
            {
                if (teren.Value.Ime.ToString().Equals(tbIme.Text.ToString()))
                {
                    if (!trenutnoIme.Equals(tbIme.Text))
                    {
                        same = true;
                    }
                }
            }

            if (same || tbIme.Text == "" || cbLokacija.SelectedItem == null || tbGodOpr.Text == "" || tbGodOpr.Text.Length < 4 || tbKapacitet.Text == "" || cbSportovi.CheckedItems.Count == 0)
            {
                tbGodOpr_Validated(sender, e);
                tbIme_Validated(sender, e);
                tbKapacitet_Validated(sender, e);
                cbLokacija_Validated(sender, e);
                cbSportovi_Validated(sender, e);
                tbIme.Focus();
            }
            else
            {
                Teren temp = new Teren(null, null, null, false, null, -1, null);
                Dictionary <Guid, Sport> colTemp = new Dictionary <Guid, Sport>();
                foreach (Sport sport in cbSportovi.CheckedItems)
                {
                    colTemp.Add(sport.Sifra, sport);
                    System.Diagnostics.Debug.WriteLine("hozzaadtunk 1 et");
                }
                temp.GodinaOpremljenja = tbGodOpr.Text;
                temp.Ime       = tbIme.Text;
                temp.Kapacitet = Convert.ToInt32(tbKapacitet.Text);
                temp.Kommentar = tbKommentar.Text;
                temp.Lokacija  = (Hala)cbLokacija.SelectedItem;
                if (stanjeDijaloga == StanjeDijaloga.DODAVANJE)
                {
                    temp.Lokacija.BrTerena++;
                }
                temp.Sportovi = colTemp;
                if (rbOtvoren.Checked == true)
                {
                    temp.Otvoren = true;
                }
                if (rbZatvoren.Checked == true)
                {
                    temp.Otvoren = false;
                }

                if (temp.Lokacija.BrTerena > 12)
                {
                    Point      location = new Point(Form1.getInstance.Location.X + 2, Form1.getInstance.Location.Y + 25);
                    Background back     = Background.getInstance;
                    back.Location = location;
                    back.Show();
                    MaxTerenWarning mtw = new MaxTerenWarning(temp.Lokacija.ImeHale + " nema više mesta za novi teren. Odaberite drugu halu!");
                    if (mtw.ShowDialog() == DialogResult.OK)
                    {
                        back.Hide();
                    }
                }
                else
                {
                    if (stanjeDijaloga == StanjeDijaloga.DODAVANJE)
                    {
                        timer1.Start();
                        //Teren teren = new Teren(temp.Ime, temp.Lokacija, temp.GodinaOpremljenja, temp.Otvoren, temp.Sportovi, temp.Kapacitet, temp.Kommentar);
                        Tereni_Collection.getInstance.addTeren(temp);
                        //System.Diagnostics.Debug.WriteLine(temp.Sifra.ToString());
                        DialogTereni.getInstance.loadTableData(temp.Sifra.ToString());
                        //DialogTereni.getInstance.setSelectedLastElement(temp.Sifra.ToString());
                        lblStatus.Text = "Teren " + temp.Ime.ToString() + " je uspesno dodat!";
                        clearForm();
                    }
                    if (stanjeDijaloga == StanjeDijaloga.IZMENA)
                    {
                        temp.Sifra = trenutnaSifra;
                        Tereni_Collection.getInstance.modifyTeren(temp);
                        DialogTereni.getInstance.loadTableData(temp.Sifra.ToString());
                        lblStatus.Text = "Teren " + temp.Ime.ToString() + " je uspesno izmenjen!";
                        clearForm();
                        DialogTereni.getInstance.Back.Close();
                        this.Close();
                    }
                }
            }
        }
Exemple #5
0
        private void btnBrisanje_Click(object sender, EventArgs e)
        {
            bool  brisanje      = true;
            Teren trenutniTeren = new Teren(null, null, null, false, null, -1, null);

            Tereni_Collection.getInstance.Teren_collection.TryGetValue(new Guid(dgvTereni.SelectedCells[0].Value.ToString()), out trenutniTeren);

            foreach (KeyValuePair <Guid, Hala> hala in Hale_Collection.getInstance.Hale_collection)
            {
                if (hala.Value.ImeHale.ToString().Equals(trenutniTeren.Lokacija.ImeHale.ToString()))
                {
                    System.Diagnostics.Debug.WriteLine(hala.Value.BrTerena);
                    if (hala.Value.BrTerena < 2)
                    {
                        brisanje = false;
                    }
                }
            }

            if (brisanje)
            {
                Control activeForm = this.FindForm();
                Point   location   = new Point(((Form1)activeForm).Location.X + 2, ((Form1)activeForm).Location.Y + 25);
                back = new Background();
                back.Show();
                back.Location = location;
                DeleteWarning deleteWarning = new DeleteWarning("Da li ste sigurni da hoćete da obrišete " + dgvTereni.SelectedCells[1].Value.ToString() + "?");
                if (deleteWarning.ShowDialog() == DialogResult.Yes)
                {
                    Guid trenutnaHala = new Guid();
                    foreach (KeyValuePair <Guid, Hala> hala in Hale_Collection.getInstance.Hale_collection)
                    {
                        if (hala.Value.ImeHale.ToString().Equals(dgvTereni.SelectedCells[2].Value.ToString()))
                        {
                            trenutnaHala = hala.Key;
                        }
                    }

                    Hale_Collection.getInstance.Hale_collection[trenutnaHala].BrTerena--;

                    Tereni_Collection.getInstance.Teren_collection.Remove(new Guid(dgvTereni.SelectedCells[0].Value.ToString()));
                    loadTableData("");
                    back.Close();
                }
                else
                {
                    back.Close();
                }
            }
            else
            {
                Point      location = new Point(Form1.getInstance.Location.X + 2, Form1.getInstance.Location.Y + 25);
                Background back     = new Background();
                back.Location = location;
                back.Show();
                MaxTerenWarning mtw = new MaxTerenWarning(dgvTereni.SelectedCells[1].Value.ToString() + " je poslednji teren u hali" + dgvTereni.SelectedCells[2].Value.ToString() + " !");
                if (mtw.ShowDialog() == DialogResult.OK)
                {
                    back.Hide();
                }
            }
            brisanje = true;
        }
Exemple #6
0
 public void removeTeren(Teren stari)
 {
     teren_collection.Remove(stari.Sifra);
     save();
 }
        public void loadHaleBaza()
        {
            Hala hala1 = new Hala("Spens", 1);
            Hala hala2 = new Hala("Pionir", 2);
            Hala hala3 = new Hala("Arena", 3);
            Hala hala4 = new Hala("Hala Sportova", 4);

            haleCollection.addHala(hala1);
            haleCollection.addHala(hala2);
            haleCollection.addHala(hala3);
            haleCollection.addHala(hala4);
            Sport sport1 = new Sport("Fudbal", "F", "U poslednje vreme najviše se igra fudbal");
            Sport sport2 = new Sport("Kosarka", "K", "Igrači su manje zainteresovani");
            Sport sport3 = new Sport("Rukomet", "R", "Igra se grubo u poslednje vreme");
            Sport sport4 = new Sport("Odbojka", "O", "Igrači su druželjubivi");

            sportoviCollection.addSport(sport1);
            sportoviCollection.addSport(sport2);
            sportoviCollection.addSport(sport3);
            sportoviCollection.addSport(sport4);
            Sportista sportista1 = new Sportista("1824923891242", "Filip", "Knezević", "2010", Sportista.Klasa.Amater, sport1, null);
            Sportista sportista2 = new Sportista("5478958241945", "Petar", "Petrović", "2011", Sportista.Klasa.Poluprofesionalac, sport2, null);
            Sportista sportista3 = new Sportista("9754863512700", "Luka", "Kovač", "2012", Sportista.Klasa.Profesionalac, sport3, null);
            Sportista sportista4 = new Sportista("1984567285020", "Sanja", "Kovačević", "2010", Sportista.Klasa.Profesionalac, sport2, null);
            Sportista sportista5 = new Sportista("1845558759848", "Vesna", "Petrović", "2012", Sportista.Klasa.Profesionalac, sport1, null);
            Sportista sportista6 = new Sportista("1845558759848", "Suzana", "Tosić", "2013", Sportista.Klasa.Amater, sport1, null);
            Sportista sportista7 = new Sportista("1845558759848", "Nemanja", "Knezić", "2013", Sportista.Klasa.Amater, sport4, null);

            sportisteCollection.addSportista(sportista1);
            sportisteCollection.addSportista(sportista2);
            sportisteCollection.addSportista(sportista3);
            sportisteCollection.addSportista(sportista4);
            sportisteCollection.addSportista(sportista5);
            sportisteCollection.addSportista(sportista6);
            sportisteCollection.addSportista(sportista7);
            Tim tim1 = new Tim("Zvezda", null, sport1, "Nezadovoljstvo u timu");
            Tim tim2 = new Tim("Rusin", null, sport2, "Entuzijazam uvećan");
            Tim tim3 = new Tim("Hajduk", null, sport3, "Prijatnost tima");
            Tim tim4 = new Tim("Partizan", null, sport4, "Svadje u timu");
            Tim tim5 = new Tim("Vojvodina", null, sport1, "Napredak opažen");

            timoviCollection.addTim(tim1);
            timoviCollection.addTim(tim2);
            timoviCollection.addTim(tim3);
            timoviCollection.addTim(tim4);
            timoviCollection.addTim(tim5);
            Teren teren1 = new Teren("Platini", hala1, "2011", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Nov teren");
            Teren teren2 = new Teren("Pehar", hala1, "2012", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Takmičarski teren");
            Teren teren3 = new Teren("Pustoš", hala1, "2011", false, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Blratnjav teren");
            Teren teren4 = new Teren("Putnik", hala1, "2011", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Veštačka trava");
            Teren teren5 = new Teren("Rusin", hala2, "2011", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Mali teren");
            Teren teren6 = new Teren("Air", hala2, "2011", false, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Veliki teren");
            Teren teren7 = new Teren("Patuljak", hala3, "2011", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Mali teren");
            Teren teren8 = new Teren("Breza", hala4, "2011", true, Sportovi_Collection.getInstance.Sportovi_collection, 23, "Okružen biljkama");

            tereniCollection.addTeren(teren1);
            tereniCollection.addTeren(teren2);
            tereniCollection.addTeren(teren3);
            tereniCollection.addTeren(teren4);
            tereniCollection.addTeren(teren5);
            tereniCollection.addTeren(teren6);
            tereniCollection.addTeren(teren7);
            tereniCollection.addTeren(teren8);
        }