Beispiel #1
0
        public List<Buchungskategorie> getBuchungsKategorien()
        {
            buildconnection();
            List<Buchungskategorie> blist = new List<Buchungskategorie>();
            NpgsqlCommand comm = null;
            NpgsqlDataReader reader = null;
            try
            {
                string sql = @"Select k.katid, k.bezeichnung from kategorie k";
                comm = new NpgsqlCommand(sql, conn);
                reader = comm.ExecuteReader();
                while (reader.Read())
                {
                    Buchungskategorie b = new Buchungskategorie();
                    b.Bkatid = reader.GetInt32(0);
                    b.Bezeichung = reader.GetString(1).Trim();
                    blist.Add(b);
                }
            }
            catch (NpgsqlException exp)
            {
                throw new DALException("DAL: Buchungskategorieliste konnte nicht aus der Datenbank geladen werden!", exp);
            }
            finally
            {
                reader.Close();
                comm.Dispose();
                conn.Close();
            }

            return blist;
        }
Beispiel #2
0
        public Buchungskategorie getBuchungsKategorie(int id)
        {
            buildconnection();
            Buchungskategorie bkat = new Buchungskategorie();
            NpgsqlCommand comm = null;
            NpgsqlDataReader reader = null;
            try
            {
                string sql = @"Select k.katid, k.bezeichnung from kategorie k where k.katid = @katid";
                comm = new NpgsqlCommand(sql, conn);
                comm.Parameters.AddWithValue("@katid", id);
                reader = comm.ExecuteReader();
                while (reader.Read())
                {
                    bkat.Bkatid = reader.GetInt32(0);
                    bkat.Bezeichung = reader.GetString(1).Trim();
                }
            }
            catch (NpgsqlException exp)
            {
                throw new DALException("DAL: Buchungskategorie konnte nicht aus der Datenbank geladen werden!", exp);
            }
            finally
            {
                reader.Close();
                comm.Dispose();
                conn.Close();
            }

            return bkat;
        }