Exemple #1
0
        public static ObservableCollection <TipNamestaja> Sort(Prikaz p, NacinSortiranja nn)
        {
            var tipoviNamestaja = new ObservableCollection <TipNamestaja>();

            switch (p)
            {
            case Prikaz.Naziv:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM TipNamestaja WHERE Obrisan=0 Order by Naziv ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM TipNamestaja WHERE Obrisan=0 Order by Naziv desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "TipNamestaja");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["TipNamestaja"].Rows)
                    {
                        var tn = new TipNamestaja();
                        tn.Id      = int.Parse(row["Id"].ToString());
                        tn.Naziv   = row["Naziv"].ToString();
                        tn.Obrisan = bool.Parse(row["Obrisan"].ToString());

                        tipoviNamestaja.Add(tn);
                    }
                }
                break;
            }
            return(tipoviNamestaja);
        }
Exemple #2
0
        public static ObservableCollection <Korisnik> Sort(Prikaz p, NacinSortiranja nn)
        {
            var korisnik = new ObservableCollection <Korisnik>();

            switch (p)
            {
            case Prikaz.Ime:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Ime";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Ime desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Korisnik");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Korisnik"].Rows)
                    {
                        var k = new Korisnik();
                        k.Id            = int.Parse(row["Id"].ToString());
                        k.Ime           = row["Ime"].ToString();
                        k.Prezime       = row["Prezime"].ToString();
                        k.KorisnickoIme = row["KorisnickoIme"].ToString();
                        k.Lozinka       = row["Lozinka"].ToString();
                        k.Obrisan       = bool.Parse(row["Obrisan"].ToString());
                        bool b = bool.Parse(row["TipKorisnika"].ToString());
                        if (b == true)
                        {
                            k.TipKorisnika = TipKorisnika.Prodavac;
                        }
                        else
                        {
                            k.TipKorisnika = TipKorisnika.Administrator;
                        }

                        korisnik.Add(k);
                    }
                }
                break;

            case Prikaz.Prezime:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Prezime";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Prezime desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Korisnik");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Korisnik"].Rows)
                    {
                        var k = new Korisnik();
                        k.Id            = int.Parse(row["Id"].ToString());
                        k.Ime           = row["Ime"].ToString();
                        k.Prezime       = row["Prezime"].ToString();
                        k.KorisnickoIme = row["KorisnickoIme"].ToString();
                        k.Lozinka       = row["Lozinka"].ToString();
                        k.Obrisan       = bool.Parse(row["Obrisan"].ToString());
                        bool b = bool.Parse(row["TipKorisnika"].ToString());
                        if (b == true)
                        {
                            k.TipKorisnika = TipKorisnika.Prodavac;
                        }
                        else
                        {
                            k.TipKorisnika = TipKorisnika.Administrator;
                        }

                        korisnik.Add(k);
                    }
                }
                break;

            case Prikaz.KorisnickoIme:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by KorisnickoIme";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by KorisnickoIme desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Korisnik");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Korisnik"].Rows)
                    {
                        var k = new Korisnik();
                        k.Id            = int.Parse(row["Id"].ToString());
                        k.Ime           = row["Ime"].ToString();
                        k.Prezime       = row["Prezime"].ToString();
                        k.KorisnickoIme = row["KorisnickoIme"].ToString();
                        k.Lozinka       = row["Lozinka"].ToString();
                        k.Obrisan       = bool.Parse(row["Obrisan"].ToString());
                        bool b = bool.Parse(row["TipKorisnika"].ToString());
                        if (b == true)
                        {
                            k.TipKorisnika = TipKorisnika.Prodavac;
                        }
                        else
                        {
                            k.TipKorisnika = TipKorisnika.Administrator;
                        }

                        korisnik.Add(k);
                    }
                }
                break;

            case Prikaz.Lozinka:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Lozinka";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by Lozinka desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Korisnik");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Korisnik"].Rows)
                    {
                        var k = new Korisnik();
                        k.Id            = int.Parse(row["Id"].ToString());
                        k.Ime           = row["Ime"].ToString();
                        k.Prezime       = row["Prezime"].ToString();
                        k.KorisnickoIme = row["KorisnickoIme"].ToString();
                        k.Lozinka       = row["Lozinka"].ToString();
                        k.Obrisan       = bool.Parse(row["Obrisan"].ToString());
                        bool b = bool.Parse(row["TipKorisnika"].ToString());
                        if (b == true)
                        {
                            k.TipKorisnika = TipKorisnika.Prodavac;
                        }
                        else
                        {
                            k.TipKorisnika = TipKorisnika.Administrator;
                        }

                        korisnik.Add(k);
                    }
                }
                break;

            case Prikaz.TipKorisnika:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by TipKorisnika";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Korisnik WHERE Obrisan=0 Order by TipKorisnika desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Korisnik");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Korisnik"].Rows)
                    {
                        var k = new Korisnik();
                        k.Id            = int.Parse(row["Id"].ToString());
                        k.Ime           = row["Ime"].ToString();
                        k.Prezime       = row["Prezime"].ToString();
                        k.KorisnickoIme = row["KorisnickoIme"].ToString();
                        k.Lozinka       = row["Lozinka"].ToString();
                        k.Obrisan       = bool.Parse(row["Obrisan"].ToString());
                        bool b = bool.Parse(row["TipKorisnika"].ToString());
                        if (b == true)
                        {
                            k.TipKorisnika = TipKorisnika.Prodavac;
                        }
                        else
                        {
                            k.TipKorisnika = TipKorisnika.Administrator;
                        }

                        korisnik.Add(k);
                    }
                }
                break;
            }
            return(korisnik);
        }
        public static ObservableCollection <DodatnaUsluga> Sort(Prikaz p, NacinSortiranja nn)
        {
            var du = new ObservableCollection <DodatnaUsluga>();

            switch (p)
            {
            case Prikaz.Naziv:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM DodatnaUsluga WHERE Obrisan=0 Order by Naziv";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM DodatnaUsluga WHERE Obrisan=0 Order by Naziv desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "DodatnaUsluga");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["DodatnaUsluga"].Rows)
                    {
                        var d = new DodatnaUsluga();
                        d.Id      = int.Parse(row["Id"].ToString());
                        d.Naziv   = row["Naziv"].ToString();
                        d.Obrisan = bool.Parse(row["Obrisan"].ToString());
                        d.Cena    = double.Parse(row["Cena"].ToString());
                        du.Add(d);
                    }
                }
                break;

            case Prikaz.Cena:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM DodatnaUsluga WHERE Obrisan=0 Order by Cena";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM DodatnaUsluga WHERE Obrisan=0 Order by Cena desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "DodatnaUsluga");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["DodatnaUsluga"].Rows)
                    {
                        var d = new DodatnaUsluga();
                        d.Id      = int.Parse(row["Id"].ToString());
                        d.Naziv   = row["Naziv"].ToString();
                        d.Obrisan = bool.Parse(row["Obrisan"].ToString());
                        d.Cena    = double.Parse(row["Cena"].ToString());
                        du.Add(d);
                    }
                }
                break;
            }
            return(du);
        }
        public static ObservableCollection <Namestaj> Sort(Prikaz p, NacinSortiranja nn)
        {
            var Namestaj = new ObservableCollection <Namestaj>();

            switch (p)
            {
            case Prikaz.Naziv:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Naziv ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Naziv desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Namestaj");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Namestaj"].Rows)
                    {
                        var tn = new Namestaj();
                        tn.Id       = int.Parse(row["Id"].ToString());
                        tn.Naziv    = row["Naziv"].ToString();
                        tn.Obrisan  = bool.Parse(row["Obrisan"].ToString());
                        tn.Cena     = double.Parse(row["Cena"].ToString());
                        tn.Kolicina = int.Parse(row["Kolicina"].ToString());
                        try
                        {
                            tn.ak = int.Parse(row["AkcijaId"].ToString());
                        }
                        catch { }

                        tn.TipN = int.Parse(row["TipNamestajaId"].ToString());
                        Namestaj.Add(tn);
                    }
                }
                break;

            case Prikaz.Cena:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Cena ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Cena desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Namestaj");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Namestaj"].Rows)
                    {
                        var tn = new Namestaj();
                        tn.Id       = int.Parse(row["Id"].ToString());
                        tn.Naziv    = row["Naziv"].ToString();
                        tn.Obrisan  = bool.Parse(row["Obrisan"].ToString());
                        tn.Cena     = double.Parse(row["Cena"].ToString());
                        tn.Kolicina = int.Parse(row["Kolicina"].ToString());
                        try
                        {
                            tn.ak = int.Parse(row["AkcijaId"].ToString());
                        }
                        catch { }

                        tn.TipN = int.Parse(row["TipNamestajaId"].ToString());
                        Namestaj.Add(tn);
                    }
                }
                break;

            case Prikaz.Kolicina:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Kolicina ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by Kolicina desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Namestaj");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Namestaj"].Rows)
                    {
                        var tn = new Namestaj();
                        tn.Id       = int.Parse(row["Id"].ToString());
                        tn.Naziv    = row["Naziv"].ToString();
                        tn.Obrisan  = bool.Parse(row["Obrisan"].ToString());
                        tn.Cena     = double.Parse(row["Cena"].ToString());
                        tn.Kolicina = int.Parse(row["Kolicina"].ToString());
                        try
                        {
                            tn.ak = int.Parse(row["AkcijaId"].ToString());
                        }
                        catch { }

                        tn.TipN = int.Parse(row["TipNamestajaId"].ToString());
                        Namestaj.Add(tn);
                    }
                }
                break;

            case Prikaz.TipNamestaja:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by TipNamestajaId ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by TipNamestajaId desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Namestaj");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Namestaj"].Rows)
                    {
                        var tn = new Namestaj();
                        tn.Id       = int.Parse(row["Id"].ToString());
                        tn.Naziv    = row["Naziv"].ToString();
                        tn.Obrisan  = bool.Parse(row["Obrisan"].ToString());
                        tn.Cena     = double.Parse(row["Cena"].ToString());
                        tn.Kolicina = int.Parse(row["Kolicina"].ToString());
                        try
                        {
                            tn.ak = int.Parse(row["AkcijaId"].ToString());
                        }
                        catch { }

                        tn.TipN = int.Parse(row["TipNamestajaId"].ToString());
                        Namestaj.Add(tn);
                    }
                }
                break;

            case Prikaz.Akcija:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by AkcijaId ";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Namestaj WHERE Obrisan=0 Order by AkcijaId desc";
                    }

                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Namestaj");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Namestaj"].Rows)
                    {
                        var tn = new Namestaj();
                        tn.Id       = int.Parse(row["Id"].ToString());
                        tn.Naziv    = row["Naziv"].ToString();
                        tn.Obrisan  = bool.Parse(row["Obrisan"].ToString());
                        tn.Cena     = double.Parse(row["Cena"].ToString());
                        tn.Kolicina = int.Parse(row["Kolicina"].ToString());
                        try
                        {
                            tn.ak = int.Parse(row["AkcijaId"].ToString());
                        }
                        catch { }

                        tn.TipN = int.Parse(row["TipNamestajaId"].ToString());
                        Namestaj.Add(tn);
                    }
                }
                break;
            }
            return(Namestaj);
        }
