public static void UpdateEntry(int id, TimeEntryEvent what, DateTime when) { using (var data = new Data()) { using (var cmd = data.GenerateCommand("UPDATE \"entries\" SET \"what\" = @what, \"when\" = @when WHERE id = @id")) { cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@what", (int)what); cmd.Parameters.AddWithValue("@when", when); cmd.ExecuteNonQuery(); } } FireChangeEvent(); }
public static TimeEntryEvent Next(this TimeEntryEvent entry) { switch (entry) { case TimeEntryEvent.StartOfDay: return(TimeEntryEvent.EndOfDay); case TimeEntryEvent.StartOfBreak: return(TimeEntryEvent.EndOfBreak); case TimeEntryEvent.EndOfBreak: return(TimeEntryEvent.EndOfDay); default: return(TimeEntryEvent.StartOfDay); } }
public static string ToString(this TimeEntryEvent entry) { switch (entry) { case TimeEntryEvent.StartOfDay: return("Start Day"); case TimeEntryEvent.StartOfBreak: return("Start Break"); case TimeEntryEvent.EndOfBreak: return("End Break"); case TimeEntryEvent.EndOfDay: return("End Day"); default: throw new Exception("Unknown TimeEntryEvent"); } }
private void TimeValueChange(TimeEntry original, TimeEntryEvent updated_event, DateTime updated_time) { Data.UpdateEntry(original.Id, updated_event, new DateTime(updated_time.Ticks, DateTimeKind.Local)); }