public Config(ConfigSystem cs, string key, object value) { ConfigSystemInfo = cs; ConfigSystem = cs.ToString(); ConfigKey = key; ConfigValue = value?.ToString().Trim(); }
public void Select() { var dr = DataAccess.Config.GetConfigByID(ConfigSystem.ToString(), ConfigKey); if (dr != null) { InitConfig(dr); } }
public bool Any() { var sql = $"SELECT * FROM {Repository.GetTableAttr<Config>().Name} WHERE ConfigSystem = @configSystem AND ConfigKey = @configKey"; SqlParameter[] para = { new SqlParameter("@configSystem", ConfigSystem.ToString()), new SqlParameter("@configKey", ConfigKey) }; var ds = DataAccess.ExecuteDataset(sql, para); return(ds.Tables[0].Rows.Count > 0); }
public void Update(SqlTransaction trans = null) { Contract.Requires(Any()); var sql = $"UPDATE {Repository.GetTableAttr<Config>().Name} SET ConfigValue = @configValue WHERE ConfigSystem = @configSystem AND ConfigKey = @configKey"; SqlParameter[] para = { new SqlParameter("@configSystem", ConfigSystem.ToString()), new SqlParameter("@configKey", ConfigKey), new SqlParameter("@configValue", ConfigValue) }; DataAccess.ExecuteNonQuery(sql, para, trans); }
private void Insert() { using (var conn = SQLConn.GetConnection()) { conn.Open(); var trans = conn.BeginTransaction(); try { DataAccess.Config.InsertConfig(ConfigSystem.ToString(), ConfigKey, ConfigValue, trans); trans.Commit(); } catch { trans.Rollback(); } //conn.Close(); } }
public void Save(SqlTransaction trans = null) { if (Any()) { Update(); } else { var sql = $"INSERT INTO {Repository.GetTableAttr<Config>().Name} (ConfigValue, ConfigSystem, ConfigKey) VALUES (@configValue, @configSystem, @configKey)"; SqlParameter[] para = { new SqlParameter("@configSystem", ConfigSystem.ToString()), new SqlParameter("@configKey", ConfigKey), new SqlParameter("@configValue", ConfigValue) }; DataAccess.ExecuteNonQuery(sql, para, trans); } }
private void Delete() { DataAccess.Config.DeleteConfig(ConfigSystem.ToString(), ConfigKey); }