Beispiel #1
0
        public static bool Delete(DbConfigItem item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("DbConfig_DeleteItem"))
            {
                sp.Params.Add("@Name", System.Data.SqlDbType.NVarChar, 255).Value = item.Name;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
Beispiel #2
0
        public static DbConfigItem GetByID(string id)
        {
            DbConfigItem item = null;
            using (StoredProcedure sp = new StoredProcedure("DbConfig_GetByID"))
            {
                sp.Params.Add("@Name", System.Data.SqlDbType.NVarChar,255).Value = id;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null && r.Read())
                    {
                        item = new DbConfigItem();

                        item.Name = Convert.ToString(r["Name"]);
                        item.Value = Convert.ToString(r["Value"]);
                        item.DateCreated = Convert.ToDateTime(r["DateCreated"]);
                    }
                }
            }
            return item;
        }
Beispiel #3
0
        public static List<DbConfigItem> GetAll()
        {
            List<DbConfigItem> all = new List<DbConfigItem>();
            using (StoredProcedure sp = new StoredProcedure("DbConfig_GetAll"))
            {
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null)
                    {
                        while (r.Read())
                        {
                            DbConfigItem item = new DbConfigItem();

                            item.Name = Convert.ToString(r["Name"]);
                            item.Value = Convert.ToString(r["Value"]);
                            item.DateCreated = Convert.ToDateTime(r["DateCreated"]);

                            all.Add(item);
                        }
                    }
                }
            }
            return all;
        }
Beispiel #4
0
        public static bool Save(DbConfigItem item)
        {
            if (item == null)
                throw new ArgumentNullException("item");

            return Save(item.Name, item.Value);
        }