Ejemplo n.º 1
0
        /// <summary>
        /// Metoda vyuziva tridu UzivatelDAO a jeji metodu GetId
        /// Ziska id uzivatele a rovnou ho ulozi s klicem[id] do cache
        /// </summary>
        /// <param name="u">Uzivatel ktereho id chceme zjistit</param>
        /// <returns>Vraci id uzivatele</returns>
        public int GetId(Uzivatel u)
        {
            int id = dao.UzivatelID(u);

            uzivatele[id] = u;
            return(id);
        }
Ejemplo n.º 2
0
        public void Update(Nabidka n)
        {
            SqlConnection conn    = DatabaseConnection.GetInstance();
            SqlCommand    command = null;
            UzivatelDao   dao     = new UzivatelDao();

            using (command = new SqlCommand("UPDATE uzivatel SET jmeno=@jmeno,heslo=@heslo,adresa=@adresa, where id = @id", conn))
            {
                command.Parameters.Add(new SqlParameter("@id", n.ID));
                command.Parameters.Add(new SqlParameter("@castka", n.castka));
                command.Parameters.Add(new SqlParameter("@heslo", dao.UzivatelID(n.prihazujici)));
                command.ExecuteNonQuery();
            }
        }
Ejemplo n.º 3
0
        public void Create(Nabidka n, Drazba d)
        {
            SqlConnection conn    = DatabaseConnection.GetInstance();
            SqlCommand    command = null;
            UzivatelDao   dao     = new UzivatelDao();
            DrazbaDAO     daoD    = new DrazbaDAO();

            using (command = new SqlCommand("INSERT INTO nabidka(castka,uzivatel_id,drazba_id) VALUES (@castka,@uzivatel_id,@drazba_id)", conn))
            {
                command.Parameters.Add(new SqlParameter("@castka", n.castka));
                command.Parameters.Add(new SqlParameter("@uzivatel_id", dao.UzivatelID(n.prihazujici)));
                command.Parameters.Add(new SqlParameter("@drazba_id", daoD.GetID(d)));
                command.ExecuteNonQuery();
                command.CommandText = "Select @@Identity";
                n.ID = Convert.ToInt32(command.ExecuteScalar());
            }
        }