Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Ime,Content,SklonisteId,Vrsta,Opis,Godine,PosvajteljId")] Ljubimac ljubimac)
        {
            if (id != ljubimac.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ljubimac);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LjubimacExists(ljubimac.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Ljubimci"));
            }
            ViewData["SklonisteId"]   = new SelectList(_context.Set <Skloniste>(), "Id", "Id", ljubimac.SklonisteId);
            ViewData["PosvajateljId"] = new SelectList(_context.Set <Skloniste>(), "Id", "Prezime", ljubimac.PosvajteljId);
            return(View(ljubimac));
        }
        public override object Izvrsi(OpstiDomenskiObjekat odo)
        {
            Ljubimac lj = odo as Ljubimac;
            Vlasnik  v  = lj.Vlasnik;
            Osoba    o  = new Osoba();

            o.Id      = v.Id;
            o.Ime     = v.Ime;
            o.Prezime = v.Prezime;
            o.Telefon = v.Telefon;
            o.Email   = v.Email;


            try
            {
                Sesija.Broker.vratiKonekciju().insert(o);
                Sesija.Broker.vratiKonekciju().insert(odo);
                Sesija.Broker.vratiKonekciju().insert(odo);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Exemplo n.º 3
0
        public override object Izvrsi(OpstiDomenskiObjekat odo)
        {
            Vlasnik v = Sesija.Broker.vratiKonekciju().vratiJedanZaID(odo) as Vlasnik;

            if (v == null)
            {
                return(null);
            }
            Osoba o = new Osoba();

            o.Id = v.Id;

            o         = Sesija.Broker.vratiKonekciju().vratiJedanZaID(o) as Osoba;
            v.Jmbg    = o.Jmbg;
            v.Ime     = o.Ime;
            v.Prezime = o.Prezime;
            v.Email   = o.Email;
            v.Telefon = o.Telefon;

            Ljubimac lj = new Ljubimac();

            lj.USLOVI  = " IDVlasnik = " + v.Id + " and Status = 'Aktivan'";
            v.Ljubimci = Sesija.Broker.vratiKonekciju().vratiSveZaUslovOpsti(lj).OfType <Ljubimac>().ToList <Ljubimac>();

            return(v);
        }
Exemplo n.º 4
0
        private void gridLjubimci_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            lj = gridLjubimci.CurrentRow.DataBoundItem as Ljubimac;


            txtLjubimac.Text = lj.ToString();
            //  cmbVeterinar.SelectedIndex = cmbVeterinar.FindStringExact(lj.Veterinar.ToString());
        }
Exemplo n.º 5
0
        public override object Izvrsi(OpstiDomenskiObjekat odo)
        {
            Ljubimac lj = new Ljubimac();

            lj.Id = Sesija.Broker.vratiKonekciju().vratiID(odo);
            //Sesija.Broker.vratiKonekciju().insert(lj);
            return(lj);
        }
Exemplo n.º 6
0
        public override object Izvrsi(OpstiDomenskiObjekat odo)
        {
            Ljubimac lj = new Ljubimac();

            lj           = Sesija.Broker.vratiKonekciju().vratiJedanZaID(odo) as Ljubimac;
            lj.Vlasnik   = Sesija.Broker.vratiKonekciju().vratiJedanZaID(lj.Vlasnik) as Vlasnik;
            lj.Zivotinja = Sesija.Broker.vratiKonekciju().vratiJedanZaID(lj.Zivotinja) as Zivotinja;

            return(lj);
        }
Exemplo n.º 7
0
        public List <Ljubimac> ucitajSveLjubimce(Ljubimac ljubimac)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.operacija = Operacija.UcitajSveLjubimce;
            transfer.poruka    = ljubimac;
            formater.Serialize(tok, transfer);
            transfer = formater.Deserialize(tok) as TransferKlasa;

            return(transfer.odgovor as List <Ljubimac>);
        }
Exemplo n.º 8
0
        public List <Ljubimac> pronadjiLjubimca(Ljubimac ljubimac)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.operacija = Operacija.PronadjiLjubimca;
            transfer.poruka    = ljubimac;
            formater.Serialize(tok, transfer);
            transfer = formater.Deserialize(tok) as TransferKlasa;

            return(transfer.odgovor as List <Ljubimac>);
        }
Exemplo n.º 9
0
        private void btnKreirajIDLj_Click(object sender, EventArgs e)
        {
            gbLjubimac.Enabled   = true;
            gbVlasnik.Enabled    = true;
            btnSacuvajLj.Enabled = true;

            if (kontroler.kreirajLjubimca(txtIDljub, btnKreirajIDLj) != null)
            {
                lj = kontroler.kreirajLjubimca(txtIDljub, btnKreirajIDLj);
            }
        }
