Esempio n. 1
0
        public ObservableCollection<Mesto> DajSvaMesta()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Mesto> _upit = (from p in _baza.Mestos
                                               //where p.MestoID == -1
                                               select p).OrderBy(w => w.MestoID);

                    ObservableCollection<Mesto> _lista = new ObservableCollection<Mesto>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public ObservableCollection<PoreskaStopa> DajSvePoreskeStope()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<PoreskaStopa> _upit = (from p in _baza.PoreskaStopas
                                                      select p).OrderBy(w => w.PoreskaStopaID);

                    ObservableCollection<PoreskaStopa> _lista = new ObservableCollection<PoreskaStopa>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        public KorisnikPrograma DajKorisnikPrograma()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<KorisnikPrograma> _upit = (from p in _baza.KorisnikProgramas
                                                          select p).OrderBy(w => w.KorisnikProgramaID).Take(1);

                    ObservableCollection<KorisnikPrograma> _lista = new ObservableCollection<KorisnikPrograma>(_upit.ToList());

                    if (_lista.Count().Equals(1))
                    {
                        return _lista.First();
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        public ObservableCollection<RadniNalog> NadjiRadniNalog(string vrstaPartnera, string radniNalogID, DateTime? datumOd, DateTime? datumDo, string partner, bool? neZavrsene, int? radnikID, int radniNalogStatusIDZavrsen)
        {
            //return new ObservableCollection<RadniNalog>();
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<RadniNalog> _upit = (from p in _baza.RadniNalogs
                                                    where p.Status.ToString() != "D"
                                                    select p).OrderBy(w => w.RadniNalogID);



                    if (neZavrsene != null && (bool)neZavrsene)
                    {
                        _upit = (from u in _upit
                                join su in _baza.StavkaUslugas
                                on u.RadniNalogID equals su.RadniNalogID
                                join surn in _baza.RadniNalogStavkaUslugas 
                                on su.StavkaUslugaID equals surn.RadniNalogStavkaUslugaID
                                where (surn.Status.ToString() != "D" && surn.RadniNalogStatusID != radniNalogStatusIDZavrsen)
                                select u);



                    }

                    if (vrstaPartnera != "")
                    {
                        if (vrstaPartnera == "Poslovni partner")
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartnerID != null
                                    select u;
                        }
                        else if (vrstaPartnera == "Fizičko lice")
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.FizickoLiceID != null
                                    select u;
                        }
                    }
                    if (radniNalogID != "")
                    {
                        if (radniNalogID.StartsWith("*") && radniNalogID.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.RadniNalogID.ToString().Contains(radniNalogID.Substring(1, radniNalogID.Length - 2))
                                    select u;
                        }
                        else if (radniNalogID.StartsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.RadniNalogID.ToString().EndsWith(radniNalogID.Substring(1, radniNalogID.Length - 1))
                                    select u;
                        }
                        else if (radniNalogID.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.RadniNalogID.ToString().StartsWith(radniNalogID.Substring(0, radniNalogID.Length - 1))
                                    select u;
                        }
                        else
                        {
                            _upit = from u in _upit
                                    where u.RadniNalogID.ToString().Equals(radniNalogID)
                                    select u;
                        }
                    }
                    if (datumOd != null || datumDo != null)
                    {
                        if (datumOd != null && datumDo == null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme >= datumOd
                                    select u;
                        }
                        else if (datumOd == null && datumDo != null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme <= datumDo
                                    select u;
                        }
                        else if (datumOd != null && datumDo != null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme >= datumOd && u.Vreme <= datumDo
                                    select u;
                        }
                    }
                    if (partner != "")
                    {
                        if (partner.StartsWith("*") && partner.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.Contains(partner.Substring(1, partner.Length - 2)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.Contains(partner.Substring(1, partner.Length - 2))
                                    select u;
                        }
                        else if (partner.StartsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.EndsWith(partner.Substring(1, partner.Length - 1)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.EndsWith(partner.Substring(1, partner.Length - 1))
                                    select u;
                        }
                        else if (partner.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.StartsWith(partner.Substring(0, partner.Length - 1)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.StartsWith(partner.Substring(0, partner.Length - 1))
                                    select u;
                        }
                        else
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.Equals(partner) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.Equals(partner)
                                    select u;
                        }
                    }

                   
                    if (radnikID != null)
                    {
                        _upit = from u in _upit
                                where u.RadnikID == radnikID
                                select u;
                    }

                    ObservableCollection<RadniNalog> _lista = new ObservableCollection<RadniNalog>(_upit.Distinct().ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 5
0
        public ObservableCollection<Proizvodjac> DajSveProizvodjac()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Proizvodjac> _upit = (from p in _baza.Proizvodjacs
                                                     join m in _baza.ModelAutomobilas
                                                     on p.Proizvodjac_ID equals m.Proizvodjac_ID
                                                     select p).Distinct().OrderBy(w => w.Naziv);

                    ObservableCollection<Proizvodjac> _lista = new ObservableCollection<Proizvodjac>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 6
0
        public ObservableCollection<RadnoMesto> DajSvaRadnaMesta()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<RadnoMesto> _upit = (from p in _baza.RadnoMestos
                                                    select p).OrderBy(w => w.RadnoMestoID);

                    ObservableCollection<RadnoMesto> _lista = new ObservableCollection<RadnoMesto>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
Esempio n. 7
0
        public ObservableCollection<PadajucaListaSezonaGumaRoban> DajPadajucuListuSezonaGumaRoban()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<PadajucaListaSezonaGumaRoban> _lista = new ObservableCollection<PadajucaListaSezonaGumaRoban>(_baza.uspDajPadajucuListuSezonaGumaRoban().ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 8
0
        public ObservableCollection<Artikal> NadjiGumuRoban(int? proizvodjacID, string namena, string sezona, string dimenzija)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _artikli = new ObservableCollection<Artikal>(_baza.uspNadjiGumu(proizvodjacID, namena, sezona, dimenzija).ToList());

                    return _artikli;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 9
0
        public ObservableCollection<Artikal> NadjiUljeRoban(int? proizvodjacID, string viskozitet)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);
                DataLoadOptions _dlo = new DataLoadOptions();

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _artikli = new ObservableCollection<Artikal>(_baza.uspNadjiUlje(proizvodjacID, viskozitet).ToList());

                    return _artikli;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 10
0
        public ObservableCollection<Artikal> NadjiArtikal(string brojZaPretragu, bool slicnoTrazenje, bool samoSaCenom, bool biloKojiBroj,
            bool brojProizvodjaca, bool oeBroj, bool korisceniBroj, bool uporedniBroj, bool eanBroj)
        {

            List<int> _vrstaBrojaZaPretragu = new List<int>();

            #region vrstaBrojaZaPretragu
            if (!biloKojiBroj)
            {
                if (brojProizvodjaca)
                {
                    _vrstaBrojaZaPretragu.Add(1);
                }
                if (oeBroj)
                {
                    _vrstaBrojaZaPretragu.Add(3);

                }
                if (korisceniBroj)
                {
                    _vrstaBrojaZaPretragu.Add(2);

                }
                if (uporedniBroj)
                {
                    _vrstaBrojaZaPretragu.Add(4);

                }
                if (eanBroj)
                {
                    _vrstaBrojaZaPretragu.Add(5);

                }
            }
            #endregion

            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);
                
                ////Da bi izbegao load podataka za tabelu NajpovoljnijiDobavljac koja ne postoji u Bazi
                ////prvo gasim dlo za sve tabele
                //_baza.DeferredLoadingEnabled = false;
                ////a onda dodajem dlo za one koje mi trebaju
                //DataLoadOptions _dlo = new DataLoadOptions();
                //_dlo.LoadWith<Artikal>(p => p.Proizvodjac);
                //_dlo.LoadWith<Artikal>(p => p.OpisTabela);
                //_dlo.LoadWith<Artikal>(p => p.VezaArtikalBrojZaPretragus);
                //_dlo.LoadWith<Artikal>(p => p.VezaArtikalDobavljacs);
                //_dlo.LoadWith<VezaArtikalDobavljac>(p => p.PoslovniPartner);
                //_dlo.LoadWith<VezaArtikalDobavljac>(p => p.KorisnikPrograma);
                //_baza.LoadOptions = _dlo;

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _lista = new ObservableCollection<Artikal>(_baza.uspNadjiArtikal(brojZaPretragu, slicnoTrazenje, samoSaCenom, biloKojiBroj, brojProizvodjaca, oeBroj, korisceniBroj, uporedniBroj, eanBroj).ToList());

                    //IQueryable<Artikal> _upit = (from a in _baza.Artikals
                    //                             select a).OrderBy(w => w.Artikal_ID);

                    //if (samoSaCenom)
                    //{
                    //    _upit = (from u in _upit
                    //             join c in _baza.VezaArtikalDobavljacs
                    //             on u.Artikal_ID equals c.ArtikalID
                    //             select u);
                    //}

                    //if (slicnoTrazenje)
                    //{
                    //    if (_vrstaBrojaZaPretragu.Count().Equals(0))
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Contains(brojZaPretragu)
                    //                 select u);
                    //    }
                    //    else if (_vrstaBrojaZaPretragu.Count().Equals(1))
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Contains(brojZaPretragu) & _vrstaBrojaZaPretragu[0].Equals(v.VrstaBrojaZaPretragu_ID)
                    //                 select u);
                    //    }
                    //    else
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Contains(brojZaPretragu) & _vrstaBrojaZaPretragu.Contains(v.VrstaBrojaZaPretragu_ID)
                    //                 select u);
                    //    }
                    //}
                    //else
                    //{
                    //    if (_vrstaBrojaZaPretragu.Count().Equals(0))
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Equals(brojZaPretragu)
                    //                 select u);
                    //    }
                    //    else if (_vrstaBrojaZaPretragu.Count().Equals(1))
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Equals(brojZaPretragu) & _vrstaBrojaZaPretragu[0].Equals(v.VrstaBrojaZaPretragu_ID)
                    //                 select u);
                    //    }
                    //    else
                    //    {
                    //        _upit = (from u in _upit
                    //                 join v in _baza.VezaArtikalBrojZaPretragus
                    //                 on u.Artikal_ID equals v.Artikal_ID
                    //                 where v.BrojZaPretragu.Equals(brojZaPretragu) & _vrstaBrojaZaPretragu.Contains(v.VrstaBrojaZaPretragu_ID)
                    //                 select u);
                    //    }
                    //}


                    //_upit = (from u in _upit
                    //         select u).Take(200);//.Distinct().Take(100);

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public ObservableCollection<ServisnaKnjizica> NadjiServisnuKnjizicu(string imeKolone, string uslov, string vrstaPartnera)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<ServisnaKnjizica> _upit = (from p in _baza.ServisnaKnjizicas
                                                          select p).OrderBy(w => w.ServisnaKnjizicaID);

                    switch (vrstaPartnera)
                    {
                        case "PoslovniPartner":
                            _upit = from u in _upit
                                    where u.PoslovniPartnerID != null
                                    select u;
                            break;
                        case "FizickoLice":
                            _upit = from u in _upit
                                    where u.FizickoLiceID != null
                                    select u;
                            break;
                        default:
                            throw new Exception("Nepoznata vrsta partnera.");
                    }

                    switch (imeKolone)
                    {
                        case "ID":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ServisnaKnjizicaID.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ServisnaKnjizicaID.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ServisnaKnjizicaID.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.ServisnaKnjizicaID.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Šifra":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Partner":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.FizickoLice.Ime.Contains(uslov.Substring(1, uslov.Length - 2))
                                        || u.PoslovniPartner.SkracenNaziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.FizickoLice.Ime.EndsWith(uslov.Substring(1, uslov.Length - 1)) ||
                                        u.PoslovniPartner.SkracenNaziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.FizickoLice.Ime.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        || u.PoslovniPartner.SkracenNaziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.FizickoLice.Ime.Equals(uslov)
                                        || u.PoslovniPartner.SkracenNaziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Tip":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                //_upit = from u in _upit
                                //        where 
                                //        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                //        || u.TipAutomobila.ModelAutomobila.OpisTabela.Opis.Contains(uslov.Substring(1, uslov.Length - 2))
                                //        || u.TipAutomobila.OpisTabela.Opis.Contains(uslov.Substring(1, uslov.Length - 2))
                                //        select u;

                                _upit = from u in _upit
                                        where (
                                        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv
                                        + u.TipAutomobila.ModelAutomobila.OpisTabela.Opis
                                        + u.TipAutomobila.OpisTabela.Opis
                                        ).Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;

                            }
                            else if (uslov.StartsWith("*"))
                            {
                                //_upit = from u in _upit
                                //        where 
                                //        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                //        || u.TipAutomobila.ModelAutomobila.OpisTabela.Opis.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                //        || u.TipAutomobila.OpisTabela.Opis.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                //        select u;
                                _upit = from u in _upit
                                        where (
                                        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv
                                        + u.TipAutomobila.ModelAutomobila.OpisTabela.Opis
                                        + u.TipAutomobila.OpisTabela.Opis
                                        ).EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;

                            }
                            else if (uslov.EndsWith("*"))
                            {
                                //_upit = from u in _upit
                                //        where 
                                //        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                //        || u.TipAutomobila.ModelAutomobila.OpisTabela.Opis.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                //        || u.TipAutomobila.OpisTabela.Opis.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                //        select u;
                                _upit = from u in _upit
                                        where (
                                        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv
                                        + u.TipAutomobila.ModelAutomobila.OpisTabela.Opis
                                        + u.TipAutomobila.OpisTabela.Opis
                                        ).StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;

                            }
                            else
                            {
                                //_upit = from u in _upit
                                //        where 
                                //        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv.Equals(uslov)
                                //        || u.TipAutomobila.ModelAutomobila.OpisTabela.Opis.Equals(uslov)
                                //        || u.TipAutomobila.OpisTabela.Opis.Equals(uslov)
                                //        select u;
                                _upit = from u in _upit
                                        where (
                                        u.TipAutomobila.ModelAutomobila.Proizvodjac.Naziv
                                        + u.TipAutomobila.ModelAutomobila.OpisTabela.Opis
                                        + u.TipAutomobila.OpisTabela.Opis
                                        ).Equals(uslov)
                                        select u;

                            }
                            break;
                        case "Broj šasije":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojSasije.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojSasije.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojSasije.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.BrojSasije.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Broj motora":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojMotora.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojMotora.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.BrojMotora.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.BrojMotora.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Godište":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Godiste.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Godiste.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Godiste.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Godiste.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Kilometraža":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Kilometraza.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Kilometraza.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Kilometraza.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Kilometraza.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Registarski broj":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RegistarskiBroj.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RegistarskiBroj.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RegistarskiBroj.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.RegistarskiBroj.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Dimenzija guma":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.DimenzijaGuma.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.DimenzijaGuma.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.DimenzijaGuma.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.DimenzijaGuma.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Napomena":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Napomena.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Napomena.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Napomena.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Napomena.Equals(uslov)
                                        select u;
                            }
                            break;
                        default:
                            throw new Exception("Nepoznata kolona.");
                    }
                    ObservableCollection<ServisnaKnjizica> _lista = new ObservableCollection<ServisnaKnjizica>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
        public ObservableCollection<ServisnaKnjizica> OsveziServisnaKnjizica(ObservableCollection<ServisnaKnjizica> servisnaKnjizica)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                List<int> _trenutnoPrikazani = new List<int>();

                foreach (ServisnaKnjizica item in servisnaKnjizica)
                {
                    _trenutnoPrikazani.Add(item.ServisnaKnjizicaID);
                }

                if (_baza.DatabaseExists())
                {
                    IQueryable<ServisnaKnjizica> _upit = (from p in _baza.ServisnaKnjizicas
                                                          where _trenutnoPrikazani.Contains(p.ServisnaKnjizicaID)
                                                          select p).OrderBy(w => w.ServisnaKnjizicaID);

                    ObservableCollection<ServisnaKnjizica> _lista = new ObservableCollection<ServisnaKnjizica>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 13
0
        public ObservableCollection<Radnik> NadjiRadnike(string imeKolone, string uslov)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Radnik> _upit = (from p in _baza.Radniks
                                                select p).OrderBy(w => w.RadnikID);

                    switch (imeKolone)
                    {
                        case "ID":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RadnikID.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RadnikID.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.RadnikID.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.RadnikID.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Šifra":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Ime":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Ime.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Ime.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Ime.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Ime.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Prezime":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Prezime.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Prezime.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Prezime.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Prezime.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Ime oca":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ImeOca.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ImeOca.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ImeOca.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.ImeOca.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Nadimak":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Nadimak.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Nadimak.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Nadimak.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Nadimak.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "JMBG":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.JMBG.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.JMBG.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.JMBG.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.JMBG.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        //case "Datum rođenja":
                        //    if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.DatumRodjenja.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                        //                select u;
                        //    }
                        //    else if (uslov.StartsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.DatumRodjenja.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                        //                select u;
                        //    }
                        //    else if (uslov.EndsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.DatumRodjenja.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                        //                select u;
                        //    }
                        //    else
                        //    {
                        //        _upit = from u in _upit
                        //                where u.DatumRodjenja.ToString().Equals(uslov)
                        //                select u;
                        //    }
                        //    break;
                        case "Mesto":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Adresa":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Adresa.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Telefon":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Telefon.Equals(uslov)
                                        select u;
                            }
                            break;
                        //case "Zaposlen Od":
                        //    if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.ZaposlenOd.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                        //                select u;
                        //    }
                        //    else if (uslov.StartsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.ZaposlenOd.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                        //                select u;
                        //    }
                        //    else if (uslov.EndsWith("*"))
                        //    {
                        //        _upit = from u in _upit
                        //                where u.ZaposlenOd.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                        //                select u;
                        //    }
                        //    else
                        //    {
                        //        _upit = from u in _upit
                        //                where u.ZaposlenOd.ToString().Equals(uslov)
                        //                select u;
                        //    }
                        //    break;
                        case "Raspored":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Raspored.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Raspored.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Raspored.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Raspored.Equals(uslov)
                                        select u;
                            }
                            break;
                        default:
                            throw new Exception("Nepoznata kolona.");
                    }


                    ObservableCollection<Radnik> _lista = new ObservableCollection<Radnik>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
        public ObservableCollection<ServisnaKnjizica> DajSveServisnaKnjizica(string vrstaPartnera)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<ServisnaKnjizica> _upit = (from p in _baza.ServisnaKnjizicas
                                                          select p).OrderBy(w => w.ServisnaKnjizicaID);

                    switch (vrstaPartnera)
                    {
                        case "PoslovniPartner":
                            _upit = from u in _upit
                                    where u.PoslovniPartnerID != null
                                    select u;
                            break;
                        case "FizickoLice":
                            _upit = from u in _upit
                                    where u.FizickoLiceID != null
                                    select u;
                            break;
                        default:
                            throw new Exception("Nepoznata vrsta partnera.");
                    }

                    ObservableCollection<ServisnaKnjizica> _lista = new ObservableCollection<ServisnaKnjizica>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 15
