Example #1
0
 private void btnUredu_Click(object sender, EventArgs e)
 {
     using (var db = new EvidencijaStudenataEntities())
     { if (timZaIzmjenu == null)
       {
           Tim tim = new Tim
           {
               OznakaTima    = txtOznakaTima.Text,
               NazivProjekta = txtNazivProjekta.Text,
               OpisProjekta  = txtOpisProjekta.Text,
               Napomena      = txtNapomena.Text
           };
           db.Tim.Add(tim);
           db.SaveChanges();
       }
       else
       {
           db.Tim.Attach(timZaIzmjenu);
           timZaIzmjenu.OznakaTima    = txtOznakaTima.Text;
           timZaIzmjenu.NazivProjekta = txtNazivProjekta.Text;
           timZaIzmjenu.OpisProjekta  = txtOpisProjekta.Text;
           timZaIzmjenu.Napomena      = txtNapomena.Text;
           db.SaveChanges();
       } }
     Close();
 }
Example #2
0
        private void dgvTimovi_SelectionChanged(object sender, EventArgs e)
        {
            Tim selektrianiTim = timBindingSource.Current as Tim;

            if (selektrianiTim != null)
            {
                PrikaziStudente(selektrianiTim);
                int sum = 0;
                for (int i = 0; i < dgvStudenti.Rows.Count; ++i)
                {
                    sum += Convert.ToInt32(dgvStudenti.Rows[i].Cells[0].Value);
                }

                /*int total = dgvStudenti.Rows.Cast<DataGridViewRow>()
                 * .Min(t => Convert.ToInt32(t.Cells[0].Value));
                 *
                 * textBox1.Text = total.ToString();*/
                using (var db = new EvidencijaStudenataEntities())
                {
                    List <Student> prviTim = (from t in db.Student
                                              where t.Status == "R".ToString()
                                              select t).ToList <Student>();

                    /*   BindingList<Student> lista =
                     *     new BindingList<Student>(prviTim.Student.ToList<Student>());
                     */
                    // dgvStudenti.DataSource = prviTim;
                }
            }
        }
Example #3
0
        private void brnbrisitim_Click(object sender, EventArgs e)
        {
            Tim selektirnaiTim = timBindingSource.Current as Tim;

            if (selektirnaiTim != null)
            {
                if (MessageBox.Show("DA li ste sigurni?", "Upozorenje!", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    using (var db = new EvidencijaStudenataEntities())
                    {
                        db.Tim.Attach(selektirnaiTim);
                        if (selektirnaiTim.Student.Count == 0)
                        {
                            db.Tim.Remove(selektirnaiTim);
                            db.SaveChanges();
                        }
                        else
                        {
                            MessageBox.Show("Nije moguće!");
                        }
                    }
                    PrikaziTimove();
                }
            }
        }
Example #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Tim selektiraniTim = timBindingSource.Current as Tim;

            if (selektiraniTim != null)
            {
                FrmNoviTim forma = new FrmNoviTim(selektiraniTim);
                forma.ShowDialog();
                PrikaziTimove();
            }
        }
Example #5
0
        private void PrikaziStudente(Tim tim)
        {
            List <Student> listaStudenata = null;

            using (var db = new EvidencijaStudenataEntities())
            {
                db.Tim.Attach(tim);
                listaStudenata = new
                                 List <Student>(tim.Student.ToList <Student>());
                listaStudenata = (from t in listaStudenata
                                  where t.Status == "R".ToString()
                                  &&
                                  t.Ime.Contains("Igor")

                                  select t).ToList <Student>();

                List <int> total = (from t in listaStudenata
                                    select t.Id).ToList <int>();
                // double a = total.Average();
                textBox1.Text = total.Count().ToString();
            }
            studentBindingSource.DataSource = listaStudenata;
        }
Example #6
0
 public FrmNoviStudent(Tim tim)
 {
     InitializeComponent();
     selektiraniTim = tim;
 }
Example #7
0
 public FrmNoviTim(Tim tim)
 {
     InitializeComponent();
     timZaIzmjenu = tim;
 }