Exemplo n.º 10
0
        public object obrisiLjubimca(Ljubimac ljubimac)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.operacija = Operacija.ObrisiLjubimca;
            transfer.poruka    = ljubimac;
            formater.Serialize(tok, transfer);
            transfer = formater.Deserialize(tok) as TransferKlasa;

            return(transfer.odgovor);
        }
Exemplo n.º 11
0
        public Ljubimac izmeniLjubimca(Ljubimac ljubimac)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.operacija = Operacija.IzmeniLjubimca;
            transfer.poruka    = ljubimac;
            formater.Serialize(tok, transfer);
            transfer = formater.Deserialize(tok) as TransferKlasa;

            return(transfer.odgovor as Ljubimac);
        }
Exemplo n.º 12
0
        public object sacuvajLjubimcaSaVlasnikom(Ljubimac ljubimac)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.operacija = Operacija.ZapamtiLjubimcaSaVlasnikom;
            transfer.poruka    = ljubimac;
            formater.Serialize(tok, transfer);
            transfer = formater.Deserialize(tok) as TransferKlasa;

            return(transfer.odgovor);
        }
Exemplo n.º 13
0
 public FrmUnesiNovogLjubimca(Ljubimac ljubimac)
 {
     lj = ljubimac;
     InitializeComponent();
     this.Text = "Ljubimac " + ljubimac.Ime;
     btnKreirajIDLj.Enabled = false;
     gbLjubimac.Enabled     = true;
     gbVlasnik.Enabled      = false;
     txtIDljub.Enabled      = false;
     btnSacuvajLj.Text      = "Izmeni Ljubimca";
     btnSacuvajLj.Enabled   = true;
 }
Exemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("Id,Ime,Opis,Datum,SkloništeId,Mjesto,Vrsta,Godine,Slika")] Ljubimac ljubimac, ICollection <IFormFile> files)
        {
            if (ModelState.IsValid)
            {
                var datum = DateTime.Now;

                ljubimac.Datum = datum;
                var uploads = Path.Combine(_environment.WebRootPath, "slike");
                if (ljubimac.Vrsta == "Mačka")
                {
                    uploads = Path.Combine(_environment.WebRootPath, "slike/macke");
                }
                else if (ljubimac.Vrsta == "Pas")
                {
                    uploads = Path.Combine(_environment.WebRootPath, "slike/psi");
                }
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);

                            if (ljubimac.Vrsta == "Mačka")
                            {
                                ljubimac.Slika = "//" + "macke" + "//" + file.FileName;
                            }
                            else if (ljubimac.Vrsta == "Pas")
                            {
                                ljubimac.Slika = "//" + "psi" + "//" + file.FileName;
                            }
                            else
                            {
                                ljubimac.Slika = file.FileName;
                            }
                        }
                    }
                }
                _context.Add(ljubimac);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            var list = new List <String>();

            list.Add("Mačka");
            list.Add("Pas");
            ViewData["Vrsta"]       = new SelectList(list);
            ViewData["SkloništeId"] = new SelectList(_context.Set <Sklonište>(), "Id", "Naziv", ljubimac.SkloništeId);

            return(View(ljubimac));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Create([Bind("Id,Ime,Content,SklonisteId,Vrsta,Opis,Godine,PosvajteljId")] Ljubimac ljubimac)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ljubimac);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Ljubimci"));
            }
            ViewData["SklonisteId"] = new SelectList(_context.Set <Skloniste>(), "Id", "Id", ljubimac.SklonisteId);

            return(View(ljubimac));
        }
Exemplo n.º 16
0
        public object vratiLjubimcaIzTabele(OpstiDomenskiObjekat odo)
        {
            try
            {
                komanda.CommandText = "Select z.Vrsta, lj.*, o.Ime, o.Prezime, o.Telefon, o.Email, v.Zanimanje from Zivotinja z join Ljubimac lj on z.ID = lj.IDZivotinja join Osoba o on lj.IDVlasnik = o.ID join Vlasnik v on o.ID = v.ID where " + odo.UslovOpsti;
                citac = komanda.ExecuteReader();
                Ljubimac lj = new Ljubimac();

                while (citac.Read())
                {
                    lj.Id      = Convert.ToInt32(citac[1]);
                    lj.Ime     = citac[2].ToString();
                    lj.Boja    = citac[5].ToString();
                    lj.Pol     = citac[4].ToString();
                    lj.Starost = Convert.ToInt32(citac[3]);

                    lj.Vlasnik           = new Vlasnik();
                    lj.Vlasnik.Id        = Convert.ToInt32(citac[7]);
                    lj.Vlasnik.Ime       = citac[9].ToString();
                    lj.Vlasnik.Prezime   = citac[10].ToString();
                    lj.Vlasnik.Telefon   = citac[11].ToString();
                    lj.Vlasnik.Email     = citac[12].ToString();
                    lj.Vlasnik.Zanimanje = citac[13].ToString();


                    //lj.Veterinar = new Veterinar();
                    //lj.Veterinar.Jmbg = Convert.ToInt32(citac[8]);
                    //lj.Veterinar.Ime = citac[15].ToString();
                    //lj.Veterinar.Prezime = citac[16].ToString();
                    //lj.Veterinar.Telefon = citac[17].ToString();
                    //lj.Veterinar.Telefon = citac[17].ToString();

                    lj.Rasa            = citac[6].ToString();
                    lj.Zivotinja       = new Zivotinja();
                    lj.Zivotinja.Id    = Convert.ToInt32(citac[8]);
                    lj.Zivotinja.Vrsta = citac[0].ToString();
                }
                citac.Close();
                return(lj);
            }
            catch (Exception)
            {
                citac.Close();
                throw;
            }
        }
