private void btnTEDel_Click(object sender, RoutedEventArgs e) { TimeException te = (TimeException)dataGridExcepTime.SelectedItem; MEAPSDbEntities context = new MEAPSDbEntities(); TimeException deletable = context.TimeExceptions.SingleOrDefault(x => x.Date == te.Date); context.TimeExceptions.Remove(deletable); context.SaveChanges(); RefreshDataGrids(); }
private void btnTEAdd_Click(object sender, RoutedEventArgs e) { MEAPSDbEntities context = new MEAPSDbEntities(); TimeException te = new TimeException(); te.Date = Convert.ToDateTime(dtTEDate.Text); string entryTime = cbInHrs.Text + ":" + cbInMins.Text; string exitTime = cbOutHrs.Text + ":" + cbOutMins.Text; te.InTime = TimeSpan.Parse(entryTime); te.OutTime = TimeSpan.Parse(exitTime); context.TimeExceptions.Add(te); context.SaveChanges(); RefreshDataGrids(); }