private static List <Note> ReadAffairs(SQLiteDataReader reader) { try { List <Note> notes = new List <Note>(); while (reader.Read()) { Affair affair = new Affair(); affair.Id = reader.GetInt32(0); affair.Name = reader.GetString(1); affair.CurrentState = (Note.State)reader.GetInt32(2); affair.Comment = reader.GetString(3); affair.Description = reader.GetString(4); affair.IsDateSet = reader.GetBoolean(5); affair.SetDate(reader.GetString(6)); notes.Add(affair); } return(notes); } catch (Exception ex) { Log.Error(string.Format("Can not read affairs:{0}{1}", Environment.NewLine, ex.ToString())); return(new List <Note>()); } }
public override Note GetNoteFromSelectedRow() { if (CurrentRow == null) { return(null); } Affair affair = new Affair(); affair.Id = CurrentRow.Cells[(int)Index.Id].Value.ToString().ToIntOrException(); affair.Name = CurrentRow.Cells[(int)Index.Name].Value.ToString(); affair.Description = CurrentRow.Cells[(int)Index.Description].Value.ToString(); affair.IsDateSet = (bool)CurrentRow.Cells[(int)Index.IsDateSet].Value; if (affair.IsDateSet) { affair.SetDate(CurrentRow.Cells[(int)Index.Date].Value.ToString().Replace('.', ' ')); } affair.CurrentState = CurrentRow.Cells[(int)Index.State].Value.ToString().ToNoteState(); affair.Comment = CurrentRow.Cells[(int)Index.Comment].Value.ToString(); return(affair); }