Exemplo n.º 17
0
        public object sacuvajLjubimca(Ljubimac ljubimac)
        {
            try
            {
                TransferKlasa transfer = new TransferKlasa();
                transfer.operacija = Operacija.ZapamtiLjubimca;
                transfer.poruka    = ljubimac;
                formater.Serialize(tok, transfer);
                transfer = formater.Deserialize(tok) as TransferKlasa;

                return(transfer.odgovor);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Exemplo n.º 18
0
        private void btnObrisiLjub_Click(object sender, EventArgs e)
        {
            try
            {
                Ljubimac lj = gridLjubimci.CurrentRow.DataBoundItem as Ljubimac;

                vlasnik = cmbVlasnici.SelectedItem as Vlasnik;
                if (kontroler.obrisiLjubimcaIzListe(lj, vlasnik))
                {
                    kontroler.prikaziLjubimce(gridLjubimci, vlasnik);
                }
                //else { this.Close(); }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Exemplo n.º 19
0
        public override object Izvrsi(OpstiDomenskiObjekat odo)
        {
            List <Vlasnik> lista = Sesija.Broker.vratiKonekciju().vratiSVe(odo).OfType <Vlasnik>().ToList <Vlasnik>();

            Ljubimac ljubimac = new Ljubimac();

            foreach (Vlasnik v in lista)
            {
                Osoba o = new Osoba();
                o.Id            = v.Id;
                o               = Sesija.Broker.vratiKonekciju().vratiJedanZaID(o) as Osoba;
                v.Jmbg          = o.Jmbg;
                v.Ime           = o.Ime;
                v.Prezime       = o.Prezime;
                v.Email         = o.Email;
                v.Telefon       = o.Telefon;
                ljubimac.USLOVI = "IDVlasnik = " + v.Id;
                v.Ljubimci      = Sesija.Broker.vratiKonekciju().vratiSveZaUslovOpsti(ljubimac).OfType <Ljubimac>().ToList <Ljubimac>();
            }
            return(lista);
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Ime,Opis,Datum,Grad,SklonisteId,Mjesto,Vrsta,Godine,PosvajteljId,Slika")] Ljubimac ljubimac, ICollection <IFormFile> files)
        {
            if (id != ljubimac.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    ljubimac.Datum = DateTime.Now;
                    var uploads = Path.Combine(_environment.WebRootPath, "slike");
                    if (ljubimac.Vrsta == "Mačka")
                    {
                        uploads = Path.Combine(_environment.WebRootPath, "slike/macke");
                    }
                    else if (ljubimac.Vrsta == "Pas")
                    {
                        uploads = Path.Combine(_environment.WebRootPath, "slike/psi");
                    }
                    foreach (var file in files)
                    {
                        if (file.Length > 0)
                        {
                            using (var fileStream = new FileStream(Path.Combine(uploads, file.FileName), FileMode.Create))
                            {
                                await file.CopyToAsync(fileStream);

                                if (ljubimac.Vrsta == "Mačka")
                                {
                                    ljubimac.Slika = "//" + "macke" + "//" + file.FileName;
                                }
                                else if (ljubimac.Vrsta == "Pas")
                                {
                                    ljubimac.Slika = "//" + "psi" + "//" + file.FileName;
                                }
                                else
                                {
                                    ljubimac.Slika = file.FileName;
                                }
                            }
                        }
                    }
                    _context.Update(ljubimac);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LjubimacExists(ljubimac.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Ljubimci"));
            }
            var list = new List <String>();

            list.Add("Mačka");
            list.Add("Pas");
            ViewData["Vrsta"]       = new SelectList(list, ljubimac.Vrsta);
            ViewData["SkloništeId"] = new SelectList(_context.Set <Skloniste>(), "Id", "Naziv", ljubimac.SklonisteId);
            var sklon = from d in _context.Skloniste
                        where d.Id == ljubimac.SklonisteId
                        select d.Naziv;

            ViewData["SkloništeNaziv"] = new SelectList(_context.Set <Skloniste>(), "Naziv", "Naziv", sklon);
            return(View(ljubimac));
        }
Exemplo n.º 21
0
 public FrmKartonLjubimca(Ljubimac ljubimac)
 {
     InitializeComponent();
     ljub = ljubimac;
 }