Exemplo n.º 1
0
        public void DodajUtakmicuURaspored()
        {
            using (var db = new TurnirEntities2())
            {
                var upitDomacin = from it in db.Ekipe
                                  where it.Naziv == cmbDomacin.Text
                                  select it;

                var upitGost = from item in db.Ekipe
                               where item.Naziv == cmbGost.Text
                               select item;

                var upit = from it in db.Grupe
                           where it.Naziv == cmbGrupa.Text
                           select it;

                Ekipe ekipeDomacin = upitDomacin.First();
                Ekipe ekipeGost    = upitGost.First();
                Grupe grupe        = upit.First();

                Rasporedi rasporedi = new Rasporedi
                {
                    GrupeId        = grupe.Id,
                    Vrijeme        = txtVrijeme.Text,
                    EkipeIdDomacin = ekipeDomacin.Id,
                    EkipeIdGost    = ekipeGost.Id,
                    GoloviDomacin  = 0,
                    GoloviGost     = 0,
                    Odigrano       = "NE"
                };

                db.Rasporedi.Add(rasporedi);
                db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public void UnosEkipe()
        {
            using (var db = new TurnirEntities2())
            {
                Ekipe ekipe = new Ekipe
                {
                    Naziv = txtUnosEkipe.Text,
                };

                db.Ekipe.Add(ekipe);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public void DodajIgraca()
        {
            Ekipe ekipe = dgvEkipe.CurrentRow.DataBoundItem as Ekipe;

            using (var db = new TurnirEntities2())
            {
                Igraci igrac = new Igraci
                {
                    Ime     = txtImeIgraca.Text,
                    Prezime = txtPrezimeIgraca.Text,
                    EkipeId = ekipe.Id
                };
                db.Igraci.Add(igrac);
                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
 public void BrisiEkipu()
 {
     if (dgvEkipe.CurrentRow != null)
     {
         Ekipe ekipa = dgvEkipe.CurrentRow.DataBoundItem as Ekipe;
         if (ekipa != null)
         {
             if (MessageBox.Show("Jeste li sigurni?", "Upozorenje!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
             {
                 using (var db = new TurnirEntities2())
                 {
                     db.Ekipe.Attach(ekipa);
                     db.Ekipe.Remove(ekipa);
                     db.SaveChanges();
                 }
             }
             PrikaziEkipe();
         }
     }
 }
Exemplo n.º 5
0
        private void dgvEkipe_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            Ekipe ekipe = dgvEkipe.CurrentRow.DataBoundItem as Ekipe;

            using (var db = new TurnirEntities2())
            {
                var upitigraci = (from it in db.Igraci
                                  where it.EkipeId == ekipe.Id
                                  orderby it.Prezime ascending
                                  select it);

                dgvIgraci.DataSource = upitigraci.ToList();

                dgvIgraci.Columns[0].Visible            = false;
                dgvIgraci.Columns[3].Visible            = false;
                dgvIgraci.Columns[4].Visible            = false;
                dgvIgraci.Columns[5].Visible            = false;
                dgvIgraci.Columns[6].Visible            = false;
                dgvIgraci.Columns[7].Visible            = false;
                dgvIgraci.Columns[8].Visible            = false;
                dgvIgraci.Columns["PrezimeIme"].Visible = false;
            }
        }
Exemplo n.º 6
0
        private void dgvEkipe_SelectionChanged(object sender, EventArgs e)
        {
            Ekipe ekipe = dgvEkipe.CurrentRow.DataBoundItem as Ekipe;

            txtUnosEkipe.Text = ekipe.Naziv;
        }
Exemplo n.º 7
0
        public void Azuriraj()
        {
            string html = String.Empty;

            html += "<html>" +
                    "<head>" +
                    "<title> Raspored </title>" +
                    "</head>" +
                    "<body>" +
                    "<div style = float:center; width:30%" +
                    "<table style = border: 2px solid #ccc; border-collapse: collapse;>" +
                    "<tr>" +
                    "<td> &nbsp VRIJEME </td>" +
                    "<td> &nbsp &nbsp GRUPA </td>" +
                    "<td> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp DOMACIN </td>" +
                    "<td> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp GOST </td>" +
                    "<td> &nbsp &nbsp &nbsp &nbsp &nbsp REZULTAT </td>" +
                    "</tr>" +
                    "<tr>" +
                    "<br>" +
                    "-------------------------------------------------------------------------------" +
                    "</br>" +
                    "</tr>";

            using (var db = new TurnirEntities2())
            {
                var upit = from item in db.Rasporedi
                           select item;

                foreach (var red in upit)
                {
                    int domacinId = (int)red.EkipeIdDomacin;
                    int gostId    = (int)red.EkipeIdGost;

                    Console.WriteLine("\n!!" + domacinId + " " + gostId);

                    var domacin = (from i in db.Ekipe
                                   where domacinId == i.Id
                                   select i).ToList <Ekipe>();

                    var gost = (from i in db.Ekipe
                                where gostId == i.Id
                                select i).ToList <Ekipe>();

                    Ekipe ekipeDomacin = domacin.FirstOrDefault();
                    Ekipe ekipeGost    = gost.FirstOrDefault();

                    html += "<tr>" +
                            "<td>" + "&nbsp &nbsp &nbsp &nbsp" + red.Vrijeme + "&nbsp &nbsp &nbsp &nbsp" + "</td>" +
                            "<td>" + "&nbsp &nbsp &nbsp" + red.Grupe.Naziv + "&nbsp" + "</td>" +
                            "<td>" + "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp" + ekipeDomacin.Naziv + "&nbsp" + "</td>" +
                            "<td>" + "&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp" + ekipeGost.Naziv + "&nbsp" + "</td>" +
                            "<td>" + "&nbsp &nbsp &nbsp &nbsp" + red.GoloviDomacin + ":" + red.GoloviGost + "&nbsp" + "</td>" +
                            "</tr>" +
                            "<br>" +
                            "</br>";

                    System.IO.File.WriteAllText(@"F:\NK Croatia '78\turnir\dat.html", html);
                }

                html += "</table>" + "</div>" + "</body>" + "</html>";

                System.IO.File.WriteAllText(@"F:\NK Croatia '78\turnir\dat.html", html);

                Console.WriteLine(html);
            }
        }
Exemplo n.º 8
0
        public void AzurirajTablicu(string domacin, string gost)
        {
            int utakmica  = Convert.ToInt32(txtUtakmicaBroj.Text);
            int azurirano = 0;

            using (var db = new TurnirEntities2())
            {
                var upit = (from it in db.Rasporedi
                            where utakmica == it.Id
                            select it);

                Rasporedi rasporedi = upit.First();
                Console.WriteLine(upit);
                rasporedi.Id = utakmica;
                Console.WriteLine(rasporedi.Id);
                azurirano = (int)rasporedi.ažurirano;
                Console.WriteLine(rasporedi.ažurirano);
                Console.WriteLine("TEST");

                if (azurirano == 1)
                {
                    MessageBox.Show("Utakmica je već ažurirana!");
                }
                else
                {
                    var upitDomacin = (from item in db.Ekipe
                                       where item.Naziv == domacin
                                       select item);

                    var upitGost = (from item in db.Ekipe
                                    where item.Naziv == gost
                                    select item);

                    Ekipe doma = upitDomacin.First();
                    Ekipe gos  = upitGost.First();

                    doma.OdigraneUtakmice += 1;
                    gos.OdigraneUtakmice  += 1;

                    doma.PostignutiGolovi += Convert.ToInt32(txtGoloviDomacin.Text);
                    doma.PrimljeniGolovi  += Convert.ToInt32(txtGoloviGost.Text);

                    gos.PostignutiGolovi += Convert.ToInt32(txtGoloviGost.Text);
                    gos.PrimljeniGolovi  += Convert.ToInt32(txtGoloviDomacin.Text);

                    doma.GolRazlika = doma.PostignutiGolovi - doma.PrimljeniGolovi;
                    gos.GolRazlika  = gos.PostignutiGolovi - gos.PrimljeniGolovi;

                    if (doma.PostignutiGolovi > gos.PostignutiGolovi)
                    {
                        doma.Pobjede += 1;
                        doma.Bodovi  += 3;
                        gos.Porazi   += 1;
                    }
                    else if (doma.PostignutiGolovi < gos.PostignutiGolovi)
                    {
                        gos.Pobjede += 1;
                        gos.Bodovi  += 3;
                        doma.Porazi += 1;
                    }
                    else if (doma.PostignutiGolovi == gos.PostignutiGolovi)
                    {
                        doma.Neriješeno += 1;
                        gos.Neriješeno  += 1;
                        doma.Bodovi     += 1;
                        gos.Bodovi      += 1;
                    }

                    rasporedi.ažurirano = 1;
                    MessageBox.Show("Tablica ažurirana!");

                    db.SaveChanges();
                }
            }
        }