Пример #1
0
        static public ObservableCollection <Lookup> GetActiveObservable(string tableName)
        {
            ObservableCollection <Lookup> objLookups = new ObservableCollection <Lookup>();
            string   query = "Select ID, Name, Description, Active from " + tableName + " where Active = 1 order by name asc";
            Database db    = DatabaseFactory.CreateDatabase("BKLeadsOnline");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, query))
            {
                while (reader.Read())
                {
                    //the factory returns the appropriate type of lookup object based
                    //on the tableName
                    Lookup objLookup = LookupFactory.CreateLookup(tableName);
                    LoadLookup(objLookup, reader);
                    objLookup.IsModified = false;
                    objLookups.Add(objLookup);
                }
                // always call Close when done reading.
                reader.Close();
                return(objLookups);
            }
        }
Пример #2
0
        static public Lookup GetByValue(string Name, string tableName)
        {
            Lookup   objLookup = LookupFactory.CreateLookup(tableName);
            string   query     = "Select ID, Name, Description, Active from " + tableName + " where Name = '" + Name + "'";
            Database db        = DatabaseFactory.CreateDatabase("BKLeadsOnline");

            using (IDataReader reader = db.ExecuteReader(CommandType.Text, query))
            {
                if (reader.Read())
                {
                    LoadLookup(objLookup, reader);
                    // always call Close when done reading.
                    reader.Close();
                    objLookup.IsModified = false;
                    return(objLookup);
                }
                else
                {
                    return(null);
                }
            }
        }