private void btnBrisanje_Click(object sender, EventArgs e)
        {
            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 " + dgvSportisti.SelectedCells[2].Value.ToString() + " " + dgvSportisti.SelectedCells[1].Value.ToString() + "?");


            if (deleteWarning.ShowDialog() == DialogResult.Yes)
            {
                Sportiste_Collection.getInstance.Sportiste_collection.Remove(new Guid(dgvSportisti.SelectedCells[0].Value.ToString()));
                List <Guid> sportistiUTimu = new List <Guid>();

                foreach (KeyValuePair <Guid, Tim> tim in Timovi_Collection.getInstance.Timovi_collection)
                {
                    if (tim.Value.Sportiste != null)
                    {
                        foreach (KeyValuePair <Guid, Sportista> sportista in tim.Value.Sportiste)
                        {
                            if (dgvSportisti.SelectedCells[0].Value.ToString().Equals(sportista.Key.ToString()))
                            {
                                sportistiUTimu.Add(sportista.Key);
                            }
                        }
                        foreach (Guid temp in sportistiUTimu)
                        {
                            Timovi_Collection.getInstance.Timovi_collection[tim.Key].Sportiste.Remove(temp);
                        }
                    }
                }

                loadTableData("");

                back.Close();
            }
            else
            {
                back.Close();
            }
        }
        private void btnBrisanje_Click(object sender, EventArgs e)
        {
            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 " + dgvTimovi.SelectedCells[1].Value.ToString() + "?");

            if (deleteWarning.ShowDialog() == DialogResult.Yes)
            {
                Timovi_Collection.getInstance.Timovi_collection.Remove(new Guid(dgvTimovi.SelectedCells[0].Value.ToString()));
                loadTableData("");
                back.Close();
            }
            else
            {
                back.Close();
            }
        }
Ejemplo n.º 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;
        }