Ejemplo n.º 1
0
        private void BtnBrisiFunkciju_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s  = DataLayer.getSession();
                Object   ob = lbFunkcije.SelectedItem;
                if (ob == null)
                {
                    MessageBox.Show("Selektujte funckiju koju zelite da obrisete!");
                    return;
                }

                int      pos        = ob.ToString().IndexOf(" ");
                int      idFunkcije = int.Parse(ob.ToString().Substring(0, pos));
                Funkcija funkcija   = s.Get <Funkcija>(idFunkcije);

                s.Delete(funkcija);
                s.Flush();
                s.Close();
                MessageBox.Show("Uspesno obrisana funkcija!");
                lbFunkcije.Items.Clear();
                this.CtrlBrisiFunkciju_Load(null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void BtnDodajFunckiju_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s  = DataLayer.getSession();
                Object   o1 = lbFunckije.SelectedItem;

                if (o1 == null)
                {
                    MessageBox.Show("Morate selektovati funckiju !");
                    return;
                }
                //MessageBox.Show(o1.ToString().IndexOf(" ").ToString());
                int pos        = o1.ToString().IndexOf(" ");
                int idFunkcije = int.Parse(o1.ToString().Substring(0, pos));

                Funkcija f = s.Load <Funkcija>(idFunkcije);
                f.TipFunkcije = txtTipFunckije.Text;
                s.Update(f);
                s.Flush();
                s.Close();
                MessageBox.Show("Uspesno azurirana funkcija !");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public FunkcijaView GetFunkcijaViewId(int id)
        {
            ISession s        = DataLayer.getSession();
            Funkcija funkcija = s.Query <Funkcija>().Where(f => f.IdFunkcije == id).Select(p => p).FirstOrDefault();

            return(new FunkcijaView(funkcija));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,naziv")] Funkcija funkcija)
        {
            if (id != funkcija.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(funkcija);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FunkcijaExists(funkcija.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(funkcija));
        }
        static void IspišiFunkcijeZasebno(Funkcija fja, double x1, double x2, int n)
        {
            // TODO: Pomoću metode GetInvocationList dohvatiti sve delegatske funkcije zasebno i za svaku ispisati vrijednosti u traženom intervalu

        
        
        }
Ejemplo n.º 6
0
 public static void IspišiFunkcijeZasebno(Funkcija fja, double x1, double x2, int n)
 {
     //  Pomoću metode GetInvocationList dohvatiti sve delegatske funkcije zasebno i za svaku ispisati vrijednosti u traženom intervalu
     foreach (Funkcija f in fja.GetInvocationList())
     {
         IspišiFunkciju(f, x1, x2, n);
     }
 }
Ejemplo n.º 7
0
 static void IspišiFunkciju(Funkcija fja, double x1, double x2, int n)
 {
     Console.WriteLine("Ispis funkcije {0}:", fja.Method);
     Console.WriteLine("{0} {1}", "x", "y");
     for (int i = 0; i < n; ++i)
     {
         double x = x1 + (x2 - x1) / (n - 1) * i;
         Console.WriteLine("{0} {1}", x, fja(x));
     }
 }
Ejemplo n.º 8
0
 static void IspišiFunkciju(Funkcija fja, double x1, double x2, int n)
 {
     Console.WriteLine("Ispis funkcije {0}:", fja.Method);
     Console.WriteLine("{0} {1}", "x", "y");
     for (int i = 0; i < n; ++i)
     {
         double x = x1 + (x2 - x1) / (n - 1) * i;
         Console.WriteLine("{0} {1}", x, fja(x));
     }
 }
Ejemplo n.º 9
0
        public async Task <IActionResult> Create([Bind("Id,naziv")] Funkcija funkcija)
        {
            if (ModelState.IsValid)
            {
                _context.Add(funkcija);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(funkcija));
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Funkcija f = Math.Cos;

            f += Math.Sin;

            Console.WriteLine("*** IspišiFunkciju ***");
            IspišiFunkciju(f, 0, Math.PI, 10);

            Console.WriteLine("*** IspišiFunkcijeZasebno ***");
            IspišiFunkcijeZasebno(f, 0, Math.PI, 10);

            Console.WriteLine("GOTOVO!!!");
            Console.ReadKey();
        }
Ejemplo n.º 11
0
 public int AddFunkcija(Funkcija f)
 {
     try
     {
         ISession s = DataLayer.getSession();
         s.Save(f);
         s.Flush();
         s.Close();
         return(1);
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
         return(-1);
     }
 }
Ejemplo n.º 12
0
        private void btnUcitajFunkciju_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s = DataLayer.getSession();

                Funkcija f = s.Load <Funkcija>(1);

                MessageBox.Show(f.TipFunkcije);

                s.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 13
0
 private void btnDodajFunckiju_Click(object sender, EventArgs e)
 {
     try
     {
         ISession s = DataLayer.getSession();
         Funkcija f = new Funkcija();
         f.TipFunkcije = txtTipFunckije.Text;
         s.Save(f);
         s.Flush();
         s.Close();
         MessageBox.Show("Uspesno dodata nova funkcija !");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        // TODO:044 Pokrenuti i provjeriti testove (test u grupi "GetInvocationList" mora proći).

        static void Main(string[] args)
        {
            // TODO:040 Pokrenuti program i provjeriti ispis.
            Funkcija f = Math.Cos;

            // TODO:041 Otkomentirati donju naredbu i ponovno pokrenuti program te provjeriti ispis.
            //f += Math.Sin;

            Console.WriteLine("*** IspišiFunkcijeUPaketu ***");
            IspišiFunkciju(f, 0, Math.PI, 10);

            Console.WriteLine("*** IspišiFunkcijeZasebno ***");
            IspišiFunkcijeZasebno(f, 0, Math.PI, 10);

            Console.WriteLine("GOTOVO!!!");
            Console.ReadKey();
        }
Ejemplo n.º 15
0
 public int RemoveFunkcija(int id)
 {
     try
     {
         ISession s = DataLayer.getSession();
         Funkcija f = s.Get <Funkcija>(id);
         s.Delete(f);
         s.Flush();
         s.Close();
         return(1);
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
         return(-1);
     }
 }
Ejemplo n.º 16
0
        private void btnDodaj_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s  = DataLayer.getSession();
                Object   o1 = Funkcije.SelectedItem;
                Object   o2 = Roditelji.SelectedItem;

                if (o1 == null || o2 == null)
                {
                    MessageBox.Show("Morate selektovati i nastavnika i predmet");
                    return;
                }

                String st1 = o1.ToString();
                String st2 = o2.ToString();


                ObavljaFunkciju   of   = new ObavljaFunkciju();
                ObavljaFunkcijuId ofId = new ObavljaFunkcijuId();
                int pos1       = o1.ToString().IndexOf(" ");
                int pos2       = o2.ToString().IndexOf(" ");
                int idRoditelj = int.Parse(st2.Substring(0, pos2));
                int idFunkcija = int.Parse(st1.Substring(0, pos1));

                NijeUcenik nu = s.Load <NijeUcenik>(idRoditelj);
                Funkcija   f  = s.Load <Funkcija>(idFunkcija);

                ofId.ObavljaFunkciju = nu;
                ofId.ObavljaSe       = f;

                of.Id = ofId;
                of.datumOdFunkcija = dtpDatumOd.Value.Date;
                of.datumDoFunkcija = dtpDatumDo.Value.Date;


                s.Save(of);
                s.Flush();
                s.Close();
                MessageBox.Show("Uspesno dodat podatak u tabelu ObavljaFunkciju !");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 17
0
 public int UpdateFunkciju(int id, Funkcija f)
 {
     try
     {
         ISession s   = DataLayer.getSession();
         Funkcija fun = s.Load <Funkcija>(id);
         fun.TipFunkcije = f.TipFunkcije;
         s.Update(fun);
         s.Flush();
         s.Close();
         return(1);
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
         return(-1);
     }
 }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            // kvadrat broja
            Funkcija f = x => x * x;

            Console.WriteLine(f(5));

            // kub broja
            f = x => x * x * x;
            Console.WriteLine(f(5));

            //  Ispisati tablicu kvadrata tako da se u pozivu metode IspišiFunkciju navede lambda izraz.
            IspišiFunkciju(x => x * x, 0, 10, 11);



            Console.WriteLine("GOTOVO!!!");
            Console.ReadKey();
        }
Ejemplo n.º 19
0
        public void Radi(string pocetno)
        {
            int j = 20;

            string StanjeTemp;
            string Temp;
            string PomakTemp;
            string UpisanZnakTemp;

            Temp = Convert.ToString(Tablica[pocetno + "," + Traka[j]]);
            Funkcija f = new Funkcija(Temp);

            StanjeTemp     = f.SljedeceStanje;
            PomakTemp      = f.Pomak;
            UpisanZnakTemp = f.UpisanZnak;

            while (1 == 1)
            {
                Traka[j] = UpisanZnakTemp;

                if (PomakTemp == "R")
                {
                    j++;
                }
                else if (PomakTemp == "L")
                {
                    j--;
                }
                if (StanjeTemp == "q9")
                {
                    break;
                }

                Temp = Convert.ToString(Tablica[StanjeTemp + "," + Traka[j]]);
                Funkcija f1 = new Funkcija(Temp);
                StanjeTemp     = f1.SljedeceStanje;
                PomakTemp      = f1.Pomak;
                UpisanZnakTemp = f1.UpisanZnak;
            }
        }
Ejemplo n.º 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ISession s  = DataLayer.getSession();
                Object   ob = lbObavljaFunkciju.SelectedItem;
                if (ob == null)
                {
                    MessageBox.Show("Selektujte ObavljaFunkciju koju zelite da obrisete!");
                    return;
                }

                int pos1 = ob.ToString().IndexOf(".");
                int pos2 = ob.ToString().IndexOf(".", pos1 + 1);
                int mid  = ob.ToString().IndexOf("-");

                int        idRoditelj = int.Parse(ob.ToString().Substring(0, pos1));
                int        idFunkcija = int.Parse(ob.ToString().Substring(mid + 1, pos2 - 1 - mid));
                NijeUcenik roditelj   = s.Load <NijeUcenik>(idRoditelj);
                Funkcija   funkcija   = s.Load <Funkcija>(idFunkcija);

                ObavljaFunkciju obavljaFunkcijua = new ObavljaFunkciju();
                obavljaFunkcijua.Id.ObavljaFunkciju = roditelj;
                obavljaFunkcijua.Id.ObavljaSe       = funkcija;

                s.Delete(obavljaFunkcijua);
                s.Flush();
                s.Close();
                MessageBox.Show("Uspesno obrisano ObavljaFunkciju!");
                lbObavljaFunkciju.Items.Clear();
                this.CtrlBrisiObavljaFunkciju_Load(null, null);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 21
0
        public int Post([FromBody] Funkcija f)
        {
            DataProvider provider = new DataProvider();

            return(provider.AddFunkcija(f));
        }
Ejemplo n.º 22
0
        public int Put(int id, [FromBody] Funkcija f)
        {
            DataProvider provider = new DataProvider();

            return(provider.UpdateFunkciju(id, f));
        }
Ejemplo n.º 23
0
 public FunkcijaView(Funkcija f)
 {
     idFunkcije  = f.IdFunkcije;
     TipFunckije = f.TipFunkcije;
 }
        public static void IspišiFunkcijeZasebno(Funkcija fja, double x1, double x2, int n)
        {
            // TODO:042 Pomoću metode GetInvocationList dohvatiti sve delegatske funkcije zasebno i za svaku ispisati vrijednosti u traženom intervalu.

            // TODO:043 Pokrenuti program i provjeriti ispis.
        }