Exemplo n.º 1
0
        /*
         * Preuzima rekorde iz baze
         *  br - broj rekorda, ili null za sve
         *  d
         */
        public List <Rekord> PreuzmiRekorde(int?br, ETipSortiranja tipSortiranja)
        {
            List <Rekord>   rekordi = new List <Rekord> ();
            MySqlCommand    cmd;
            MySqlDataReader reader;
            string          query;

            switch (tipSortiranja)
            {
            case ETipSortiranja.NajboljiPoBrojuSlova:
                query = "SELECT * FROM rekordi ORDER BY broj_pogresnih_slova ASC";
                break;

            case ETipSortiranja.NajboljiPoVremenu:
                query = "SELECT * FROM rekordi ORDER BY broj_sekundi ASC";
                break;

            default:
                query = "SELECT * FROM rekordi ORDER BY broj_pogresnih_slova+broj_sekundi ASC";
                break;
            }

            using (cmd = new MySqlCommand(query, conn))
            {
                try
                {
                    reader = cmd.ExecuteReader();

                    while (reader.Read() && (br != null ? br-- > 0 : true))
                    {
                        int    id = reader.GetInt32(0);
                        int    brojPogresnihSlova = reader.GetInt32(1);
                        long   vreme = reader.GetInt64(2);
                        string ime   = reader.GetString(3);
                        rekordi.Add(new Rekord(id, brojPogresnihSlova,
                                               vreme, ime));
                    }
                } catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(rekordi);
        }
Exemplo n.º 2
0
		/*
		 * Preuzima rekorde iz baze
		 * 	br - broj rekorda, ili null za sve
		 * 	d
		 */
		public List<Rekord> PreuzmiRekorde(int? br, ETipSortiranja tipSortiranja)
		{
			List <Rekord> rekordi = new List<Rekord> ();
			MySqlCommand cmd;
			MySqlDataReader reader;
			string query;

			switch (tipSortiranja)
			{
			case ETipSortiranja.NajboljiPoBrojuSlova:
				query = "SELECT * FROM rekordi ORDER BY broj_pogresnih_slova ASC";
				break;
			case ETipSortiranja.NajboljiPoVremenu:
				query = "SELECT * FROM rekordi ORDER BY broj_sekundi ASC";
				break;
			default:
				query = "SELECT * FROM rekordi ORDER BY broj_pogresnih_slova+broj_sekundi ASC";
				break;
			}

			using (cmd = new MySqlCommand (query, conn))
			{
				try
				{
					reader = cmd.ExecuteReader ();

					while (reader.Read () && (br != null ? br-- > 0 : true))
					{
						int id = reader.GetInt32 (0);
						int brojPogresnihSlova = reader.GetInt32 (1);
						long vreme = reader.GetInt64 (2);
						string ime = reader.GetString (3);
						rekordi.Add (new Rekord(id, brojPogresnihSlova,
												vreme, ime));
					}
				} catch (Exception ex)
				{
						throw ex;
				}
			}

			return rekordi;
		}
Exemplo n.º 3
0
		/*
		 * Rekordi
		 */

		/**
		* Metoda vraca listu Rekordas \n
		* prima dva argumenta \n
		* br (int) - koji predstavlja broj
		* rekorda koje treba preuzeti, ako je null (default)
		* vraca sve rekorde \n
		* tipSortiranja (ETipSortiranja) - enumeracija
		* predstavlja tip sortiranja (default - NajboljiUkupno)
		*/
		public List<Rekord> PreuzmiRekorde (int? br = null,
			ETipSortiranja tipSortiranja = ETipSortiranja.NajboljiUkupno)
		{
			List<Rekord> rekordi;
			using (DataBase data = new DataBase ())
			{
				try
				{
					data.Open ();
					rekordi = data.PreuzmiRekorde (br, tipSortiranja);
				} catch (Exception ex)
				{
					ServiceFault fault = new ServiceFault ("Greska prilikom preuzimanja rekorda!");
					throw new FaultException<ServiceFault> (fault);
				}
			}

			return rekordi;
		}
Exemplo n.º 4
0
        /*
         * Rekordi
         */

        public List <Rekord> PreuzmiRekorde(int?br = null,
                                            ETipSortiranja tipSortiranja = ETipSortiranja.NajboljiUkupno)
        {
            return(Channel.PreuzmiRekorde(br, tipSortiranja));
        }