Exemple #5
0
        public static ObservableCollection <AkcijskaProdaja> Sort(Prikaz p, NacinSortiranja nn)
        {
            var akcija = new ObservableCollection <AkcijskaProdaja>();

            switch (p)
            {
            case Prikaz.DatumKraja:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Dk";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Dk desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Akcija");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Akcija"].Rows)
                    {
                        var a = new AkcijskaProdaja();
                        a.Id           = int.Parse(row["Id"].ToString());
                        a.Obrisan      = bool.Parse(row["Obrisan"].ToString());
                        a.DatumPocetka = DateTime.Parse(row["Dp"].ToString());
                        a.DatumKraja   = DateTime.Parse(row["Dk"].ToString());
                        a.popust       = int.Parse(row["Popust"].ToString());
                        akcija.Add(a);
                    }
                }
                break;

            case Prikaz.DatumPocetka:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Dp";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Dp desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Akcija");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Akcija"].Rows)
                    {
                        var a = new AkcijskaProdaja();
                        a.Id           = int.Parse(row["Id"].ToString());
                        a.Obrisan      = bool.Parse(row["Obrisan"].ToString());
                        a.DatumPocetka = DateTime.Parse(row["Dp"].ToString());
                        a.DatumKraja   = DateTime.Parse(row["Dk"].ToString());
                        a.popust       = int.Parse(row["Popust"].ToString());
                        akcija.Add(a);
                    }
                }
                break;

            case Prikaz.Popust:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Popust";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Akcija WHERE Obrisan=0 Order by Popust desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Akcija");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Akcija"].Rows)
                    {
                        var a = new AkcijskaProdaja();
                        a.Id           = int.Parse(row["Id"].ToString());
                        a.Obrisan      = bool.Parse(row["Obrisan"].ToString());
                        a.DatumPocetka = DateTime.Parse(row["Dp"].ToString());
                        a.DatumKraja   = DateTime.Parse(row["Dk"].ToString());
                        a.popust       = int.Parse(row["Popust"].ToString());
                        akcija.Add(a);
                    }
                }
                break;
            }
            return(akcija);
        }
        public static ObservableCollection <Racun> Sort(Prikaz p, NacinSortiranja nn)
        {
            var racun = new ObservableCollection <Racun>();

            switch (p)
            {
            case Prikaz.DatumProdaje:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by Dp";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by Dp desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Racun");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Racun"].Rows)
                    {
                        var r = new Racun();
                        r.Id           = int.Parse(row["Id"].ToString());
                        r.datumProdaje = DateTime.Parse(row["Dp"].ToString());
                        r.Kupac        = row["Kupac"].ToString();
                        r.UkupnaCena   = double.Parse(row["UkupnaCena"].ToString());
                        racun.Add(r);
                    }
                }
                break;

            case Prikaz.Kupac:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by Kupac";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by Kupac desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Racun");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Racun"].Rows)
                    {
                        var r = new Racun();
                        r.Id           = int.Parse(row["Id"].ToString());
                        r.datumProdaje = DateTime.Parse(row["Dp"].ToString());
                        r.Kupac        = row["Kupac"].ToString();
                        r.UkupnaCena   = double.Parse(row["UkupnaCena"].ToString());
                        racun.Add(r);
                    }
                }
                break;

            case Prikaz.Cena:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    if (nn == NacinSortiranja.asc)
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by UkupnaCena";
                    }
                    else
                    {
                        cmd.CommandText = "SELECT * FROM Racun Order by UkupnaCena desc";
                    }


                    DataSet        ds = new DataSet();
                    SqlDataAdapter da = new SqlDataAdapter();

                    da.SelectCommand = cmd;
                    da.Fill(ds, "Racun");     // Query se izvrsava
                    foreach (DataRow row in ds.Tables["Racun"].Rows)
                    {
                        var r = new Racun();
                        r.Id           = int.Parse(row["Id"].ToString());
                        r.datumProdaje = DateTime.Parse(row["Dp"].ToString());
                        r.Kupac        = row["Kupac"].ToString();
                        r.UkupnaCena   = double.Parse(row["UkupnaCena"].ToString());
                        racun.Add(r);
                    }
                }
                break;
            }
            return(racun);
        }