Esempio n. 1
0
        public List<EventType> SelectEventTypesForAccounting()
        {
            const string q = @"SELECT id, event_type, description
                               FROM dbo.EventTypes
                               WHERE accounting = 1
                               ORDER BY sort_order";

            List<EventType> list = new List<EventType>();
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            using (OpenCbsReader r = c.ExecuteReader())
            {
                if (r.Empty) return list;

                while (r.Read())
                {
                    EventType et = new EventType
                    {
                        Id = r.GetInt("id"),
                        Description = r.GetString("description"),
                        EventCode = r.GetString("event_type")
                    };
                    list.Add(et);
                }

                return list;
            }
        }
Esempio n. 2
0
        public EventType SelectEventTypeByEventType(string eventType)
        {
            const string q = @"SELECT id, event_type, description
                                     FROM EventTypes
                                     WHERE event_type = @event_type";
            using (SqlConnection conn = GetConnection())
            using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
            {
                c.AddParam("@event_type", eventType);

                using (OpenCbsReader r = c.ExecuteReader())
                {
                    if (r == null || r.Empty) return new EventType();
                    EventType evntType = new EventType();
                    while (r.Read())
                    {
                        evntType = new EventType
                                     {
                                         Id = r.GetInt("id"),
                                         Description = r.GetString("description"),
                                         EventCode = r.GetString("event_type")
                                     };
                    }

                    return evntType;
                }
            }
        }