Ejemplo n.º 1
0
        public static int generisiPitanjeID(Anketa anketa)
        {
            int max = 0;

            foreach (Anketa ank in ListePodataka.ListaAnketa)
            {
                foreach (Pitanje pit in ank.ListaPitanja)
                {
                    if (pit.PitanjeID > max)
                    {
                        max = pit.PitanjeID;
                    }
                }
            }

            /*
             * if (anketa.ListaPitanja.Count > 0)
             * {
             *  foreach (Pitanje pit in anketa.ListaPitanja)
             *  {
             *      if (pit.PitanjeID > max)
             *      {
             *          max = pit.PitanjeID;
             *      }
             *  }
             * }
             */
            max++;
            return(max);
        }
Ejemplo n.º 2
0
        public static int generisiPitanjeID(int anketaId)
        {
            int    max    = 0;
            Anketa anketa = null;

            foreach (Anketa a in ListaAnketa)
            {
                if (a.AnketaID == anketaId)
                {
                    anketa = a;
                }
            }

            if (anketa != null)
            {
                if (anketa.ListaPitanja.Count > 0)
                {
                    foreach (Pitanje pit in anketa.ListaPitanja)
                    {
                        if (pit.PitanjeID > max)
                        {
                            max = pit.PitanjeID;
                        }
                    }
                }
            }
            max++;
            return(max);
        }
Ejemplo n.º 3
0
        public static ObservableCollection <Anketa> UcitajAnkete()
        {
            ObservableCollection <Anketa> listaAnketa = new ObservableCollection <Anketa>();

            SqlConnection conn = new SqlConnection(connectionString);
            SqlCommand    command;
            string        sql = "SELECT * FROM Anketa;";
            SqlDataReader dataReader;

            conn.Open();
            command    = new SqlCommand(sql, conn);
            dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
                int    AnketaID     = Convert.ToInt32(dataReader.GetValue(0).ToString());
                string NaslovAnkete = dataReader.GetValue(1).ToString();
                bool   Aktivnost    = Convert.ToBoolean(dataReader.GetValue(2).ToString());
                bool   Javnost      = Convert.ToBoolean(dataReader.GetValue(3).ToString());

                Anketa a = new Anketa(AnketaID, NaslovAnkete, Aktivnost, Javnost);

                listaAnketa.Add(a);
            }

            dataReader.Close();
            command.Dispose();
            conn.Close();

            return(listaAnketa);
        }
Ejemplo n.º 4
0
        public static void upisAnkete(Anketa anketa)
        {
            string upis = "insert into Anketa(AnketaID, NaslovAnkete, Aktivnost, Javnost) values('" +
                          anketa.AnketaID + "','" +
                          anketa.NaslovAnkete + "','" +
                          anketa.Aktivnost + "','" +
                          anketa.Javnost + "');";

            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = upis;
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }
Ejemplo n.º 5
0
 public ResenaAnketa(Osoba osoba, Anketa anketa)
 {
     this.osoba           = osoba;
     this.anketa          = anketa;
     ListaResenihOdgovora = new ObservableCollection <ResenOdgovor>();
 }