Example #1
0
        private void btnPotvrda_Click(object sender, EventArgs e)
        {
            if (cbNamena.SelectedItem == null)
            {
                cbNamena_Validated(sender, e);
                cbNamena.Focus();
                isCorrect = false;
            }
            else
            {
                if (!checkSportOfTerenAndTim())
                {
                    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(trenutnoImeTerena + " ne podrzava sport koji igra " + trenutnoImeTima + " !");
                    if (mtw.ShowDialog() == DialogResult.OK)
                    {
                        back.Hide();
                    }
                }
                else
                {
                    Zauzimanje temp = new Zauzimanje(new Guid(tbSifraTima.Text), new Guid(tbSifraTerena.Text), dtpZauzimanjeTerena.Value.Date, dtpOslobadanjeTerena.Value.Date, Zauzimanje.Namena.Drugo, null, status);
                    temp.Namena1  = (Zauzimanje.Namena)cbNamena.SelectedItem;
                    temp.Primedbe = tbPrimedbe.Text;

                    if (status == Enumeration.Status.OSLOBADJANJE)
                    {
                        Teren teren = new Teren(null, null, null, false, null, -1, null);
                        Tereni_Collection.getInstance.Teren_collection.TryGetValue(new Guid(tbSifraTerena.Text), out teren);
                        Tim tim = new Tim(null, null, null, null);
                        Timovi_Collection.getInstance.Timovi_collection.TryGetValue(new Guid(tbSifraTima.Text), out tim);
                        Form1.getInstance.setLblStatusBar(teren.Ime + " je oslobođen od tima " + tim.Ime + "!");
                    }
                    if (status == Enumeration.Status.ZAUZIMANJE)
                    {
                        Teren teren = new Teren(null, null, null, false, null, -1, null);
                        Tereni_Collection.getInstance.Teren_collection.TryGetValue(new Guid(tbSifraTerena.Text), out teren);
                        Tim tim = new Tim(null, null, null, null);
                        Timovi_Collection.getInstance.Timovi_collection.TryGetValue(new Guid(tbSifraTima.Text), out tim);
                        Form1.getInstance.setLblStatusBar(tim.Ime + " je zauzeo teren " + teren.Ime + "!");
                    }

                    Zauzimanje_Collection.getInstance.addZauzimanje(temp);
                    ZauzimanjeTerena.getInstance.loadTableData("");
                    Background.getInstance.Visible = false;
                    isCorrect = true;
                    this.Close();
                }
            }
        }
Example #2
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();
                    }
                }
            }
        }
Example #3
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;
        }