示例#1
0
 void GridDoubleClickHandler(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0 && e.ColumnIndex == colNote.Index)
     {
         var time = (TimedEvent)grid.Rows[e.RowIndex].DataBoundItem;
         using (var form = new NoteWindow(time.Note))
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 time.Note = form.Note;
             }
     }
 }
示例#2
0
 void NewTimeNoteHandler(object sender, EventArgs e)
 {
     using (var form = new NoteWindow(""))
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             using (var db = new DatabaseContext())
             {
                 var now  = DateTime.Now;
                 var last = m_user.GetTimes(db).OrderByDescending(fn => fn.Start).FirstOrDefault();
                 if (last.End == null)
                 {
                     last.End = now;
                 }
                 db.TimedEvents.Add(new TimedEvent {
                     Start = now, UserId = m_user.UserId, Note = form.Note
                 });
                 db.SaveChanges();
             }
         }
 }
示例#3
0
 void EditNoteHandler(object sender, EventArgs e)
 {
     using (var db = new DatabaseContext())
     {
         var last = m_user.GetTimes(db).OrderByDescending(fn => fn.Start).FirstOrDefault();
         if (last == null)
         {
             return;
         }
         using (var form = new NoteWindow(last.Note))
         {
             if (form.ShowDialog(this) != DialogResult.OK)
             {
                 return;
             }
             last.Note = form.Note;
             db.SaveChanges();
         }
     }
 }