コード例 #1
0
        /// <summary>
        /// Insert
        /// </summary>
        public int Insert(Kategorie kategorie)
        {
            mDatabase.Connect();

            SqlCommand command = mDatabase.CreateCommand(SQL_INSERT);

            PrepareCommand(command, kategorie);
            int ret = mDatabase.ExecuteNonQuery(command);

            mDatabase.Close();
            return(ret);
        }
コード例 #2
0
        /// <summary>
        /// Read
        /// </summary>

        private Collection <Kategorie> Read(SqlDataReader reader)
        {
            Collection <Kategorie> kategories = new Collection <Kategorie>();

            while (reader.Read())
            {
                Kategorie kategorie = new Kategorie();
                int       i         = -1;
                kategorie.Pk_id_kategorie = reader.GetInt32(++i);
                kategorie.Nazev           = reader.GetString(++i);

                kategories.Add(kategorie);
            }
            return(kategories);
        }
コード例 #3
0
        /// <summary>
        /// Select the record.
        /// </summary>
        public Kategorie SelectOne(int idKategorie)
        {
            mDatabase.Connect();
            SqlCommand command = mDatabase.CreateCommand(SQL_SELECT_ID);

            command.Parameters.AddWithValue("@pk_id_kategorie", idKategorie);
            SqlDataReader reader = mDatabase.Select(command);

            Collection <Kategorie> kategories = Read(reader);
            Kategorie kategorie = null;

            if (kategories.Count == 1)
            {
                kategorie = kategories[0];
            }
            reader.Close();
            mDatabase.Close();
            return(kategorie);
        }
コード例 #4
0
 /// <summary>
 /// Prepare a command.
 /// </summary>
 private void PrepareCommand(SqlCommand command, Kategorie kategorie)
 {
     command.Parameters.AddWithValue("@pk_id_kategorie", kategorie.Pk_id_kategorie);
     command.Parameters.AddWithValue("@nazev", kategorie.Nazev);
 }