0
        public TipAutomobila DajTipAutomobila(int tipAutomobilaID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<TipAutomobila> _upit = (from p in _baza.TipAutomobilas
                                                       where p.TipAutomobila_ID == tipAutomobilaID
                                                       select p).OrderBy(w => w.OpisTabela.Opis).Take(1);

                    return _upit.ToList().First();
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 16
0
        public ObservableCollection<TipAutomobila> DajTipAutomobilaZaModel(int modelAutomobilaID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<TipAutomobila> _upit = (from p in _baza.TipAutomobilas
                                                       where p.ModelAutomobila_ID == modelAutomobilaID
                                                       select p).OrderBy(w => w.OpisTabela.Opis);

                    ObservableCollection<TipAutomobila> _lista = new ObservableCollection<TipAutomobila>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 17
0
        public ObservableCollection<ModelAutomobila> DajModelAutomobilaZaProizvodjac(int proizvodjacID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<ModelAutomobila> _upit = (from p in _baza.ModelAutomobilas
                                                         join t in _baza.TipAutomobilas
                                                         on p.ModelAutomobila_ID equals t.ModelAutomobila_ID
                                                         where p.Proizvodjac_ID == proizvodjacID
                                                         select p).Distinct().OrderBy(w => w.OpisTabela.Opis);

                    ObservableCollection<ModelAutomobila> _lista = new ObservableCollection<ModelAutomobila>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        public ObservableCollection<ServisnaKnjizica> NadjiServisnuKnjizicu(int servisnaKnjizicaID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<ServisnaKnjizica> _upit = (from p in _baza.ServisnaKnjizicas
                                                          where p.ServisnaKnjizicaID == servisnaKnjizicaID
                                                          select p).OrderBy(w => w.ServisnaKnjizicaID);


                    ObservableCollection<ServisnaKnjizica> _lista = new ObservableCollection<ServisnaKnjizica>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 19
0
        public ObservableCollection<Proizvodjac> DajPadajucuListuProizvodjacRobeRoban()
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Proizvodjac> _upit = (from a in _baza.Artikals
                                                     join b in _baza.Proizvodjacs
                                                     on a.Proizvodjac_ID equals b.Proizvodjac_ID
                                                     where a.IzvorPodatakaID == 2 || a.IzvorPodatakaID == 3
                                                     select b).Distinct().OrderBy(o => o.Naziv);

                    ObservableCollection<Proizvodjac> _lista = new ObservableCollection<Proizvodjac>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }                
Esempio n. 20
0
        public ObservableCollection<VezaArtikalBrojZaPretragu> DajBrojeveZaArtikal(int artikalID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<VezaArtikalBrojZaPretragu> _upit = (from a in _baza.VezaArtikalBrojZaPretragus
                                                                   where a.Artikal_ID == artikalID
                                                                   select a).Distinct().OrderBy(w => w.VrstaBrojaZaPretragu_ID);

                    ObservableCollection<VezaArtikalBrojZaPretragu> _lista = new ObservableCollection<VezaArtikalBrojZaPretragu>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 21
0
        public ObservableCollection<Artikal> NadjiArtikal(string brojProizvodjaca, string proizvodjacNaziv)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);
                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _lista = new ObservableCollection<Artikal>(_baza.uspNadjiArtikal_1(brojProizvodjaca, proizvodjacNaziv).ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 22
0
        public ObservableCollection<Ponuda> NadjiPonude(string vrstaPartnera, string ponudaID, DateTime? datumOd, DateTime? datumDo, string partner, bool? neZavrsene, int? radnikID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Ponuda> _upit = (from p in _baza.Ponudas
                                                where p.Status.ToString() != "D"
                                                select p).OrderBy(w => w.PonudaID);

                    if (vrstaPartnera != "")
                    {
                        if (vrstaPartnera == "Poslovni partner")
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartnerID != null
                                    select u;
                        }
                        else if (vrstaPartnera == "Fizičko lice")
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.FizickoLiceID != null
                                    select u;
                        }
                    }
                    if (ponudaID != "")
                    {
                        if (ponudaID.StartsWith("*") && ponudaID.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.PonudaID.ToString().Contains(ponudaID.Substring(1, ponudaID.Length - 2))
                                    select u;
                        }
                        else if (ponudaID.StartsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.PonudaID.ToString().EndsWith(ponudaID.Substring(1, ponudaID.Length - 1))
                                    select u;
                        }
                        else if (ponudaID.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.PonudaID.ToString().StartsWith(ponudaID.Substring(0, ponudaID.Length - 1))
                                    select u;
                        }
                        else
                        {
                            _upit = from u in _upit
                                    where u.PonudaID.ToString().Equals(ponudaID)
                                    select u;
                        }
                    }
                    if (datumOd != null || datumDo != null)
                    {
                        if (datumOd != null && datumDo == null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme >= datumOd
                                    select u;
                        }
                        else if (datumOd == null && datumDo != null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme <= datumDo
                                    select u;
                        }
                        else if (datumOd != null && datumDo != null)
                        {
                            _upit = from u in _upit
                                    where u.Vreme >= datumOd && u.Vreme <= datumDo
                                    select u;
                        }
                    }
                    if (partner != "")
                    {
                        if (partner.StartsWith("*") && partner.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.Contains(partner.Substring(1, partner.Length - 2)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.Contains(partner.Substring(1, partner.Length - 2))
                                    select u;
                        }
                        else if (partner.StartsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.EndsWith(partner.Substring(1, partner.Length - 1)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.EndsWith(partner.Substring(1, partner.Length - 1))
                                    select u;
                        }
                        else if (partner.EndsWith("*"))
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.StartsWith(partner.Substring(0, partner.Length - 1)) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.StartsWith(partner.Substring(0, partner.Length - 1))
                                    select u;
                        }
                        else
                        {
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartner.SkracenNaziv.Equals(partner) ||
                                    u.ServisnaKnjizica.FizickoLice.Ime.Equals(partner)
                                    select u;
                        }
                    }
                    if (neZavrsene != null && (bool)neZavrsene)
                    {
                        _upit = from u in _upit
                                where(u.StavkaUslugas.Where(f => f.Status != 'D').Count().Equals(0)) || 
                                     (u.PreuzimaLicno && u.PreuzeoLicnoU == null) ||
                                     (u.ObavestiTelefonom && u.ObavestenTelefonomU == null) ||
                                     (u.PosaljiEMail && u.PoslatEMailU == null) ||
                                     (u.PosaljiSMSObavestenje && u.PoslatoSMSObavestenjeU == null)
                                select u;
                    }

                    if (radnikID != null)
                    {
                        _upit = from u in _upit
                                where u.RadnikID == radnikID
                                select u;
                    }

                    ObservableCollection<Ponuda> _lista = new ObservableCollection<Ponuda>(_upit.Distinct().ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 23
0
        public ObservableCollection<Artikal> NadjiAkumulatorRoban(int? proizvodjacID, int? amperaza)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _artikli = new ObservableCollection<Artikal>(_baza.uspNadjiAkumulator(proizvodjacID, amperaza).ToList());


                    return _artikli;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 24
0
        public ObservableCollection<RadniNalog> DajSveRadneNalogeZaPartnera(int partnerID, string vrstaPartnera)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<RadniNalog> _upit = (from p in _baza.RadniNalogs
                                                    where p.Status.ToString() != "D"
                                                    select p).OrderBy(w => w.RadniNalogID);

                    switch (vrstaPartnera)
                    {
                        case "PoslovniPartner":
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.PoslovniPartnerID == partnerID
                                    select u;
                            break;
                        case "FizickoLice":
                            _upit = from u in _upit
                                    where u.ServisnaKnjizica.FizickoLiceID == partnerID
                                    select u;
                            break;
                        default:
                            throw new Exception("Nepoznata vrsta partnera.");
                    }

                    ObservableCollection<RadniNalog> _lista = new ObservableCollection<RadniNalog>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 25
0
        public ObservableCollection<Artikal> NadjiRobuRoban(Int16? proizvodjacID, string sifra, string naziv)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    ObservableCollection<Artikal> _artikli = new ObservableCollection<Artikal>(_baza.uspNadjiRobu(proizvodjacID, sifra, naziv).ToList());

                    
                    return _artikli;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 26
0
        public ObservableCollection<PoslovniPartner> OsveziPoslovniPartner(ObservableCollection<PoslovniPartner> poslovniPartner)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);
                DataLoadOptions _dlo = new DataLoadOptions();
                _dlo.LoadWith<PoslovniPartner>(p => p.Mesto);
                _dlo.LoadWith<PoslovniPartner>(p => p.NacinOrganizacijeFirme);
                _baza.LoadOptions = _dlo;


                List<int> _trenutnoPrikazani = new List<int>();

                foreach (PoslovniPartner item in poslovniPartner)
                {
                    _trenutnoPrikazani.Add(item.PoslovniPartnerID);
                }

                if (_baza.DatabaseExists())
                {
                    IQueryable<PoslovniPartner> _upit = (from p in _baza.PoslovniPartners
                                                         where _trenutnoPrikazani.Contains(p.PoslovniPartnerID)
                                                         select p).OrderBy(w => w.PoslovniPartnerID);

                    ObservableCollection<PoslovniPartner> _lista = new ObservableCollection<PoslovniPartner>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 27
0
        public Radnik DajRadnika(string korisnickiNalog, string lozinka)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<Radnik> _upit = (from p in _baza.Radniks
                                                join k in _baza.VezaRadnikKorisnickiNalogs
                                                on p.RadnikID equals k.RadnikID
                                                where k.KorisnickiNalog == korisnickiNalog &&
                                                k.Lozinka == lozinka
                                                select p).Take(1);

                    ObservableCollection<Radnik> _lista = new ObservableCollection<Radnik>(_upit.ToList());

                    if (_lista.Count.Equals(1))
                    {
                        return _lista.First();
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 28
0
        public ObservableCollection<RadniNalog> OsveziRadniNalog(ObservableCollection<RadniNalog> radniNalog)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                List<int> _trenutnoPrikazani = new List<int>();

                foreach (RadniNalog item in radniNalog)
                {
                    _trenutnoPrikazani.Add(item.RadniNalogID);
                }

                if (_baza.DatabaseExists())
                {
                    IQueryable<RadniNalog> _upit = (from p in _baza.RadniNalogs
                                                    where _trenutnoPrikazani.Contains(p.RadniNalogID) &&
                                                p.Status.ToString() != "D"
                                                    select p).OrderBy(w => w.RadniNalogID);

                    ObservableCollection<RadniNalog> _lista = new ObservableCollection<RadniNalog>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 29
0
        public ObservableCollection<RadniNalog> DajSveRadneNalogeZaServisnuKnjizicu(int servisnaKnjizicaID)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                if (_baza.DatabaseExists())
                {
                    IQueryable<RadniNalog> _upit = (from p in _baza.RadniNalogs
                                                    where p.Status.ToString() != "D" &&
                                                    p.ServisnaKnjizicaID == servisnaKnjizicaID
                                                    select p).OrderBy(w => w.RadniNalogID);

                    ObservableCollection<RadniNalog> _lista = new ObservableCollection<RadniNalog>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 30
0
        public ObservableCollection<PoslovniPartner> NadjiPoslovniPartner(string imeKolone, string uslov)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);
                DataLoadOptions _dlo = new DataLoadOptions();
                _dlo.LoadWith<PoslovniPartner>(p => p.Mesto);
                _dlo.LoadWith<PoslovniPartner>(p => p.NacinOrganizacijeFirme);
                _baza.LoadOptions = _dlo;


                if (_baza.DatabaseExists())
                {
                    IQueryable<PoslovniPartner> _upit = (from p in _baza.PoslovniPartners
                                                         select p).OrderBy(w => w.PoslovniPartnerID);

                    switch (imeKolone)
                    {
                        case "ID":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PoslovniPartnerID.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PoslovniPartnerID.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PoslovniPartnerID.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.PoslovniPartnerID.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Šifra":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Sifra.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Sifra.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Skraćen naziv":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.SkracenNaziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.SkracenNaziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.SkracenNaziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.SkracenNaziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Pun naziv":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PunNaziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PunNaziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PunNaziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.PunNaziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Način organizacije firme":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.NacinOrganizacijeFirme.Naziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.NacinOrganizacijeFirme.Naziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.NacinOrganizacijeFirme.Naziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.NacinOrganizacijeFirme.Naziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "PIB":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PIB.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PIB.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.PIB.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.PIB.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Matični broj":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.MaticniBroj.ToString().Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.MaticniBroj.ToString().EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.MaticniBroj.ToString().StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.MaticniBroj.ToString().Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Žiro račun":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ZiroRacun.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ZiroRacun.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.ZiroRacun.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.ZiroRacun.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Mesto":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Mesto.Naziv.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Adresa":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Adresa.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Adresa.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Kontakt osoba":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.KontaktOsoba1.Contains(uslov.Substring(1, uslov.Length - 2))
                                        || u.KontaktOsoba2.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.KontaktOsoba1.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        || u.KontaktOsoba2.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.KontaktOsoba1.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        || u.KontaktOsoba2.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.KontaktOsoba1.Equals(uslov)
                                        || u.KontaktOsoba2.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Telefon":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon1.Contains(uslov.Substring(1, uslov.Length - 2))
                                        || u.Telefon2.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon1.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        || u.Telefon2.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Telefon1.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        || u.Telefon2.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Telefon1.Equals(uslov)
                                        || u.Telefon2.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "E-mail":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.EMail1.Contains(uslov.Substring(1, uslov.Length - 2))
                                        || u.EMail2.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.EMail1.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        || u.EMail2.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.EMail1.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        || u.EMail2.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.EMail1.Equals(uslov)
                                        || u.EMail2.Equals(uslov)
                                        select u;
                            }
                            break;
                        case "Faks":
                            if (uslov.StartsWith("*") && uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Faks.Contains(uslov.Substring(1, uslov.Length - 2))
                                        select u;
                            }
                            else if (uslov.StartsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Faks.EndsWith(uslov.Substring(1, uslov.Length - 1))
                                        select u;
                            }
                            else if (uslov.EndsWith("*"))
                            {
                                _upit = from u in _upit
                                        where u.Faks.StartsWith(uslov.Substring(0, uslov.Length - 1))
                                        select u;
                            }
                            else
                            {
                                _upit = from u in _upit
                                        where u.Faks.Equals(uslov)
                                        select u;
                            }
                            break;

                        default:
                            throw new Exception("Nepoznata kolona.");
                    }
                    ObservableCollection<PoslovniPartner> _lista = new ObservableCollection<PoslovniPartner>(_upit.ToList());

                    return _lista;
                }
                else
                {
                    throw new Exception("Baza ne postoji.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }