@@ -282,7 +282,98 @@ private void singleSubstract()
282
282
283
283
private void editRecords ( )
284
284
{
285
- throw new NotImplementedException ( ) ;
285
+ getRecords ( RA . recent ) ;
286
+ var idx = 0 ;
287
+ foreach ( var r in records )
288
+ {
289
+ Console . WriteLine ( $ "{ idx ++ , 3 } - { r . start : yyyy-MM-dd HH:mm:ss} { r . status } ") ;
290
+ }
291
+ Console . Write ( "line to edit:>" ) ;
292
+ var line = Console . ReadLine ( ) ;
293
+ if ( line == null )
294
+ return ;
295
+ try
296
+ {
297
+ idx = Int32 . Parse ( line ) ;
298
+ }
299
+ catch { return ; }
300
+ if ( idx < 0 || idx >= records . Count )
301
+ return ;
302
+ var record = records [ idx ] ;
303
+ Console . Write ( "time or status? >" ) ;
304
+ var key = Console . ReadKey ( true ) ;
305
+ switch ( key . Key )
306
+ {
307
+ case ConsoleKey . T :
308
+ Console . WriteLine ( ) ;
309
+ Console . WriteLine ( $ "old: { record . start : yyyy-MM-dd HH:mm:ss} ") ;
310
+ Console . Write ( "new: " ) ;
311
+ var pos = Console . GetCursorPosition ( ) ;
312
+ string ke = "" ;
313
+ var done = false ;
314
+ while ( ! done )
315
+ {
316
+ Console . SetCursorPosition ( pos . Left , pos . Top ) ;
317
+ var ke2 = ke ;
318
+ while ( ke2 . Length < 14 )
319
+ ke2 = "_" + ke2 ;
320
+ ke2 = ke2 . Substring ( 0 , 4 ) + "-" + ke2 . Substring ( 4 , 2 ) + "-" + ke2 . Substring ( 6 , 2 )
321
+ + " " + ke2 . Substring ( 8 , 2 ) + ":" + ke2 . Substring ( 10 , 2 ) + ":" + ke2 . Substring ( 12 , 2 ) ;
322
+ Console . Write ( ke2 ) ;
323
+ key = Console . ReadKey ( true ) ;
324
+ switch ( key . Key )
325
+ {
326
+ case ConsoleKey . D0 :
327
+ case ConsoleKey . D1 :
328
+ case ConsoleKey . D2 :
329
+ case ConsoleKey . D3 :
330
+ case ConsoleKey . D4 :
331
+ case ConsoleKey . D5 :
332
+ case ConsoleKey . D6 :
333
+ case ConsoleKey . D7 :
334
+ case ConsoleKey . D8 :
335
+ case ConsoleKey . D9 :
336
+ ke += key . KeyChar ;
337
+ if ( ke . Length > 14 )
338
+ ke = ke . Substring ( 1 ) ;
339
+ break ;
340
+ case ConsoleKey . Escape :
341
+ return ;
342
+ case ConsoleKey . Backspace :
343
+ ke = ke . Substring ( 0 , ke . Length - 1 ) ;
344
+ break ;
345
+ case ConsoleKey . Enter :
346
+ done = true ;
347
+ break ;
348
+ }
349
+ }
350
+ var od = record . start . ToString ( "yyyyMMddHHmmss" ) ;
351
+ var nd = od . Substring ( 0 , 14 - ke . Length ) + ke ;
352
+ nd = nd . Substring ( 0 , 4 ) + "-" + nd . Substring ( 4 , 2 ) + "-" + nd . Substring ( 6 , 2 )
353
+ + " " + nd . Substring ( 8 , 2 ) + ":" + nd . Substring ( 10 , 2 ) + ":" + nd . Substring ( 12 , 2 ) ;
354
+ Console . WriteLine ( ) ;
355
+ Console . WriteLine ( nd ) ;
356
+ deleteRecord ( record ) ;
357
+ record . start = DateTime . Parse ( nd ) ;
358
+ insertRecord ( record ) ;
359
+ break ;
360
+ case ConsoleKey . S :
361
+ switch ( record . status )
362
+ {
363
+ case "in" :
364
+ record . status = "out" ;
365
+ break ;
366
+ case "out" :
367
+ record . status = "in" ;
368
+ break ;
369
+ }
370
+ insertRecord ( record ) ;
371
+ break ;
372
+ }
373
+ getRecords ( RA . recent ) ;
374
+ recalculate ( ) ;
375
+ showWorkLeft ( ) ;
376
+
286
377
}
287
378
288
379
void getConfig ( )
0 commit comments