Exemplo n.º 1
0
        public PolaznikModel(bool isSingle)
        {
            if (isSingle)
            {
                this.lstGradovi = new List <GradModel>();
                string conString = ConfigurationManager.ConnectionStrings["sqlConnString"].ConnectionString;
                using (SqlConnection conn = new SqlConnection(conString))
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = conn;
                    cmd.CommandText = "SELECT * FROM tblGradovi";

                    cmd.Connection.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            GradModel grad = new GradModel
                            {
                                IdGrad   = int.Parse(reader["IdGrada"].ToString()),
                                Naziv    = reader["Naziv"].ToString(),
                                IdDrzava = int.Parse(reader["IdDrzave"].ToString())
                            };

                            this.lstGradovi.Add(grad);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public string ImeGrad()
        {
            string    ime;
            GradModel obj = this.lstGradovi.Where(grad => grad.IdGrad == this.IdGrad).SingleOrDefault();

            if (obj != null)
            {
                ime = obj.Naziv;
            }
            else
            {
                ime = "";
            }
            return(ime);
        }