public static ObservableCollection <Racun> Search(Prikaz p, String s)
        {
            var racun = new ObservableCollection <Racun>();

            switch (p)
            {
            case Prikaz.DatumProdaje:
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["POP"].ConnectionString))
                {
                    SqlCommand cmd = con.CreateCommand();
                    cmd.CommandText = "SELECT * FROM Racun WHERE Dp like '%'+@s+'%'";
                    cmd.Parameters.AddWithValue("s", s);


                    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();
                    cmd.CommandText = "SELECT * FROM Racun WHERE Kupac like '%'+@s+'%'";
                    cmd.Parameters.AddWithValue("s", s);


                    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();
                    cmd.CommandText = "SELECT * FROM Racun WHERE UkupnaCena like '%'+@s+'%'";
                    cmd.Parameters.AddWithValue("s", s);


                    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);
        }
        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);
        }