public static SpeedSystemType GetCurrentSystem(SqlConnection cn) { if (!SortingClass.CheckColumn("CompetitionData", "SpeedType", "VARCHAR(3) NOT NULL DEFAULT '" + SpeedSystemType.EKB.ToString() + "'", cn)) { return(SpeedSystemType.EKB); } SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandText = "SELECT SpeedType FROM CompetitionData(NOLOCK)"; string str = cmd.ExecuteScalar().ToString(); try { #if FULL return((SpeedSystemType)Enum.Parse(typeof(SpeedSystemType), str, true)); #else SpeedSystemType st = (SpeedSystemType)Enum.Parse(typeof(SpeedSystemType), str, true); if (st == SpeedSystemType.IVN) { throw new Exception(); } return(st); #endif } catch { cmd.CommandText = "UPDATE CompetitionData SET SpeedType = '" + SpeedSystemType.EKB.ToString() + "'"; cmd.ExecuteNonQuery(); return(SpeedSystemType.EKB); } }
public static void SetCurrentSystem(SpeedSystemType val, SqlConnection cn) { SortingClass.CheckColumn("CompetitionData", "SpeedType", "VARCHAR(3) NOT NULL DEFAULT '" + SpeedSystemType.EKB.ToString() + "'", cn); SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; #if FULL cmd.CommandText = "UPDATE CompetitionData SET SpeedType='" + val.ToString() + "'"; #else SpeedSystemType sVal = (val == SpeedSystemType.IVN) ? SpeedSystemType.EKB : val; cmd.CommandText = "UPDATE CompetitionData SET SpeedType='" + sVal.ToString() + "'"; #endif cmd.ExecuteNonQuery(); }